:root {
  --bg-1: #0a0f3c;
  --bg-2: #020414;
  --panel: rgba(16, 26, 84, 0.78);
  --panel-border: #2d3fa8;
  --text: #f1f3ff;
  --muted: #9aa3d6;
  --gold: #f5c542;
  --gold-dark: #b8901c;
  --accent: #3d5afe;
  --correct: #1fa954;
  --wrong: #d63131;
  --selected: #f08c00;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }
html { background: var(--bg-2); }

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--text);
  background: radial-gradient(ellipse at top, #1b2a8a 0%, var(--bg-1) 40%, var(--bg-2) 100%) fixed;
  min-height: 100vh;
}

a { color: var(--gold); }

button, input, select, textarea { font: inherit; }
button, a, .option { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
img, table { max-width: 100%; }

/* ---------- üst bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap;
  padding: 12px 20px; border-bottom: 1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.25);
}
.brand { color: var(--gold); font-weight: 700; font-size: 1.15rem; text-decoration: none; letter-spacing: .3px; }
.userbox { display: flex; align-items: center; gap: 10px; color: var(--muted); }

.container { max-width: 1000px; margin: 0 auto; padding: 24px 16px 60px; }
.narrow { max-width: 440px; }

/* ---------- paneller ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--panel-border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
.panel h2 { margin: 0 0 14px; font-size: 1.15rem; color: var(--gold); }
.panel h3 { margin: 0 0 10px; font-size: 1rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 10px; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }

/* ---------- form ---------- */
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid #3a4aa8; background: rgba(0,0,0,.35); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 0; }
textarea { min-height: 80px; resize: vertical; }
select option, select optgroup { background: #101a54; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 8px; border: 1px solid transparent; cursor: pointer;
  background: var(--accent); color: #fff; font-weight: 600; text-decoration: none;
  transition: filter .15s, transform .05s;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn.gold { background: linear-gradient(180deg, var(--gold), var(--gold-dark)); color: #1a1300; }
.btn.ghost { background: transparent; border-color: #4a5bc4; color: var(--text); }
.btn.danger { background: var(--wrong); }
.btn.sm { padding: 6px 10px; font-size: .85rem; }
.btn.lg { padding: 14px 26px; font-size: 1.1rem; }

.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tabs button { flex: 1; }

/* ---------- liste ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px; background: rgba(0,0,0,.22); margin-bottom: 8px;
}
.list li .title { font-weight: 600; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem;
  background: rgba(255,255,255,.1); color: var(--muted);
}
.badge.gold { background: rgba(245,197,66,.18); color: var(--gold); }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  padding: 12px 20px; border-radius: 8px; background: #222b66; border: 1px solid var(--panel-border);
  box-shadow: 0 8px 24px rgba(0,0,0,.5); z-index: 100; max-width: 90vw;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
#toast.show { opacity: 1; }
#toast.error { background: #5c1414; border-color: var(--wrong); }
#toast.ok { background: #0f4d2a; border-color: var(--correct); }

/* ---------- soru düzenleme ---------- */
.q-item { display: block !important; }
.q-item .q-head { display: flex; gap: 10px; align-items: flex-start; }
.q-item .q-text { flex: 1; white-space: pre-wrap; }
.q-item ol { margin: 8px 0 0; padding-left: 28px; list-style: upper-alpha; }
.q-item ol li { background: none; padding: 1px 0; margin: 0; display: list-item; }
.q-item ol li.is-correct { color: #6be09a; font-weight: 600; }
.opt-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.opt-row .letter { width: 22px; font-weight: 700; color: var(--gold); }
.opt-row input[type=radio] { width: 18px; height: 18px; accent-color: var(--correct); }
pre.help {
  background: rgba(0,0,0,.35); padding: 10px 12px; border-radius: 8px;
  font-size: .85rem; overflow-x: auto; color: #cfd5ff; margin: 8px 0;
}

/* ---------- oda / lobi ---------- */
.room-code {
  font-size: 2.6rem; letter-spacing: 8px; font-weight: 800; color: var(--gold);
  font-family: Consolas, monospace;
}
.players li .crown { color: var(--gold); }
.players li.offline { opacity: .45; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--correct); display: inline-block; }
.offline .dot { background: #666; }

.center-screen { text-align: center; padding: 60px 16px; }
.countdown { font-size: 7rem; font-weight: 800; color: var(--gold); text-shadow: 0 0 40px rgba(245,197,66,.5); }

/* ---------- oyun ekranı ---------- */
.game { max-width: 1000px; margin: 0 auto; padding: 16px; }
.game-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.game-top .qnum { font-weight: 700; color: var(--gold); font-size: 1.1rem; }
.timer-circle {
  width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center;
  font-size: 1.5rem; font-weight: 800; border: 4px solid var(--gold); color: var(--gold);
  background: rgba(0,0,0,.4);
}
.timer-circle.low { border-color: var(--wrong); color: #ff6b6b; animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }

.timerbar { height: 8px; border-radius: 4px; background: rgba(255,255,255,.1); overflow: hidden; margin-bottom: 20px; }
.timerbar > div { height: 100%; background: linear-gradient(90deg, var(--gold), #ff8a00); width: 100%; }

.hex {
  position: relative; border: 2px solid #8fa2ff;
  background: linear-gradient(180deg, #1a2780 0%, #070d3a 100%);
  clip-path: polygon(3% 0, 97% 0, 100% 50%, 97% 100%, 3% 100%, 0 50%);
}
.question-box {
  padding: 26px 48px; text-align: center; font-size: 1.35rem; line-height: 1.45;
  min-height: 110px; display: grid; place-items: center; margin-bottom: 22px; white-space: pre-wrap;
}
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 700px) {
  .options { grid-template-columns: 1fr; }
  .question-box { padding: 20px 26px; font-size: 1.1rem; }
}
.option {
  display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 14px 36px; color: var(--text); cursor: pointer; font-size: 1.05rem; min-height: 60px;
  transition: background .15s;
}
.option:hover:not(:disabled) { background: linear-gradient(180deg, #2d3cb0 0%, #121a66 100%); }
.option:disabled { cursor: default; }
.option .letter { color: var(--gold); font-weight: 800; }
.option .label { flex: 1; }
.option .count { font-size: .85rem; background: rgba(0,0,0,.35); padding: 2px 8px; border-radius: 999px; }
.option.selected { background: linear-gradient(180deg, #ffa53a, var(--selected)); color: #000; }
.option.selected .letter { color: #fff; }
.option.correct { background: linear-gradient(180deg, #35d27a, var(--correct)); color: #000; animation: blink .4s 3; }
.option.correct .letter { color: #fff; }
.option.wrong { background: linear-gradient(180deg, #ff5757, var(--wrong)); }
.option.dim { opacity: .55; }
@keyframes blink { 50% { filter: brightness(1.5); } }

.feedback { text-align: center; font-size: 1.3rem; font-weight: 700; min-height: 40px; margin: 18px 0 8px; }
.feedback.good { color: #4ee38b; }
.feedback.bad { color: #ff6b6b; }
.feedback.blank { color: var(--muted); }

.mini-board { max-width: 520px; margin: 10px auto 0; }

/* ---------- sonuç tablosu ---------- */
table.results { width: 100%; border-collapse: collapse; }
table.results th, table.results td { padding: 10px 8px; text-align: center; border-bottom: 1px solid rgba(255,255,255,.08); }
table.results th { color: var(--muted); font-weight: 600; font-size: .85rem; }
table.results td.name { text-align: left; font-weight: 600; }
table.results tr.me td { background: rgba(245,197,66,.12); }
table.results .c { color: #4ee38b; font-weight: 700; }
table.results .w { color: #ff6b6b; font-weight: 700; }
table.results .b { color: var(--muted); font-weight: 700; }
.medal { font-size: 1.3rem; }

.review-item { padding: 12px; border-radius: 8px; background: rgba(0,0,0,.22); margin-bottom: 10px; }
.review-item .q { font-weight: 600; margin-bottom: 6px; white-space: pre-wrap; }
.review-item .ok { color: #4ee38b; }
.review-item .no { color: #ff6b6b; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- mobil ---------- */
@media (max-width: 600px) {
  /* iOS'ta odaklanınca otomatik yakınlaştırmayı önler */
  input[type=text], input[type=password], input[type=number], select, textarea { font-size: 16px; }

  .topbar { padding: 10px 12px; }
  .brand { font-size: 1rem; }
  .userbox { gap: 6px; font-size: .85rem; }
  .container { padding: 16px 12px 40px; }
  .panel { padding: 14px; margin-bottom: 14px; }
  .grid-2 { gap: 0; }

  .list li { flex-wrap: wrap; }
  .q-item .q-head { flex-wrap: wrap; }
  .q-item .q-text { flex: 1 1 calc(100% - 30px); }

  .room-code { font-size: 2.1rem; letter-spacing: 5px; }
  .countdown { font-size: 5rem; }
  .btn.lg { padding: 12px 18px; font-size: 1rem; }

  .game { padding: 10px 12px 24px; }
  .game-top { gap: 8px; margin-bottom: 8px; }
  .game-top .qnum { font-size: 1rem; }
  .timer-circle { width: 52px; height: 52px; font-size: 1.25rem; border-width: 3px; }
  .timerbar { margin-bottom: 12px; }
  .question-box { padding: 16px 22px; font-size: 1.05rem; min-height: 80px; margin-bottom: 14px; }
  .options { gap: 10px; }
  .option { padding: 12px 22px; font-size: .98rem; min-height: 54px; }
  .feedback { font-size: 1.1rem; margin: 12px 0 6px; }

  table.results th, table.results td { padding: 8px 4px; font-size: .9rem; }
  table.results .col-time { display: none; }
}

@media (max-width: 380px) {
  .brand { font-size: .9rem; }
  .option { padding: 10px 18px; }
}
