:root {
  --primary: #b45309; --primary-dark: #8f4207; --primary-light: #ffdcb8; --bg: #fff8f2; --surface: #fff;
  --text: #1c1b1f; --muted: #6b6258; --line: #e3d2c0; --good: #2e7d32; --good-bg: #d8f0d4; --bad: #b3261e; --bad-bg: #f9dedc;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { margin: 0 0 12px; font-weight: 600; }
.hidden { display: none !important; }

/* generic */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 28px; padding: 12px 24px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; } .btn-primary:hover { background: var(--primary-dark); }
.btn-tonal { background: var(--primary-light); color: #4a2500; }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-danger { background: var(--bad); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-lg { padding: 16px 36px; font-size: 20px; }
.card { background: var(--surface); border-radius: 16px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.center-card { max-width: 420px; margin: 12vh auto 0; padding: 0 20px; text-align: center; }
.muted { color: var(--muted); }
.error { background: var(--bad-bg); color: var(--bad); padding: 10px 14px; border-radius: 10px; margin: 12px 0; }
input[type=text], input[type=tel] { width: 100%; font: inherit; font-size: 20px; padding: 14px 16px; border: 2px solid var(--line); border-radius: 12px; background: #fff; text-align: center; margin-bottom: 12px; }
input:focus { outline: none; border-color: var(--primary); }

/* board */
.board-wrap { position: relative; width: min(94vw, 62vh); margin: 0 auto; }
.board { width: 100%; aspect-ratio: 1; }
.board.flash-bad { box-shadow: 0 0 0 4px var(--bad); border-radius: 4px; }
.promo { position: absolute; inset: 0; background: rgba(0,0,0,.5); display: none; align-items: center; justify-content: center; gap: 8px; z-index: 10; }
.promo.open { display: flex; }
.promo button { width: 18%; aspect-ratio: 1; border: 2px solid #fff; border-radius: 8px; background: #f0d9b5; position: relative; padding: 0; cursor: pointer; }
.promo .cg-wrap { position: absolute; inset: 0; }
.promo piece { position: absolute; inset: 2px; width: auto; height: auto; background-size: cover; display: block; pointer-events: none; }
.pause-overlay { position: absolute; inset: 0; background: rgba(255,248,242,.9); display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700; z-index: 5; border-radius: 4px; }

/* timer */
.timer { display: flex; align-items: center; gap: 10px; }
.timer-bar { flex: 1; height: 12px; background: var(--line); border-radius: 6px; overflow: hidden; }
.timer-fill { height: 100%; width: 100%; background: var(--primary); transform-origin: left; }
.timer-fill.low { background: var(--bad); }
.timer-text { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 3ch; text-align: right; }

/* player */
body.player #app { max-width: 560px; margin: 0 auto; padding: 12px 12px 40px; }
.topbar { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.topbar strong { color: var(--text); }
.prompt { font-size: 18px; font-weight: 600; margin: 10px 0; text-align: center; }
.q-image { max-width: 100%; max-height: 160px; display: block; margin: 8px auto; border-radius: 8px; }
.status-line { text-align: center; min-height: 28px; margin: 10px 0; font-weight: 600; }
.status-line.bad { color: var(--bad); } .status-line.good { color: var(--good); }
.result-banner { text-align: center; padding: 16px; border-radius: 14px; margin: 12px 0; font-size: 20px; font-weight: 700; }
.result-banner.good { background: var(--good-bg); color: var(--good); }
.result-banner.bad { background: var(--bad-bg); color: var(--bad); }
.result-banner.neutral { background: var(--primary-light); color: #4a2500; }
.result-banner small { display: block; font-size: 14px; font-weight: 500; margin-top: 4px; }
.hint-box { text-align: center; margin: 8px 0; }
.lines { margin: 12px 0; } .lines div { font-family: ui-monospace, monospace; font-size: 15px; margin: 4px 0; }
.explain { margin: 10px 0; padding: 12px; background: #fff; border-radius: 10px; border-left: 4px solid var(--primary); }
.stats { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 10px 0; }
.stat { padding: 4px 10px; border-radius: 12px; font-size: 13px; font-weight: 600; background: #fff; }
.stat.good { background: var(--good-bg); color: var(--good); } .stat.bad { background: var(--bad-bg); color: var(--bad); }

/* leaderboard */
.lb { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }
.lb-row { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 12px; padding: 10px 14px; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.lb-row.me { outline: 3px solid var(--primary); background: var(--primary-light); }
.lb-rank { width: 2.2ch; font-weight: 700; text-align: center; }
.lb-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-pts { font-weight: 700; font-variant-numeric: tabular-nums; }
.lb-delta { width: 4ch; text-align: right; font-size: 13px; font-weight: 700; }
.lb-delta.up { color: var(--good); } .lb-delta.down { color: var(--bad); }
.lb-gap { text-align: center; color: var(--muted); }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; margin: 16px 0 24px; min-height: 160px; }
.podium .step { flex: 1; max-width: 160px; text-align: center; }
.podium .step .bar { background: var(--primary); color: #fff; border-radius: 10px 10px 0 0; padding: 10px 4px; font-size: 28px; font-weight: 800; }
.podium .step.p1 .bar { height: 120px; background: #d4a017; } .podium .step.p2 .bar { height: 90px; background: #9aa0a6; } .podium .step.p3 .bar { height: 66px; background: #a8672d; }
.podium .step .nm { font-weight: 700; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium .step .pt { font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.pill-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 14px 0; }
.pill { background: #fff; border-radius: 20px; padding: 6px 14px; font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.1); display: inline-flex; align-items: center; gap: 6px; }
.pill.off { opacity: .5; } .pill.done { background: var(--good-bg); }
.pill button { border: 0; background: transparent; cursor: pointer; font-size: 16px; color: var(--bad); padding: 0 2px; }

/* host + projection */
body.screen #app { padding: 16px 24px 40px; max-width: 1500px; margin: 0 auto; }
.screen-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.screen-head h1 { margin: 0; font-size: 24px; }
.controls { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 14px 0; }
.pin { font-size: clamp(56px, 12vw, 140px); font-weight: 800; letter-spacing: .12em; color: var(--primary); line-height: 1; text-align: center; }
.join-hint { text-align: center; font-size: clamp(16px, 2.4vw, 28px); margin: 8px 0 20px; }
.lobby-grid { display: grid; grid-template-columns: 1fr 260px; gap: 24px; align-items: center; }
.lobby-grid img { width: 100%; background: #fff; border-radius: 12px; padding: 8px; }
@media (max-width: 800px) { .lobby-grid { grid-template-columns: 1fr; } }
.split { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr); gap: 28px; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
body.projection .prompt { font-size: clamp(22px, 3vw, 40px); }
body.projection .timer-text { font-size: clamp(24px, 3vw, 44px); }
body.projection .timer-bar { height: 20px; }
body.projection .lb-row { font-size: clamp(18px, 2.4vw, 32px); padding: 14px 20px; }
body.projection .lines div { font-size: clamp(18px, 2.2vw, 30px); }
body.projection .board-wrap { width: min(46vw, 78vh); }
body.projection.ended .board-wrap { display: none; }
.big-counter { text-align: center; font-size: clamp(20px, 3vw, 36px); font-weight: 700; margin: 12px 0; }
