/* Hai Bánh: a bright seaside look. Sky and sea blues, white cards, sun
   yellow and coral; a clear rounded face made for Vietnamese (Be Vietnam Pro,
   bundled: fonts/, fonts.css). A run is the view full screen, a bar along the
   top, and a big pad for each wheel at the bottom corners. */
:root {
  --ink: #12324a;
  --muted: #4f6b80;
  --faint: #7d93a4;
  --sky: #3fa9e6;
  --sea: #1679b8;
  --sun: #ffc23d;
  --coral: #ff6b5b;
  --card: rgba(255, 255, 255, 0.94);
  --edge: #d5e8f4;
  --text: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-family: var(--text);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { touch-action: manipulation; }
body {
  min-height: 100dvh;
  background: linear-gradient(180deg, #8fd3f7 0%, #c9ecfb 38%, #63b9e8 62%, #1b84c6 100%) fixed;
  overscroll-behavior: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  line-height: 1.4; /* (Vietnamese accents need the room) */
}
body[data-screen='game'] { background: #cdeefb; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
input { font: inherit; font-size: 16px; }
[hidden] { display: none !important; }
h1, h2, h3 { font-weight: 700; }

/* ---------- the menu, the rooms, the waiting room ---------- */
.menu, .lobby {
  max-width: 460px;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.title { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.title .logo { width: 96px; height: 96px; filter: drop-shadow(0 4px 6px rgba(10, 60, 100, 0.3)); }
.title h1 { margin: 0; font-size: 44px; line-height: 1.25; color: #fff; text-shadow: 0 3px 0 var(--sea), 0 6px 14px rgba(10, 60, 100, 0.35); letter-spacing: 0.5px; }
.tagline { margin: 0; text-align: center; font-size: 14px; line-height: 1.5; color: #154766; }
.card {
  padding: 14px 12px;
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 6px 18px rgba(10, 70, 120, 0.18);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card h2 { margin: 0; font-size: 18px; color: var(--sea); }
.screen-title { margin: 0; text-align: center; font-size: 26px; color: #fff; text-shadow: 0 2px 0 var(--sea); }
.screen-sub { margin: 4px 0 0; font-size: 18px; color: #fff; text-shadow: 0 2px 0 var(--sea); }
.note { margin: 0; text-align: center; font-size: 13px; color: var(--muted); }
.btn {
  min-height: 46px;
  padding: 8px 14px;
  border: 0;
  border-radius: 14px;
  background: #eaf5fc;
  color: var(--ink);
  box-shadow: inset 0 -3px 0 rgba(18, 50, 74, 0.12), 0 2px 0 rgba(18, 50, 74, 0.12);
  font-weight: 700;
  font-size: 16px;
}
.btn:active { transform: translateY(2px); }
.btn.primary { background: linear-gradient(180deg, #ff8a5c, var(--coral)); color: #fff; box-shadow: inset 0 -3px 0 rgba(120, 20, 10, 0.25), 0 3px 0 #c9483a; }
.btn.sun { background: linear-gradient(180deg, #ffd666, var(--sun)); color: #4a2f00; box-shadow: inset 0 -3px 0 rgba(120, 70, 0, 0.2), 0 3px 0 #d69a16; }
.btn.small { min-height: 36px; padding: 4px 12px; font-size: 14px; }
.btn.wide { width: 100%; }
.btn.big { min-height: 70px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 18px; }
.btn.big small { font-weight: 500; font-size: 12px; opacity: 0.85; }
.btn:disabled { opacity: 0.5; filter: grayscale(0.4); }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.side-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.side-row button { min-height: 40px; border: 2px solid var(--edge); border-radius: 12px; background: #fff; color: var(--muted); font-weight: 700; font-size: 14px; }
.side-row button[aria-checked='true'] { border-color: var(--sky); background: #e3f4fe; color: var(--sea); }
.me { display: flex; align-items: center; gap: 10px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--sky); color: #fff; font-weight: 700; }
.who { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.who small { font-size: 12px; color: var(--faint); }
.who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stars-all { margin: 0; text-align: center; font-weight: 700; color: #b77900; }
.link { background: none; border: 0; padding: 6px; color: var(--sea); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.link.muted { color: var(--faint); text-decoration: none; }
a.link { display: inline-block; }
.how ul { margin: 0; padding-left: 18px; font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
.how summary { font-weight: 700; color: var(--sea); }
.safety-card a, .safety-card button { color: var(--sea); }
.foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; }
.foot .link { color: #fff; text-shadow: 0 1px 2px rgba(0, 40, 80, 0.5); }

/* The tracks: a numbered list, the picked one lit, each with its stars and best. */
.tracks { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.track { width: 100%; min-height: 64px; display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; align-items: center; gap: 0 8px; padding: 6px 10px; border: 2px solid var(--edge); border-radius: 14px; background: #fff; text-align: left; }
.track .num { grid-row: span 2; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: #eaf5fc; color: var(--sea); font-weight: 700; font-size: 14px; }
.track .name { font-size: 14px; line-height: 1.3; }
.track .stars { grid-column: 2; font-size: 13px; color: #f0a500; letter-spacing: 1px; }
.track .best { display: none; }
.track.on { border-color: var(--coral); background: #fff4f1; }
.track.on .num { background: var(--coral); color: #fff; }
.track-pick { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.chip { min-height: 36px; padding: 4px 12px; border: 2px solid var(--edge); border-radius: 999px; background: #fff; color: var(--muted); font-weight: 700; font-size: 13px; }
.chip.on { border-color: var(--coral); background: #fff4f1; color: #c9483a; }
.chip:disabled { opacity: 1; }

.join { flex-direction: row; gap: 8px; }
.join input { flex: 1; min-width: 0; height: 48px; padding: 0 14px; border: 2px solid var(--edge); border-radius: 12px; background: #fff; color: var(--ink); font-weight: 700; font-size: 22px; letter-spacing: 6px; text-transform: uppercase; }
.players-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.players-list li { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 10px; border: 2px solid var(--edge); border-radius: 12px; background: #fff; }
.players-list li.me { border-color: var(--sky); }
.players-list .dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.players-list .name { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.players-list small { color: var(--faint); }
.players-list.open-rooms li, .rank-list li { background: rgba(255, 255, 255, 0.94); }
.rank-list .rank { width: 26px; font-weight: 700; color: var(--sea); }
.rank-list b { font-variant-numeric: tabular-nums; }
.rank-list li.note { justify-content: center; color: var(--muted); }
.lobby h2 { margin: 0; text-align: center; font-size: 26px; color: #fff; text-shadow: 0 2px 0 var(--sea); }
.lobby .card h2 { text-align: left; font-size: 18px; color: var(--sea); text-shadow: none; }
.code { letter-spacing: 4px; }
.row { display: flex; gap: 8px; }
.row .btn { flex: 1; }
.toggle { flex-direction: row; align-items: center; gap: 10px; font-weight: 600; }
.toggle input { width: 22px; height: 22px; accent-color: var(--coral); }
.no-gl { margin: 40vh 20px 0; text-align: center; font-weight: 700; }

/* ---------- a run ---------- */
.game { position: fixed; inset: 0; overflow: hidden; touch-action: none; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hud {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.stat { display: flex; align-items: center; gap: 4px; min-width: 0; height: 38px; padding: 0 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.88); box-shadow: 0 2px 6px rgba(10, 60, 100, 0.25); white-space: nowrap; }
.stat b { font-size: 17px; font-variant-numeric: tabular-nums; }
.stat.time { flex: 1 1 auto; justify-content: center; max-width: 130px; }
/* (Online, with chat and talk too: narrower, so all fit on a phone.) */
.hud:has(#game-talk:not([hidden])) .stat { padding: 0 7px; }
.hud:has(#game-talk:not([hidden])) .stat.falls { display: none; }
.hud-btn { width: 40px; height: 38px; flex: none; margin-left: auto; border: 0; border-radius: 999px; background: rgba(255, 255, 255, 0.88); box-shadow: 0 2px 6px rgba(10, 60, 100, 0.25); display: grid; place-items: center; position: relative; }
.hud-btn + .hud-btn { margin-left: 0; }
.hud-btn svg { width: 20px; height: 20px; }
.minimap { position: absolute; right: 10px; top: calc(56px + env(safe-area-inset-top)); width: 104px; height: 104px; border-radius: 16px; background: rgba(20, 110, 170, 0.35); box-shadow: 0 2px 8px rgba(10, 60, 100, 0.25); pointer-events: none; }
.banner {
  position: absolute;
  left: 50%;
  top: 30%;
  transform: translate(-50%, -50%);
  padding: 10px 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--sea);
  font-weight: 700;
  font-size: 20px;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(10, 60, 100, 0.3);
  pointer-events: none;
  will-change: transform;
}
.countdown { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); font-size: 110px; font-weight: 700; color: #fff; text-shadow: 0 5px 0 var(--coral), 0 10px 22px rgba(0, 0, 0, 0.3); pointer-events: none; will-change: transform; }
/* The pads: one each side, the wheel's colour; the other player's dimmed. */
.pads { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: flex-end; padding: 0 12px calc(16px + env(safe-area-inset-bottom)); pointer-events: none; }
.pad { --c: #ff5a5f; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: auto; }
.pad-who { padding: 2px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.88); font-size: 13px; font-weight: 700; color: var(--ink); max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pad-who:empty { display: none; }
.pad button { border: 0; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.pad .push { width: min(30vw, 128px); aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 50% 35%, #fff 0%, color-mix(in srgb, var(--c) 30%, #fff) 30%, var(--c) 78%); box-shadow: 0 6px 0 color-mix(in srgb, var(--c) 60%, #000), 0 10px 18px rgba(0, 0, 0, 0.3); font-size: 40px; color: #fff; text-shadow: 0 2px 2px rgba(0, 0, 0, 0.35); }
.pad .back { width: min(16vw, 66px); height: 40px; border-radius: 999px; background: rgba(255, 255, 255, 0.9); box-shadow: 0 3px 0 rgba(0, 0, 0, 0.18); font-size: 16px; color: var(--muted); }
.pad button.down { transform: translateY(4px) scale(0.96); }
.pad .push.down { box-shadow: 0 2px 0 color-mix(in srgb, var(--c) 60%, #000), 0 4px 10px rgba(0, 0, 0, 0.3); }
.pad.theirs button { opacity: 0.35; pointer-events: none; }
.pad.theirs .pad-who { opacity: 0.85; }
#pad-R { order: 2; }

/* ---------- toasts, sheets, banners ---------- */
.toast { position: fixed; z-index: 50; left: 50%; top: calc(64px + env(safe-area-inset-top)); transform: translateX(-50%); max-width: 90vw; padding: 10px 16px; border-radius: 14px; background: rgba(18, 50, 74, 0.92); color: #fff; font-weight: 600; text-align: center; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3); }
.sheet-wrap { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(8, 40, 64, 0.45); }
.sheet-wrap.fresh { pointer-events: none; }
.sheet { width: 100%; max-width: 380px; max-height: 88vh; overflow-y: auto; padding: 18px 16px; border-radius: 22px; background: #fff; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35); }
.sheet h2 { margin: 0 0 12px; text-align: center; color: var(--sea); }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.sheet-actions .btn { flex: 1 1 40%; }
.sheet input[type='range'] { width: 100%; accent-color: var(--coral); }
.finish { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.finish .stars { margin: 0; font-size: 44px; color: #f0a500; letter-spacing: 6px; text-shadow: 0 2px 0 #b77900; }
.finish .time { margin: 0; font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.finish .new-best { margin: 4px 0 0; font-weight: 700; color: #c9483a; }
.ask, .update { position: fixed; z-index: 45; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; width: min(440px, calc(100vw - 24px)); padding: 10px 12px; border-radius: 16px; background: #fff; box-shadow: 0 8px 22px rgba(0, 0, 0, 0.3); }
.ask { top: calc(10px + env(safe-area-inset-top)); }
.ask span, .update span { flex: 1; min-width: 0; font-weight: 700; }
.update { bottom: calc(14px + env(safe-area-inset-bottom)); }

/* ---------- room chat ---------- */
.chat-open { position: relative; }
#lobby-chat { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.chat-badge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--coral); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.chat-sheet { position: fixed; inset: 0; z-index: 42; display: flex; align-items: flex-end; justify-content: center; background: rgba(8, 40, 64, 0.35); }
.chat-card { width: 100%; max-width: 480px; height: min(70vh, 520px); display: flex; flex-direction: column; gap: 8px; padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0; background: #fff; box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.25); }
.chat-head { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; }
.chat-head h2 { margin: 0 0 0 4px; font-size: 19px; color: var(--sea); }
.chat-head .close { width: 44px; height: 36px; border: 0; background: none; font-size: 18px; color: var(--muted); }
.chat-empty { text-align: left; margin: 2px 4px; }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; margin: 0; padding: 0 2px; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.chat-log:empty { display: none; }
.chat-log li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; align-self: flex-start; max-width: 88%; padding: 7px 11px; border-radius: 14px; background: #eaf5fc; overflow-wrap: anywhere; font-size: 15px; }
.chat-log li b { flex-basis: 100%; font-size: 12px; color: var(--muted); }
.chat-log li span { flex: 1; min-width: 0; }
.chat-log li.mine { align-self: flex-end; background: #ffe9e4; }
.chat-log li.system { align-self: center; background: none; padding: 2px 8px; font-size: 13px; color: var(--faint); text-align: center; }
.chat-log li .flag { margin-left: auto; padding: 0 4px; border: 0; background: none; font-size: 14px; opacity: 0.7; cursor: pointer; }
.chat-log li .flag::before { content: '🚩'; }
.chat-quick { flex-shrink: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chat-quick .quick { flex: 0 0 auto; min-height: 36px; padding: 4px 12px; border: 2px solid var(--edge); border-radius: 999px; background: #fff; font-size: 14px; font-weight: 600; }
.chat-form { flex-shrink: 0; display: flex; gap: 8px; }
.chat-form input { flex: 1; min-width: 0; height: 44px; padding: 0 12px; border: 2px solid var(--edge); border-radius: 12px; background: #fff; color: var(--ink); font-size: 16px; }
.chat-toast { position: fixed; z-index: 41; left: 50%; top: calc(104px + env(safe-area-inset-top)); transform: translateX(-50%); max-width: 86vw; padding: 8px 14px; border: 0; border-radius: 14px; background: rgba(255, 255, 255, 0.95); color: var(--ink); font-weight: 600; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25); }

/* ---------- voice chat (../js/voice.js): hold to talk; who's talking ---------- */
.talk { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#lobby-talk { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; }
.hud-btn.talk { font-size: 18px; line-height: 1; }
.talk.on { background: #e5484d; color: #fff; box-shadow: 0 0 0 4px rgba(229, 72, 77, 0.35); }
.talking-now { position: fixed; z-index: 41; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.talking-now:empty { display: none; }
body[data-screen='game'] .talking-now { bottom: auto; top: calc(60px + env(safe-area-inset-top)); }
.talking-now button { pointer-events: auto; padding: 6px 14px; border: 0; border-radius: 999px; background: rgba(255, 255, 255, 0.95); color: var(--ink); font: inherit; font-weight: 700; font-size: 15px; line-height: 1.4; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25); }
.talking-now button.muted { opacity: 0.7; }
.players-list .voice-mute, .players-list .voice-report { border: 0; background: none; font-size: 18px; padding: 4px 6px; cursor: pointer; }
/* (The iOS app's way back to its games: js/native.js.) */
.app-home { align-self: flex-start; }
