/* ════════════════════════════════════════════════════════
   КВИЗ-БАТЛ — Styles
   ════════════════════════════════════════════════════════ */

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: #0a0a1a;
  color: #f0f0f0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Index Page ─────────────────────────────────────────── */

.index-body {
  min-height: 100vh;
  background: linear-gradient(135deg, #0a0a2e 0%, #1a0a3e 50%, #0a1a2e 100%);
  display: flex;
  justify-content: center;
  padding: 1.5rem;
}

.index-wrap {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.hub-back-link {
  color: rgba(255,255,255,.5);
  text-decoration: none;
  font-size: .9rem;
  transition: color .2s;
}
.hub-back-link:hover { color: #fff; }

.logo {
  text-align: center;
  padding: 1.5rem 0 .5rem;
}
.logo-icon { font-size: 3.5rem; margin-bottom: .3rem; }
.logo-title {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 3px;
  background: linear-gradient(135deg, #a78bfa, #60a5fa, #34d399);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.logo-subtitle {
  font-size: 1rem;
  color: rgba(255,255,255,.6);
  margin-top: .2rem;
}

.index-card {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 16px;
  padding: 1.5rem;
}

.field { margin-bottom: 1rem; }
.field label {
  display: block;
  font-size: .85rem;
  color: rgba(255,255,255,.6);
  margin-bottom: .4rem;
  font-weight: 600;
}

.field input, .field select {
  width: 100%;
  padding: .75rem 1rem;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.08);
  color: #fff;
  font-size: 1rem;
  outline: none;
  transition: border-color .2s;
}
.field input:focus, .field select:focus {
  border-color: #a78bfa;
}
.field input::placeholder { color: rgba(255,255,255,.3); }

.room-actions { display: flex; flex-direction: column; gap: .8rem; }

.room-divider {
  text-align: center;
  color: rgba(255,255,255,.3);
  font-size: .85rem;
  position: relative;
}
.room-divider span {
  background: rgba(10,10,30,.8);
  padding: 0 .8rem;
  position: relative;
  z-index: 1;
}
.room-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(255,255,255,.1);
}

.btn-enter {
  width: 100%;
  padding: .85rem;
  border: none;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .15s, opacity .15s;
  background: linear-gradient(135deg, #7c3aed, #6366f1);
  color: #fff;
}
.btn-enter:hover { transform: scale(1.02); }
.btn-enter:active { transform: scale(.98); }
.btn-enter.btn-join {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.err-msg {
  color: #f87171;
  text-align: center;
  font-size: .9rem;
  min-height: 1.2em;
  margin-top: .5rem;
}

.qr-preview {
  width: min(220px, 65vw);
  background: #fff;
  border-radius: 16px;
  padding: 10px;
  margin: .5rem auto;
  display: block;
}
.qr-hint {
  margin: .3rem 0 .8rem;
  color: rgba(255,255,255,.6);
  font-size: .85rem;
}
.qr-link {
  font-size: .78rem;
  opacity: .5;
  word-break: break-word;
}

.roles-preview {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .5rem;
  padding: .5rem 0;
}
.role-pill {
  display: flex;
  align-items: center;
  gap: .35rem;
  background: rgba(255,255,255,.08);
  border-radius: 20px;
  padding: .35rem .8rem;
  font-size: .85rem;
}
.rp-ic { font-size: 1.1rem; }

.index-hint {
  text-align: center;
  font-size: .82rem;
  color: rgba(255,255,255,.4);
  line-height: 1.5;
}

/* ── Game Page ──────────────────────────────────────────── */

.game-body {
  min-height: 100vh;
  background: linear-gradient(135deg, #0a0a2e 0%, #1a0a3e 50%, #0a1a2e 100%);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 1rem;
}

.game-wrap {
  width: 100%;
  max-width: 560px;
}

.phase-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  min-height: 80vh;
}

/* ── Lobby ─────────────────────────────────────────── */

.lobby-header {
  text-align: center;
  padding: 1rem 0;
}
.lobby-header h1 {
  font-size: 1.8rem;
  font-weight: 900;
  background: linear-gradient(135deg, #a78bfa, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.room-badge {
  display: inline-block;
  background: rgba(255,255,255,.1);
  border-radius: 10px;
  padding: .4rem 1rem;
  margin-top: .5rem;
  font-size: .95rem;
}

.lobby-players {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.lobby-player {
  background: rgba(255,255,255,.06);
  border-radius: 10px;
  padding: .7rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.lobby-player.dc { opacity: .4; }
.lp-dc { font-size: .8rem; color: #f87171; }

.lobby-config {
  width: 100%;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 16px;
  padding: 1.5rem;
}
.lobby-config h3 {
  text-align: center;
  margin-bottom: 1rem;
  font-weight: 700;
  color: rgba(255,255,255,.8);
}

.config-row {
  display: flex;
  align-items: center;
  gap: .8rem;
  margin-bottom: .8rem;
}
.config-row label {
  min-width: 100px;
  font-size: .9rem;
  color: rgba(255,255,255,.6);
}
.config-row input[type="range"] {
  flex: 1;
  accent-color: #7c3aed;
}
.config-row select {
  flex: 1;
  padding: .5rem .7rem;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.08);
  color: #fff;
  font-size: .9rem;
}

.config-cats { flex-wrap: wrap; }
.cat-pills {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}
.cat-pill {
  padding: .35rem .7rem;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.05);
  color: rgba(255,255,255,.6);
  font-size: .82rem;
  cursor: pointer;
  transition: all .2s;
}
.cat-pill.active {
  background: rgba(124, 58, 237, .3);
  border-color: #7c3aed;
  color: #fff;
}
.cat-pill:hover { border-color: #a78bfa; }

.btn-start {
  width: 100%;
  padding: 1rem;
  margin-top: 1rem;
  border: none;
  border-radius: 14px;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, #7c3aed, #6366f1);
  color: #fff;
  transition: transform .15s;
}
.btn-start:hover { transform: scale(1.02); }
.btn-start:active { transform: scale(.98); }

/* ── Loading ───────────────────────────────────────── */

.loading-box {
  text-align: center;
  padding: 3rem 0;
}
.loading-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255,255,255,.15);
  border-top-color: #a78bfa;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto 1.5rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

.round-badge {
  display: inline-block;
  background: rgba(255,255,255,.1);
  border-radius: 8px;
  padding: .3rem .8rem;
  margin-top: .8rem;
  font-size: .9rem;
}

/* ── Question / Answering ──────────────────────────── */

.question-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .5rem 0;
}
.q-round {
  font-size: .9rem;
  color: rgba(255,255,255,.5);
  font-weight: 600;
}
.q-timer {
  font-size: 2rem;
  font-weight: 900;
  color: #60a5fa;
  min-width: 50px;
  text-align: center;
  transition: color .3s;
}
.q-timer.urgent {
  color: #ef4444;
  animation: pulse .5s infinite alternate;
}
@keyframes pulse { from { opacity: 1; } to { opacity: .5; } }

.q-cat {
  font-size: .9rem;
  color: rgba(255,255,255,.6);
}

.question-card {
  width: 100%;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 18px;
  padding: 1.5rem;
}

.question-text {
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  margin-bottom: 1.5rem;
}

.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .8rem;
}

.option-btn {
  padding: 1rem;
  border: 2px solid transparent;
  border-radius: 14px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .3rem;
  text-align: center;
  transition: transform .15s, opacity .15s, border-color .2s;
  color: #fff;
  position: relative;
}
.option-btn:hover:not(.disabled) { transform: scale(1.03); }
.option-btn:active:not(.disabled) { transform: scale(.97); }

.opt-a { background: rgba(231, 76, 60, .7); }
.opt-b { background: rgba(52, 152, 219, .7); }
.opt-c { background: rgba(243, 156, 18, .7); }
.opt-d { background: rgba(46, 204, 113, .7); }

.opt-letter {
  font-size: 1.2rem;
  font-weight: 900;
  opacity: .7;
}
.opt-text {
  font-size: .95rem;
  line-height: 1.3;
}

.option-btn.selected {
  border-color: #fff;
  box-shadow: 0 0 15px rgba(255,255,255,.3);
}
.option-btn.disabled {
  cursor: default;
  opacity: .7;
}
.option-btn.correct {
  border-color: #22c55e;
  box-shadow: 0 0 20px rgba(34, 197, 94, .4);
  opacity: 1 !important;
}
.option-btn.wrong.mine {
  border-color: #ef4444;
  box-shadow: 0 0 15px rgba(239, 68, 68, .3);
}
.option-btn.wrong:not(.mine) {
  opacity: .4;
}

.opt-check {
  position: absolute;
  top: .4rem;
  right: .6rem;
  font-size: 1.5rem;
  color: #22c55e;
}

.answered-bar {
  font-size: .9rem;
  color: rgba(255,255,255,.5);
  padding: .5rem 0;
}

/* ── Reveal ────────────────────────────────────────── */

.fact-box {
  width: 100%;
  background: rgba(167, 139, 250, .12);
  border: 1px solid rgba(167, 139, 250, .3);
  border-radius: 12px;
  padding: 1rem 1.2rem;
  font-size: .95rem;
  line-height: 1.5;
}

.round-results {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.rr-line {
  display: flex;
  justify-content: space-between;
  padding: .5rem .8rem;
  border-radius: 8px;
  font-size: .9rem;
}
.rr-correct { background: rgba(34, 197, 94, .12); color: #86efac; }
.rr-wrong { background: rgba(239, 68, 68, .08); color: #fca5a5; }

/* ── Scoreboard ────────────────────────────────────── */

.score-title {
  font-size: 1.5rem;
  font-weight: 800;
  text-align: center;
  color: rgba(255,255,255,.8);
}

.scoreboard, .final-scoreboard {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.sb-row {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .7rem 1rem;
  background: rgba(255,255,255,.06);
  border-radius: 10px;
  font-size: 1rem;
}
.sb-row.sb-me {
  background: rgba(124, 58, 237, .2);
  border: 1px solid rgba(124, 58, 237, .3);
}
.sb-rank { min-width: 2rem; text-align: center; font-size: 1.2rem; }
.sb-name { flex: 1; font-weight: 600; }
.sb-streak { font-size: .85rem; }
.sb-score { font-weight: 800; font-size: 1.1rem; color: #a78bfa; }
.sb-stats { font-size: .82rem; color: rgba(255,255,255,.5); }

.score-next {
  text-align: center;
  font-size: .9rem;
  color: rgba(255,255,255,.4);
  padding: .5rem;
}

/* ── Game Over ─────────────────────────────────────── */

.gameover-box {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
}
.gameover-icon { font-size: 4rem; }
.gameover-box h1 {
  font-size: 2rem;
  font-weight: 900;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.winner-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fbbf24;
}

.btn-back {
  display: inline-block;
  margin-top: .5rem;
  padding: .7rem 1.5rem;
  border-radius: 10px;
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.6);
  text-decoration: none;
  font-size: .95rem;
  transition: background .2s;
}
.btn-back:hover { background: rgba(255,255,255,.12); }

/* ── Responsive ────────────────────────────────────── */

@media (max-width: 420px) {
  .options-grid {
    grid-template-columns: 1fr;
  }
  .question-text { font-size: 1.05rem; }
  .option-btn { padding: .8rem; }
}
