/* Self-hosted fonts (SIL Open Font License, see fonts/OFL-*.txt). No requests go to Google. */
@font-face { font-family: 'Archivo'; src: url('../fonts/archivo.woff') format('woff'); font-weight: 100 900; font-stretch: 62% 125%; font-style: normal; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('../fonts/jetbrains-mono.woff') format('woff'); font-weight: 100 800; font-style: normal; font-display: swap; }

/* FoS: The Daily Load Test — field-test theme. Dark "night shift" is default; light "daylight shop" via data-theme="light". */
:root,
[data-theme="dark"] {
  --bg: #0E1116;
  --panel: #12161C;
  --card: #171B22;
  --line: #262C36;
  --line2: #343C48;
  --steel: #2A313C;
  --steel-edge: #4A5462;
  --ink: #EDEFF2;
  --muted: #A7AFBC;
  --amber: #FFB020;      /* fills, borders */
  --amber-ink: #1A1204;  /* text on amber */
  --amber-text: #FFB020; /* amber used as text */
  --cyan: #3FD0E0;
  --cyan-text: #3FD0E0;
  --cyan-soft: #12232A;
  --bad: #FF5A4E;
  --bad-text: #FF8A80;
  --good: #3FD0E0;
  --mid: #7FD6B8;
  --warn: #FFB020;
  --paper: #F2EEE3;
  --paper-ink: #1C1F24;
  --stamp: #1F6FB5;
  --grid: rgba(63, 208, 224, .06);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #ECE8DE;
  --panel: #F6F3EB;
  --card: #FFFFFF;
  --line: #D5CFC2;
  --line2: #B9B2A3;
  --steel: #B9C0CA;
  --steel-edge: #7D8794;
  --ink: #1C1F24;
  --muted: #565B63;
  --amber: #F2A20C;
  --amber-ink: #1A1204;
  --amber-text: #8A5200;
  --cyan: #0E8796;
  --cyan-text: #0B6875;
  --cyan-soft: #E1F2F4;
  --bad: #C0362C;
  --bad-text: #A82E25;
  --good: #0B6875;
  --mid: #3C7A55;
  --warn: #8A5200;
  --paper: #FFFDF7;
  --paper-ink: #1C1F24;
  --stamp: #1F5FA5;
  --grid: rgba(14, 135, 150, .08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}
.mono { font-family: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
.small-text { font-size: 13px; }
a { color: var(--amber-text); }
b { font-weight: 700; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
[hidden] { display: none !important; }

.hazard { height: 6px; background: repeating-linear-gradient(-45deg, var(--amber) 0 10px, var(--bg) 10px 20px); }
.hazard.small { height: 8px; }
.grid-paper {
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 16px 16px;
}

.app { max-width: 480px; margin: 0 auto; padding: 0 14px 28px; }

/* Header */
.top { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; }
.top-right { display: flex; }
.brand { text-align: center; }
.brand h1 { margin: 0; font-weight: 800; font-stretch: 125%; font-size: 26px; letter-spacing: .04em; line-height: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.brand h1 .tagline { font-size: 10.5px; letter-spacing: .22em; font-stretch: 112%; color: var(--amber-text); font-weight: 700; }
.brand .sub { font-size: 12px; color: var(--muted); margin-top: 4px; letter-spacing: .04em; }
.icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: none; background: none; border-radius: 10px; }
.icon-btn:hover { background: var(--card); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.notice { font-size: 13px; color: var(--amber-text); border: 1px solid var(--line2); border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; }

/* Rig */
.rig { border: 1px solid var(--line); border-radius: 14px; background-color: var(--panel); padding: 10px 12px 10px; }
.rig-head { display: flex; justify-content: space-between; align-items: flex-end; }
.rig-head .right { text-align: right; }
.label { font-size: 12px; letter-spacing: .08em; color: var(--muted); }
.fos { font-size: 38px; font-weight: 700; line-height: 1.05; color: var(--good); transition: color .3s; }
.fos-max { font-size: 20px; font-weight: 700; }
.beam-svg { width: 100%; height: auto; display: block; }
.steel { fill: var(--steel); stroke: var(--steel-edge); }
.steel-flat { fill: var(--steel); }
.floor { fill: var(--line); }
.arrows { stroke: var(--amber); stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }
#beam { stroke: var(--bg); stroke-width: 1.5; transition: d .5s ease, fill .5s; }
#ram, #rod { transition: y .5s ease, height .5s ease; }
.cracks path { stroke: var(--bad); stroke-width: 2; fill: none; }

.rounds-track { list-style: none; margin: 6px 0 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.rounds-track li { border: 1px solid var(--line2); border-radius: 8px; padding: 4px 2px; text-align: center; font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--muted); }
.rounds-track li .v { display: block; font-size: 15px; font-weight: 700; color: var(--ink); }
.rounds-track li.current { border-color: var(--amber); color: var(--amber-text); }
.rounds-track li.r3 { border-color: var(--good); }
.rounds-track li.r3 .v { color: var(--good); }
.rounds-track li.r2 .v { color: var(--mid); }
.rounds-track li.r1 .v { color: var(--warn); }
.rounds-track li.r0 .v { color: var(--bad-text); }

/* Round card */
.round { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.round-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.round-type { font-weight: 800; font-stretch: 112%; letter-spacing: .06em; font-size: 15px; color: var(--cyan-text); text-transform: uppercase; }
.round-meta { font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--muted); }
.prompt { font-size: 17px; font-weight: 600; margin: 0; }

.clue { display: flex; gap: 10px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; animation: slide-in .35s ease both; }
.clue .n { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--amber); color: var(--amber-text); display: flex; align-items: center; justify-content: center; font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 700; }
.clue .t { flex: 1; font-size: 15.5px; }
.clue.big .t { font-family: 'JetBrains Mono', monospace; font-size: 18px; font-weight: 700; }
.miss { display: flex; align-items: center; gap: 8px; padding-left: 48px; font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--amber-text); }
.miss svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 3; fill: none; stroke-linecap: round; }

@keyframes slide-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Inputs and buttons */
.controls { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.row { display: flex; gap: 8px; }
.text-input { flex: 1; height: 48px; padding: 0 14px; border-radius: 10px; border: 1.5px solid var(--line2); background: var(--card); font-size: 16px; min-width: 0; }
.text-input::placeholder { color: var(--muted); }
.text-input:focus { border-color: var(--cyan); outline: none; }
.btn { height: 46px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line2); background: none; font-size: 15px; }
.btn:hover { background: var(--card); }
.btn.primary { border: none; background: var(--amber); color: var(--amber-ink); font-weight: 800; font-stretch: 112%; letter-spacing: .05em; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.cyan { border-color: var(--cyan); color: var(--cyan-text); }
.btn.danger-outline { border-color: var(--bad); color: var(--bad-text); }
.btn.wide { width: 100%; height: 52px; }
.btn.grow { flex: 1; }

.suggest { border: 1px solid var(--line2); border-radius: 10px; overflow: hidden; background: var(--card); margin: 0; padding: 0; list-style: none; }
.suggest li button { display: block; width: 100%; text-align: left; padding: 11px 12px; border: none; border-bottom: 1px solid var(--line); background: none; font-size: 15px; }
.suggest li:last-child button { border-bottom: none; }
.suggest li button[aria-selected="true"], .suggest li button:hover { background: var(--cyan-soft); }
.suggest .none { padding: 10px 12px; font-size: 13px; color: var(--muted); }
.error { font-size: 13px; color: var(--bad-text); margin: 0; }

.options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.options button { min-height: 48px; padding: 6px 8px; border-radius: 10px; border: 1px solid var(--cyan); background: var(--cyan-soft); font-size: 14.5px; }
.options button:disabled { border-color: var(--line); background: none; color: var(--muted); text-decoration: line-through; cursor: default; }

/* Sort */
.sort-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sort-item { display: flex; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 4px 6px 4px 12px; }
.sort-item .pos { font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--muted); width: 18px; }
.sort-item .val { flex: 1; font-family: 'JetBrains Mono', monospace; font-size: 17px; font-weight: 700; white-space: nowrap; min-width: 0; }
.sort-item .mark { font-family: 'JetBrains Mono', monospace; font-size: 12px; padding: 6px; border-radius: 6px; display: inline-flex; align-items: center; gap: 4px; }
.mark.ok { color: var(--good); border: 1px solid var(--good); }
.mark.no { color: var(--amber-text); border: 1px solid var(--amber); }
.mark svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.sort-item .mv { width: 44px; height: 44px; border-radius: 8px; border: 1px solid var(--line2); background: none; display: inline-flex; align-items: center; justify-content: center; }
.sort-item .mv svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.sort-item .mv:disabled { opacity: .35; cursor: default; }
.sort-ends { display: flex; justify-content: space-between; font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--muted); padding: 0 4px; }

/* Estimate */
.unit-tag { height: 48px; display: inline-flex; align-items: center; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line2); font-family: 'JetBrains Mono', monospace; font-size: 14px; color: var(--muted); }
.tries { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.tries li { display: flex; align-items: center; gap: 8px; font-family: 'JetBrains Mono', monospace; font-size: 14px; border: 1px solid var(--amber); color: var(--amber-text); border-radius: 10px; padding: 8px 12px; }
.tries li svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* Round result */
.result { border: 1px solid var(--line2); border-radius: 12px; padding: 12px 14px; background: var(--card); display: flex; flex-direction: column; gap: 8px; animation: slide-in .35s ease both; }
.result .verdict { font-weight: 800; font-stretch: 125%; font-size: 20px; letter-spacing: .04em; }
.result .verdict.ok { color: var(--good); }
.result .verdict.no { color: var(--bad-text); }
.result .answer { font-size: 15px; }
.result .fact { font-size: 14.5px; color: var(--muted); }

/* Dialogs */
dialog { width: min(440px, calc(100vw - 24px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--line2); border-radius: 16px; background: var(--card); color: var(--ink); overflow: auto; }
dialog::backdrop { background: rgba(5, 7, 10, .75); }
.dlg-body { padding: 16px 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; }
.dlg-head h2 { margin: 0; font-weight: 800; font-stretch: 125%; font-size: 22px; letter-spacing: .05em; }
.dlg-head .icon-btn { margin-right: -10px; }
dialog p { margin: 0; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: 15px; }
.steps li { display: flex; gap: 12px; }
.step-n { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--amber); color: var(--amber-text); display: flex; align-items: center; justify-content: center; font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 700; }
.score-table { border: 1px solid var(--line); border-radius: 10px; background: var(--bg); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.score-grid { display: grid; grid-template-columns: 1.4fr repeat(4, 1fr); gap: 4px; text-align: center; font-size: 13px; font-weight: 700; }
.score-grid span:first-child, .score-grid span:nth-child(6) { text-align: left; font-weight: 400; }
.c-good { color: var(--good); } .c-mid { color: var(--mid); } .c-warn { color: var(--warn); } .c-bad { color: var(--bad-text); }

.setting { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.setting.col { flex-direction: column; align-items: stretch; gap: 6px; }
.setting input[type=checkbox] { width: 24px; height: 24px; accent-color: var(--amber); flex: none; }

/* Report */
.paper { position: relative; background: var(--paper); color: var(--paper-ink); border-radius: 6px; padding: 14px 14px 12px; font-family: 'JetBrains Mono', monospace; }
.paper .ph { display: flex; justify-content: space-between; font-size: 12px; letter-spacing: .06em; border-bottom: 1.5px solid var(--paper-ink); padding-bottom: 6px; }
.paper table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
.paper td { padding: 4px 0; border-bottom: 1px dashed #A49E90; vertical-align: top; }
.paper td.r { text-align: right; font-weight: 700; white-space: nowrap; padding-left: 8px; }
.paper .total { display: flex; justify-content: space-between; font-weight: 700; font-size: 15px; margin-top: 8px; }
.stamp { position: static; display: block; width: fit-content; margin: 10px 4px 2px auto; transform: rotate(-6deg); border: 3px solid var(--stamp); color: var(--stamp); border-radius: 8px; padding: 4px 10px; text-align: center; font-family: 'Archivo', sans-serif; font-weight: 800; font-stretch: 125%; background: color-mix(in srgb, var(--paper) 80%, transparent); }
.stamp .s1 { font-size: 18px; letter-spacing: .08em; line-height: 1.1; }
.stamp .s2 { font-size: 12px; }
.stamp.cond { border-color: #9A5B00; color: #9A5B00; }
.stamp.fail { border-color: #B3261E; color: #B3261E; }

.stats4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; text-align: center; font-family: 'JetBrains Mono', monospace; }
.stats4 div { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 2px; }
.stats4 .n { font-size: 20px; font-weight: 700; display: block; }
.stats4 .l { font-size: 11.5px; color: var(--muted); }
.hist { display: flex; flex-direction: column; gap: 4px; }
.hist .hrow { display: flex; align-items: center; gap: 8px; font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.hist .hl { width: 54px; color: var(--muted); }
.hist .hb { flex: 1; }
.hist .bar { height: 16px; min-width: 18px; border-radius: 3px; background: var(--steel); color: var(--ink); font-weight: 700; display: flex; align-items: center; justify-content: flex-end; padding: 0 5px; font-size: 11.5px; }
.hist .bar.today { background: var(--amber); color: var(--amber-ink); }
.share-row { display: flex; align-items: center; gap: 12px; }
.share-row .cd { flex: 1; }
.cd .t { font-family: 'JetBrains Mono', monospace; font-size: 24px; font-weight: 700; color: var(--cyan-text); }
.share-preview { font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; white-space: pre-line; }
.rank-box { border: 1px dashed var(--line2); border-radius: 10px; padding: 10px 12px; font-size: 13px; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 10; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

/* Odd one out */
.odd-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.odd-card { min-height: 84px; padding: 10px; border-radius: 12px; border: 1.5px solid var(--line2); background: var(--card); font-size: 16px; font-weight: 600; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; transition: border-color .15s, transform .1s; }
.odd-card:hover:not(:disabled) { border-color: var(--amber); }
.odd-card:active:not(:disabled) { transform: scale(.98); }
.odd-card:disabled { cursor: default; }
.odd-card.is-wrong { color: var(--muted); border-style: dashed; }
.odd-card.is-odd { border-color: var(--good); color: var(--good); }
.odd-tag { display: inline-flex; align-items: center; gap: 4px; font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 400; }
.odd-tag svg { width: 13px; height: 13px; stroke: currentColor; stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* Tools drawer: calculator + notebook */
.tools-tab { position: fixed; right: 0; top: 42%; z-index: 5; writing-mode: vertical-rl; transform: rotate(180deg); padding: 14px 8px; border: none; border-radius: 0 10px 10px 0; background: var(--amber); color: var(--amber-ink); font-weight: 800; font-stretch: 112%; letter-spacing: .12em; font-size: 13px; }
.tools { position: fixed; top: 0; right: 0; bottom: 0; z-index: 6; width: min(360px, 100vw); background: var(--card); border-left: 1px solid var(--line2); display: flex; flex-direction: column; overflow-y: auto;
  transform: translateX(100%); visibility: hidden; transition: transform .25s ease, visibility 0s linear .25s; }
.tools.open { transform: none; visibility: visible; transition: transform .25s ease; }
.tools-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; }
.tabs [role=tab] { height: 40px; padding: 0 10px; border: 1px solid transparent; border-radius: 8px; background: none; font-weight: 700; color: var(--muted); }
.tabs [role=tab][aria-selected=true] { color: var(--ink); border-color: var(--line2); background: var(--bg); }
.pane { padding: 12px 14px 20px; display: flex; flex-direction: column; gap: 8px; }
.calc-in { height: 48px; padding: 0 12px; border-radius: 10px; border: 1.5px solid var(--line2); background: var(--bg); font-size: 16px; }
.calc-in:focus { border-color: var(--cyan); outline: none; }
.calc-out { text-align: right; font-size: 28px; font-weight: 700; color: var(--cyan-text); min-height: 40px; word-break: break-all; }
.calc-out.err { font-size: 14px; color: var(--bad-text); font-weight: 400; }
.keypad { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.keypad button { height: 48px; border-radius: 8px; border: 1px solid var(--line2); background: var(--bg); font-family: 'JetBrains Mono', monospace; font-size: 17px; font-weight: 500; }
.keypad button:hover { border-color: var(--cyan); }
.keypad button.op { color: var(--cyan-text); }
.keypad button.eq { background: var(--amber); color: var(--amber-ink); border: none; font-weight: 800; }
.keypad button.clr { color: var(--bad-text); }
.calc-hist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.calc-hist button { width: 100%; display: flex; justify-content: space-between; gap: 8px; padding: 6px 8px; border: none; border-radius: 6px; background: none; font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--muted); text-align: left; }
.calc-hist button:hover { background: var(--bg); color: var(--ink); }
.calc-hist .res { color: var(--ink); white-space: nowrap; }
.notes { min-height: 60vh; resize: vertical; padding: 12px; border-radius: 10px; border: 1.5px solid var(--line2); background: var(--bg); font-size: 14px; line-height: 1.6;
  background-image: linear-gradient(transparent calc(1.6em - 1px), var(--grid) calc(1.6em - 1px)); background-size: 100% 1.6em; background-attachment: local; }
.notes:focus { border-color: var(--cyan); outline: none; }
@media (min-width: 900px) { body.tools-open .app { transform: translateX(-180px); } .app { transition: transform .25s ease; } }
@media (max-width: 599px) {
  .tools-tab { writing-mode: horizontal-tb; transform: none; top: auto; bottom: 16px; right: 14px; border-radius: 999px; padding: 12px 18px; }
  .app { padding-bottom: 90px; }
}

/* Hint cards */
.hint-card { border: 1px dashed var(--cyan); border-radius: 10px; padding: 10px 12px; background: var(--cyan-soft); animation: slide-in .3s ease both; }
.hint-card .label { color: var(--cyan-text); margin-bottom: 4px; }
.hint-body { font-family: 'JetBrains Mono', monospace; font-size: 15px; white-space: pre-line; }

/* Formula sheet */
#sheet { display: flex; flex-direction: column; gap: 14px; }
.sheet-sec h3 { margin: 0 0 6px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--cyan-text); font-weight: 700; }
.sheet-sec dl { margin: 0; display: flex; flex-direction: column; gap: 2px; }
.sheet-row { padding: 6px 8px; border-radius: 6px; background: var(--bg); }
.sheet-row dt { font-size: 14.5px; font-weight: 700; }
.sheet-row dd { margin: 0; font-size: 13px; color: var(--muted); }

/* Per-round rig label */
.rig-test { text-align: center; font-size: 12px; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; margin: -2px 0 2px; }

/* Post-round test cutscene */
.cutscene { position: fixed; inset: 0; z-index: 20; background: rgba(5, 7, 10, .88); display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade-in .2s ease both; }
.cs-inner { width: min(480px, 100%); background: var(--panel); border: 1px solid var(--line2); border-radius: 16px; overflow: hidden; }
.cs-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.cs-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 13px; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; }
#cs-load { color: var(--ink); font-weight: 700; font-size: 18px; white-space: nowrap; }
.cs-svg { width: 100%; height: auto; display: block; background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px); background-size: 16px 16px; border-radius: 10px; border: 1px solid var(--line); }
.cs-bar { position: relative; height: 12px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line); overflow: hidden; }
#cs-fill { height: 100%; width: 0; background: var(--amber); }
.cs-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line2); }
.cs-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: -6px; }
.cs-verdict { min-height: 30px; font-weight: 800; font-stretch: 125%; font-size: 20px; letter-spacing: .04em; text-align: center; }
.cs-verdict.ok { color: var(--good); } .cs-verdict.mid { color: var(--warn); } .cs-verdict.no { color: var(--bad-text); }
.cs-verdict .stampish { display: inline-block; border: 3px solid currentColor; border-radius: 8px; padding: 2px 12px; transform: rotate(-4deg); animation: stamp .25s ease-out both; }
.shake { animation: shake .35s ease; }
@keyframes stamp { from { transform: rotate(-4deg) scale(1.6); opacity: 0; } to { transform: rotate(-4deg) scale(1); opacity: 1; } }
@keyframes shake { 0%,100% { transform: none; } 20% { transform: translate(-6px, 2px); } 40% { transform: translate(5px, -2px); } 60% { transform: translate(-4px, 1px); } 80% { transform: translate(3px, 0); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.cs-info { display: flex; flex-direction: column; gap: 4px; font-size: 14.5px; animation: slide-in .3s ease both; }
.cs-info .fact { color: var(--muted); font-size: 14px; }
.cutscene { overflow-y: auto; }

/* Load-in animation: a press stamps the logo, the gauge fills, the curtain lifts. ~1.6 s, tap to skip. */
.splash { position: fixed; inset: 0; z-index: 50; background: #0E1116; display: flex; align-items: center; justify-content: center; overflow: hidden;
  animation: sp-out .35s ease-in 1.45s forwards; }
.splash.out { animation: sp-out .25s ease-in forwards; }
.sp-stage { position: relative; width: 260px; height: 300px; }
.sp-rod { position: absolute; left: 118px; top: -400px; width: 24px; height: 470px; background: #2A313C; animation: sp-press .45s cubic-bezier(.7,0,.9,.6) .15s both; }
.sp-ram { position: absolute; left: 70px; top: 70px; width: 120px; height: 34px; border-radius: 4px; background: #2A313C; border: 2px solid #4A5462; animation: sp-press .45s cubic-bezier(.7,0,.9,.6) .15s both; }
.sp-logo { position: absolute; left: 0; right: 0; top: 104px; text-align: center; font-family: 'Archivo', system-ui, sans-serif; font-weight: 800; font-stretch: 125%; font-size: 84px; line-height: 1; color: #FFB020; letter-spacing: .02em;
  transform-origin: 50% 100%; animation: sp-squash .5s ease-out .6s both; }
.sp-bed { position: absolute; left: 30px; right: 30px; top: 190px; height: 8px; background: #343C48; border-radius: 2px; }
.sp-tag { position: absolute; left: 0; right: 0; top: 212px; text-align: center; font-family: 'Archivo', system-ui, sans-serif; font-weight: 800; font-stretch: 112%; font-size: 14px; letter-spacing: .28em; color: #EDEFF2; animation: sp-fade .3s ease .8s both; }
.sp-gauge { position: absolute; left: 50px; right: 50px; top: 248px; height: 6px; border-radius: 3px; background: #262C36; overflow: hidden; }
.sp-fill { height: 100%; width: 0; background: #3FD0E0; animation: sp-fill 1s ease-in-out .3s forwards; }
.sp-read { position: absolute; left: 0; right: 0; top: 262px; text-align: center; font-size: 11px; letter-spacing: .14em; color: #A7AFBC; animation: sp-fade .3s ease .4s both; }
.sp-hz { position: absolute; left: 0; right: 0; height: 14px; background: repeating-linear-gradient(-45deg, #FFB020 0 14px, #0E1116 14px 28px); }
.sp-hz-top { top: 0; animation: sp-slide-r .4s ease-out both; }
.sp-hz-bot { bottom: 0; animation: sp-slide-l .4s ease-out both; }
@keyframes sp-press { 0% { transform: translateY(-260px); } 100% { transform: translateY(0); } }
@keyframes sp-squash { 0% { opacity: 0; transform: scaleY(.3) scaleX(1.4); } 35% { opacity: 1; transform: scaleY(.82) scaleX(1.12); } 70% { transform: scaleY(1.05) scaleX(.97); } 100% { opacity: 1; transform: none; } }
@keyframes sp-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes sp-fill { to { width: 100%; } }
@keyframes sp-slide-r { from { transform: translateX(-100%); } to { transform: none; } }
@keyframes sp-slide-l { from { transform: translateX(100%); } to { transform: none; } }
@keyframes sp-out { to { transform: translateY(-100%); visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .splash { display: none; } }

/* Feedback, partial credit, report extras */
.good-text { color: var(--good); font-weight: 700; }
.tries li.close { border-color: var(--cyan); color: var(--cyan-text); }
.hist .hl.wide { width: 112px; }
.hist .bar.weak { background: var(--bad); color: #fff; }
.weak-tag { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--bad-text); }
.teaser { border: 1px solid var(--line2); border-radius: 10px; padding: 10px 12px; font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.teaser .label { color: var(--cyan-text); }

/* First-visit tour */
.coach { position: fixed; inset: 0; z-index: 40; }
.coach-spot { position: fixed; border-radius: 14px; box-shadow: 0 0 0 200vmax rgba(5, 7, 10, .82); border: 2px solid var(--amber); transition: all .25s ease; pointer-events: none; }
.coach-bubble { position: fixed; left: 50%; transform: translateX(-50%); width: min(400px, calc(100vw - 24px)); background: var(--card); border: 1px solid var(--line2); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; transition: top .25s ease; }
.coach-bubble p { margin: 0; font-size: 15.5px; }
.coach-step { font-size: 11px; letter-spacing: .1em; color: var(--amber-text); }

/* Accent colors (Settings → Accent color). Fill colors keep dark text readable;
   the -text variants are darker in light mode so text keeps 4.5:1 contrast. */
[data-accent="orange"] { --amber: #FF7A1A; --amber-text: #FF8A33; }
[data-accent="green"]  { --amber: #8BE04E; --amber-text: #8BE04E; }
[data-accent="blue"]   { --amber: #5AB0FF; --amber-text: #6DB9FF; }
[data-accent="pink"]   { --amber: #FF6FD0; --amber-text: #FF85D8; }
[data-theme="light"][data-accent="orange"] { --amber: #FF7A1A; --amber-text: #A3420A; }
[data-theme="light"][data-accent="green"]  { --amber: #7BD13E; --amber-text: #3B6E12; }
[data-theme="light"][data-accent="blue"]   { --amber: #5AB0FF; --amber-text: #0B5CA8; }
[data-theme="light"][data-accent="pink"]   { --amber: #FF6FD0; --amber-text: #A3237B; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line2); display: inline-flex; align-items: center; justify-content: center; color: #1A1204; }
.swatch[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--ink); }
.swatch svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 3; fill: none; stroke-linecap: round; stroke-linejoin: round; }
