:root {
  --bg: #0F172A;
  --bg-2: #1E293B;
  --bg-3: #334155;
  --text: #F8FAFC;
  --muted: #94A3B8;
  --accent: #F2A541;
  --good: #22C55E;
  --bad: #EF4444;
  --opt-0: #E21B3C;
  --opt-1: #1368CE;
  --opt-2: #D89E00;
  --opt-3: #26890C;
  --radius: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; }
button:disabled { cursor: default; }
h1, h2 { margin: 0.2em 0; line-height: 1.15; }

/* ---------- player ---------- */
body.player {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  background: var(--bg-2);
  font-weight: 700;
  font-size: 1.1rem;
}
.me-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-score { color: var(--accent); white-space: nowrap; }
#app { flex: 1; display: flex; min-height: 0; }
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  gap: 8px;
  min-height: 0;
}
.owl { font-size: 4.5rem; line-height: 1; }
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.player h1 { font-size: 2.2rem; color: var(--accent); }
.player h2 { font-size: 1.8rem; }
.hint { color: var(--muted); font-size: 0.95rem; margin: 4px 0; }
.big-hint { color: var(--muted); font-size: 1.25rem; margin: 4px 0; }

.join-form { display: flex; flex-direction: column; gap: 12px; width: min(100%, 380px); text-align: left; }
.join-form label { font-weight: 700; font-size: 1.1rem; }
.join-form input {
  font: inherit; font-size: 1.6rem; padding: 14px 16px; border-radius: var(--radius);
  border: 2px solid var(--bg-3); background: var(--bg-2); color: var(--text); width: 100%;
}
.join-form input:focus { outline: none; border-color: var(--accent); }
.btn-primary {
  background: var(--accent); color: #111827; font-weight: 800; font-size: 1.5rem;
  padding: 16px; border-radius: var(--radius); min-height: 64px;
}
.btn-primary:disabled { opacity: 0.6; }
.error { color: #FCA5A5; min-height: 1.4em; margin: 0; font-weight: 600; }

.screen-question { justify-content: flex-start; align-items: stretch; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.q-head { text-align: center; }
.q-meta { color: var(--accent); font-weight: 700; font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.04em; }
.q-prompt { font-size: 1.3rem; font-weight: 700; margin: 6px 0 10px; }
.timer { height: 12px; background: var(--bg-3); border-radius: 99px; overflow: hidden; }
.timer-fill { height: 100%; width: 100%; background: var(--accent); transform-origin: left; transition: transform 0.15s linear; }
.timer-fill.low { background: var(--bad); }
.timer-num { font-weight: 800; font-size: 1.2rem; margin-top: 4px; min-height: 1.4em; }

.options { flex: 1; display: grid; gap: 12px; min-height: 0; margin-top: 8px; }
.options.n2 { grid-template-rows: 1fr 1fr; }
.options.n3 { grid-template-rows: repeat(3, 1fr); }
.options.n4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.opt {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--radius); padding: 12px; min-height: 72px; font-weight: 800;
  font-size: 1.15rem; line-height: 1.2; color: #fff; box-shadow: inset 0 -6px 0 rgba(0,0,0,0.25);
  transition: transform 0.08s, opacity 0.2s, outline-color 0.2s;
  outline: 4px solid transparent; outline-offset: 3px;
}
.opt:active { transform: scale(0.97); }
.opt .shape { font-size: 2.4rem; line-height: 1; }
.options.n2 .opt { flex-direction: row; gap: 18px; font-size: 2.6rem; }
.options.n2 .opt .shape { font-size: 3rem; }
.opt-0 { background: var(--opt-0); }
.opt-1 { background: var(--opt-1); }
.opt-2 { background: var(--opt-2); }
.opt-3 { background: var(--opt-3); }
.opt.selected { outline-color: #fff; }
.opt.dim { opacity: 0.45; }
.poll-options .opt { font-size: 1.35rem; }
.poll-options .opt .count { font-size: 1rem; font-weight: 700; opacity: 0.9; }

.chosen { font-size: 5rem; width: 140px; height: 140px; border-radius: 28px; display: grid; place-items: center; color: #fff; }
.result-icon { font-size: 5.5rem; line-height: 1; }
.points { font-size: 2.4rem; font-weight: 900; color: var(--accent); margin: 0; }
#screen-reveal.good { background: radial-gradient(circle at 50% 30%, rgba(34,197,94,0.25), transparent 70%); }
#screen-reveal.bad { background: radial-gradient(circle at 50% 30%, rgba(239,68,68,0.22), transparent 70%); }

.board { list-style: none; padding: 0; margin: 8px 0 0; width: min(100%, 420px); display: flex; flex-direction: column; gap: 6px; overflow: auto; }
.board li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: 12px; background: var(--bg-2); font-weight: 700; font-size: 1.1rem; }
.board li.me { outline: 3px solid var(--accent); }
.board .rk { color: var(--accent); min-width: 2ch; text-align: left; }
.board .nm { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (min-width: 700px) {
  .options.n2 { grid-template-rows: none; grid-template-columns: 1fr 1fr; }
  .screen-question { max-width: 900px; margin: 0 auto; width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
