/* Drawlol Arcade design tokens and components: the drawlol "Quiet Toy" look.
   Tokens and the base components are copied from drawlol (client/src/styles/tokens.css, app.css).
   Rules of the look: white page, ink lines, NO drop shadows, one main action per screen,
   yellow for good news, orange only as a fill for "hurry". Games add their accent with var(--accent). */
@import url("fonts.css");

:root {
  --white: #FFFFFF;
  --ink: #17243B;
  --blue: #2358E8;
  --blue-dark: #1B46BC;
  --orange: #FF6B35; /* fill only, with ink text on it. Never text on white. */
  --yellow: #FFD447;
  --blue-tint: #EAF0FF;
  --orange-tint: #FFEDE6;
  --yellow-tint: #FFF7D6;
  --gray-100: #F5F7FB;
  --gray-200: #DCE2ED;
  --gray-500: #7A869A; /* borders of controls and icons only, not text */
  --gray-700: #56637A; /* quiet text */

  /* The game's own color. The shell sets these three from game.json "accent". */
  --accent: var(--blue);
  --accent-dark: var(--blue-dark);
  --accent-ink: var(--white);   /* text color that reads on the accent */
  --accent-tint: var(--blue-tint);

  --font-title: Outfit, system-ui, sans-serif;
  --font-text: "IBM Plex Sans", system-ui, sans-serif;
  --text-12: 0.75rem;
  --text-14: 0.875rem;
  --text-16: 1rem;
  --text-20: 1.25rem;
  --text-28: 1.75rem;
  --text-40: 2.5rem;
  --text-display: clamp(2.25rem, 11.8vw, 5.5rem);

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-6: 24px; --space-8: 32px; --space-12: 48px; --space-16: 64px;

  --radius-s: 8px; --radius-m: 12px; --radius-l: 16px; --radius-full: 999px;
  --target-min: 44px;
  --line: 2px solid var(--ink);
  --shelf: 3px solid var(--ink);

  --motion-press: 100ms; --motion-quick: 160ms; --motion-face: 240ms; --motion-big: 400ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-pop: cubic-bezier(0.2, 1.6, 0.4, 1);
}
@media (prefers-reduced-motion: reduce) {
  :root { --motion-press: 0ms; --motion-quick: 0ms; --motion-face: 0ms; --motion-big: 0ms; }
  .btn:active { transform: none; }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--white); color: var(--ink); font: 400 var(--text-16)/1.45 var(--font-text); -webkit-tap-highlight-color: transparent; }
img, svg, canvas { display: block; }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--blue); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; box-shadow: 0 0 0 2px var(--white); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.quiet { color: var(--gray-700); }
.t { font-family: var(--font-title); font-weight: 700; letter-spacing: 0; }
.h1 { font: 800 var(--text-40)/1.1 var(--font-title); letter-spacing: 0; overflow-wrap: anywhere; }
.h2 { font: 700 var(--text-20)/1.2 var(--font-title); letter-spacing: 0; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: var(--space-3); }
.stack { display: flex; flex-direction: column; gap: var(--space-3); }
.trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.grow { flex: 1; min-width: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 48px; min-width: var(--target-min); padding: 0 var(--space-6);
  border: 2px solid transparent; border-radius: var(--radius-m);
  font: 600 var(--text-16)/1 var(--font-text); color: var(--ink); background: var(--white);
  text-decoration: none; white-space: nowrap; cursor: pointer; user-select: none;
  transition: transform var(--motion-press) var(--ease-out), background-color var(--motion-quick);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { color: var(--gray-700); background: var(--gray-100); border-color: var(--gray-200); cursor: not-allowed; transform: none; }
.btn-primary { color: var(--white); background: var(--blue); }
.btn-accent { color: var(--accent-ink); background: var(--accent); }
.btn-quiet { border-color: var(--gray-500); }
.btn-danger { color: var(--white); background: var(--ink); }
@media (hover: hover) {
  .btn-primary:hover:not(:disabled) { background: var(--blue-dark); }
  .btn-accent:hover:not(:disabled) { background: var(--accent-dark); }
  .btn-quiet:hover:not(:disabled) { background: var(--gray-100); }
  .btn-danger:hover:not(:disabled) { background: #0E1728; }
  .iconbtn:hover { background: var(--gray-100); }
}
.btn-big { min-height: 56px; font-size: var(--text-20); padding: 0 var(--space-8); }
.btn-small { min-height: var(--target-min); padding: 0 var(--space-4); font-size: var(--text-14); }
.btn-wide { width: 100%; }
.btn svg, .btn img { flex: none; width: 20px; height: 20px; }
.iconbtn { display: inline-grid; place-items: center; flex: none; width: var(--target-min); height: var(--target-min); padding: 0; border: 0; border-radius: var(--radius-m); background: transparent; color: var(--ink); cursor: pointer; }
.iconbtn img, .iconbtn svg { width: 24px; height: 24px; }
.linklike { padding: 0; border: 0; background: none; color: var(--blue); text-decoration: underline; cursor: pointer; }
.link { display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--target-min); font-weight: 600; font-size: var(--text-14); }

/* ---------- fields ---------- */
.field { flex: 1; min-width: 0; min-height: 48px; padding: 0 var(--space-4); border: 2px solid var(--gray-500); border-radius: var(--radius-m); background: var(--white); font-size: var(--text-16); outline-offset: 2px; }
.field:focus { outline: 3px solid var(--ink); box-shadow: none; }
.field:disabled { background: var(--gray-100); border-color: var(--gray-200); }
.field::placeholder { color: var(--gray-700); }
.lab { font-weight: 600; font-size: var(--text-14); display: block; margin-bottom: var(--space-1); }
.hint { font-size: var(--text-14); color: var(--gray-700); }
.code-field { width: 150px; flex: none; text-transform: uppercase; font-weight: 600; letter-spacing: 0.12em; }
.code-field::placeholder { letter-spacing: 0; font-weight: 400; text-transform: none; }

/* ---------- small pieces ---------- */
.notice { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); border-radius: var(--radius-m); background: var(--yellow-tint); font-weight: 600; }
.notice.hurry { background: var(--orange-tint); }
.you { display: inline-block; padding: 0 6px; border-radius: var(--radius-s); background: var(--blue-tint); color: var(--blue); font: 600 var(--text-14)/1.4 var(--font-text); }
.tag { display: inline-block; padding: 0 6px; border-radius: var(--radius-s); background: var(--gray-100); color: var(--gray-700); font: 600 var(--text-14)/1.4 var(--font-text); }
.roomchip { display: inline-flex; gap: 4px; }
.roomchip i { width: 44px; height: 52px; display: grid; place-items: center; border: var(--line); border-radius: var(--radius-s); font: 800 var(--text-28)/1 var(--font-title); font-style: normal; background: var(--white); }
.roomchip.s i { width: 28px; height: 34px; font-size: var(--text-16); border-radius: 6px; }
.chipbtn { padding: 0; border: 0; background: none; cursor: pointer; border-radius: var(--radius-s); }
@media (hover: hover) { .chipbtn:hover i { background: var(--gray-100); } }
/* A yellow pill for a countdown. Add .hurry in the last 10 seconds. */
.timer { display: inline-grid; place-items: center; min-width: 88px; padding: 0 var(--space-3); border-radius: var(--radius-m); background: var(--yellow); font: 800 var(--text-40)/1.15 var(--font-title); font-variant-numeric: tabular-nums; }
.timer.s { min-width: 56px; font-size: var(--text-20); line-height: 1.6; border-radius: var(--radius-s); }
.timer.hurry { background: var(--orange); animation: ar-tick 1s var(--ease-out) infinite; }
@keyframes ar-tick { 0% { transform: scale(1.14); } 30%, 100% { transform: scale(1); } }
/* Speech bubble. */
.bub { position: relative; min-width: 0; padding: 6px 12px; border: var(--line); border-radius: var(--radius-l); background: var(--white); }
.bub::after { content: ""; position: absolute; width: 10px; height: 10px; background: inherit; border: var(--line); border-width: 0 0 2px 2px; }
.bub.left::after { left: -7px; top: 14px; transform: rotate(45deg); }
.bub.down::after { left: calc(50% - 5px); bottom: -7px; transform: rotate(-45deg); }
/* A creature. <img class="av" src=".../shared/avatars/avatar-01.svg"> */
.av { display: inline-block; flex: none; width: 48px; height: 48px; line-height: 0; }
.perch { width: 100%; display: flex; justify-content: center; align-items: flex-end; padding: var(--space-2) 2px 3px; border-bottom: var(--shelf); position: relative; }
/* A plain outlined box for a game board or a panel. Hard outline, no shadow. */
.board { background: var(--white); box-shadow: 0 0 0 2px var(--ink); border-radius: var(--radius-s); overflow: hidden; }
.panel { padding: var(--space-4); border-radius: var(--radius-l); background: var(--gray-100); }

/* Segmented pick and switch (lobby settings). */
.seg { display: flex; border: var(--line); border-radius: var(--radius-m); overflow: hidden; }
.seg label { flex: 1 1 0; position: relative; display: grid; place-items: center; min-height: var(--target-min); min-width: 0; padding: 0 var(--space-2); font-weight: 600; font-size: var(--text-14); cursor: pointer; }
.seg label + label { border-left: var(--line); }
.seg input { position: absolute; inset: 0; opacity: 0; margin: 0; width: 100%; height: 100%; cursor: pointer; }
.seg label:has(input:checked) { background: var(--ink); color: var(--white); }
.seg label:has(input:focus-visible) { outline: 3px solid var(--blue); outline-offset: -3px; }
.seg label:has(input:disabled) { cursor: default; }
.seg label:has(input:disabled) input { cursor: default; }
.switch { display: flex; align-items: center; justify-content: flex-end; min-height: var(--target-min); cursor: pointer; position: relative; }
.switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch i { display: block; pointer-events: none; width: 56px; height: 32px; border: var(--line); border-radius: var(--radius-full); background: var(--white); position: relative; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); transition: left var(--motion-quick) var(--ease-out); }
.switch input:checked + i { background: var(--blue); }
.switch input:checked + i::after { left: 27px; background: var(--white); }
.switch input:focus-visible + i { outline: 3px solid var(--ink); outline-offset: 2px; }
.switch input:disabled, .switch:has(input:disabled) { cursor: default; }
/* Lobby option buttons: equal buttons in a grid, label centered, up to two lines. shell.js sets --opt-min
   (the narrowest a button may get) and, once it knows the width, --cols with the class .fit for even rows. */
.ar-opts { display: grid; gap: 6px; grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--opt-min, 72px)), 1fr)); grid-auto-rows: 1fr; min-width: 0; }
.ar-opts.fit { grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); }
.ar-opts label { position: relative; display: flex; align-items: center; justify-content: center; min-width: 0; min-height: var(--target-min); padding: 6px 8px; border: var(--line); border-radius: var(--radius-s); background: var(--white); text-align: center; font-weight: 600; font-size: var(--text-14); line-height: 1.2; overflow-wrap: anywhere; cursor: pointer; }
.ar-opts label > span { display: block; min-width: 0; }
.ar-opts input { position: absolute; inset: 0; opacity: 0; margin: 0; width: 100%; height: 100%; cursor: pointer; }
.ar-opts label:has(input:checked) { background: var(--ink); color: var(--white); }
.ar-opts label:has(input:focus-visible) { outline: 3px solid var(--blue); outline-offset: 2px; }
.ar-opts label:has(input:disabled), .ar-opts input:disabled { cursor: default; }
.set-row { display: grid; grid-template-columns: 112px minmax(0, 1fr); align-items: center; gap: var(--space-3); }
.set-row.inline { grid-template-columns: 1fr auto; }
/* A setting's name lines up with the first row of its buttons, also when they take two rows. */
.set-row.opts-row { align-items: start; }
.set-row.opts-row > .lb { display: flex; align-items: center; min-height: var(--target-min); }
.set-row > .lb { font-weight: 600; font-size: var(--text-14); }
.range { width: 100%; accent-color: var(--ink); min-height: var(--target-min); }
.ar-course-setting { display: block; }
.ar-course-setting > .lb { display: block; margin-bottom: var(--space-2); }
.ar-course-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.ar-course-card, .ar-pick-card { position: relative; display: block; min-width: 0; border: 2px solid var(--ink); border-radius: var(--radius-m); overflow: hidden; background: var(--white); cursor: pointer; box-shadow: 0 3px 0 var(--ink); }
.ar-course-card:has(input:checked), .ar-pick-card:has(input:checked) { outline: 3px solid #ee743b; outline-offset: 2px; }
.ar-course-card:has(input:focus-visible), .ar-pick-card:has(input:focus-visible) { outline: 4px solid var(--blue); outline-offset: 3px; }
.ar-course-card:has(input:disabled), .ar-pick-card:has(input:disabled) { cursor: default; }
.ar-course-card input, .ar-pick-card input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: inherit; z-index: 3; }
.ar-course-preview { position: relative; height: 108px; overflow: hidden; background: #80b683; }
.ar-course-preview[data-course-id="canyon"] { background: #c48a6a; }
.ar-course-preview[data-course-id="harbor"] { background: #6eacbb; }
.ar-course-preview[data-course-id="alpine"] { background: #bdd3d5; }
.ar-course-preview img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ar-course-route { position: absolute; right: 6px; top: 6px; z-index: 1; width: 44px; height: 44px; padding: 4px; border: 1px solid #183b4a; border-radius: 7px; background: #ffffffdf; }
.ar-course-route path { fill: none; stroke: #1c4a5e; stroke-width: 8; stroke-linecap: round; stroke-linejoin: round; }
.ar-course-preview-error { position: absolute; left: 6px; bottom: 6px; z-index: 2; border-radius: 4px; padding: 2px 5px; background: #fff; color: #7d251d; font-size: 11px; font-weight: 700; }
.ar-course-copy { display: flex; flex-direction: column; gap: 3px; min-height: 72px; padding: 8px 10px 10px; }
.ar-course-name { font: 700 var(--text-16)/1.1 var(--font-title); }
.ar-course-description { color: var(--gray-700); font-size: 12px; line-height: 1.2; }
.ar-course-selected { display: none; margin-top: auto; color: #a33c1b; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.ar-course-card:has(input:checked) .ar-course-selected, .ar-pick-card:has(input:checked) .ar-course-selected { display: block; }
@media (max-width: 400px) { .ar-course-preview { height: 92px; } .ar-course-copy { min-height: 77px; } .ar-pick-grid .ar-course-preview { height: 64px; } .ar-pick-grid .ar-course-copy { min-height: 0; } }
/* Picks: each player's own choices (a car). Smaller cards, three across. */
.ar-pick-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ar-pick-grid .ar-course-preview { height: 72px; background: #dfe6ee; }
.ar-pick-grid .ar-course-copy { min-height: 0; padding: 6px 8px; }
.ar-pick-grid .ar-course-description { display: none; }
.lseat .ar-seat-picks { font-size: var(--text-12, 12px); color: var(--gray-700); text-align: center; line-height: 1.25; overflow-wrap: anywhere; }

/* Dialog: centered on desktop, a bottom sheet on phones. */
.scrim { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: var(--space-4); background: rgba(23, 36, 59, 0.5); }
.dialog { width: min(440px, 100%); padding: var(--space-6); border-radius: var(--radius-l); background: var(--white); display: flex; flex-direction: column; gap: var(--space-4); }
.dialog h2 { font: 700 var(--text-28)/1.15 var(--font-title); overflow-wrap: anywhere; }
.dialog-actions { display: flex; gap: var(--space-3); }
.dialog-actions .btn { flex: 1 1 0; min-width: 0; white-space: normal; line-height: 1.15; }

/* ---------- page frame ---------- */
.page { min-height: 100dvh; display: flex; flex-direction: column; }
.head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); padding: var(--space-3) var(--space-8); }
.head > a:first-child { display: inline-flex; align-items: center; min-height: var(--target-min); text-decoration: none; }
.head img.logo { width: 145px; height: auto; }
.head .arcade-word { margin-left: var(--space-2); padding: 2px 8px; border-radius: var(--radius-s); background: var(--yellow); color: var(--ink); font: 800 var(--text-14)/1.4 var(--font-title); text-decoration: none; }

/* ---------- shell: game home ---------- */
.ar-home { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: var(--space-12); align-items: center; width: min(1040px, 100%); margin: 0 auto; padding: var(--space-4) var(--space-8) var(--space-8); }
.ar-home-intro { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.ar-home-intro h1 { font: 800 clamp(2.25rem, 6vw, 4.5rem)/1.02 var(--font-title); letter-spacing: 0; overflow-wrap: anywhere; }
.ar-home-intro h1 em { font-style: normal; color: var(--accent); }
.ar-home-intro .tagline { font-size: var(--text-20); color: var(--gray-700); }
.ar-meta { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.ar-how { display: flex; flex-direction: column; gap: var(--space-2); }
.ar-how li { display: flex; gap: var(--space-3); align-items: baseline; }
.ar-how li b { flex: none; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: var(--white); font: 700 var(--text-14)/1 var(--font-title); transform: translateY(-1px); }
.ar-form { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.ar-who { display: flex; align-items: flex-end; gap: var(--space-4); }
.ar-who .perch { width: 112px; flex: none; }
.ar-who .perch .av { width: 88px; height: 88px; }
.ar-who .field-block { flex: 1; min-width: 0; }
.ar-who .field { width: 100%; }
.grid16 { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.pickcell { display: grid; place-items: center; aspect-ratio: 1; width: 100%; min-width: 0; padding: 0; border: 3px solid transparent; border-radius: var(--radius-m); background: var(--white); cursor: pointer; }
.pickcell .av { width: 84%; height: 84%; }
.pickcell[aria-pressed="true"] { border-color: var(--blue); background: var(--blue-tint); }
@media (hover: hover) { .pickcell:hover { background: var(--gray-100); } }
.ar-or { display: flex; align-items: center; gap: var(--space-3); color: var(--gray-700); font-size: var(--text-14); font-weight: 600; }
.ar-or::before, .ar-or::after { content: ""; flex: 1; border-top: 2px solid var(--gray-200); }
.code-row { display: flex; gap: var(--space-2); }
.code-row .btn { flex: 1; }
.msg-slot { min-height: 44px; }
.msg-slot .notice { font-size: var(--text-14); line-height: 1.3; }
.ar-foot { font-size: var(--text-14); color: var(--gray-700); }

/* ---------- shell: lobby ---------- */
.ar-lobby { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: var(--space-12); width: min(1216px, 100%); margin: 0 auto; padding: var(--space-2) var(--space-8) var(--space-6); align-items: start; }
.ar-lobby-main, .ar-lobby-side { display: flex; flex-direction: column; gap: var(--space-6); min-width: 0; }
.ar-lobby-title { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.ar-lobby-count { font: 700 var(--text-20)/1.2 var(--font-title); color: var(--gray-700); font-variant-numeric: tabular-nums; }
.ar-kicker { font: 700 var(--text-14)/1.2 var(--font-title); color: var(--gray-700); text-transform: none; }
.seats { display: grid; grid-template-columns: repeat(4, 1fr); row-gap: var(--space-4); }
.lseat { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; animation: ar-arrive var(--motion-big) var(--ease-out); }
.lseat .perch .av { width: 88px; height: 88px; }
.lseat.off .perch .av { opacity: 0.35; }
.lseat .nm { max-width: 100%; padding: var(--space-1) 2px 0; font: 700 var(--text-16)/1.25 var(--font-title); overflow-wrap: anywhere; }
.lseat .nm.free { font-weight: 400; font-family: var(--font-text); color: var(--gray-700); }
.lseat .tags { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: var(--space-1); min-height: 22px; font-size: var(--text-14); color: var(--gray-700); }
.lseat .seat-x { position: absolute; right: 2px; top: 0; width: 32px; height: 32px; }
.lseat .seat-x img { width: 18px; height: 18px; }
.emptyseat { width: 88px; height: 88px; border: 3px dashed var(--gray-500); border-radius: 50%; }
.seatdot { position: absolute; left: calc(50% + 30px); bottom: 6px; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--ink); }
.crown { position: absolute; left: 50%; top: -8px; z-index: 1; transform: translateX(-50%); width: 26px; height: 26px; background: var(--white); border-radius: 50%; display: grid; place-items: center; }
.crown img { width: 20px; height: 20px; }
.share { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.copy-msg { font-size: var(--text-14); font-weight: 600; min-height: 20px; }
.ar-settings { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4) 0; border-block: 2px solid var(--gray-200); }
.ar-settings h2 { font: 700 var(--text-20)/1.2 var(--font-title); }
.startbar { display: flex; flex-direction: column; gap: var(--space-2); }
.startbar .why { font-size: var(--text-14); color: var(--gray-700); font-weight: 600; text-align: center; min-height: 20px; }
.startbar .acts { display: flex; gap: var(--space-2); }
.startbar .acts .btn-big { flex: 1; }
.ar-watchers { font-size: var(--text-14); color: var(--gray-700); }
@keyframes ar-arrive { from { opacity: 0; transform: translateY(8px); } }

/* ---------- shell: play ---------- */
.ar-play { height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.ar-top { flex: none; display: flex; align-items: center; gap: var(--space-2); padding: var(--space-1) var(--space-4); border-bottom: 2px solid var(--gray-200); min-height: 52px; }
.ar-top .gname { font: 800 var(--text-20)/1.1 var(--font-title); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.ar-top .spacer { flex: 1; }
.ar-scores { flex: 1; display: flex; align-items: center; gap: var(--space-2); min-width: 0; overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--gray-500) transparent; padding: 2px 2px 7px; }
.ar-scores::-webkit-scrollbar { height: 5px; }
.ar-scores::-webkit-scrollbar-thumb { background: var(--gray-500); border-radius: 5px; }
@media (max-width: 760px) { .ar-top:has(.ar-scores .pchip:nth-child(4)) .ar-scores { -webkit-mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 20px), transparent); mask-image: linear-gradient(90deg, #000 0, #000 calc(100% - 20px), transparent); } }
.pchip { flex: none; display: flex; align-items: center; gap: 6px; padding: 2px 10px 2px 2px; border: 2px solid var(--gray-200); border-radius: var(--radius-full); font-size: var(--text-14); font-weight: 600; max-width: 180px; }
.pchip.me { border-color: var(--ink); }
.pchip.off { opacity: 0.45; }
.pchip .dot { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; }
.pchip .dot .av { width: 26px; height: 26px; }
.pchip .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pchip .sc { font: 800 var(--text-16)/1 var(--font-title); font-variant-numeric: tabular-nums; }
.ar-root { flex: 1; min-height: 0; position: relative; overflow: hidden; touch-action: manipulation; }
.ar-watching { flex: none; text-align: center; padding: 2px var(--space-4); background: var(--yellow-tint); font-size: var(--text-14); font-weight: 600; }
.ar-shake { animation: ar-shake 320ms var(--ease-out); }
@keyframes ar-shake { 20% { transform: translate(-6px, 2px); } 40% { transform: translate(5px, -3px); } 60% { transform: translate(-4px, 2px); } 80% { transform: translate(2px, -1px); } }

/* 3-2-1 */
.ar-count { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(255, 255, 255, 0.92); }
.ar-count .n { display: grid; place-items: center; width: 200px; height: 200px; border-radius: 50%; background: var(--yellow); border: var(--shelf); font: 800 7rem/1 var(--font-title); font-variant-numeric: tabular-nums; animation: ar-pop var(--motion-big) var(--ease-pop); }
.ar-count p { position: absolute; top: calc(50% + 124px); font: 700 var(--text-20)/1.2 var(--font-title); }
@keyframes ar-pop { from { transform: scale(0.6); opacity: 0; } }

/* ---------- shell: results ---------- */
.ar-over { flex: 1; display: flex; flex-direction: column; align-items: center; gap: var(--space-6); width: min(720px, 100%); margin: 0 auto; padding: var(--space-2) var(--space-8) var(--space-8); }
.ar-over h1 { font: 800 3.5rem/1.05 var(--font-title); text-align: center; overflow-wrap: anywhere; }
.ar-over .summary { font-size: var(--text-20); color: var(--gray-700); text-align: center; margin-top: calc(-1 * var(--space-4)); }
.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: var(--space-2); width: min(560px, 100%); }
.podium.two { grid-template-columns: repeat(2, minmax(0, 1fr)); width: min(380px, 100%); }
.podium.one { grid-template-columns: minmax(0, 220px); justify-content: center; }
.pod { display: flex; flex-direction: column; align-items: center; min-width: 0; text-align: center; animation: ar-arrive var(--motion-big) var(--ease-out) backwards; }
.pod .who { position: relative; }
.pod .av { width: 96px; height: 96px; }
.pod.first .av { width: 144px; height: 144px; }
.pod .nm { font: 700 var(--text-16)/1.2 var(--font-title); max-width: 100%; overflow-wrap: anywhere; padding: 0 2px; }
.pod .step { width: 100%; margin-top: var(--space-1); border: var(--line); border-bottom-width: 3px; border-radius: var(--radius-m) var(--radius-m) 0 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: var(--space-2); background: var(--white); }
.pod.first .step { min-height: 148px; background: var(--yellow); }
.pod.second .step { min-height: 104px; }
.pod.third .step { min-height: 72px; }
.pod .place { font: 800 var(--text-28)/1 var(--font-title); }
.pod .place { font-size: var(--text-16); color: var(--gray-700); }
.pod.first .place { color: var(--ink); }
.pod .score { font: 800 var(--text-28)/1 var(--font-title); font-variant-numeric: tabular-nums; }
.pod .score { max-width: 100%; overflow-wrap: anywhere; }
.pod .note { font-size: var(--text-14); line-height: 1.2; overflow-wrap: anywhere; }
.pod.first { order: 2; animation-delay: 300ms; } .pod.second { order: 1; animation-delay: 150ms; } .pod.third { order: 3; }
.podium.two .pod.first { order: 1; } .podium.two .pod.second { order: 2; }
.pod .crown { top: -4px; background: none; width: 36px; height: 36px; }
.pod .crown img { width: 34px; height: 34px; }
.rest { width: min(560px, 100%); }
.rest li { display: flex; align-items: center; gap: var(--space-3); min-height: 44px; border-top: 2px solid var(--gray-200); min-width: 0; }
.rest li .hint { overflow-wrap: anywhere; min-width: 0; }
.rest li .num { flex: none; }
.rest li .av { width: 36px; height: 36px; }
.rest li .place { width: 24px; font: 700 var(--text-16)/1 var(--font-title); color: var(--gray-700); text-align: center; }
.wins { width: min(560px, 100%); display: flex; flex-direction: column; gap: var(--space-2); }
.wins h2 { font: 700 var(--text-20)/1.2 var(--font-title); }
.wins ul { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.wins li { display: flex; align-items: center; gap: 6px; padding: 2px 12px 2px 4px; border-radius: var(--radius-full); background: var(--gray-100); font-weight: 600; font-size: var(--text-14); }
.wins li .av { width: 28px; height: 28px; }
.wins li b { font: 800 var(--text-16)/1 var(--font-title); font-variant-numeric: tabular-nums; }
.over-acts { width: min(560px, 100%); display: flex; flex-direction: column; gap: var(--space-2); align-items: stretch; }
.over-acts .acts { display: flex; gap: var(--space-2); }
.over-acts .acts .btn { flex: 1; }
.over-acts .why { font-size: var(--text-14); color: var(--gray-700); font-weight: 600; text-align: center; }

/* ---------- shell: stop pages, banners, toasts ---------- */
.stop { flex: 1; display: flex; align-items: center; justify-content: center; gap: var(--space-12); padding: var(--space-6) var(--space-8); }
.stop-face { flex: none; width: 240px; height: 240px; }
.stop-text { max-width: 480px; display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-4); }
.stop-text h1 { font: 800 var(--text-40)/1.1 var(--font-title); }
.stop-acts { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-2); }
.ar-net { position: fixed; left: 50%; top: var(--space-2); z-index: 50; transform: translateX(-50%); display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-4); border-radius: var(--radius-full); background: var(--ink); color: var(--white); font-weight: 600; font-size: var(--text-14); white-space: nowrap; }
.ar-net img { width: 18px; height: 18px; filter: invert(1); }
.ar-toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px)); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: var(--space-2); pointer-events: none; padding: 0 var(--space-4); }
.ar-toast { max-width: min(440px, 100%); padding: var(--space-2) var(--space-4); border-radius: var(--radius-m); background: var(--ink); color: var(--white); font-weight: 600; font-size: var(--text-14); text-align: center; animation: ar-arrive var(--motion-big) var(--ease-out); }
.ar-toast.good { background: var(--yellow); color: var(--ink); }
.ar-toast.bad { background: var(--orange); color: var(--ink); }
.ar-confetti { position: fixed; inset: 0; z-index: 55; pointer-events: none; width: 100%; height: 100%; }

/* ---------- touch controls (shared/input.js) ---------- */
.ar-stick { position: absolute; left: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 5; width: 116px; height: 116px; border-radius: 50%; border: var(--line); background: rgba(255, 255, 255, 0.7); touch-action: none; user-select: none; -webkit-user-select: none; }
.ar-stick.right { left: auto; right: 20px; }
.ar-stick i { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: var(--ink); pointer-events: none; will-change: transform; }
.ar-pads { position: absolute; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 5; display: flex; gap: var(--space-3); align-items: flex-end; touch-action: none; user-select: none; -webkit-user-select: none; }
.ar-pads.left { right: auto; left: 20px; }
.ar-pad { width: 68px; height: 68px; border-radius: 50%; border: var(--line); background: rgba(255, 255, 255, 0.8); font: 800 var(--text-16)/1 var(--font-title); color: var(--ink); display: grid; place-items: center; padding: 0; touch-action: none; }
.ar-pad.down { background: var(--ink); color: var(--white); transform: scale(0.94); }
.ar-pad:nth-child(2n) { margin-bottom: 28px; }

/* ---------- hub ---------- */
.hub { flex: 1; width: min(1216px, 100%); margin: 0 auto; padding: var(--space-4) var(--space-8) var(--space-12); display: flex; flex-direction: column; gap: var(--space-8); }
.hub-hero h1 { font: 800 min(var(--text-display), 6.875vw)/1.02 var(--font-title); letter-spacing: 0; }
.hub-hero h1 em { font-style: normal; color: var(--blue); }
.hub-hero p { margin-top: var(--space-3); font-size: var(--text-20); color: var(--gray-700); }
.hub-join { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.hub-filters { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2) var(--space-4); margin-bottom: var(--space-4); }
.hub-filters label { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-14); font-weight: 700; }
.hub-filters select { min-height: 44px; padding: 0 28px 0 10px; border: var(--line); border-radius: var(--radius-m); background: var(--white); color: var(--ink); font: 600 var(--text-14) var(--font-text); }
.hub-filter-count { margin-left: auto; font-size: var(--text-14); color: var(--gray-700); }
.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-6); }
.gcard { display: flex; flex-direction: column; min-width: 0; border-radius: var(--radius-l); box-shadow: 0 0 0 2px var(--ink); background: var(--white); color: var(--ink); text-decoration: none; overflow: hidden; transition: transform var(--motion-quick) var(--ease-out); }
.gcard:active { transform: scale(0.98); }
@media (hover: hover) { .gcard:hover { transform: translateY(-4px); } .gcard:hover .go { background: var(--ink); color: var(--white); } }
.gcard.pending { cursor: default; }
.gcard.pending:active, .gcard.pending:hover { transform: none; }
.gcard.pending:hover .go { background: var(--white); color: var(--ink); }
.gcard .cover { position: relative; aspect-ratio: 16 / 9; background: var(--card-accent, var(--blue)); display: grid; place-items: center; overflow: hidden; border-bottom: var(--line); }
.gcard .cover img.art { width: 100%; height: 100%; object-fit: cover; }
.gcard .cover .mono { font: 800 5rem/1 var(--font-title); color: var(--card-ink, var(--white)); }
.gcard .cover .blob { position: absolute; border-radius: 50%; background: var(--card-ink, var(--white)); opacity: 0.16; }
.gcard .body { flex: 1; display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-4); }
.gcard h2 { font: 800 var(--text-28)/1.1 var(--font-title); overflow-wrap: anywhere; }
.gcard p { color: var(--gray-700); flex: 1; }
.gcard .foot { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin-top: var(--space-2); }
.gcard .go { display: inline-grid; place-items: center; min-height: 36px; padding: 0 var(--space-4); border: var(--line); border-radius: var(--radius-full); font-weight: 600; font-size: var(--text-14); transition: background-color var(--motion-quick); }
.hub-empty { grid-column: 1 / -1; display: flex; align-items: center; gap: var(--space-6); }
.hub-empty .av { width: 120px; height: 120px; }
.hub-foot { padding: var(--space-4) var(--space-8) var(--space-8); text-align: center; font-size: var(--text-14); color: var(--gray-700); }

/* ---------- phones ---------- */
@media (max-width: 760px) {
  .head { padding: var(--space-2) var(--space-4); }
  .head img.logo { width: 110px; }
  .h1 { font-size: var(--text-28); }
  .ar-home { grid-template-columns: minmax(0, 1fr); gap: var(--space-6); align-items: start; align-content: start; padding: var(--space-2) var(--space-4) var(--space-6); }
  .ar-home-intro { gap: var(--space-2); }
  .ar-home-intro .tagline { font-size: var(--text-16); }
  .ar-home .ar-how { display: none; }
  .ar-who .perch { width: 88px; }
  .ar-who .perch .av { width: 68px; height: 68px; }
  .ar-lobby { grid-template-columns: minmax(0, 1fr); gap: var(--space-6); padding: var(--space-2) var(--space-4) 0; }
  .ar-lobby-main, .ar-lobby-side { gap: var(--space-4); }
  /* On a phone a setting's name sits above its buttons, so the buttons get the full width. */
  .set-row.opts-row { grid-template-columns: minmax(0, 1fr); gap: var(--space-2); }
  .set-row.opts-row > .lb { min-height: 0; }
  /* Track cards sit above the seats so a phone can tap one without scrolling. */
  .ar-lobby:has(.ar-course-setting) .ar-lobby-side { display: contents; }
  .ar-lobby:has(.ar-course-setting) .ar-settings { order: -2; }
  /* Each player's own picks (a car) come right after the host's settings. */
  .ar-lobby:has(.ar-course-setting) .ar-picks { order: -1; }
  /* The start bar sticks to the bottom. Leave that strip out of the scroll target. */
  .ar-lobby:has(.ar-course-setting) .set-row,
  .ar-lobby:has(.ar-course-setting) .ar-course-card { scroll-margin-bottom: 96px; }
  .seats { grid-template-columns: repeat(3, 1fr); }
  .lseat .perch .av, .emptyseat { width: 72px; height: 72px; }
  .seatdot { left: calc(50% + 24px); }
  .startbar { position: sticky; bottom: 0; z-index: 3; margin: 0 calc(-1 * var(--space-4)); padding: var(--space-2) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom, 0px)); background: var(--white); border-top: 2px solid var(--gray-200); }
  .ar-top { padding: 2px var(--space-2); flex-wrap: wrap; row-gap: 0; }
  .ar-top .gname { font-size: var(--text-16); flex: 1; }
  .ar-top .ar-scores { order: 9; flex: 0 0 100%; padding-bottom: 4px; }
  .pchip .nm { max-width: 84px; }
  .ar-over { padding: var(--space-2) var(--space-4) 0; gap: var(--space-4); }
  .ar-over h1 { font-size: 2.5rem; }
  .ar-over .summary { font-size: var(--text-16); margin-top: calc(-1 * var(--space-2)); }
  .pod .av { width: 72px; height: 72px; }
  .pod.first .av { width: 112px; height: 112px; }
  .pod.first .step { min-height: 124px; } .pod.second .step { min-height: 92px; } .pod.third .step { min-height: 68px; }
  .pod .step { padding: var(--space-2) var(--space-1); }
  .pod .score { font-size: var(--text-16); line-height: 1.2; }
  .rest li { flex-wrap: wrap; column-gap: var(--space-2); padding: var(--space-1) 0; }
  .rest li .hint { flex-basis: 100%; order: 2; padding-left: 68px; }
  .over-acts { margin-top: auto; padding: var(--space-2) 0 calc(var(--space-3) + env(safe-area-inset-bottom, 0px)); background: var(--white); border-top: 2px solid var(--gray-200); }
  .stop { flex-direction: column; gap: var(--space-6); padding: var(--space-6) var(--space-4); }
  .stop-face { width: 160px; height: 160px; }
  .stop-text { align-items: stretch; }
  .stop-text h1 { font-size: var(--text-28); }
  .stop-acts .btn { width: 100%; }
  .scrim { place-items: end center; padding: 0; }
  .dialog { width: 100%; border-radius: var(--radius-l) var(--radius-l) 0 0; padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px)); }
  .ar-count .n { width: 160px; height: 160px; font-size: 5.5rem; }
  .ar-count p { top: calc(50% + 100px); }
  .hub { padding: var(--space-2) var(--space-4) var(--space-8); gap: var(--space-6); }
  .hub-hero p { font-size: var(--text-16); }
  .hub-grid { grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
  .gcard .cover { aspect-ratio: 21 / 9; }
  .gcard .cover .mono { font-size: 3.5rem; }
  .gcard h2 { font-size: var(--text-20); }
  .hub-join .code-row { width: 100%; }
}
@media (max-width: 760px) and (max-height: 700px) {
  /* One row keeps the lap choice above the start bar on a short phone. */
  .ar-course-grid { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; }
  .ar-course-card, .ar-pick-card { flex: 0 0 148px; scroll-snap-align: start; }
  .ar-course-preview { height: 56px; }
  .ar-course-copy { min-height: 0; padding: 6px 8px 8px; }
}
@media (max-height: 480px) and (min-width: 520px) {
  /* A sideways phone. Tracks stay on the left. Start stays on the right, so it does not cover the laps. */
  .page:has(.ar-course-setting) .head { padding: 2px 12px; }
  .page:has(.ar-course-setting) .head img.logo { width: 88px; }
  .ar-lobby:has(.ar-course-setting) {
    grid-template-columns: minmax(0, 1fr) 232px;
    gap: 8px 12px;
    padding: 4px 12px 12px;
  }
  .ar-lobby:has(.ar-course-setting) .ar-lobby-side { display: contents; }
  .ar-lobby:has(.ar-course-setting) .ar-lobby-side > * { grid-column: 1 / -1; }
  .ar-lobby:has(.ar-course-setting) .ar-lobby-main { grid-column: 1 / -1; }
  .ar-lobby:has(.ar-course-setting) .ar-settings { order: -1; grid-column: 1; grid-row: 1; }
  .ar-lobby:has(.ar-course-setting) .ar-settings > h2,
  .ar-course-setting > .lb { display: none; }
  .ar-lobby:has(.ar-course-setting) .startbar {
    order: -1; grid-column: 2; grid-row: 1; position: static; margin: 0; align-self: start;
    padding: 8px; background: transparent; border-top: 0;
  }
  .ar-course-grid { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; }
  .ar-course-card, .ar-pick-card { flex: 0 0 156px; scroll-snap-align: start; }
  .ar-course-preview { height: 44px; }
  .ar-course-copy { min-height: 0; padding: 4px 8px 6px; }
}
@media (max-height: 500px) and (min-width: 600px) {
  /* a phone on its side: give the play area every pixel */
  .ar-top { min-height: 44px; }
}
/* A tablet: less gutter and seats that wrap, so creatures do not overlap at 768 px. */
@media (min-width: 761px) and (max-width: 1023px) {
  .ar-lobby { gap: var(--space-8); padding: var(--space-2) var(--space-6) var(--space-6); }
  .seats { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
}
/* A lobby with per-player picks has a long side column: on wide screens Start moves up under the room code. */
@media (min-width: 761px) {
  .ar-lobby:has(.ar-picks) .ar-lobby-side > .startbar { order: 1; }
  .ar-lobby:has(.ar-picks) .ar-lobby-side > .ar-settings { order: 2; }
}
