/* Liberty Run: storybook ink-and-paper UI. Landscape, phone first. */

:root {
  --ink: #3a2a1a;
  --ink-soft: #6b5640;
  --paper: #fbf3df;
  --paper-2: #f3e6c8;
  --paper-3: #e9d8b0;
  --red: #c8483e;
  --blue: #4f7fb8;
  --gold: #e0a53a;
  --green: #5f9a5a;
  --navy: #2c3e66;
  --good: #3f8f4a;
  --bad: #b23a2e;
  --hand: 'Patrick Hand', 'Comic Sans MS', cursive;
  --script: 'Caveat', 'Patrick Hand', cursive;
  --safe-l: max(12px, env(safe-area-inset-left));
  --safe-r: max(12px, env(safe-area-inset-right));
  --safe-b: max(8px, env(safe-area-inset-bottom));
  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='p'><feTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .35 0 0 0 0 .28 0 0 0 0 .2 0 0 0 .2 0'/></filter><rect width='100%25' height='100%25' filter='url(%23p)'/></svg>");
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2b2016; color: var(--ink); overscroll-behavior: none; }
body { font-family: var(--hand); font-size: clamp(15px, 3.9vh, 22px); line-height: 1.2; -webkit-user-select: none; user-select: none; touch-action: manipulation; -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
input { -webkit-user-select: text; user-select: text; }

#game { position: fixed; inset: 0; visibility: hidden; }
#game canvas { display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#ui > * { pointer-events: auto; }
#ui .passthru { pointer-events: none; }
#ui .passthru > * { pointer-events: auto; }

/* ---------- shared pieces ---------- */
.paper { background: var(--grain), var(--paper); border: 2.5px solid var(--ink); border-radius: 14px 10px 16px 11px; box-shadow: 4px 5px 0 rgba(58, 42, 26, .28); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4em; padding: .45em 1.1em; min-height: 44px; background: var(--grain), var(--paper); border: 2.5px solid var(--ink); border-radius: 12px 9px 13px 10px; box-shadow: 3px 4px 0 rgba(58, 42, 26, .3); color: var(--ink); font-family: var(--hand); font-size: 1em; line-height: 1.05; transition: transform .08s, box-shadow .08s; text-decoration: none; }
.btn:active { transform: translate(2px, 3px); box-shadow: 1px 1px 0 rgba(58, 42, 26, .3); }
.btn.big { font-family: var(--script); font-size: 1.6em; padding: .25em 1.2em; }
.btn.red { background: var(--grain), var(--red); color: var(--paper); }
.btn.blue { background: var(--grain), var(--blue); color: var(--paper); }
.btn.gold { background: var(--grain), var(--gold); color: var(--ink); }
.btn.green { background: var(--grain), var(--green); color: var(--paper); }
.btn.navy { background: var(--grain), var(--navy); color: var(--paper); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn[disabled], .btn.locked { opacity: .45; pointer-events: none; }
.icon-btn { width: 44px; height: 44px; padding: 0; border-radius: 50% 46% 52% 48%; }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn.sm { width: 38px; height: 38px; min-height: 38px; }
.icon-btn.sm svg { width: 20px; height: 20px; }
.btn svg, .pill svg { width: 1.15em; height: 1.15em; flex: none; }
.script { font-family: var(--script); }
.muted { color: var(--ink-soft); }
.row { display: flex; gap: .6em; align-items: center; }
.grow { flex: 1; }
.hidden { display: none !important; }

.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 10px var(--safe-r) var(--safe-b) var(--safe-l); }
.screen.dim { background: rgba(43, 32, 22, .55); }
.screen.backdrop { background: var(--grain), radial-gradient(120% 90% at 50% 40%, #6a4a31, #3a2618 75%); }

/* ---------- title ---------- */
.title-art { position: fixed; inset: 0; background-size: cover; background-position: center; }
.title-wrap { position: relative; width: min(100%, 1100px); height: 100%; display: grid; grid-template-columns: 1.15fr 1fr; align-items: center; gap: 2vw; }
.logo { text-align: left; }
.logo h1 { margin: 0; font-family: var(--script); font-weight: 700; font-size: clamp(54px, 21vh, 132px); line-height: .82; color: var(--paper); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 4px 5px 0 var(--ink), 0 0 30px rgba(255, 240, 200, .35); transform: rotate(-3deg); }
.logo h1 span { color: var(--red); display: block; margin-left: .4em; }
.logo p { display: inline-block; margin: .6em 0 0 .3em; padding: .25em .7em; font-size: 1em; color: var(--ink); background: var(--grain), rgba(251, 243, 223, .92); border: 2px solid var(--ink); border-radius: 12px 9px 13px 10px; box-shadow: 2px 3px 0 rgba(58, 42, 26, .3); max-width: 26em; }
.title-actions { display: flex; flex-direction: column; gap: 12px; align-items: stretch; max-width: 360px; justify-self: end; width: 100%; }
.title-actions .who { align-self: center; padding: .1em .7em; color: var(--ink); background: rgba(251, 243, 223, .92); border: 2px solid var(--ink); border-radius: 99px; font-size: .95em; }
.install-tip { align-self: center; text-align: center; font-size: .85em; padding: .25em .8em; background: rgba(251, 243, 223, .94); border: 2px dashed var(--ink); border-radius: 10px; }
.install-tip b { font-weight: normal; color: var(--navy); text-decoration: underline; }
.title-eagle { position: absolute; right: 3%; bottom: 2%; width: clamp(110px, 34vh, 230px); pointer-events: none; animation: bob 1.6s ease-in-out infinite; }

/* ---------- forms (codename) ---------- */
.card { width: min(100%, 760px); max-height: 100%; overflow: auto; padding: 16px 20px; }
.card h2 { margin: 0 0 .2em; font-family: var(--script); font-size: 2em; line-height: 1; }
.card .sub { margin: 0 0 .6em; color: var(--ink-soft); }
.heroes { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; margin: .3em 0 .5em; }
.hero-tabs { display: flex; flex-wrap: wrap; margin-top: .2em; }
.hero-tabs button { padding: .15em .7em; min-height: 34px; font-size: .9em; }
.hero-tag { padding: .15em .4em; min-height: 36px; background: var(--paper-2); border: 2px solid var(--ink); border-radius: 9px 7px 10px 8px; text-align: center; font-size: .95em; line-height: 1.05; }
.hero-tag small { display: block; font-size: .7em; color: var(--ink-soft); }
.hero-tag.on { background: var(--gold); box-shadow: inset 0 0 0 2px var(--ink); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: .85em; color: var(--ink-soft); }
.field input, .field select { background: #fffaf0; border: 2.5px solid var(--ink); border-radius: 10px 8px 11px 9px; padding: .35em .6em; min-height: 44px; font-size: 1.05em; width: 100%; }
.field input:focus, .field select:focus { outline: 3px solid var(--gold); outline-offset: 1px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px 12px; align-items: end; }
.err { color: var(--bad); min-height: 1.2em; font-size: .9em; margin: .3em 0; }
.codename-reveal { text-align: center; padding: .3em 0; }
.codename-reveal .name { font-family: var(--script); font-size: 3em; line-height: 1; }
.codename-reveal .pin { font-size: 1.3em; letter-spacing: .25em; }
.note { background: #fff3b8; border: 2px dashed var(--ink); border-radius: 10px; padding: .4em .7em; font-size: .9em; }

/* ---------- passport hub ---------- */
.passport { width: min(100%, 1180px); height: min(100%, 640px); display: grid; grid-template-columns: minmax(0, .92fr) minmax(0, 1.25fr); filter: drop-shadow(0 14px 18px rgba(0, 0, 0, .45)); }
.pp-page { position: relative; background: var(--grain), repeating-radial-gradient(circle at 30% 35%, rgba(36, 96, 110, .06) 0 1px, transparent 1px 6px), #efe6cf; padding: clamp(10px, 3vh, 22px) clamp(12px, 2.4vw, 26px); display: flex; flex-direction: column; min-height: 0; }
.pp-page.l { border-radius: 10px 0 0 10px; box-shadow: inset -16px 0 18px -14px rgba(0, 0, 0, .35); }
.pp-page.r { border-radius: 0 10px 10px 0; box-shadow: inset 16px 0 18px -14px rgba(0, 0, 0, .35); }
.kicker { font-size: .7em; letter-spacing: .22em; color: var(--navy); text-transform: uppercase; }
.pp-top { display: flex; align-items: center; gap: 6px; }
.pp-id { gap: .5em; flex-wrap: wrap; margin: .05em 0 .1em; }
.pp-name { font-family: var(--script); font-size: 2em; line-height: .95; }
.pp-rank { display: inline-flex; align-items: center; gap: .3em; background: var(--navy); color: var(--paper); border-radius: 99px; padding: .05em .7em; font-size: .85em; white-space: nowrap; }
.pp-rank svg { width: 1.05em; height: 1.05em; }
.meter-label { display: flex; justify-content: space-between; font-size: .8em; color: var(--ink-soft); margin-top: .55em; }
.meter { position: relative; height: 12px; background: rgba(44, 62, 102, .14); border: 2px solid var(--ink); border-radius: 99px; overflow: hidden; margin-top: 3px; }
.meter i { position: absolute; inset: 0 auto 0 0; background: var(--navy); border-radius: 99px; }
.meter.score i { background: var(--green); }
.meter.score.low i { background: var(--gold); }
.meter .line { position: absolute; top: -2px; bottom: -2px; left: 70%; width: 3px; background: var(--red); }
.pp-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: .7em; text-align: center; }
.pp-stats div { background: rgba(255, 255, 255, .45); border: 2px solid rgba(58, 42, 26, .25); border-radius: 10px; padding: .2em .1em; font-size: .78em; color: var(--ink-soft); }
.pp-stats b { display: block; font-weight: normal; font-size: 1.55em; color: var(--ink); line-height: 1.05; }
.pp-actions { margin-top: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding-top: .6em; }
.pp-actions .wide { grid-column: 1 / -1; }
.stamp-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); gap: 4px 6px; flex: 1; min-height: 0; margin-top: 4px; }
.stamp-cell { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 0; padding: 2px; border-radius: 12px; background: none; border: 0; }
.stamp-cell svg { width: 100%; height: 100%; max-height: 100%; min-height: 0; flex: 1; }
.stamp-cell .lbl { font-size: .62em; line-height: 1; text-align: center; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.stamp-cell .prog { position: absolute; top: 2px; right: 2px; font-size: .62em; background: var(--paper); border: 1.5px solid var(--ink); border-radius: 99px; padding: 0 .4em; }
.stamp-cell.locked { opacity: .5; }
.stamp-cell.next { animation: glow 1.8s ease-in-out infinite; }
.stamp-cell:active { transform: scale(.96); }
.pp-tabs { position: absolute; right: -34px; top: 14%; display: flex; flex-direction: column; gap: 8px; z-index: 2; }
.pp-tab { writing-mode: vertical-rl; transform: rotate(180deg); padding: 12px 6px; border-radius: 6px 0 0 6px; border: 2px solid var(--ink); border-right: 0; color: var(--paper); font-size: .8em; min-width: 34px; }

/* world sheet */
.sheet { width: min(100%, 820px); max-height: 100%; overflow: auto; padding: 14px 18px; display: grid; grid-template-columns: 170px 1fr; gap: 6px 18px; }
.sheet .stamp-big svg { width: 100%; height: auto; }
.sheet h2 { margin: 0; font-family: var(--script); font-size: 2.2em; line-height: 1; }
.sheet .blurb { color: var(--ink-soft); margin: .2em 0 .5em; font-size: .92em; }
.levels { display: flex; flex-wrap: wrap; gap: 8px; margin: .3em 0 .6em; }
.lvl { min-width: 92px; flex-direction: column; gap: 0; line-height: 1; padding: .35em .6em; }
.lvl small { font-size: .7em; color: var(--ink-soft); }
.lvl.done { background: var(--grain), #dfecd2; }
.stars3 { color: var(--gold); letter-spacing: .05em; font-size: .9em; -webkit-text-stroke: .6px var(--ink); }

/* ---------- in-run HUD and question UI ---------- */
.hud { position: fixed; top: max(6px, env(safe-area-inset-top)); left: var(--safe-l); right: var(--safe-r); display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; pointer-events: none; }
.hud > * { pointer-events: auto; }
.pill { display: inline-flex; align-items: center; gap: .3em; background: var(--grain), var(--paper); border: 2px solid var(--ink); border-radius: 11px 8px 12px 9px; padding: .1em .6em; min-height: 34px; box-shadow: 2px 3px 0 rgba(58, 42, 26, .25); font-size: .95em; white-space: nowrap; }
.pill svg { width: 1.15em; height: 1.15em; }
.hearts svg { width: 1.25em; height: 1.25em; transition: transform .2s, opacity .2s; }
.hearts svg.gone { opacity: .22; transform: scale(.8); filter: grayscale(1); }
.hud .right { display: flex; gap: 6px; align-items: center; }
.qbanner { position: fixed; top: max(6px, env(safe-area-inset-top)); left: calc(var(--safe-l) + 128px); right: calc(var(--safe-r) + 160px); margin: 0 auto; max-width: 700px; transform: rotate(-.5deg); padding: .3em .9em .4em; text-align: center; font-size: clamp(17px, 5.6vh, 34px); line-height: 1.12; transition: transform .25s, opacity .25s; }
.qbanner small { display: block; font-family: var(--script); color: var(--red); font-size: .72em; line-height: 1; }
.qbanner.out { opacity: 0; transform: translateY(-120%); }
.answers { position: fixed; left: var(--safe-l); right: var(--safe-r); bottom: var(--safe-b); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; transition: transform .25s, opacity .25s; }
.answers.out { opacity: 0; transform: translateY(130%); pointer-events: none; }
.ans { display: flex; align-items: center; gap: .45em; min-height: clamp(54px, 17vh, 86px); padding: .3em .55em; text-align: left; font-size: clamp(16px, 4.5vh, 26px); line-height: 1.05; background: var(--grain), var(--paper); border: 2.5px solid var(--ink); border-radius: 12px 9px 13px 10px; box-shadow: 3px 4px 0 rgba(58, 42, 26, .28); }
.ans:nth-child(odd) { transform: rotate(-.6deg); }
.ans:nth-child(even) { transform: rotate(.5deg); }
.ans b { flex: none; display: grid; place-items: center; width: 1.75em; height: 1.75em; border-radius: 50%; border: 2px solid var(--ink); color: var(--paper); font-family: var(--script); font-size: 1.2em; font-weight: 700; }
.ans:active { transform: translate(2px, 3px); box-shadow: 1px 1px 0 rgba(58, 42, 26, .3); }
.ans.picked { background: var(--grain), #fff3b8; }
.ans.right { background: var(--grain), #d7ecc9; box-shadow: 0 0 0 3px var(--good), 3px 4px 0 rgba(58, 42, 26, .28); }
.ans.wrong { background: var(--grain), #f6d2cb; text-decoration: line-through; text-decoration-color: rgba(178, 58, 46, .7); }
.answers.locked .ans { pointer-events: none; }
.writein { position: fixed; left: 50%; transform: translateX(-50%); bottom: var(--safe-b); width: min(70vw, 620px); display: flex; gap: 8px; align-items: stretch; transition: opacity .25s, transform .25s; }
.writein.out { opacity: 0; transform: translate(-50%, 130%); pointer-events: none; }
.writein input { flex: 1; min-width: 0; background: #fffaf0; border: 2.5px solid var(--ink); border-radius: 12px 9px 13px 10px; padding: .25em .7em; font-size: clamp(16px, 4.6vh, 26px); box-shadow: inset 2px 2px 0 rgba(58, 42, 26, .12); }
.writein input:focus { outline: 3px solid var(--gold); }
.writein .hint { position: absolute; bottom: 100%; left: 0; right: 0; text-align: center; font-size: .8em; color: var(--paper); text-shadow: 1px 1px 0 var(--ink), -1px 1px 0 var(--ink), 1px -1px 0 var(--ink), -1px -1px 0 var(--ink); margin-bottom: 4px; }
.feedback { position: fixed; left: 50%; top: 32%; transform: translate(-50%, -50%) rotate(-2deg); font-family: var(--script); font-size: clamp(30px, 12vh, 70px); color: var(--paper); -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 3px 4px 0 var(--ink); pointer-events: none; animation: pop .9s ease-out forwards; white-space: nowrap; }
.feedback.good { color: #d7ecc9; }
.feedback.bad { color: #f6d2cb; }
.finale-cheer { animation: pop 4.2s ease-out forwards; top: 40%; font-size: clamp(36px, 14vh, 84px); white-space: normal; text-align: center; width: 90vw; }
.reveal { position: fixed; left: 50%; top: 22%; transform: translateX(-50%); padding: .3em .9em; font-size: clamp(14px, 4vh, 22px); text-align: center; max-width: 70vw; pointer-events: none; }
.reveal b { color: var(--good); font-weight: normal; }
.tap-hint { position: fixed; left: 50%; bottom: 30%; transform: translateX(-50%); background: var(--grain), var(--paper); border: 2px solid var(--ink); border-radius: 12px 9px 13px 10px; box-shadow: 2px 3px 0 rgba(58, 42, 26, .3); padding: .2em .8em; font-size: .95em; pointer-events: none; white-space: nowrap; animation: fade 2.4s ease-in-out infinite; }

.boss-bar { position: fixed; right: var(--safe-r); top: 52px; width: min(38vw, 360px); text-align: right; pointer-events: none; }
.boss-bar .nm { font-family: var(--script); font-size: 1.5em; color: var(--paper); -webkit-text-stroke: 1.5px var(--ink); paint-order: stroke fill; text-shadow: 2px 3px 0 var(--ink); line-height: 1; }
.boss-bar .hp { height: 16px; border: 2.5px solid var(--ink); border-radius: 99px; background: rgba(255, 255, 255, .6); overflow: hidden; margin-top: 4px; }
.boss-bar .hp i { display: block; height: 100%; background: var(--red); transition: width .35s; }

/* ---------- modal cards: results, pause, stamp ---------- */
.modal { width: min(100%, 640px); max-height: 100%; overflow: auto; padding: 14px 20px; text-align: center; }
.modal h2 { margin: 0; font-family: var(--script); font-size: 2.4em; line-height: 1; }
.modal .big-num { font-family: var(--script); font-size: 3.6em; line-height: 1; }
.modal .stats { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin: .5em 0; }
.modal .stats div { background: rgba(255, 255, 255, .5); border: 2px solid rgba(58, 42, 26, .25); border-radius: 10px; padding: .15em .7em; font-size: .85em; color: var(--ink-soft); min-width: 92px; }
.modal .stats b { display: block; font-weight: normal; font-size: 1.5em; color: var(--ink); }
.modal .actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: .6em; }
.stamp-slam { width: min(48vh, 260px); margin: 0 auto; animation: slam .55s cubic-bezier(.2, 1.6, .4, 1) both; }
.stamp-slam svg { width: 100%; height: auto; }
.rank-up { display: inline-block; background: var(--navy); color: var(--paper); border-radius: 99px; padding: .15em .9em; margin-top: .3em; animation: pop-in .5s .4s both; }

/* Keyboard hints, only on devices with a mouse/trackpad (body.kbd). */
.kbd .ans { position: relative; }
.kbd .ans[data-key]::after { content: attr(data-key); position: absolute; top: -.6em; right: 8px; min-width: 1.3em; padding: 0 .3em; font-size: .7em; line-height: 1.35; text-align: center; color: var(--ink-soft); border: 1.5px solid rgba(58, 42, 26, .45); border-bottom-width: 2.5px; border-radius: 5px; background: #fbf3df; }
.kbd .writein .hint::after { content: ' Press Enter to go.'; }
.btn:focus-visible, .ans:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- practice test ---------- */
.test { width: min(100%, 980px); height: 100%; display: flex; flex-direction: column; gap: 8px; padding: 8px 0; }
.test-top { display: flex; align-items: center; gap: 10px; }
.test-top .meter { flex: 1; margin: 0; }
.test-top > span { color: var(--paper); font-weight: 700; white-space: nowrap; text-shadow: 0 1px 2px rgba(0, 0, 0, .5); }
.test-q { padding: .5em 1em; font-size: clamp(17px, 5.4vh, 32px); line-height: 1.12; text-align: center; min-height: 0; }
.test-q small { display: block; font-family: var(--script); color: var(--red); font-size: .6em; }
.test-answers { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.test-answers .ans { min-height: clamp(52px, 15vh, 78px); }
.test-answers.locked .ans { pointer-events: none; }
.misses-note { align-self: center; text-align: center; font-size: clamp(16px, 4vh, 24px); font-weight: 700; padding: .25em .9em; border-radius: 12px; background: var(--grain), var(--paper); border: 2.5px solid var(--ink); box-shadow: 3px 4px 0 rgba(58, 42, 26, .28); }
.misses-note:empty { visibility: hidden; }
.misses-note.good { color: var(--good); }
.misses-note.bad { color: var(--red); }
.test .writein { position: static; transform: none; width: 100%; }

/* ---------- certificate ---------- */
.cert { width: min(100%, 880px); padding: clamp(12px, 3vh, 26px) clamp(16px, 4vw, 40px); text-align: center; background: var(--grain), var(--paper); border: 3px solid var(--ink); box-shadow: inset 0 0 0 7px var(--paper-2), inset 0 0 0 10px var(--ink), 6px 8px 0 rgba(0, 0, 0, .35); border-radius: 6px; position: relative; }
.cert .seal { position: absolute; right: 4%; bottom: 8%; width: min(26vh, 150px); transform: rotate(-10deg); }
.cert .seal svg { width: 100%; height: auto; }
.cert h2 { font-family: var(--script); font-size: clamp(30px, 11vh, 64px); margin: 0; line-height: 1; }
.cert .who { font-family: var(--script); font-size: clamp(34px, 13vh, 76px); line-height: 1; color: var(--navy); margin: .1em 0; }
.cert p { margin: .25em 0; }

/* ---------- leaderboard ---------- */
.board { width: min(100%, 760px); height: 100%; display: flex; flex-direction: column; padding: 12px 16px; }
.board h2 { margin: 0; font-family: var(--script); font-size: 2.1em; }
.board-list { flex: 1; overflow: auto; margin-top: 6px; border-top: 2px solid var(--ink); -webkit-overflow-scrolling: touch; }
.board-row { display: grid; grid-template-columns: 2.2em 1fr auto auto; gap: 10px; align-items: center; padding: .3em .2em; border-bottom: 1.5px dashed rgba(58, 42, 26, .35); }
.board-row.me { background: #fff3b8; }
.board-row .pos { font-family: var(--script); font-size: 1.4em; text-align: center; }
.board-row small { color: var(--ink-soft); }
.seg { display: inline-flex; border: 2px solid var(--ink); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--paper); padding: .2em .8em; min-height: 36px; }
.seg button.on { background: var(--navy); color: var(--paper); }

/* ---------- toast + rotate + loading ---------- */
.toast { position: fixed; left: 50%; bottom: 18%; transform: translateX(-50%); padding: .35em 1em; pointer-events: none; animation: toast 2.6s ease-out forwards; z-index: 50; }
.loading { position: fixed; inset: 0; display: grid; place-items: center; color: var(--paper); font-family: var(--script); font-size: 2.2em; background: #2b2016; z-index: 40; }
#rotate { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; background: var(--grain), #2b2016; color: var(--paper); text-align: center; }
.rotate-card p { font-family: var(--script); font-size: 2em; margin: .5em 1em 0; }
.rotate-phone { width: 70px; height: 120px; margin: 0 auto; border: 4px solid var(--paper); border-radius: 14px; animation: turn 2.2s ease-in-out infinite; }
@media (orientation: portrait) and (pointer: coarse) { #rotate { display: flex; } }

/* ---------- animation ---------- */
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes glow { 0%, 100% { filter: drop-shadow(0 0 0 rgba(224, 165, 58, 0)); } 50% { filter: drop-shadow(0 0 8px rgba(224, 165, 58, .95)); } }
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.6) rotate(-2deg); } 18% { opacity: 1; transform: translate(-50%, -50%) scale(1.08) rotate(-2deg); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -70%) scale(1) rotate(-2deg); } }
@keyframes pop-in { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: scale(1); } }
@keyframes slam { 0% { opacity: 0; transform: scale(2.2) rotate(-18deg); } 60% { opacity: 1; transform: scale(.94) rotate(-8deg); } 100% { transform: scale(1) rotate(-8deg); } }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 20px); } 12%, 80% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; } }
@keyframes fade { 0%, 100% { opacity: .65; } 50% { opacity: 1; } }
@keyframes turn { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.shake { animation: shake .3s; }

/* Short landscape phones: tighten everything a notch. */
@media (max-height: 420px) {
  .card, .modal, .sheet { padding: 8px 14px; }
  .pp-stats div { padding: 0 .1em; }
  .pp-stats b { font-size: 1.3em; }
  .meter-label { margin-top: .35em; }
  .pp-actions .btn.big { font-size: 1.3em; }
  .cert { padding: 8px 18px; }
  .cert p { margin: .1em 0; font-size: .9em; }
  .cert .seal { width: 92px; right: 3%; bottom: 6%; }
  .card h2 { font-size: 1.6em; }
  .card .sub { margin-bottom: .2em; font-size: .85em; }
  .hero-tag { min-height: 32px; font-size: .85em; }
  .field input, .field select { min-height: 38px; padding: .2em .5em; }
  .btn.big { font-size: 1.35em; }
  .err { margin: .15em 0; }
  .pp-stats { margin-top: .4em; }
  .sheet { grid-template-columns: 130px 1fr; }
}
