/* Factory Floor — steampunk theme: brass, copper, riveted plate, gaslight, parchment ledger.
   Pure CSS gradients + inline SVG. Fonts: Cinzel (headings) and Crimson Pro (text), both SIL OFL, self-hosted. */
@font-face { font-family: "Cinzel"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/cinzel-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Crimson Pro"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/crimson-pro-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Crimson Pro"; font-weight: 400; font-style: italic; font-display: swap; src: url("../fonts/crimson-pro-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Crimson Pro"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/crimson-pro-latin-600-normal.woff2") format("woff2"); }

:root {
  --coal: #17110b; --coal2: #241a10; --soot: #33261a;
  --brass-hi: #f6dc8c; --brass: #d3a246; --brass-lo: #9a6e22; --brass-dk: #5a3d12;
  --copper: #b4653c; --copper-dk: #7a3f20; --verdigris: #2f7f78; --verdigris-dk: #1f5c57;
  --parch: #f1e3bf; --parch2: #e7d3a2; --parch-lo: #d9c18a; --ink: #2b1d10; --ink-soft: #52391f;
  --red: #a63a24; --green: #3d7a4b; --amber: #c58a1d;
  --head: "Cinzel", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --body: "Crimson Pro", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --gaslight: radial-gradient(ellipse 80% 60% at 50% -10%, rgba(255, 190, 90, .30), rgba(255, 150, 50, .08) 55%, transparent 75%);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: #0f0a06; }
body {
  margin: 0; min-height: 100vh; color: var(--ink); font: 400 19px/1.5 var(--body);
  background: var(--gaslight), repeating-linear-gradient(90deg, rgba(255,255,255,.015) 0 2px, transparent 2px 6px), linear-gradient(#1b130b, #0f0a06 60%, #17110b);
  background-attachment: fixed;
}
h1, h2, h3, .head { font-family: var(--head); font-weight: 600; letter-spacing: .04em; margin: 0; }
.skip { position: absolute; left: -999px; top: 0; background: var(--brass); color: var(--ink); padding: 10px 14px; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
h1:focus, main:focus { outline: none; }
:focus-visible { outline: 3px solid #19b5aa; outline-offset: 2px; box-shadow: 0 0 0 2px #0e0905; }

/* ---------- header plate with gears and pipe ---------- */
.plate { position: relative; background: linear-gradient(#3a2a18, #21170d); border-bottom: 3px solid var(--brass-dk); box-shadow: 0 3px 0 #0b0704, 0 6px 14px rgba(0,0,0,.5); color: var(--brass-hi); }
.plate-in { max-width: 820px; margin: 0 auto; display: flex; align-items: center; gap: 10px; padding: 8px 12px; min-height: 60px; }
.gears { position: relative; width: 62px; height: 46px; flex: none; }
.gears .gear { position: absolute; }
.gears .g1 { left: 0; top: 2px; animation: spin 24s linear infinite; }
.gears .g2 { left: 28px; top: 14px; animation: spin-r 15s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } } @keyframes spin-r { to { transform: rotate(-360deg); } }
.plate .title { flex: 1; min-width: 0; line-height: 1.1; }
.plate .title b { display: block; font-family: var(--head); font-size: 1.28rem; letter-spacing: .08em; text-transform: uppercase; text-shadow: 0 2px 0 #000, 0 0 12px rgba(255,190,90,.35); }
.plate .title small { display: block; font-size: .85rem; color: #e1c88c; letter-spacing: .03em; }
.pipe { height: 10px; background: linear-gradient(#e0a070, #b4653c 45%, #6c3518); border-top: 1px solid #4a230f; border-bottom: 1px solid #2a1206; position: relative; }
.pipe::before, .pipe::after { content: ""; position: absolute; top: -3px; bottom: -3px; width: 14px; background: linear-gradient(90deg, #8a5a2a, #e0b070 50%, #8a5a2a); border-radius: 2px; border: 1px solid #3a1c08; }
.pipe::before { left: 16%; } .pipe::after { right: 22%; }
.iconbtn { flex: none; display: inline-flex; align-items: center; gap: 6px; min-width: 48px; min-height: 48px; padding: 0 12px; font: 600 .78rem var(--head); letter-spacing: .06em; text-transform: uppercase; color: var(--ink);
  background: linear-gradient(#f3d98b, #d3a246 50%, #a97a2a); border: 1px solid #6b4a14; border-radius: 10px; box-shadow: inset 0 1px 0 #fff3bf, 0 2px 0 var(--brass-dk), 0 4px 8px rgba(0,0,0,.4); cursor: pointer; justify-content: center; }
.iconbtn:active { transform: translateY(2px); box-shadow: inset 0 1px 0 #fff3bf, 0 0 0 var(--brass-dk); }
.iconbtn .lbl { display: none; }
@media (min-width: 560px) { .iconbtn .lbl { display: inline; } }

/* ---------- gauge board ---------- */
.board { background: linear-gradient(#2b1e12, #1a120a); border-bottom: 3px solid var(--brass-dk); box-shadow: inset 0 -8px 14px rgba(0,0,0,.45); position: sticky; top: 0; z-index: 20; }
.board-in { max-width: 820px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 6px 8px 5px; }
.g { text-align: center; position: relative; color: var(--brass-hi); }
.g .gsvg { width: 100%; max-width: 78px; height: auto; display: block; margin: 0 auto; filter: drop-shadow(0 3px 3px rgba(0,0,0,.6)); }
.g .needle { transition: transform 1.1s cubic-bezier(.3, 1.5, .5, 1); }
.g .gl { font: 600 .66rem/1.1 var(--head); letter-spacing: .08em; text-transform: uppercase; margin-top: 1px; color: #e9d29a; }
.g .gv { font: 600 1rem/1.15 var(--head); color: #fff1c4; min-height: 1.25em; }
.g .delta { margin-left: 4px; font-size: .78rem; padding: 0 5px; border-radius: 8px; background: #000a; display: inline-block; }
.g .delta.good { color: #8fe0a0; } .g .delta.bad { color: #ff9c85; } .g .delta.flat { color: #cfc2a0; }
@media (min-width: 600px) { .g .gsvg { max-width: 86px; } .g .gl { font-size: .74rem; } .g .gv { font-size: 1.15rem; } }
.g.flash .gsvg { animation: flash .9s ease-out; }
@keyframes flash { 0% { filter: drop-shadow(0 0 0 rgba(255,200,100,0)); } 30% { filter: drop-shadow(0 0 10px rgba(255,200,100,.95)); } 100% { filter: drop-shadow(0 3px 3px rgba(0,0,0,.6)); } }

/* ---------- main layout and parchment ledger ---------- */
main { max-width: 820px; margin: 0 auto; padding: 14px 10px 130px; outline: none; }
.page {
  position: relative; padding: 20px 18px 22px; border-radius: 6px; border: 2px solid var(--brass-lo);
  background:
    radial-gradient(ellipse at 50% 0, rgba(255, 250, 225, .85), rgba(255,250,225,0) 60%),
    repeating-linear-gradient(transparent 0 29px, rgba(120, 80, 30, .10) 29px 30px),
    radial-gradient(ellipse at 100% 100%, rgba(150, 100, 40, .25), transparent 55%),
    linear-gradient(var(--parch), var(--parch2));
  box-shadow: 0 0 0 4px var(--brass), 0 0 0 6px var(--brass-dk), 0 14px 28px rgba(0,0,0,.65), inset 0 0 40px rgba(110, 70, 20, .28);
  margin: 8px 6px 18px; animation: rise .35s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.page::before, .page::after { content: ""; position: absolute; left: 6px; right: 6px; height: 14px; pointer-events: none;
  background: radial-gradient(circle at 7px 7px, #f6dc8c 0 2px, #8a5f1c 3px 4px, transparent 5px) 0 0 / auto 14px no-repeat, radial-gradient(circle at calc(100% - 7px) 7px, #f6dc8c 0 2px, #8a5f1c 3px 4px, transparent 5px) 0 0 / auto 14px no-repeat; }
.page::before { top: 4px; } .page::after { bottom: 4px; }
.kicker { font: 600 .8rem var(--head); letter-spacing: .22em; text-transform: uppercase; color: var(--copper-dk); }
.page h1 { font-size: 1.7rem; line-height: 1.15; margin: 2px 0 8px; }
.page h2 { font-size: 1.28rem; margin: 18px 0 6px; line-height: 1.2; }
.page h3 { font-size: 1.02rem; margin: 14px 0 4px; letter-spacing: .06em; text-transform: uppercase; color: var(--copper-dk); }
.page p { margin: 0 0 .75em; }
.lede { font-size: 1.12em; }
.dateplate { display: inline-block; font: 600 .86rem var(--head); letter-spacing: .12em; padding: 4px 14px; color: var(--brass-hi); background: linear-gradient(#3a2a18, #1f150b); border: 2px solid var(--brass-lo); border-radius: 4px; box-shadow: inset 0 0 0 2px #0006, 0 2px 0 var(--brass-dk); margin-bottom: 8px; }
.divider { display: flex; align-items: center; gap: 8px; margin: 14px 0; } .divider .dl { flex: 1; height: 3px; background: linear-gradient(90deg, transparent, var(--brass-lo), transparent); border-radius: 2px; }
.divider .gear { animation: spin 40s linear infinite; }
.fine { font-size: .9rem; color: var(--ink-soft); font-style: italic; }
.pill { display: inline-block; font: 600 .7rem var(--head); letter-spacing: .08em; padding: 2px 8px; border-radius: 10px; border: 1px solid var(--copper-dk); color: var(--copper-dk); background: #fff6; margin: 0 4px 4px 0; vertical-align: middle; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 10px 22px; font: 600 .95rem var(--head); letter-spacing: .06em; text-transform: uppercase; text-align: center; color: var(--ink); cursor: pointer; width: 100%;
  background: linear-gradient(#f6dd92, #d3a246 48%, #a57626); border: 1px solid #5f400f; border-radius: 12px; box-shadow: inset 0 1px 0 #fff4c4, inset 0 -3px 0 rgba(90,60,10,.35), 0 3px 0 var(--brass-dk), 0 6px 10px rgba(0,0,0,.35); text-decoration: none; }
.btn:hover { filter: brightness(1.07); } .btn:active { transform: translateY(2px); box-shadow: inset 0 1px 0 #fff4c4, 0 1px 0 var(--brass-dk); }
.btn.alt { background: linear-gradient(#d98a5c, #b4653c 50%, #86421f); color: #fff6e6; border-color: #4e230d; text-shadow: 0 1px 0 #0006; }
.btn.ghost { background: linear-gradient(#efe0b8, #dcc690); color: var(--ink); }
.btn[disabled] { opacity: .55; cursor: not-allowed; filter: grayscale(.4); }
.row { display: grid; gap: 10px; margin-top: 12px; } @media (min-width: 560px) { .row.two { grid-template-columns: 1fr 1fr; } }
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(15,10,6,.92) 38%); }
.dock .btn { max-width: 560px; margin: 0 auto; display: flex; }

/* ---------- decision choices ---------- */
.choices { display: grid; gap: 12px; margin: 10px 0 0; padding: 0; list-style: none; }
.choice { display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: start; width: 100%; text-align: left; font: inherit; color: var(--ink); cursor: pointer; padding: 12px 12px 12px 10px; min-height: 64px;
  background: linear-gradient(#fbf1d3, #ecdbac); border: 2px solid var(--brass-lo); border-radius: 12px; box-shadow: 0 3px 0 var(--brass-dk), 0 6px 10px rgba(60,35,10,.25), inset 0 0 0 1px #fff8; transition: transform .12s, box-shadow .12s; }
.choice:hover:not([disabled]) { transform: translateY(-2px); box-shadow: 0 5px 0 var(--brass-dk), 0 10px 16px rgba(60,35,10,.35), 0 0 14px rgba(255,190,90,.5); }
.choice:active:not([disabled]) { transform: translateY(2px); }
.choice .med { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font: 600 1.1rem var(--head); color: #fff2d6; background: radial-gradient(circle at 35% 30%, #e59a6a, #b4653c 55%, #6e3418); border: 2px solid #4a230f; box-shadow: inset 0 0 0 2px #e6b48a55, 0 2px 0 #2a1206; }
.choice b { display: block; font: 600 1.06rem/1.25 var(--body); }
.choice span.d { display: block; color: var(--ink-soft); font-size: .98rem; margin-top: 2px; }
.choice[disabled] { cursor: not-allowed; border-style: dashed; background: #e5d6ac; }
.choice[disabled] b, .choice[disabled] .d, .choice[disabled] .med { opacity: .62; }
.choice[disabled] .need { color: #8e2a17; }
.choice .need { display: flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--red); margin-top: 4px; font-weight: 600; }
.decnote { font: 600 .8rem var(--head); letter-spacing: .1em; text-transform: uppercase; color: var(--verdigris-dk); }

/* ---------- result and sources ---------- */
.chosen { border-left: 6px solid var(--copper); background: #fff7; padding: 8px 12px; border-radius: 0 8px 8px 0; margin: 4px 0 10px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.chip { font: 600 .82rem var(--head); letter-spacing: .04em; padding: 3px 10px; border-radius: 12px; border: 1.5px solid; background: #fff9; }
.chip.good { color: #1f5e33; border-color: #3d7a4b; } .chip.bad { color: #86261a; border-color: var(--red); } .chip.flat { color: var(--ink-soft); border-color: #8a7a60; }
.src { margin: 12px 0; padding: 10px 14px 12px; border: 2px solid var(--verdigris-dk); border-radius: 6px; background: linear-gradient(#efe9c9, #e2d9ad); position: relative; box-shadow: inset 0 0 0 3px #fff6; }
.src .seal { display: inline-flex; align-items: center; gap: 6px; font: 600 .72rem var(--head); letter-spacing: .1em; text-transform: uppercase; padding: 3px 9px; border-radius: 10px; color: #fff; background: var(--verdigris-dk); margin-bottom: 6px; }
.src blockquote { margin: 4px 0 6px; padding: 0 0 0 12px; border-left: 3px solid var(--verdigris); font-style: italic; }
.src .cite { font-size: .9rem; color: var(--ink-soft); }
.src.quote { border-color: var(--verdigris-dk); }
.src.paraphrase { border-color: #4b5f7a; } .src.paraphrase .seal { background: #3e5069; }
.src.statute { border-color: #6a4d8a; } .src.statute .seal { background: #53386f; }
.src.secondary { border-color: #6d6a3a; } .src.secondary .seal { background: #5a5726; }
.src.illustrative { border: 2px dashed var(--red); background: repeating-linear-gradient(45deg, #f4e4c0 0 12px, #efdcb4 12px 24px); } .src.illustrative .seal { background: var(--red); }
.hist { margin: 12px 0; padding: 10px 14px; border-radius: 6px; background: #fff7; border: 1px solid #b99a5a; }
.hist h3 { margin-top: 0; }
.event { margin: 12px 0; padding: 10px 14px; border-radius: 6px; border: 2px solid var(--copper-dk); background: linear-gradient(#f3dcb8, #e8c99a); }
.event h3 { margin: 0 0 4px; color: var(--copper-dk); }
details.acc { margin: 10px 0; border: 1px solid #b99a5a; border-radius: 6px; background: #fff6; }
details.acc summary { cursor: pointer; padding: 10px 12px; font: 600 .85rem var(--head); letter-spacing: .06em; text-transform: uppercase; min-height: 44px; display: flex; align-items: center; }
details.acc ul { margin: 0; padding: 0 12px 10px 30px; }

/* ---------- glossary terms ---------- */
.term { font: inherit; color: var(--verdigris-dk); background: none; border: 0; border-bottom: 2px dotted var(--verdigris); padding: 0 1px; cursor: help; font-weight: 600; }
.term:hover, .term:focus-visible { background: #2f7f7822; }
.term.seen { border-bottom-style: solid; }

/* ---------- quiz ---------- */
.qprog { display: flex; align-items: center; gap: 4px; margin: 6px 0 10px; } .qprog i { flex: 1; height: 8px; border-radius: 4px; background: #c9b27a; border: 1px solid #8a6a2a; } .qprog i.done { background: var(--brass); } .qprog i.cur { background: var(--copper); }
.opt { grid-template-columns: 40px 1fr; } .opt .med { width: 34px; height: 34px; font-size: .95rem; }
.opt[disabled] { opacity: 1; cursor: default; border-style: solid; background: linear-gradient(#fbf1d3, #ecdbac); }
.opt.dim[disabled] { opacity: .72; }
.opt.right { border-color: var(--green); background: linear-gradient(#e4f0d0, #cfe3b4); } .opt.wrong { border-color: var(--red); background: linear-gradient(#f6d9c8, #ebbfa6); } .opt.dim { opacity: .75; }
.opt .mark { display: flex; align-items: center; gap: 6px; font-weight: 600; margin-top: 4px; } .opt.right .mark { color: #1f5e33; } .opt.wrong .mark { color: #86261a; }
.feedback { margin: 14px 0; padding: 10px 14px; border-radius: 6px; border: 2px solid; } .feedback.ok { border-color: var(--green); background: #e6f1d8; } .feedback.no { border-color: var(--red); background: #f7e0d2; }
.feedback h3 { margin-top: 0; }
.score { text-align: center; font: 600 3rem/1 var(--head); color: var(--copper-dk); text-shadow: 0 2px 0 #fff8; margin: 6px 0 2px; }

/* ---------- end screen ---------- */
.endrow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; margin: 8px 0; } .endrow .box { background: #fff7; border: 1px solid #b99a5a; border-radius: 6px; padding: 6px 2px; font: 600 .75rem var(--head); } .endrow .box b { display: block; font-size: 1.4rem; color: var(--copper-dk); }
table.ledger { width: 100%; border-collapse: collapse; font-size: .92rem; } table.ledger th, table.ledger td { text-align: left; padding: 6px 6px; border-bottom: 1px solid #c3a766; vertical-align: top; } table.ledger th { font: 600 .72rem var(--head); letter-spacing: .08em; text-transform: uppercase; color: var(--copper-dk); }
.ach { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; } .ach li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid #b99a5a; border-radius: 6px; background: #fff7; } .ach li.off { opacity: .55; } .ach .ico { flex: none; color: var(--copper-dk); }
ol.debrief { padding-left: 22px; } ol.debrief li { margin-bottom: .6em; }
.sumbox { width: 100%; min-height: 150px; font: .85rem/1.35 ui-monospace, Menlo, Consolas, monospace; padding: 8px; border: 2px solid var(--brass-lo); border-radius: 6px; background: #fffaf0; color: var(--ink); }
.input { width: 100%; min-height: 48px; font: inherit; padding: 8px 12px; border: 2px solid var(--brass-lo); border-radius: 10px; background: #fffaf0; color: var(--ink); }
label.lab { display: block; font: 600 .8rem var(--head); letter-spacing: .08em; text-transform: uppercase; color: var(--copper-dk); margin: 12px 0 4px; }

/* ---------- title ---------- */
.titlecard { text-align: center; }
.titlecard h1 { font-size: 2.3rem; letter-spacing: .1em; text-transform: uppercase; text-shadow: 0 2px 0 #fff9, 0 3px 6px rgba(70,40,10,.4); }
.titlecard .sub { font-style: italic; font-size: 1.2rem; color: var(--ink-soft); margin-bottom: 8px; }
.bigGears { display: flex; justify-content: center; align-items: center; gap: 0; margin: 4px 0 6px; } .bigGears .gear:nth-child(1) { animation: spin 30s linear infinite; } .bigGears .gear:nth-child(2) { margin-left: -14px; margin-top: 30px; animation: spin-r 19s linear infinite; } .bigGears .gear:nth-child(3) { margin-left: -12px; margin-top: -26px; animation: spin 14s linear infinite; }
.menu { display: grid; gap: 10px; margin-top: 14px; }
.gold-rule { height: 4px; border-radius: 3px; background: linear-gradient(90deg, transparent, var(--brass), var(--copper), var(--brass), transparent); margin: 14px 0; }

/* ---------- dialogs ---------- */
dialog { width: min(680px, 94vw); max-height: 88vh; padding: 0; border: 3px solid var(--brass); border-radius: 10px; color: var(--ink); background: linear-gradient(var(--parch), var(--parch2)); box-shadow: 0 0 0 4px var(--brass-dk), 0 20px 50px rgba(0,0,0,.8); }
dialog::backdrop { background: rgba(10, 6, 3, .78); backdrop-filter: blur(2px); }
.dlg-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 16px; background: linear-gradient(#3a2a18, #21170d); color: var(--brass-hi); position: sticky; top: 0; z-index: 2; }
.dlg-head h2 { flex: 1; font-size: 1.05rem; letter-spacing: .08em; text-transform: uppercase; }
.dlg-body { padding: 14px 16px 18px; overflow: auto; max-height: calc(88vh - 62px); }
.gl-item { padding: 8px 0; border-bottom: 1px solid #c3a766; } .gl-item b { font-family: var(--head); letter-spacing: .03em; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 50; padding: 10px 18px; border-radius: 10px; background: #1a120a; color: var(--brass-hi); border: 2px solid var(--brass); font-weight: 600; box-shadow: 0 6px 14px #000a; }
footer.foot { text-align: center; color: #bfa874; font-size: .85rem; padding: 4px 16px 120px; max-width: 820px; margin: 0 auto; }

@media (max-width: 420px) { body { font-size: 18px; } .page { padding: 18px 14px 20px; margin: 6px 3px 14px; } .page h1 { font-size: 1.45rem; } .titlecard h1 { font-size: 1.85rem; } .plate .title b { font-size: 1.05rem; } .gears { width: 52px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media print { body { background: #fff; } .plate, .board, .dock, .pipe, .toast, footer.foot { display: none !important; } .page { box-shadow: none; border: 1px solid #000; animation: none; } .btn, .row { display: none !important; } }

/* decorative vertical pipes on wide screens */
@media (min-width: 1000px) {
  body::before, body::after { content: ""; position: fixed; top: 0; bottom: 0; width: 22px; z-index: 0; pointer-events: none;
    background: repeating-linear-gradient(transparent 0 180px, rgba(20,8,2,.55) 180px 190px, rgba(240,200,140,.5) 190px 192px, transparent 192px 200px), linear-gradient(90deg, #5a2c12, #e3a672 35%, #b4653c 60%, #5a2c12);
    border: 1px solid #2a1206; box-shadow: 0 0 14px rgba(0,0,0,.7); }
  body::before { left: calc(50% - 470px); } body::after { right: calc(50% - 470px); }
  .plate { z-index: 1; }
}
