/* Food Court — inspired by the backlit menu boards of Indian mall food courts: charcoal panels, saffron
   headings, mono price columns. Light theme is warm menu paper. One token set via light-dark(). */
:root {
  color-scheme: light dark;
  --bg: light-dark(#f7f0e3, #120f0d);
  --panel: light-dark(#fffaf1, #1c1815);
  --panel-2: light-dark(#f1e7d6, #26201b);
  --line: light-dark(#dccdb4, #3a312a);
  --ink: light-dark(#2a1f16, #f4ebde);
  --muted: light-dark(#6f5d4b, #b9a993);
  --accent: light-dark(#b8560b, #f2a93b);
  --accent-ink: light-dark(#fff, #1a1208);
  --hot: light-dark(#c2361b, #ff6b4a);
  --ok: light-dark(#1f7a4a, #5fd394);
  --warn: light-dark(#9a5b00, #ffc35a);
  --focus: light-dark(#0b5fd1, #8ec5ff);
  --r: 14px;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --head: "Bricolage Grotesque", "Atkinson Hyperlegible", sans-serif;
  font: 16px/1.5 "Atkinson Hyperlegible", system-ui, sans-serif;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); min-height: 100vh; }
body::before { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background: radial-gradient(60rem 30rem at 85% -10%, color-mix(in oklch, var(--accent) 16%, transparent), transparent),
              radial-gradient(40rem 24rem at -10% 110%, color-mix(in oklch, var(--hot) 10%, transparent), transparent); }
h1, h2, h3 { font-family: var(--head); line-height: 1.15; margin: 0 0 .5rem; text-wrap: balance; }
h1 { font-size: clamp(1.7rem, 4vw, 2.8rem); font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 1.2rem; font-weight: 800; }
h3 { font-size: .95rem; font-weight: 800; margin-top: 1rem; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; }
p { margin: 0 0 .75rem; text-wrap: pretty; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 1rem; top: 1rem; z-index: 10; background: var(--panel); padding: .5rem 1rem; }
[hidden] { display: none !important; }

.topbar { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: auto 1fr auto; gap: 1rem; align-items: center;
  padding: .6rem clamp(1rem, 3vw, 2rem); background: color-mix(in oklch, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; gap: .6rem; align-items: center; color: var(--ink); text-decoration: none; }
.brand strong { display: block; font-family: var(--head); font-size: 1.15rem; } .brand small { color: var(--muted); font-size: .75rem; }
.brand-mark { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-size: 1.3rem; }
.stage { justify-self: center; display: flex; align-items: baseline; gap: .7rem; flex-wrap: wrap; justify-content: center; text-align: center; }
.stage-name { font-family: var(--head); font-weight: 800; font-size: 1.05rem; padding: .15rem .6rem; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); }
.stage[data-stage="play"] .stage-name, .stage[data-stage="final"] .stage-name { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.stage[data-stage="negotiate"] .stage-name { background: color-mix(in oklch, var(--warn) 25%, var(--panel)); }
.stage[data-stage="grace"] .stage-name, .stage[data-stage="closed"] .stage-name { background: var(--ink); color: var(--bg); }
.countdown { font-family: var(--mono); font-weight: 700; font-size: clamp(1.6rem, 4vw, 2.3rem); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stage[data-urgent] .countdown { color: var(--hot); animation: pulse 1s steps(2) infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.stage-sub { color: var(--muted); font-size: .85rem; }
.top-tools { display: flex; gap: .5rem; align-items: center; }
.icon-btn { font: inherit; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; width: 2.4rem; height: 2.4rem; cursor: pointer; }
.link { width: .7rem; height: .7rem; border-radius: 50%; background: var(--muted); }
.link[data-state="open"] { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in oklch, var(--ok) 25%, transparent); }
.link[data-state="reconnecting"], .link[data-state="connecting"] { background: var(--warn); animation: pulse 1s steps(2) infinite; }
.link[data-state="closed"] { background: var(--hot); }

.timeline { position: relative; height: 10px; margin: 0 clamp(1rem, 3vw, 2rem); display: flex; border-radius: 0 0 6px 6px; overflow: visible; }
.timeline .seg-bar { height: 100%; background: var(--panel-2); border-right: 2px solid var(--bg); }
.timeline .seg-bar.play, .timeline .seg-bar.final { background: color-mix(in oklch, var(--accent) 45%, var(--panel-2)); }
.timeline .seg-bar.negotiate { background: color-mix(in oklch, var(--warn) 30%, var(--panel-2)); }
.timeline .seg-bar.past { opacity: .45; }
.timeline .cp { position: absolute; top: -3px; width: 4px; height: 16px; background: var(--ink); border-radius: 2px; translate: -2px 0; }
.timeline .now { position: absolute; top: -5px; width: 3px; height: 20px; background: var(--hot); translate: -1px 0; transition: left 1s linear; }
.help-line { margin: .4rem clamp(1rem, 3vw, 2rem) 0; color: var(--muted); font-size: .9rem; text-align: center; }

main { padding: 1rem clamp(1rem, 3vw, 2rem) 3rem; max-width: 1500px; margin: 0 auto; outline: none; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem 1.1rem; box-shadow: 0 1px 0 color-mix(in oklch, var(--ink) 6%, transparent); }
.screen { animation: rise .5s ease backwards; } /* not "both": a lingering translate would trap the fixed mobile chat */
@keyframes rise { from { opacity: 0; translate: 0 12px; } }
@media (prefers-reduced-motion: reduce) { *, ::before, ::after { animation: none !important; transition: none !important; } }

.btn { font: inherit; font-weight: 700; padding: .55rem 1rem; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.big { font-size: 1.1rem; padding: .8rem 1.4rem; width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary:not(:disabled):hover { filter: brightness(1.08); }
.chip { font: inherit; font-size: .85rem; padding: .25rem .7rem; border-radius: 999px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); cursor: pointer; }
.chip.ghost { background: transparent; }
.chip:disabled { opacity: .5; cursor: not-allowed; }
/* One look for every field: selects match text, number, date and time inputs (same box, height and font). */
input:not([type="radio"], [type="checkbox"], [type="file"]), textarea, select { font: inherit; color: var(--ink); background-color: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: .5rem .7rem; min-height: 2.6rem; }
select { appearance: none; padding-right: 2.2rem; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 1.15rem) 52%, calc(100% - .8rem) 52%; background-size: .35rem .35rem; background-repeat: no-repeat; }
select:disabled, input:disabled { opacity: .55; cursor: not-allowed; }
label { display: grid; gap: .25rem; }
/* A button right after a field gets breathing room (side-by-side rows such as the chat form are unaffected). */
label + .btn, label + button, p:has(> .btn:first-child) { margin-top: .75rem; }

.hero { margin: 1rem 0 1.5rem; max-width: 60rem; }
.hero h1 span { color: var(--accent); }
.lede { font-size: 1.1rem; }
.sessions { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); }
.session { display: grid; gap: .5rem; animation: rise .5s ease both; animation-delay: calc(var(--i, 0) * 70ms); }
.session[data-phase="live"] { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 25%, transparent); }
.session .when { font-family: var(--head); font-size: 1.35rem; font-weight: 800; }
.session .local { color: var(--muted); font-size: .85rem; }
.pill { display: inline-block; font-size: .75rem; font-weight: 700; padding: .1rem .55rem; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); }
.pill.best { background: var(--ok); color: var(--bg); border-color: transparent; }

.lobby { text-align: center; padding: 2rem 1rem; margin-bottom: 1rem; }
.lobby-clock { font-size: 1.1rem; } .lobby-clock time { font-family: var(--mono); font-size: 2rem; font-weight: 700; display: block; }

.banner { margin-bottom: .8rem; padding: .7rem 1rem; border-radius: var(--r); border: 1px solid color-mix(in oklch, var(--warn) 60%, var(--line)); background: color-mix(in oklch, var(--warn) 14%, var(--panel)); }
.room { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr) minmax(19rem, 25rem);
  grid-template-areas: "board side" "outcomes side" "results results" "rules rules"; align-items: start; }
.room:has(.results:not([hidden])) { grid-template-areas: "results results" "board side" "outcomes side" "rules rules"; }
.board { grid-area: board; } .outcomes { grid-area: outcomes; } .results { grid-area: results; } .room > .rules-host { grid-area: rules; }
/* Desktop: scores + chat stay in view while the plan scrolls; chat takes the remaining height. */
.side { grid-area: side; position: sticky; top: 6.6rem; height: calc(100dvh - 7.6rem); display: flex; flex-direction: column; gap: 1rem; }
.side .scores { flex: 0 1 auto; min-height: 0; overflow-y: auto; }
.side .chat { flex: 1 1 15rem; min-height: 15rem; display: flex; flex-direction: column; }
.chat .messages { flex: 1 1 auto; max-height: none; min-height: 0; }
.chat-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.chat-toggle { display: none; }
.badge { display: inline-grid; place-items: center; min-width: 1.4rem; height: 1.4rem; padding: 0 .35rem; border-radius: 999px; background: var(--hot); color: #fff; font: 700 .75rem var(--mono); vertical-align: middle; }
@media (max-width: 960px) {
  .room, .room:has(.results:not([hidden])) { grid-template-columns: minmax(0, 1fr); grid-template-areas: "results" "side" "board" "outcomes" "rules"; }
  .side { position: static; height: auto; display: block; }
  .topbar { grid-template-columns: auto auto; } .stage { grid-column: 1 / -1; order: 3; }
  /* Mobile: Talk is docked at the bottom and always visible: latest message + input; expand for history. */
  #screen-room { padding-bottom: 10rem; }
  .side .chat { position: fixed; inset: auto 0 0 0; z-index: 6; min-height: 0; margin: 0; border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 30px color-mix(in oklch, var(--ink) 18%, transparent); padding: .6rem .8rem calc(.6rem + env(safe-area-inset-bottom)); }
  .side .chat h2 { font-size: 1rem; margin: 0; }
  .chat-toggle { display: inline-block; }
  .chat:not([data-open]) .messages { max-height: 3.6rem; min-height: 0; overflow: hidden; margin-bottom: .4rem; }
  .chat:not([data-open]) .messages li:not(:last-child) { display: none; }
  .chat[data-open] .messages { max-height: 50dvh; }
}
.board-head { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: baseline; justify-content: space-between; margin-bottom: .6rem; }
.table-wrap { overflow-x: auto; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: .3rem .35rem; text-align: center; border-bottom: 1px solid var(--line); }
thead th { font-family: var(--head); font-size: .85rem; position: sticky; top: 0; background: var(--panel); vertical-align: bottom; }
th.month { text-align: left; font-family: var(--mono); font-weight: 500; white-space: nowrap; }
th.month small { display: block; color: var(--muted); font-size: .7rem; }
.dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; background: var(--c); margin-right: .25rem; vertical-align: middle; }
th.me, td.me { background: color-mix(in oklch, var(--accent) 9%, transparent); }
th .status { display: block; font-family: "Atkinson Hyperlegible", sans-serif; font-weight: 700; font-size: .7rem; margin-top: .15rem; }
th .status.draft { color: var(--warn); } th .status.saved { color: var(--ok); }
th .online { font-size: .7rem; color: var(--muted); font-weight: 400; }
.cell { font-family: var(--mono); font-weight: 700; display: inline-block; min-width: 3rem; padding: .2rem .4rem; border-radius: 8px;
  background: color-mix(in oklch, var(--accent) calc(var(--v, 0) * 2.6%), var(--panel-2)); }
.cell.flash { animation: flash 1.4s ease; }
@keyframes flash { 0% { box-shadow: 0 0 0 3px var(--hot); } 100% { box-shadow: 0 0 0 0 transparent; } }
.choices { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--panel-2); }
.choices label { display: block; position: relative; cursor: pointer; }
.choices input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choices span { display: block; font-family: var(--mono); font-weight: 700; font-size: .85rem; padding: .3rem .5rem; min-width: 2.6rem; }
.choices label + label span { border-left: 1px solid var(--line); }
.choices input:checked + span { background: var(--accent); color: var(--accent-ink); }
.choices input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -3px; }
.choices input:disabled + span { cursor: not-allowed; opacity: .55; }
.choices.changed { box-shadow: 0 0 0 2px var(--warn); }
.choices label:hover span { background: color-mix(in oklch, var(--accent) 22%, var(--panel-2)); }
.choices input:checked + span:hover { background: var(--accent); }
tfoot td, tfoot th { font-family: var(--mono); font-weight: 700; border-bottom: 0; padding-top: .5rem; }
tfoot th { text-align: left; font-family: var(--head); font-size: .8rem; }
.bulk { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; margin-top: .7rem; }
.effect { margin: .6rem 0 0; padding: .6rem .8rem; border-radius: 10px; background: var(--panel-2); font-size: .92rem; min-height: 2.8rem; }
.effect b { font-family: var(--mono); }
.up { color: var(--ok); } .down { color: var(--hot); }

.mine { display: grid; gap: .5rem; }
.big-score { display: flex; align-items: baseline; gap: .6rem; }
.big-score .num { font-family: var(--mono); font-weight: 700; font-size: 3rem; line-height: 1; color: var(--sc, var(--ink)); }
.big-score .label { font-weight: 700; }
.kv { display: grid; grid-template-columns: auto 1fr 1fr; gap: .2rem .6rem; align-items: baseline; font-size: .9rem; }
.kv .h { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.kv .v { font-family: var(--mono); font-weight: 700; color: var(--sc, var(--ink)); }
.kv .v small { font-weight: 500; color: var(--muted); }
.bar { height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.bar i { display: block; height: 100%; width: var(--w); background: var(--sc); transition: width .4s; }
.save-row { display: grid; gap: .4rem; margin: .9rem 0 .2rem; }
.save-note { font-size: .85rem; color: var(--muted); margin: 0; min-height: 1.3em; }
.save-note.bad { color: var(--hot); } .save-note.good { color: var(--ok); }
.other { display: grid; grid-template-columns: 1fr auto auto; gap: .2rem .6rem; align-items: center; padding: .35rem 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.other .s { font-family: var(--mono); font-weight: 700; color: var(--sc); }
.other .d { font-family: var(--mono); font-size: .8rem; min-width: 4.5rem; text-align: right; }
.checkpoints { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; }
.checkpoints li { text-align: center; padding: .4rem .2rem; border-radius: 10px; background: var(--panel-2); font-size: .8rem; }
.checkpoints li b { display: block; font-family: var(--mono); font-size: 1rem; color: var(--sc, var(--muted)); }
.checkpoints li.done { outline: 1px solid var(--line); }

.messages { list-style: none; margin: 0 0 .6rem; padding: 0; max-height: 22rem; min-height: 8rem; overflow-y: auto; display: flex; flex-direction: column; gap: .4rem; }
.messages li { padding: .4rem .6rem; border-radius: 10px; background: var(--panel-2); border-left: 4px solid var(--c, var(--line)); overflow-wrap: anywhere; }
.messages li.mine-msg { background: color-mix(in oklch, var(--accent) 12%, var(--panel-2)); }
.messages .who { font-weight: 700; font-size: .8rem; } .messages time { color: var(--muted); font-size: .75rem; font-family: var(--mono); margin-left: .4rem; }
.messages li.system { border-left-color: var(--muted); font-size: .85rem; color: var(--muted); }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: .4rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; font-size: .8rem; }
.seg label { display: block; position: relative; padding: .2rem .7rem; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg label:has(input:checked) { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.seg label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: -3px; }
.outcome td { font-family: var(--mono); font-size: .85rem; }
.results { border: 2px solid var(--accent); }
.results textarea { width: 100%; font-family: var(--mono); font-size: .75rem; }
.receipt-label { margin-top: 1rem; font-weight: 700; }
.final-grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }
.final-grid .card { background: var(--panel-2); }
.rules summary { cursor: pointer; list-style: none; } .rules summary::-webkit-details-marker { display: none; }
.rules summary h2::after { content: " ▾"; color: var(--muted); } .rules:not([open]) summary h2::after { content: " ▸"; }
.rules-grid { display: grid; gap: 1rem 2rem; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
.rules ul, .rules ol { padding-left: 1.2rem; margin: 0 0 .5rem; }
.phases { padding-left: 0 !important; list-style: none; } .phases b { font-family: var(--mono); }
@media (max-width: 480px) {
  main { padding-inline: .6rem; }
  .card { padding: .8rem .7rem; }
  th, td { padding: .25rem .15rem; }
  .choices span { min-width: 0; padding: .3rem .32rem; font-size: .78rem; }
  .cell { min-width: 2.4rem; padding: .2rem .25rem; font-size: .85rem; }
  th .online { display: none; }
}

/* Simple scoreboard: one light bar per restaurant, you highlighted. */
#scores-title small { font-family: "Atkinson Hyperlegible", sans-serif; font-weight: 400; font-size: .75rem; }
.ladder { list-style: none; margin: .4rem 0 .3rem; padding: 0; display: grid; gap: .45rem; }
.ladder li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .15rem .6rem; align-items: baseline; padding: .3rem .45rem; border-radius: 10px; }
.ladder li.you { background: color-mix(in oklch, var(--accent) 13%, transparent); outline: 1px solid color-mix(in oklch, var(--accent) 45%, transparent); }
.ladder .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92rem; }
.ladder li.you .name { font-weight: 700; }
.ladder .val { font-family: var(--mono); font-weight: 700; font-size: 1.05rem; color: var(--sc); }
.ladder .val small { font-size: .72rem; font-weight: 500; margin-left: .3rem; }
.ladder .track { grid-column: 1 / -1; height: 7px; border-radius: 4px; background: color-mix(in oklch, var(--ink) 7%, transparent); position: relative; overflow: hidden; }
.ladder .track i { position: absolute; inset: 0 auto 0 0; width: var(--w); border-radius: 4px; background: color-mix(in oklch, var(--sc) 55%, transparent); transition: width .5s ease; }
.ladder .track b { position: absolute; top: -2px; bottom: -2px; width: 2px; left: var(--d); background: var(--ink); opacity: .55; }
.ladder li.you .track i { background: var(--sc); }
.ladder-note { margin: 0 0 .4rem; }
.draft-line { margin: .2rem 0 0; padding: .45rem .6rem; border-radius: 10px; background: color-mix(in oklch, var(--warn) 14%, var(--panel)); font-size: .9rem; }
.draft-line b { font-family: var(--mono); }
.details { margin-top: .6rem; border-top: 1px solid var(--line); padding-top: .5rem; }
.details summary { cursor: pointer; font-weight: 700; color: var(--muted); }
.details[open] summary { margin-bottom: .5rem; }
@media (max-width: 600px) {
  .topbar { grid-template-columns: auto 1fr auto; gap: .5rem; padding: .4rem .6rem; }
  .brand > span:last-child { display: none; }
  .brand-mark { width: 2rem; height: 2rem; font-size: 1.1rem; }
  .stage { grid-column: auto; order: 0; gap: .35rem; flex-wrap: nowrap; }
  .stage-name { font-size: .85rem; padding: .1rem .5rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 9.5rem; }
  .countdown { font-size: 1.45rem; }
  .stage-sub { display: none; }
  .icon-btn { width: 2rem; height: 2rem; }
  .timeline { margin-inline: .6rem; }
  .help-line { font-size: .8rem; margin-inline: .6rem; }
  .side { top: 0; }
  .messages li { padding: .3rem .5rem; font-size: .9rem; }
  .messages li > div { display: inline; margin-left: .3rem; }
  .side .chat { padding-inline: .6rem; }
  .chat-head .chip { font-size: .8rem; padding: .2rem .6rem; }
}
.pill + .pill { margin-left: .35rem; }
