:root {
  --bg: #f4f5fb;
  --surface: #ffffff;
  --text: #1c1d33;
  --muted: #5d6079;
  --line: #e1e3f0;
  --primary: #4f46e5;
  --primary-ink: #ffffff;
  --good: #16a34a;
  --bad: #dc2626;
  --o0: #e2445c; --o1: #2f7bf5; --o2: #e0a100; --o3: #12a36b;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 20, 60, .06), 0 8px 24px rgba(20, 20, 60, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12121f; --surface: #1c1c2e; --text: #eeeefb; --muted: #a2a4c2; --line: #2e2e47;
    --primary: #8b83ff; --primary-ink: #12121f; --good: #4ade80; --bad: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}
#app { max-width: 560px; margin: 0 auto; display: grid; gap: 14px; }
h1, h2, p { margin: 0; }
h2 { font-size: 1.15rem; }

.brand { text-align: center; padding: 8px 0 2px; }
.brand h1 { font-size: 2.1rem; letter-spacing: -.03em; font-weight: 800; }
.brand h1 span { color: var(--primary); }
.brand p { color: var(--muted); margin-top: 2px; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; display: grid; gap: 12px; }
.muted { color: var(--muted); font-size: .95rem; }
.foot { text-align: center; color: var(--muted); }
.foot a { color: var(--primary); text-decoration: none; font-weight: 600; }

label { font-weight: 600; font-size: .9rem; color: var(--muted); margin-bottom: -6px; }
input, select {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 2px solid var(--line); border-radius: 12px; padding: 12px 14px; min-height: 48px;
}
input:focus-visible, select:focus-visible, .btn:focus-visible, .opt:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.row { display: flex; gap: 10px; }
.code-in { text-transform: uppercase; letter-spacing: .25em; text-align: center; font-weight: 700; }

.btn {
  font: inherit; font-weight: 700; min-height: 48px; padding: 12px 18px; border-radius: 14px; cursor: pointer;
  border: 2px solid var(--line); background: var(--surface); color: var(--text);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none; text-align: center;
  transition: transform .08s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.big { align-items: flex-start; text-align: left; padding: 14px 18px; }
.btn.big small { font-weight: 400; opacity: .8; font-size: .85rem; }
.btn.link { border-color: transparent; background: transparent; color: var(--primary); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.code-big { font-size: 3rem; font-weight: 800; letter-spacing: .18em; text-align: center; color: var(--primary); padding-left: .18em; }
.players { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.players li { background: var(--bg); border-radius: 12px; padding: 10px 14px; font-weight: 600; }

.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rank li { display: flex; align-items: center; gap: 12px; background: var(--bg); border-radius: 12px; padding: 12px 14px; }
.rank li.me { outline: 2px solid var(--primary); }
.rank .pos { width: 2rem; text-align: center; font-size: 1.2rem; }
.rank .who { flex: 1; font-weight: 600; overflow-wrap: anywhere; }

/* Spiel */
.game-head { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { background: var(--surface); border-radius: 999px; padding: 4px 12px; font-size: .85rem; font-weight: 600; color: var(--muted); box-shadow: var(--shadow); }
.pill.score { margin-left: auto; color: var(--primary); }
.timer { position: relative; height: 14px; background: var(--line); border-radius: 999px; overflow: hidden; }
.timer-fill { height: 100%; width: 100%; background: var(--primary); border-radius: 999px; transition: width .1s linear; }
.timer-fill.urgent { background: var(--bad); }
.timer-label { position: absolute; inset: 0; display: grid; place-items: center; font-size: .7rem; font-weight: 800; color: var(--text); mix-blend-mode: normal; }
.stage { display: grid; gap: 14px; }
.question { font-size: 1.35rem; line-height: 1.3; background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-height: 6.5rem; display: flex; align-items: center; }
.options { display: grid; gap: 10px; }
.opt {
  --c: var(--o0); position: relative; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  font: inherit; font-weight: 600; text-align: left; color: var(--text); cursor: pointer; min-height: 56px;
  background: var(--surface); border: 2px solid var(--line); border-left: 8px solid var(--c); border-radius: 14px; padding: 12px 14px;
  transition: transform .08s, opacity .2s, background .2s;
}
.opt-0 { --c: var(--o0); } .opt-1 { --c: var(--o1); } .opt-2 { --c: var(--o2); } .opt-3 { --c: var(--o3); }
.opt .letter { width: 1.9rem; height: 1.9rem; border-radius: 8px; background: var(--c); color: #fff; display: grid; place-items: center; font-weight: 800; flex: none; }
.opt .opt-text { flex: 1; min-width: 40%; }
.opt:not(:disabled):active { transform: scale(.98); }
.opt.picked { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, var(--surface)); }
.opt.correct { border-color: var(--good); background: color-mix(in srgb, var(--good) 18%, var(--surface)); }
.opt.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 15%, var(--surface)); }
.opt.dim { opacity: .55; }
.opt:disabled { cursor: default; }
.chip { font-style: normal; font-size: .75rem; background: var(--bg); border-radius: 999px; padding: 2px 8px; color: var(--muted); }
.note { text-align: center; min-height: 1.5rem; color: var(--muted); font-weight: 600; }
.note.good { color: var(--good); }
.board { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.board li { display: flex; justify-content: space-between; background: var(--surface); border-radius: 10px; padding: 8px 14px; font-size: .95rem; }
.board li.me { outline: 2px solid var(--primary); }
.countdown { text-align: center; padding: 40px 0; }
.countdown strong { display: block; font-size: 6rem; line-height: 1; color: var(--primary); }

.spinner { width: 44px; height: 44px; margin: 24px auto; border-radius: 50%; border: 5px solid var(--line); border-top-color: var(--primary); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600; max-width: calc(100vw - 32px); z-index: 10; }
[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001s !important; transition-duration: .001s !important; }
}
