:root {
  --bg: #10241a; --surface: #1a3527; --surface-2: #254a35; --ink: #f2e8cf; --ink-2: #a9bfa3; --line: #2f5a3c;
  --accent: #7ad97a; --accent-ink: #0b2314; --ok: #7ad97a; --warn: #f4c661; --bad: #ff8a8a; --info: #8bd0ff;
  --p-red: #e63946; --p-blue: #457bd6; --p-green: #2a9d8f; --p-yellow: #f4a261;
  --parchment: #f2e8cf; --parchment-2: #e6d9b7; --timber: #b5651d;
  --font-display: "Kalam", "Nunito Sans", cursive; --font-ui: "Nunito Sans", system-ui, sans-serif;
}
:root[data-theme="light"] { --bg: #e9e3d1; --surface: #fbf6e9; --surface-2: #e3d8bf; --ink: #16281c; --ink-2: #5a6b58; --line: #cdbf9e; --accent: #2c8a4a; --accent-ink: #fff; --info: #2a7fd6; }
:root[data-colorblind="1"] { --p-red: #d55e00; --p-blue: #0072b2; --p-green: #009e73; --p-yellow: #f0e442; }
body { background: radial-gradient(ellipse at 50% 0%, #1c3d2a 0%, var(--bg) 62%); }
:root[data-theme="light"] body { background: radial-gradient(ellipse at 50% 0%, #fff9ea 0%, var(--bg) 62%); }
/* home */
.logo { display: flex; justify-content: center; margin-bottom: -4px; } .logo canvas { width: 240px; height: 96px; }
.title { font-size: clamp(2.5rem, 12.5vw, 4.6rem); font-weight: 700; letter-spacing: .01em; text-shadow: 0 2px 0 rgba(0,0,0,.35), 0 0 22px color-mix(in oklab, var(--accent) 45%, transparent); }
.tagline { font-family: var(--font-display); font-size: 1.3rem; }
.modes { grid-template-columns: 1fr 1fr; }
.seg-line [role="radio"] { height: 44px; }
.board-home { gap: var(--s-4); }
/* the level segment means nothing here: AI seats just roll */
.seat-row .seg[aria-label="level"] { display: none; }
.seat-row[data-seat="0"] { --pc: var(--p-red); } .seat-row[data-seat="1"] { --pc: var(--p-blue); } .seat-row[data-seat="2"] { --pc: var(--p-green); } .seat-row[data-seat="3"] { --pc: var(--p-yellow); }
.seat-row .seat-toggle { width: 44px; height: 44px; min-height: 44px; font-size: 1.3rem; }
.seat-row .seat-name { flex: 1 1 60px; white-space: normal; line-height: 1.15; }
.seat-row .seat-name .seat-sub { display: block; font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-row .seg [role="radio"] { padding: 0 9px; }
.best-line { gap: 14px; }
/* play */
.play .stage { padding: 4px 8px; }
.play .stage-canvas { border-radius: 14px; box-shadow: 0 0 0 1px rgba(0,0,0,.35), 0 24px 50px rgba(0,0,0,.5); }
.hud-pill .sep { color: var(--ink-2); padding: 0 2px; }
#hud-board { font-family: var(--font-display); font-size: 1.05rem; }
.rail { min-height: 50px; padding: 4px 10px; }
.rail-bottom { padding-bottom: 2px; }
.seat { max-width: 48%; height: 42px; padding-right: 10px; flex: 0 1 auto; min-width: 0; }
.seat .avatar { font-family: var(--font-display); font-size: .95rem; color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.35); position: relative; overflow: visible; }
.seat .avatar::after { content: ""; position: absolute; left: 6px; top: 4px; width: 9px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.7); transform: rotate(-30deg); }
.seat .badge { position: absolute; right: -6px; top: -8px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: .66rem; font-weight: 800; color: #3b2a1a; background: linear-gradient(#ffe38a, #e0a800); box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.seat .badge[data-rank="2"] { background: linear-gradient(#f3f3f3, #b8bcc4); } .seat .badge[data-rank="3"] { background: linear-gradient(#f0b98a, #b5651d); } .seat .badge[data-rank="4"] { background: var(--surface-2); color: var(--ink-2); }
.seat { position: relative; }
.seat[data-done="true"] { opacity: .75; }
.seat[data-active="true"] .who small { color: var(--pc); }
.controls { position: relative; z-index: 3; display: flex; align-items: center; justify-content: center; gap: 14px; padding: 4px 16px max(10px, env(safe-area-inset-bottom)); flex: 0 0 auto; }
.die-wrap { width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center; cursor: pointer; transition: transform var(--t-fast); -webkit-tap-highlight-color: transparent; }
.die-wrap:active { transform: scale(.95); }
.die-wrap canvas { display: block; }
.roll-cta { font-family: var(--font-display); font-size: 1.5rem; height: 56px; min-height: 56px; padding: 0 36px; letter-spacing: .04em; flex: 0 1 240px; box-shadow: 0 0 24px color-mix(in oklab, var(--accent) 40%, transparent), 0 6px 0 color-mix(in oklab, var(--accent) 55%, #000); transform: translateY(0); transition: transform var(--t-fast), box-shadow var(--t-fast), opacity var(--t-base); }
.roll-cta:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 0 24px color-mix(in oklab, var(--accent) 40%, transparent), 0 2px 0 color-mix(in oklab, var(--accent) 55%, #000); }
.roll-cta:disabled { opacity: .5; box-shadow: none; }
.controls[data-ready="true"] .roll-cta:not(:disabled) { animation: roll-pulse 1.6s ease-in-out infinite; }
@keyframes roll-pulse { 0%, 100% { box-shadow: 0 0 18px color-mix(in oklab, var(--accent) 35%, transparent), 0 6px 0 color-mix(in oklab, var(--accent) 55%, #000); } 50% { box-shadow: 0 0 34px color-mix(in oklab, var(--accent) 70%, transparent), 0 6px 0 color-mix(in oklab, var(--accent) 55%, #000); } }
/* the turn toast sits just under the top rail so it never covers the HUD */
body:has(.play:not([hidden])) .toast-host { top: 108px; }
/* result */
.result-verdict { font-family: var(--font-display); font-size: 1.35rem; color: var(--ink); }
.ranking { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr; gap: 6px; }
@container screen (min-width: 640px) { .ranking { grid-template-columns: 1fr 1fr; } }
.ranking li { display: flex; align-items: center; gap: 8px; padding: 6px 12px; min-height: 36px; border-radius: var(--r-md); background: var(--surface-2); font-weight: 700; font-size: .9rem; }
.ranking li i { width: 14px; height: 14px; border-radius: 50%; background: var(--pc); box-shadow: inset 0 -2px 0 rgba(0,0,0,.3); flex: 0 0 auto; }
.ranking li small { color: var(--ink-2); font-weight: 600; margin-left: auto; white-space: nowrap; font-variant-numeric: tabular-nums; }
@container screen (min-width: 640px) { .board-home .modes { grid-template-columns: 1fr 1fr; } }
/* desktop: rails beside the board, controls under the right rail */
@media (min-width: 900px) and (min-aspect-ratio: 5/4) {
  .play { grid-template-rows: auto 1fr auto; grid-template-areas: "hud hud hud" "left stage right" "left stage controls"; }
  .play .controls { grid-area: controls; padding-bottom: 32px; }
  .seat { max-width: none; }
  .play .rail-top, .play .rail-bottom { gap: 14px; }
}
