:root {
  --night: #1b1030;
  --night-2: #261744;
  --night-3: #33205a;
  --line: rgba(255, 255, 255, 0.09);
  --text: #fff7ec;
  --muted: #c9b8e0;
  --danfo: #f5c400;
  --sunset: #f26b3a;
  --good: #3bd68a;
  --bad: #ff6b6b;
  --radius: 18px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--night); color: var(--text); }
body {
  font: 500 15px/1.4 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}
button { font: inherit; color: inherit; border: 0; cursor: pointer; }
#app { height: 100dvh; display: flex; flex-direction: column; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
b, strong { font-weight: 800; }

.boot { margin: auto; text-align: center; }
.logo { font-weight: 900; letter-spacing: 2px; font-size: 26px; }
.logo span { color: var(--danfo); }

/* ---------- home ---------- */
.home { flex: 1; overflow-y: auto; padding: 14px 16px 28px; }
.top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.top .logo { font-size: 20px; flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 99px;
  background: var(--night-3); font-weight: 700; font-size: 13px;
}
.icon-btn { width: 38px; height: 38px; border-radius: 12px; background: var(--night-3); font-size: 18px; }

.cup {
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px;
  background: linear-gradient(120deg, #8c3b78, var(--sunset) 70%, #ffb25c);
  display: flex; align-items: center; gap: 12px;
}
.cup .big { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; opacity: 0.9; }
.cup .time { font-size: 24px; font-weight: 900; font-variant-numeric: tabular-nums; }
.cup .right { margin-left: auto; text-align: right; font-size: 13px; font-weight: 700; }

.game {
  border-radius: 22px; overflow: hidden; background: var(--night-2); border: 1px solid var(--line); margin-bottom: 14px;
}
.game canvas { display: block; width: 100%; height: 190px; }
.game .body { padding: 14px 16px 16px; }
.game h2 { margin: 0 0 2px; font-size: 20px; font-weight: 900; }
.game .stats { display: flex; gap: 14px; margin: 8px 0 14px; font-size: 13px; color: var(--muted); font-weight: 600; }
.record { margin: -6px 0 14px; font-size: 13px; font-weight: 800; color: var(--danfo); }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); margin-right: 6px; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
.row { display: flex; gap: 10px; }
.btn {
  flex: 1; height: 50px; border-radius: 15px; font-weight: 900; font-size: 16px;
  background: var(--danfo); color: #1b1030; box-shadow: 0 4px 0 #c99a00;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #c99a00; }
.btn.ghost { background: var(--night-3); color: var(--text); box-shadow: 0 4px 0 #1a0f30; }
.btn.small { height: 40px; font-size: 14px; flex: none; padding: 0 16px; }
.btn[disabled] { opacity: 0.5; }

.section { margin: 18px 2px 10px; font-weight: 900; font-size: 16px; display: flex; align-items: center; }
.section .more { margin-left: auto; font-size: 13px; color: var(--danfo); background: none; font-weight: 800; }
.tables { display: grid; gap: 8px; }
.table-card {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px;
  background: var(--night-2); border: 1px solid var(--line); text-align: left; width: 100%;
}
.stage { font-size: 11px; font-weight: 900; padding: 4px 8px; border-radius: 8px; background: var(--night-3); color: var(--danfo); white-space: nowrap; }
.stage.s3 { background: var(--danfo); color: #1b1030; }
.table-card .who { flex: 1; min-width: 0; }
.table-card .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { padding: 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 16px; font-size: 14px; }

.soon-card { display: flex; flex-direction: column; gap: 4px; padding: 16px; border-radius: 16px; background: var(--night-2); border: 1px solid var(--line); }
.soon-card b { font-size: 18px; }
.soon-tag { align-self: flex-start; font-size: 11px; font-weight: 900; padding: 4px 8px; border-radius: 8px; background: var(--night-3); color: var(--danfo); text-transform: uppercase; letter-spacing: 0.5px; }
.soon { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.soon div { padding: 16px; border-radius: 16px; background: var(--night-2); border: 1px solid var(--line); }
.soon b { display: block; font-size: 16px; }

/* ---------- table ---------- */
.table-view { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; background: #000; }
.table-view canvas { flex: 1 1 0; height: 0; width: 100%; min-height: 0; display: block; touch-action: none; }
.bar {
  order: -1; display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--night); border-bottom: 1px solid var(--line);
}
.bar .title { flex: 1; font-weight: 800; font-size: 14px; }
.overlay {
  position: absolute; left: 16px; right: 16px; top: 22%; text-align: center; pointer-events: none;
  text-shadow: 0 2px 0 #1b1030, 0 0 12px rgba(0, 0, 0, 0.5);
}
.overlay .huge { font-size: 64px; font-weight: 900; }
.overlay .msg { font-size: 22px; font-weight: 900; }
.overlay .sub { font-size: 15px; font-weight: 700; }
.ticker {
  position: absolute; top: 66px; left: 12px; right: 12px; text-align: center; font-weight: 800; font-size: 13px;
  pointer-events: none; text-shadow: 0 1px 0 #000;
}
.cheers { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
/* Reactions stay small and low, over the road, so they never cover the pylons or the danfo. */
.cheers span { position: absolute; bottom: 6px; font-size: 16px; opacity: 0.9; animation: rise 1.6s ease-out forwards; }
@keyframes rise { to { transform: translateY(-36px); opacity: 0; } }

.dock { background: var(--night); padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.seats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seat { padding: 8px 4px; border-radius: 12px; background: var(--night-2); text-align: center; border: 2px solid transparent; min-width: 0; }
.seat.flying { border-color: var(--danfo); }
.seat.winner { border-color: var(--good); }
.seat .nm { font-size: 12px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat .sc { font-size: 18px; font-weight: 900; }
.seat .st { font-size: 10px; color: var(--muted); font-weight: 700; }
.seat.pick { cursor: pointer; }
.seat.picked { background: var(--night-3); border-color: var(--sunset); }
.cheer-row { display: flex; justify-content: space-between; margin-top: 8px; }
.cheer-row button { font-size: 24px; background: var(--night-2); border-radius: 12px; width: 13%; height: 40px; }
.hint { margin-top: 6px; text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; }

/* ---------- sheets ---------- */
.sheet {
  position: fixed; inset: 0; background: rgba(10, 5, 20, 0.6); display: flex; align-items: flex-end; z-index: 10;
}
.sheet[hidden] { display: none; }
.sheet .panel {
  width: 100%; max-height: 88dvh; overflow-y: auto; background: var(--night-2); border-radius: 24px 24px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}
.sheet h3 { margin: 0 0 4px; font-size: 20px; font-weight: 900; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.item { padding: 12px; border-radius: 16px; background: var(--night-3); text-align: center; border: 2px solid transparent; }
.item.on { border-color: var(--danfo); }
.item canvas { width: 100%; height: 70px; display: block; image-rendering: pixelated; }
.item b { display: block; margin: 6px 0 2px; }
.item .btn { width: 100%; height: 38px; font-size: 14px; margin-top: 8px; box-shadow: 0 3px 0 #c99a00; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.rank { width: 28px; font-weight: 900; color: var(--danfo); text-align: center; }
.result-list { margin: 12px 0 16px; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: 24px; padding: 12px 16px; border-radius: 14px;
  background: var(--text); color: var(--night); font-weight: 800; text-align: center; z-index: 20;
}
.toast[hidden] { display: none; }
