/* Tokens first: every colour, radius and shadow is named once here. */
:root {
  color-scheme: light dark;
  --bg: light-dark(#f5f5f2, #111113);
  --card: light-dark(#ffffff, #1b1b1f);
  --line: light-dark(#e2e2dc, #2d2d34);
  --text: light-dark(#17171a, #f1f1ee);
  --muted: light-dark(#6c6c75, #9a9aa5);
  --accent: light-dark(#4f46e5, #8b85ff);
  --accent-deep: light-dark(#4038c7, #a09bff);
  --on-accent: light-dark(#ffffff, #111113);
  --soft: light-dark(#eeedfd, #26253f);
  --good: light-dark(#d9f2e1, #173d27);
  --near: light-dark(#eef7f0, #1b2a21);
  --far: light-dark(#fde3e0, #47201c);
  --bad: light-dark(#b42318, #ff8a7d);
  --scrim: rgb(0 0 0 / 0.45);
  --shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 4px 14px rgb(0 0 0 / 0.06);
  --radius: 12px;
  --gap: 14px;
  --bar: 56px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}

main {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px calc(40px + env(safe-area-inset-bottom));
}

h1, h2, p, ul, ol { margin: 0; }
h1 { font-size: 30px; line-height: 1.15; letter-spacing: -0.02em; }
h2 { font-size: 18px; }
small, em { color: var(--muted); font-size: 11px; font-style: normal; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }

.lede { font-size: 18px; color: var(--muted); }
.note { color: var(--muted); font-size: 14px; }
.center { text-align: center; }
.eyebrow { color: var(--accent); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: -8px; }
.error { color: var(--bad); font-size: 14px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; letter-spacing: 0.12em; }
.code.big { font-size: 34px; line-height: 1; }

/* ── building blocks ── */

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 8px; }
.row > input, .grow { flex: 1; min-width: 0; }
input.code { text-transform: uppercase; }
.or { color: var(--muted); font-size: 13px; text-align: center; }
label { font-weight: 600; }

input, button { font: inherit; color: inherit; border-radius: var(--radius); }
input { width: 100%; min-height: 48px; padding: 0 14px; background: var(--bg); border: 1px solid var(--line); }
input:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* One button, four voices: primary (the next step), soft (a second option), ghost (quiet), danger (confirm). */
button {
  min-height: 48px; padding: 0 18px;
  background: var(--card); border: 1px solid var(--line);
  font-weight: 650; cursor: pointer;
  transition: background 0.12s, transform 0.06s, border-color 0.12s;
}
button:active:not(:disabled) { transform: scale(0.98); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: var(--shadow); }
button.primary:hover:not(:disabled) { background: var(--accent-deep); border-color: var(--accent-deep); }
button.soft { background: var(--soft); border-color: transparent; color: var(--accent); }
button.ghost { min-height: 36px; padding: 0 10px; background: none; border-color: transparent; color: var(--accent); font-size: 14px; }
button.ghost:hover:not(:disabled) { background: var(--soft); }
button.danger { min-height: 36px; padding: 0 12px; background: var(--far); border-color: transparent; color: var(--bad); font-size: 14px; }
main > button.ghost, main > button.danger { align-self: center; }

.chip { padding: 5px 10px; background: var(--soft); color: var(--accent); border-radius: 8px; font-size: 14px; }

/* ── top bar and slide-out menu ── */

.bar { display: flex; align-items: center; gap: 12px; }
header.bar {
  position: sticky; top: 0; z-index: 5;
  height: var(--bar); padding: 0 8px 0 16px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 9px; margin-right: auto; color: var(--text); font-weight: 800; font-size: 18px; letter-spacing: -0.02em; text-decoration: none; }
.logo b { display: grid; place-items: center; width: 30px; height: 30px; background: var(--accent); color: var(--on-accent); border-radius: 8px; font-size: 14px; letter-spacing: 0; }

.burger { display: grid; gap: 5px; align-content: center; width: 44px; min-height: 44px; padding: 0 11px; background: none; border-color: transparent; }
.burger:hover { background: var(--soft); }
.burger i { height: 2px; background: var(--text); border-radius: 2px; }

.scrim { position: fixed; inset: 0; z-index: 10; background: var(--scrim); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 11;
  display: flex; flex-direction: column; gap: 22px;
  width: min(340px, 88vw); padding: 0 16px calc(24px + env(safe-area-inset-bottom));
  background: var(--card); border-left: 1px solid var(--line);
  overflow-y: auto;
}
.drawer.slide { animation: slide 0.18s ease-out; }
@keyframes slide { from { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .drawer.slide { animation: none; } button { transition: none; } }
.drawer > .bar { height: var(--bar); margin: 0 -8px 0 0; justify-content: space-between; }
.drawer section { display: flex; flex-direction: column; gap: 10px; }
.drawer section + section { padding-top: 22px; border-top: 1px solid var(--line); }
.drawer p { color: var(--muted); font-size: 14px; }
.drawer p.code { color: var(--text); }

.people { display: flex; flex-direction: column; padding: 0; list-style: none; }
.people li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.people li:last-child { border-bottom: 0; }
.people span { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.people .row { gap: 2px; }

/* ── the table ── */

.roster { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; list-style: none; }
.roster li { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.roster li.ready { background: var(--good); border-color: transparent; }
.roster li.ready::before { content: "✓"; font-weight: 700; }

.meter { display: flex; gap: 4px; }
.meter i { flex: 1; height: 4px; background: var(--line); border-radius: 2px; }
.meter i.on { background: var(--accent); }

/* Fixed floor so the board below never jumps under a thumb when the card changes. */
.deal { display: flex; flex-direction: column; justify-content: center; gap: 8px; min-height: 184px; text-align: center; border-color: var(--accent); }

/* Card pictures. The box is sized before the photo loads, so nothing shifts. */
.art { display: block; object-fit: cover; object-position: 50% 25%; background: var(--soft); }
.art.tile { display: grid; place-items: center; line-height: 1; }
.art.feature { width: 100%; aspect-ratio: 16 / 9; border-radius: 8px; font-size: 72px; }
.art.thumb { flex: none; width: 34px; height: 34px; border-radius: 6px; font-size: 18px; }
figure { position: relative; margin: 0; }
figure a { position: absolute; right: 6px; bottom: 6px; padding: 2px 6px; background: var(--scrim); color: #fff; border-radius: 4px; font-size: 10px; text-decoration: none; }
.item div { display: flex; align-items: center; gap: 10px; }
.deal .about { color: var(--muted); font-size: 15px; text-wrap: balance; }
.deal strong { font-size: 28px; line-height: 1.2; letter-spacing: -0.01em; overflow-wrap: anywhere; }

.board { display: flex; flex-direction: column; gap: 6px; padding: 0; list-style: none; }
.slot { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 8px 12px; text-align: left; font-weight: 500; border-radius: var(--radius); }
.slot b { width: 22px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.slot span { overflow-wrap: anywhere; }
li.slot { background: var(--card); border: 1px solid var(--line); }
button.slot { background: none; border-style: dashed; }
button.slot:hover:not(:disabled) { border-color: var(--accent); }
button.slot.chosen { background: var(--soft); border: 1px solid var(--accent); color: var(--accent); }
button.slot.chosen b { color: var(--accent); }

/* ── results ── */

.past { display: flex; align-items: center; gap: 10px; text-align: left; }
.past span { flex: 1; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--gap); }
.facts .card { display: flex; flex-direction: column; gap: 2px; }
.facts strong { font-size: 18px; }
.facts span { color: var(--muted); font-size: 14px; }

.scroll { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 10px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: 12px; font-weight: 600; max-width: 84px; overflow: hidden; text-overflow: ellipsis; }
.item { text-align: left; white-space: normal; min-width: 120px; font-weight: 600; }
.rank { color: var(--accent); font-weight: 800; }
.avg { color: var(--muted); }
th.me { color: var(--accent); }
td.exact { background: var(--good); font-weight: 700; }
td.near { background: var(--near); }
td.far { background: var(--far); }
tfoot td { border-bottom: 0; font-weight: 700; }
tfoot td:first-child { text-align: left; color: var(--muted); font-weight: 600; }
