:root {
  --bg: #f4f5fb;
  --surface: #ffffff;
  --text: #1d1f2c;
  --muted: #646a82;
  --border: #dfe2ee;
  --primary: #4b3fd8;
  --primary-ink: #ffffff;
  --ok: #1f8a4c;
  --ok-bg: #e2f5ea;
  --bad: #c62838;
  --bad-bg: #fbe5e7;
  --warn: #9a6700;
  --warn-bg: #fff4d6;
  --c0: #e21b3c;
  --c1: #1368ce;
  --c2: #c98a00;
  --c3: #26890c;
  --c4: #864cbf;
  --c5: #0aa3a3;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(20, 22, 50, .07);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12131c;
    --surface: #1c1e2b;
    --text: #eceef7;
    --muted: #a2a7bf;
    --border: #2f3245;
    --primary: #7c72ff;
    --ok: #4cd18a;
    --ok-bg: #173826;
    --bad: #ff6b78;
    --bad-bg: #3d1a20;
    --warn: #f0c04a;
    --warn-bg: #3a2f12;
    --shadow: 0 2px 10px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  -webkit-text-size-adjust: 100%;
  min-height: 100dvh;
}
[x-cloak] { display: none !important; }
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 520px; margin: 0 auto; padding: 16px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar .brand { font-weight: 800; color: var(--text); text-decoration: none; letter-spacing: .3px; }
.topbar nav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1 1 auto; }
.stack > * + * { margin-top: 12px; }

label { display: block; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=file], textarea, select {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.check input { width: 20px; height: 20px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 18px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; min-height: 44px;
}
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-lg { font-size: 1.15rem; padding: 14px 22px; min-height: 54px; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; min-height: 34px; font-size: .875rem; }

.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; }
.alert-bad { background: var(--bad-bg); color: var(--bad); }
.alert-ok { background: var(--ok-bg); color: var(--ok); }
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.alert ul { margin: 6px 0 0; padding-left: 20px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 700; background: var(--border); color: var(--text); }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-primary { background: var(--primary); color: var(--primary-ink); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .82rem; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Katılım ---------- */
.pin-input { font-size: 2rem !important; text-align: center; letter-spacing: .4em; font-weight: 800; }
.hero { padding: 32px 0 8px; text-align: center; }
.hero .logo { font-size: 2.4rem; font-weight: 900; letter-spacing: 1px; color: var(--primary); }

/* ---------- Sınav ekranı ---------- */
.play-top {
  position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 10px 16px; display: flex; align-items: center; gap: 12px;
}
.timer { border: 1px solid var(--border); font-weight: 800; font-variant-numeric: tabular-nums; font-size: 1.15rem; padding: 4px 12px; border-radius: 10px; background: var(--bg); }
.timer.low { background: var(--bad-bg); color: var(--bad); }
.progress { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); transition: width .3s; }

.question-text { font-size: 1.3rem; font-weight: 700; margin: 8px 0 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
.choices { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .choices { grid-template-columns: 1fr 1fr; } }
.choice {
  display: flex; align-items: center; gap: 12px; text-align: left; width: 100%;
  padding: 16px; min-height: 68px; border-radius: var(--radius); border: 3px solid transparent;
  color: #fff; font: inherit; font-size: 1.08rem; font-weight: 700; cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,.18); transition: transform .06s, opacity .15s;
  overflow-wrap: anywhere;
}
.choice:active { transform: translateY(2px); box-shadow: none; }
.choice .shape { font-size: 1.4rem; width: 28px; text-align: center; flex: 0 0 auto; }
.choice.c0 { background: var(--c0); } .choice.c1 { background: var(--c1); }
.choice.c2 { background: var(--c2); } .choice.c3 { background: var(--c3); }
.choice.c4 { background: var(--c4); } .choice.c5 { background: var(--c5); }
.choices.has-answer .choice:not(.selected) { opacity: .45; }
.choice.selected { border-color: var(--text); opacity: 1; box-shadow: 0 0 0 3px var(--surface), 0 0 0 6px var(--text); }

.qnav { display: flex; flex-wrap: wrap; gap: 6px; }
.qnav button {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-weight: 700; cursor: pointer;
}
.qnav button.answered { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.qnav button.current { outline: 3px solid var(--text); outline-offset: 1px; }

.saved-hint { font-size: .85rem; color: var(--muted); min-height: 1.3em; }
.lobby-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--primary); display: inline-block; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: .3; transform: scale(.85);} 50% { opacity: 1; transform: scale(1.1);} }

.score-big { font-size: 3rem; font-weight: 900; line-height: 1; }
.result-item { border-left: 5px solid var(--border); padding: 8px 12px; margin-bottom: 10px; background: var(--bg); border-radius: 8px; }
.result-item.ok { border-color: var(--ok); }
.result-item.bad { border-color: var(--bad); }
.result-item.warn { border-color: var(--warn); }

/* ---------- Yansıtma ekranı ---------- */
.host-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 900px) { .host-grid { grid-template-columns: 380px 1fr; } }
.host-pin { font-size: 3.4rem; font-weight: 900; letter-spacing: .12em; text-align: center; line-height: 1.1; }
.qr-box { background: #fff; border-radius: var(--radius); padding: 12px; }
.qr-box img { width: 100%; height: auto; display: block; }
.people { display: flex; flex-wrap: wrap; gap: 8px; }
.person { padding: 6px 12px; border-radius: 99px; background: var(--bg); border: 1px solid var(--border); font-weight: 600; }
.person.done { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }

.matrix td.ok { background: var(--ok-bg); }
.matrix td.bad { background: var(--bad-bg); }
.matrix td.warn { background: var(--warn-bg); }
.matrix td { white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }

.q-list li { margin-bottom: 12px; }
.q-list .correct { color: var(--ok); font-weight: 700; }

/* ---------- Canlı mod: yansıtma ekranı ---------- */
.live-question { padding: 22px 24px 26px; }
.live-q-row { display: flex; align-items: center; gap: 24px; margin-top: 14px; }
.live-q-text { flex: 1 1 auto; min-width: 0; font-size: clamp(1.4rem, 3.2vw, 2.4rem); font-weight: 800; line-height: 1.25; overflow-wrap: anywhere; white-space: pre-wrap; }
.live-answered { font-weight: 700; font-size: 1.1rem; }
.live-timer { position: relative; flex: 0 0 auto; width: 96px; height: 96px; display: grid; place-items: center; }
.live-timer svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.live-timer circle { fill: none; stroke-width: 10; }
.live-timer .track { stroke: var(--border); }
.live-timer .ring { stroke: var(--primary); stroke-dasharray: 326.7; stroke-linecap: round; transition: stroke-dashoffset .25s linear; }
.live-timer.low .ring { stroke: var(--bad); }
.live-timer span { font-size: 2rem; font-weight: 900; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .live-q-row { flex-direction: column; align-items: stretch; }
  .live-timer { margin: 0 auto; }
}

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
@media (max-width: 640px) { .tiles { grid-template-columns: 1fr; } }
.tile {
  display: flex; align-items: center; gap: 14px; padding: 20px 22px; min-height: 92px; border-radius: var(--radius);
  color: #fff; font-size: clamp(1.1rem, 2.2vw, 1.6rem); font-weight: 800; box-shadow: 0 4px 0 rgba(0,0,0,.18);
  overflow-wrap: anywhere; transition: opacity .25s, transform .25s;
}
.tile .shape { font-size: 1.6em; width: 1.4em; text-align: center; flex: 0 0 auto; }
.tile.c0 { background: var(--c0); } .tile.c1 { background: var(--c1); }
.tile.c2 { background: var(--c2); } .tile.c3 { background: var(--c3); }
.tile.c4 { background: var(--c4); } .tile.c5 { background: var(--c5); }
.tile.dim { opacity: .3; }
.tile.correct { transform: scale(1.02); box-shadow: 0 0 0 5px var(--surface), 0 0 0 9px var(--ok); }
.tile-count { background: rgba(0,0,0,.25); border-radius: 99px; padding: 2px 14px; font-variant-numeric: tabular-nums; }
.tile-mark { font-size: 1.6em; }
.live-correct-text { font-size: clamp(1.6rem, 4vw, 2.6rem); font-weight: 900; color: var(--ok); overflow-wrap: anywhere; }

.board-row { display: flex; align-items: center; gap: 16px; padding: 14px 18px; border-radius: 12px; background: var(--bg); margin-bottom: 10px; font-size: 1.35rem; font-weight: 700; }
.board-row.small-row { font-size: 1rem; padding: 10px 14px; margin-bottom: 8px; }
.board-row.me { outline: 3px solid var(--primary); }
.board-rank { width: 2.2em; height: 2.2em; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: var(--primary-ink); flex: 0 0 auto; font-size: .9em; }
.board-name { overflow-wrap: anywhere; }
.board-score { font-variant-numeric: tabular-nums; }

.podium { display: flex; justify-content: center; align-items: flex-end; gap: 14px; margin: 30px 0 20px; }
.podium-col { flex: 0 1 220px; text-align: center; }
.podium-name { font-weight: 800; font-size: 1.25rem; overflow-wrap: anywhere; min-height: 1.6em; }
.podium-score { color: var(--muted); font-weight: 700; margin-bottom: 8px; }
.podium-block { border-radius: 14px 14px 0 0; color: #fff; font-size: 2.6rem; font-weight: 900; display: grid; place-items: center; }
.podium-col.p1 .podium-block { height: 200px; background: #d4a017; }
.podium-col.p2 .podium-block { height: 150px; background: #8e99a8; }
.podium-col.p3 .podium-block { height: 110px; background: #b0703c; }

/* ---------- Canlı mod: telefon ---------- */
.live-result { border-width: 3px; }
.live-result.ok { border-color: var(--ok); background: var(--ok-bg); }
.live-result.bad { border-color: var(--bad); background: var(--bad-bg); }
.live-result.warn { border-color: var(--warn); background: var(--warn-bg); }
.live-result-icon { font-size: 3.4rem; line-height: 1; }
.live-gain { font-size: 2.6rem; font-weight: 900; color: var(--ok); }
