/* Ghostlist — warm, witty, candlelit. System fonts only. */
:root {
  --bg: #F7F1E6; --surface: #FFFDF8; --paper: #FFFBF0; --cloth: #EEE3D0;
  --ink: #1E1A16; --ink-2: #5B5248; --ink-3: #A99D8C; --line: #E3D8C6;
  --ctl: #8C8070; /* control boundaries: at least 3:1 on every background */
  --accent: #7A2E3A; --accent-ink: #FFFFFF; --gold: #B8892B; --gold-ink: #85601A;
  --came: #2F7D5B; --kid: #B5621A; --ghost: #6E6A8F; --unborn: #8F7442; --danger: #B3261E;
  --shadow: 0 1px 0 rgba(90, 60, 30, .06), 0 3px 10px rgba(90, 60, 30, .07);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Noto Serif", "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --card-h: 6rem; --card-back-h: 6rem; --bw: 1px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14121A; --surface: #1F1C27; --paper: #25212E; --cloth: #191620;
    --ink: #F3EDE2; --ink-2: #B9AFA2; --ink-3: #6F6878; --line: #2E2A38; --ctl: #77708A;
    --accent: #E07A86; --accent-ink: #1A0F12; --gold: #E3B95B; --gold-ink: #E3B95B;
    --came: #6CC59A; --kid: #F0A35E; --ghost: #A7A3D6; --unborn: #D8C08E; --danger: #FF8A80;
    --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14121A; --surface: #1F1C27; --paper: #25212E; --cloth: #191620;
  --ink: #F3EDE2; --ink-2: #B9AFA2; --ink-3: #6F6878; --line: #2E2A38; --ctl: #77708A;
  --accent: #E07A86; --accent-ink: #1A0F12; --gold: #E3B95B; --gold-ink: #E3B95B;
  --came: #6CC59A; --kid: #F0A35E; --ghost: #A7A3D6; --unborn: #D8C08E; --danger: #FF8A80;
  --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
:root[data-contrast="1"] { --ink-2: var(--ink); --ink-3: var(--ink-2); --ctl: var(--ink); --line: var(--ink-2); --bw: 3px; }
:root[data-contrast="1"] a { text-decoration: underline; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html.modal-open { overflow: hidden; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 1rem/1.5 var(--sans); min-height: 100vh; min-height: 100dvh; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); text-underline-offset: 3px; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[tabindex="-1"]:focus { outline: none; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 60; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 8px; }
.gone { display: none !important; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.center { text-align: center; }
.strong { font-weight: 650; }

/* Header */
.hdr { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: var(--bw) solid var(--line); padding-top: env(safe-area-inset-top); }
.hdr-in { max-width: 32.5rem; margin: 0 auto; height: 3rem; display: flex; align-items: center; justify-content: space-between; padding: 0 .5rem 0 1rem; }
.brand { display: flex; align-items: baseline; gap: .5rem; text-decoration: none; color: var(--ink); }
.wordmark { font: 700 1.3rem/1 var(--serif); letter-spacing: .01em; }
.hdr-n { font: 600 .85rem var(--sans); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.hdr-btns { display: flex; }
.icon-btn { width: 2.75rem; height: 2.75rem; display: grid; place-items: center; border: 0; background: none; border-radius: 12px; cursor: pointer; color: var(--ink); font-size: 1.05rem; }
.icon-btn:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.icon-btn svg { width: 1.4rem; height: 1.4rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn svg .fill { fill: currentColor; stroke: none; }
.flagmsg { max-width: 32.5rem; margin: .5rem auto 0; display: flex; gap: .5rem; align-items: center; justify-content: space-between; background: var(--surface); border: 1px solid var(--gold); border-radius: 12px; padding: .25rem .25rem .25rem .875rem; font-size: .9rem; }

main { display: block; max-width: 30rem; margin: 0 auto; padding: .75rem 1rem 1.25rem; }
.boot { min-height: 60vh; display: grid; place-content: center; justify-items: center; text-align: center; color: var(--ink-2); gap: .5rem; }
.boot-plate { font-size: 2.2rem; animation: breathe 1.6s ease-in-out infinite; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 2.75rem; padding: 0 1.1rem; border-radius: 12px; border: var(--bw) solid var(--line); background: var(--surface); color: var(--ink); font: 600 1rem var(--sans); cursor: pointer; text-decoration: none; touch-action: manipulation; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.big { width: 100%; min-height: 3.25rem; font-size: 1.07rem; border-radius: 14px; }
.btn.small { font-size: .9rem; }
.btn.danger { color: var(--danger); border-color: currentColor; background: transparent; white-space: normal; text-align: left; padding: .5rem 1rem; }
.btn:disabled, .btn.waiting { opacity: .5; cursor: default; filter: none; }
.btn:active:not(:disabled):not(.waiting) { transform: scale(.97); }
.btn.pulse:not(:disabled) { animation: pulse 1.6s ease-in-out infinite; }
.link-btn { background: none; border: 0; color: var(--accent); font: 600 .95rem var(--sans); padding: .6rem .5rem; min-height: 2.75rem; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.row2 { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; }
.row2 > .btn { flex: 1 1 8rem; }

/* Table view: header */
.tut-intro { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: .1rem 0 .5rem; }
.hook { font: 600 1.2rem/1.25 var(--serif); }
.t-head { margin-bottom: .5rem; }
.t-row { display: flex; align-items: baseline; gap: .15rem .6rem; flex-wrap: wrap; }
.t-row.over { align-items: center; flex-wrap: nowrap; min-height: 1.25rem; }
.t-of { font: 650 .7rem/1.4 var(--sans); letter-spacing: .09em; text-transform: uppercase; color: var(--ink-2); white-space: nowrap; }
.dots { display: flex; gap: .3rem; }
.dots i { width: .5rem; height: .5rem; border-radius: 50%; border: 1.5px solid var(--ctl); }
.dots i.done { background: var(--ink-2); border-color: var(--ink-2); }
.dots i.cur { background: var(--accent); border-color: var(--accent); }
.clock { margin-left: auto; font: .82rem var(--sans); color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.t-title { font: 650 1.2rem/1.2 var(--serif); margin-right: auto; }
.t-score { font: 700 .95rem var(--sans); font-variant-numeric: tabular-nums; white-space: nowrap; opacity: 0; transition: opacity .15s; }
.t-score.on { opacity: 1; }
.t-score.vs { font-weight: 600; font-size: .85rem; color: var(--ink-2); }
.table-view.full .t-score { color: var(--gold-ink); animation: shimmer .6s ease-out; }

/* Place cards. Both faces share one grid cell, so a card is as tall as its tallest face and text is never clipped. */
.cloth { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; padding: .55rem; border-radius: 18px; background: var(--cloth); box-shadow: inset 0 1px 3px rgba(80, 50, 20, .08); }
.card { position: relative; display: grid; min-width: 0; min-height: var(--card-h); perspective: 900px; transition: min-height .2s; }
.revealing .card { min-height: var(--card-back-h); }
.card-in { display: grid; min-width: 0; transform-style: preserve-3d; transition: transform 420ms cubic-bezier(.2, .8, .2, 1); }
.card.flipped .card-in { transform: rotateY(180deg); }
.card.knock { animation: knock 450ms ease-in-out; }
.face { grid-area: 1 / 1; min-width: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 12px; padding: .55rem .7rem; display: flex; flex-direction: column; overflow: hidden; }
.front { background: var(--surface); border: var(--bw) solid var(--line); box-shadow: var(--shadow); gap: .25rem; }
.c-name { font: 650 1.08rem/1.2 var(--serif); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.c-foot { display: flex; align-items: center; gap: .35rem; margin-top: auto; min-width: 0; }
.c-icon { font-size: 1.05rem; line-height: 1; flex: none; }
.c-desc { font-size: .8rem; line-height: 1.25; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.back { transform: rotateY(180deg); padding: .5rem .65rem; gap: .1rem; background: var(--surface); background: color-mix(in srgb, var(--st, var(--ink)) 11%, var(--surface)); border: calc(var(--bw) + 1px) solid var(--st, var(--line)); }
.st-c { --st: var(--came); } .st-k { --st: var(--kid); } .st-g { --st: var(--ghost); } .st-u { --st: var(--unborn); }
.b-top { display: flex; align-items: center; justify-content: space-between; gap: .3rem; flex: none; }
.b-st { font: 750 .7rem/1.3 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.b-pts { flex: none; font: 750 1.15rem/1 var(--sans); font-variant-numeric: tabular-nums; color: var(--ink); }
.b-name { flex: none; font: 650 1rem/1.2 var(--serif); overflow-wrap: anywhere; }
.b-det { margin-top: auto; font-size: .8rem; line-height: 1.25; color: var(--ink-2); min-width: 0; }
.b-l { display: block; }

/* Invitation card */
.inv { position: relative; margin-top: .75rem; padding: .7rem 1rem .55rem; text-align: center; background: var(--paper); border: 1px solid var(--gold); border-radius: 14px; box-shadow: inset 0 0 0 4px var(--paper), inset 0 0 0 5px color-mix(in srgb, var(--gold) 40%, transparent); -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.inv-label { font: 650 .68rem/1.3 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--gold-ink); }
.inv-line { font: italic .95rem/1.3 var(--serif); color: var(--ink-2); margin-top: .15rem; }
.inv-year { position: relative; z-index: 2; display: inline-block; margin-top: .05rem; font: 650 3.5rem/1.05 var(--serif); font-variant-numeric: tabular-nums lining-nums; letter-spacing: .02em; color: var(--ink); background: none; border: 0; padding: 0 .6rem; border-radius: 12px; cursor: pointer; }
.inv-year:hover:not(:disabled) { background: color-mix(in srgb, var(--gold) 14%, transparent); }
.inv-year:disabled { cursor: default; color: var(--ink); }
.inv-seal { position: absolute; right: .7rem; top: 50%; width: 4rem; height: 4rem; margin-top: -2rem; border-radius: 50%; display: grid; place-items: center; font: 700 .9rem var(--serif); color: #4A3410; background: radial-gradient(circle at 35% 30%, #F6DE9C, #D9A93F 55%, #A9781F); box-shadow: 0 0 0 3px color-mix(in srgb, #A9781F 40%, transparent), 0 3px 8px rgba(0, 0, 0, .25); opacity: 0; transform: scale(1.4) rotate(-8deg); pointer-events: none; }
.inv.sealed .inv-seal { animation: stamp 350ms cubic-bezier(.2, .8, .2, 1) forwards; }
.inv.compact { display: flex; align-items: center; justify-content: center; gap: .5rem; padding: .3rem 3rem .3rem 1rem; animation: fadein .25s; }
.inv.compact .inv-label { display: none; }
.inv.compact .inv-line { margin: 0; }
.inv.compact .inv-year { font-size: 1.6rem; padding: 0; }
.inv.compact .inv-seal { width: 2.3rem; height: 2.3rem; margin-top: -1.15rem; right: .5rem; font-size: .58rem; }

/* Dial */
.dial { position: relative; margin-top: .55rem; transition: opacity .2s; }
.dial.locked { opacity: .4; pointer-events: none; }
.coach { position: absolute; top: -1.15rem; left: 0; right: 0; margin: 0 auto; width: fit-content; max-width: 100%; z-index: 3; pointer-events: none; background: var(--ink); color: var(--bg); font: 600 .78rem/1.3 var(--sans); padding: .3rem .65rem; border-radius: 10px; text-align: center; animation: bob 1.8s ease-in-out infinite; }
.landmarks { position: relative; height: 1.9rem; margin: 0 1.4rem; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.lm-i { position: absolute; bottom: .15rem; transform: translateX(-50%); font-size: 1.1rem; line-height: 1; pointer-events: none; }
.lm { position: absolute; bottom: 0; width: 2.75rem; height: 2.75rem; padding: 0; background: none; border: 0; border-radius: 10px; cursor: pointer; touch-action: manipulation; }
.lm-tip { position: absolute; left: -1.4rem; right: -1.4rem; bottom: calc(100% + .1rem); display: flex; justify-content: center; pointer-events: none; opacity: 0; transition: opacity .15s; z-index: 4; }
.lm-tip.show { opacity: 1; }
.lm-tip span { background: var(--ink); color: var(--bg); font: 600 .75rem/1.3 var(--sans); padding: .3rem .6rem; border-radius: 8px; text-align: center; max-width: 100%; }
.lm-tip span:empty { display: none; }
.track { position: relative; height: 2.9rem; margin: 0 1.4rem; touch-action: pan-y; cursor: pointer; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.track:focus-visible { outline-offset: 6px; }
.rail, .fill { position: absolute; top: .9rem; height: 6px; border-radius: 3px; }
.rail { left: 0; right: 0; background: var(--ctl); }
.fill { left: 0; background: var(--accent); }
.tick { position: absolute; top: .75rem; width: 1px; height: 12px; background: var(--ctl); }
.tick-l { position: absolute; top: 1.7rem; transform: translateX(-50%); font: .7rem var(--sans); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.thumb { position: absolute; top: calc(.9rem + 3px); width: 1.75rem; height: 1.75rem; margin: -.875rem 0 0 -.875rem; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--surface), 0 2px 6px rgba(0, 0, 0, .28); transition: transform .12s; }
.track.drag .thumb { transform: scale(1.15); }
.nudges { display: flex; gap: .5rem; margin-top: .3rem; }
.nudge-gap { flex: 1 1 0; }
.nudge { flex: 0 1 3.4rem; min-width: 0; height: 2.75rem; padding: 0; border-radius: 1.4rem; border: var(--bw) solid var(--ctl); background: var(--surface); color: var(--ink); font: 650 1rem var(--sans); font-variant-numeric: tabular-nums; cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.nudge:active { background: var(--cloth); }
.kbd-hint { display: none; text-align: center; font-size: .78rem; color: var(--ink-2); margin-top: .4rem; }

/* The action button sits right under the dial while choosing (it never floats over live controls).
   Once the invitations are sent it sticks to the bottom so "Next" is always in reach. */
.t-actions { margin-top: .8rem; padding: .5rem 0 calc(.5rem + env(safe-area-inset-bottom)); }
.revealing .t-actions { position: sticky; bottom: 0; z-index: 5; background: linear-gradient(to bottom, transparent, var(--bg) 35%); }

/* Reveal: tutorial note, lifelines and fact */
.t-note { display: none; }
.t-note.show { display: grid; gap: .45rem; margin-top: .7rem; text-align: center; background: var(--surface); border: var(--bw) solid var(--line); border-radius: 16px; padding: .8rem .9rem; box-shadow: var(--shadow); animation: rise .3s cubic-bezier(.2, .8, .2, 1); }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: .25rem .9rem; font-size: .9rem; }
.t-after { display: none; }
.t-after.show { display: block; animation: rise .3s cubic-bezier(.2, .8, .2, 1); }
.ll { margin: .8rem 0 0; }
.ll-svg { display: block; width: 100%; height: auto; overflow: visible; }
.ll-band { fill: var(--gold); opacity: .32; }
.ll-bar { fill: none; stroke-width: 8; stroke-linecap: round; stroke-dasharray: 1 1; stroke-dashoffset: 1; animation: draw .4s cubic-bezier(.2, .8, .2, 1) forwards; animation-delay: calc(var(--i, 0) * 80ms); }
.ll-bar.st-c { stroke: var(--came); } .ll-bar.st-k { stroke: var(--kid); } .ll-bar.st-g { stroke: var(--ghost); } .ll-bar.st-u { stroke: var(--unborn); } .ll-bar.st-n { stroke: var(--ink-3); }
.stop-c { stop-color: var(--came); } .stop-k { stop-color: var(--kid); } .stop-g { stop-color: var(--ghost); } .stop-u { stop-color: var(--unborn); } .stop-n { stop-color: var(--ink-3); }
.ll-name, .ll-you-t { paint-order: stroke; stroke: var(--bg); stroke-width: 3px; stroke-linejoin: round; }
.ll-name { font: 650 10.5px var(--sans); fill: var(--ink); }
.ll-tick { font: 10px var(--sans); fill: var(--ink-2); }
.ll-axis { stroke: var(--line); stroke-width: 1; fill: none; }
.ll-you { stroke: var(--accent); stroke-width: 2; fill: none; animation: fadein .3s .35s both; }
.ll-you-t { font: 750 10.5px var(--sans); fill: var(--accent); animation: fadein .3s .35s both; }
.ll-cap { margin-top: .3rem; text-align: center; font: 650 .9rem/1.35 var(--sans); color: var(--gold-ink); }
.fact { margin: .7rem .25rem 0; text-align: center; font: italic 1.08rem/1.4 var(--serif); color: var(--ink); animation: fadein .4s both; scroll-margin-bottom: 6rem; }
.past-t .ll-name, .past-t .ll-you-t, .party .ll-name, .party .ll-you-t { stroke: var(--surface); }

/* Reduced motion and fast-forward */
.rm .card-in { transition: none; transform: none !important; }
.rm .back { transform: none; opacity: 0; transition: opacity 150ms; }
.rm .front { transition: opacity 150ms; }
.rm .card.flipped .back { opacity: 1; }
.rm .card.flipped .front { opacity: 0; }
.ff *, .ff *::before, .ff *::after, .rm *, .rm *::before, .rm *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; } }
:root[data-motion="reduced"] *, :root[data-motion="reduced"] *::before, :root[data-motion="reduced"] *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }

/* Results */
.results { text-align: center; display: grid; gap: .45rem; }
.r-h { font: 650 1.35rem/1.25 var(--serif); }
.r-score { line-height: 1; margin-top: .25rem; }
.r-num { font: 650 3.25rem/1 var(--serif); font-variant-numeric: tabular-nums lining-nums; }
.r-of { font: 600 1.1rem var(--sans); color: var(--ink-2); margin-left: .2rem; }
.r-title { font: italic 650 1.25rem var(--serif); color: var(--gold-ink); }
.r-sub { font-size: .9rem; color: var(--ink-2); }
.r-grid { display: grid; gap: .15rem; justify-content: center; margin: .35rem 0 .4rem; font-size: 1.55rem; line-height: 1.25; }
.gr { display: flex; gap: .7rem; justify-content: center; }
.gq { display: inline-flex; gap: .1rem; }
.r-meta { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; font-size: .9rem; margin-top: .2rem; }
.cd { font-variant-numeric: tabular-nums; font-weight: 650; }
.banner { background: var(--surface); border: var(--bw) solid var(--gold); border-radius: 12px; padding: .6rem .8rem; font-size: .92rem; margin-bottom: .6rem; text-align: left; }
.banner.gold { border-width: 2px; font-weight: 650; text-align: center; }
.duel { background: var(--surface); border: var(--bw) solid var(--line); border-radius: 14px; padding: .7rem .8rem; text-align: left; }
.duel-h { font-size: 1rem; }
.duel-rows { margin: .4rem 0 0; padding-left: 1.1rem; font-size: .85rem; color: var(--ink-2); }
.sec-h { font: 650 1.05rem var(--serif); margin: 1.2rem 0 .45rem; }
.parties { margin-top: .6rem; }
.party { border: var(--bw) solid var(--line); background: var(--surface); border-radius: 12px; margin-bottom: .45rem; }
.party summary { display: grid; grid-template-columns: 1fr auto; gap: .1rem .5rem; padding: .6rem .8rem; cursor: pointer; list-style: none; }
.party summary::-webkit-details-marker { display: none; }
.party summary::after { content: '▸'; grid-column: 2; grid-row: 1 / span 2; align-self: center; color: var(--ink-2); }
.party[open] summary::after { content: '▾'; }
.p-name { font: 650 .98rem var(--serif); }
.p-you { font-size: .82rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.p-g { grid-column: 1; font-size: 1rem; letter-spacing: .05em; }
.p-body { padding: 0 .8rem .8rem; }
.p-guests { font-size: .85rem; color: var(--ink-2); }
.teaser { width: 100%; min-height: 2.75rem; margin-top: .8rem; text-align: left; background: var(--surface); border: var(--bw) solid var(--line); border-radius: 12px; padding: .8rem; font: 600 .95rem var(--sans); color: var(--ink); cursor: pointer; }
.ask, .tip { margin-top: .8rem; background: var(--surface); border: var(--bw) solid var(--line); border-radius: 12px; padding: .8rem; display: grid; gap: .55rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { min-height: 2.75rem; padding: 0 .85rem; border-radius: 1.4rem; border: var(--bw) solid var(--ctl); background: var(--bg); font: 600 .88rem var(--sans); cursor: pointer; }
.foot { margin-top: 1.2rem; font-size: .82rem; color: var(--ink-2); text-align: center; line-height: 2; }
.past, .empty { display: grid; gap: .7rem; }
.empty { min-height: 55vh; place-content: center; text-align: center; }
.past-t { background: var(--surface); border: var(--bw) solid var(--line); border-radius: 14px; padding: .8rem; }
.past-name { font: 650 1.05rem var(--serif); margin-bottom: .2rem; }

/* Sheets, toast */
.sheet-back { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; background: rgba(20, 14, 10, .48); animation: fadein .18s; }
.sheet-back.out { opacity: 0; transition: opacity .18s; }
.sheet { width: 100%; max-width: 32.5rem; max-height: 88vh; max-height: 88dvh; overflow: auto; overscroll-behavior: contain; background: var(--surface); border-radius: 18px 18px 0 0; padding: 0 1rem calc(1rem + env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px rgba(0, 0, 0, .22); animation: up .22s cubic-bezier(.2, .8, .2, 1); }
.sheet.tall { height: 88vh; height: 88dvh; }
.sheet:focus { outline: none; }
@media (min-width: 600px) { .sheet-back { align-items: center; } .sheet { border-radius: 18px; } }
/* Anchored to the top: the on-screen keyboard can never cover it (type-a-year). */
.sheet-back.top { align-items: flex-start; }
.sheet-back.top .sheet { width: calc(100% - 2rem); margin-top: calc(env(safe-area-inset-top) + 3.6rem); border-radius: 18px; padding-bottom: 1rem; animation-name: down; }
.sheet-hd { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; padding: .85rem 0 .4rem; background: var(--surface); }
.sheet-title { font: 700 1.25rem var(--serif); }
.sheet-bd { display: grid; gap: .65rem; }
.sheet-bd p { line-height: 1.5; }
.legend-list { margin: 0; padding-left: 1.1rem; display: grid; gap: .2rem; }
.toast { position: fixed; left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom)); z-index: 70; transform: translate(-50%, 1rem); width: max-content; max-width: calc(100% - 2rem); background: var(--ink); color: var(--bg); font: 600 .92rem/1.35 var(--sans); padding: .65rem 1rem; border-radius: 12px; text-align: center; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.top { bottom: auto; top: calc(3.6rem + env(safe-area-inset-top)); transform: translate(-50%, -1rem); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.receipt-pre { margin: 0; padding: .8rem; background: var(--bg); border: var(--bw) solid var(--line); border-radius: 12px; font: .95rem/1.45 var(--sans); white-space: pre-wrap; word-break: break-word; }
.seg { display: flex; flex-wrap: wrap; gap: .3rem; }
.seg-b { flex: 1 1 auto; min-height: 2.75rem; padding: 0 .75rem; border-radius: 10px; border: var(--bw) solid var(--ctl); background: var(--bg); font: 600 .88rem var(--sans); cursor: pointer; }
.seg-b[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.check { display: flex; align-items: center; gap: .5rem; min-height: 2.75rem; font-weight: 600; }
.check input { width: 1.25rem; height: 1.25rem; accent-color: var(--accent); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; min-height: 3.1rem; padding: .15rem 0; border-bottom: 1px solid var(--line); }
.set-row .seg { justify-content: flex-end; }
.set-l { font-weight: 600; }
.toggle input { appearance: none; -webkit-appearance: none; margin: 0; width: 3rem; height: 1.75rem; border-radius: 1rem; background: var(--ctl); position: relative; cursor: pointer; flex: none; transition: background .15s; }
.toggle input::after { content: ''; position: absolute; top: .2rem; left: .2rem; width: 1.35rem; height: 1.35rem; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .15s; }
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { transform: translateX(1.25rem); }
.year-form { display: grid; gap: .5rem; }
.year-in { font: 650 2.2rem var(--serif); text-align: center; padding: .4rem; border-radius: 12px; border: 2px solid var(--ctl); background: var(--bg); color: var(--ink); width: 100%; font-variant-numeric: tabular-nums; }
.year-in::placeholder { color: var(--ink-3); }
.year-in:focus { border-color: var(--accent); outline: none; }
.year-in.shake { animation: shake .35s; border-color: var(--danger); }
.year-msg { min-height: 1.3em; color: var(--danger); font-size: .9rem; text-align: center; }
.code, .manual-ta { width: 100%; font: .82rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; padding: .6rem; border-radius: 10px; border: var(--bw) solid var(--ctl); background: var(--bg); color: var(--ink); resize: vertical; }
textarea.code:not([readonly]) { font-size: max(1rem, 16px); } /* under 16px iOS zooms the page on focus */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; }
.tile { background: var(--bg); border-radius: 12px; padding: .55rem .3rem; display: grid; text-align: center; }
.tile-v { font: 650 1.35rem var(--serif); font-variant-numeric: tabular-nums; }
.tile-l { font-size: .7rem; color: var(--ink-2); line-height: 1.2; }
.hist { display: grid; gap: .25rem; }
.hb { display: grid; grid-template-columns: 4.6rem 1fr 1.8rem; align-items: center; gap: .4rem; font-size: .75rem; font-variant-numeric: tabular-nums; }
.hb-l { color: var(--ink-2); text-align: right; }
.hb-bar { height: .9rem; border-radius: 4px; background: var(--ctl); }
.hb.today .hb-bar { background: var(--accent); }
.hb-n { font-weight: 650; }
.gb { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; font-size: .9rem; }
.gb li { padding: .45rem .1rem; border-bottom: 1px solid var(--line); }
.gb-q { width: 100%; min-height: 2.75rem; padding: 0 .8rem; border-radius: 10px; border: var(--bw) solid var(--ctl); background: var(--bg); color: var(--ink); font: inherit; }

/* Animations */
@keyframes stamp { 0% { opacity: 0; transform: scale(1.4) rotate(-8deg); } 70% { opacity: 1; transform: scale(.95) rotate(1deg); } 100% { opacity: 1; transform: scale(1) rotate(0); } }
@keyframes knock { 0%, 100% { transform: rotate(0); } 17% { transform: rotate(-2deg); } 33% { transform: rotate(2deg); } 50% { transform: rotate(-2deg); } 67% { transform: rotate(2deg); } 83% { transform: rotate(-1deg); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.03); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes down { from { transform: translateY(-24px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes shimmer { 0% { text-shadow: 0 0 0 transparent; } 40% { text-shadow: 0 0 12px var(--gold); } 100% { text-shadow: 0 0 0 transparent; } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes breathe { 0%, 100% { transform: scale(1); opacity: .8; } 50% { transform: scale(1.08); opacity: 1; } }

/* Height tiers: the whole table screen (cards, invitation, dial and Send) fits without scrolling on each. */
@media (max-height: 700px) { :root { --card-h: 5.25rem; --card-back-h: 5.75rem; } }
@media (max-height: 650px) {
  main { padding-top: .5rem; }
  .inv { margin-top: .6rem; padding: .5rem 1rem .35rem; }
  .inv-year { font-size: 3rem; }
  .t-actions { margin-top: .55rem; }
}
@media (max-height: 625px) {
  :root { --card-h: 5rem; }
  .inv-label { display: none; }
  .front { padding: .45rem .65rem; } .c-name { font-size: 1.02rem; line-height: 1.15; } .c-desc { font-size: .76rem; line-height: 1.2; }
}
/* iPhone SE with browser bars, small Androids, in-app browsers: a one-line invitation. */
@media (max-height: 600px) {
  :root { --card-h: 4.6rem; --card-back-h: 5.3rem; }
  main { padding-top: .4rem; }
  .t-head { margin-bottom: .35rem; }
  .front { padding: .4rem .6rem; } .c-name { font-size: 1rem; }
  .back { padding: .4rem .6rem; } .b-pts { font-size: 1.05rem; } .b-name { font-size: .95rem; } .b-det { font-size: .76rem; }
  .inv { display: flex; align-items: center; justify-content: center; gap: .5rem; margin-top: .5rem; padding: .3rem 3rem .3rem 1rem; }
  .inv .inv-line { margin: 0; }
  .inv .inv-year { font-size: 2.1rem; padding: 0 .3rem; margin: 0; }
  .inv.compact .inv-year { font-size: 1.6rem; }
  .inv .inv-seal { width: 2.3rem; height: 2.3rem; margin-top: -1.15rem; right: .5rem; font-size: .58rem; }
  .dial { margin-top: .3rem; }
  .landmarks { height: 1.7rem; }
  .track { height: 2.7rem; }
  .coach { top: -.9rem; font-size: .72rem; padding: .2rem .55rem; }
  .t-actions { margin-top: .4rem; padding-top: .3rem; }
  .btn.big { min-height: 3rem; }
}
@media (max-width: 350px) { main { padding-left: .6rem; padding-right: .6rem; } .c-name { font-size: .98rem; } .inv-year { font-size: 2.8rem; } .landmarks, .track { margin: 0 1rem; } .lm-tip { left: -1rem; right: -1rem; } }
@media (min-width: 768px) { main { max-width: 32.5rem; } .kbd-hint { display: block; } }

/* Content pages */
.doc { max-width: 40rem; padding-bottom: 3rem; }
.doc h1 { font: 650 1.8rem/1.2 var(--serif); margin: 1rem 0 .8rem; }
.doc h2 { font: 650 1.2rem/1.3 var(--serif); margin: 1.4rem 0 .4rem; }
.doc p, .doc li { line-height: 1.6; margin: 0 0 .7rem; }
.doc ul { padding-left: 1.2rem; }
.doc code { font: .9em ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--cloth); padding: .1em .3em; border-radius: 4px; }
.hdr-in .btn.small { min-height: 2.5rem; padding: 0 .8rem; font-size: .85rem; }
