:root {
  --bg: #0f1226;
  --bg2: #191d3a;
  --card: #222750;
  --card2: #2b3163;
  --text: #eef0ff;
  --muted: #9aa0c9;
  --accent: #6c7bff;
  --accent2: #37e0b0;
  --danger: #ff5c76;
  --gold: #ffd34d;
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 600px at 50% -10%, #262c5e 0%, var(--bg) 55%);
  display: flex;
  justify-content: center;
  padding: 24px 16px 48px;
}

.app { width: 100%; max-width: 640px; }

header { text-align: center; margin-bottom: 20px; }
h1 { margin: 0; font-size: 2rem; letter-spacing: .5px; }
.tagline { color: var(--muted); font-size: .92rem; margin: 6px 0 0; }

.screen { display: flex; flex-direction: column; gap: 16px; }
.hidden { display: none !important; }

.card {
  background: var(--card);
  border: 1px solid rgba(255,255,255,.06);
  border-radius: var(--radius);
  padding: 18px;
}

label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }

input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.12);
  background: var(--bg2);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 12px;
  outline: none;
}
input:focus { border-color: var(--accent); }

.btn {
  width: 100%;
  padding: 13px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.14);
  background: var(--card2);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .08s, filter .15s;
}
.btn:hover:not(:disabled) { filter: brightness(1.12); }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), #8b5cff);
  border: none;
}

.sep { text-align: center; color: var(--muted); margin: 14px 0; font-size: .8rem; position: relative; }
.sep::before, .sep::after {
  content: ""; position: absolute; top: 50%; width: 38%; height: 1px; background: rgba(255,255,255,.1);
}
.sep::before { left: 0; } .sep::after { right: 0; }

.error { color: var(--danger); font-size: .9rem; margin: 10px 0 0; min-height: 1em; }

.code-box { text-align: center; }
.code-box .code {
  font-size: 3rem; font-weight: 800; letter-spacing: .5rem;
  color: var(--gold); margin: 8px 0;
}
.waiting { color: var(--muted); animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .4; } }

/* ---------- HUD ---------- */
.hud { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; }
.vs { font-weight: 800; color: var(--muted); font-size: .9rem; }

.player-card {
  background: var(--card);
  border-radius: 14px;
  padding: 12px;
  border: 2px solid transparent;
  transition: border-color .2s;
}
.player-card.active { border-color: var(--accent); }
.player-card.attacker { border-color: var(--gold); }
.pc-top { display: flex; justify-content: space-between; font-size: .85rem; margin-bottom: 8px; gap: 6px; }
.pc-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-score { color: var(--muted); }
.hpbar { height: 12px; border-radius: 8px; background: #141834; overflow: hidden; }
.hpfill {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--accent2), #5ad0ff);
  transition: width .45s ease;
}
.hp-text { font-size: .75rem; color: var(--muted); }

.progress { text-align: center; color: var(--muted); font-size: .85rem; }

/* ---------- Timer ---------- */
.timer { display: flex; align-items: center; justify-content: center; gap: 14px; }
.timer-ring {
  width: 72px; height: 72px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 1.7rem; font-weight: 800;
  background: conic-gradient(var(--danger) var(--pct, 100%), #2a2f5c 0);
  position: relative;
}
.timer-ring::after {
  content: ""; position: absolute; inset: 7px;
  border-radius: 50%; background: var(--bg2);
}
.timer-ring span { position: relative; z-index: 1; }
.timer-label { font-weight: 600; color: var(--gold); }

/* ---------- Question ---------- */
.question-card h2 { margin: 0 0 16px; font-size: 1.25rem; line-height: 1.35; }
.choices { display: grid; gap: 10px; }
.choice {
  text-align: left;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.12);
  background: var(--bg2);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  transition: transform .08s, border-color .15s, background .15s;
}
.choice:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); }
.choice.selected { border-color: var(--accent); background: #2b3163; }
.choice.correct { border-color: var(--accent2); background: rgba(55,224,176,.18); }
.choice.wrong { border-color: var(--danger); background: rgba(255,92,118,.18); }
.choice:disabled { cursor: default; opacity: .85; }

.feedback { min-height: 1.2em; font-weight: 600; margin: 14px 0 0; }

.actions { display: flex; justify-content: center; }
.actions .btn { max-width: 280px; }

.status { text-align: center; color: var(--muted); font-size: .85rem; min-height: 1.2em; }

.rules {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 18px;
  color: var(--muted);
  font-size: .88rem;
}
.rules summary { cursor: pointer; color: var(--text); font-weight: 600; }
.rules ul { margin: 10px 0 0; padding-left: 18px; line-height: 1.5; }
.rules strong { color: var(--text); }

@media (max-width: 480px) {
  .hud { grid-template-columns: 1fr auto 1fr; }
  .code-box .code { font-size: 2.4rem; letter-spacing: .3rem; }
  h1 { font-size: 1.6rem; }
}
