/* ═══════════════════════════════════════════════════
   TRIVIAL PURSUIT ∞
   Palette: Deep navy + vivid category colors + ivory
   Display: Playfair Display · Body: DM Sans
═══════════════════════════════════════════════════ */

:root {
  --navy:      #0d0d1a;
  --navy2:     #13132a;
  --navy3:     #1c1c38;
  --surface:   #21213f;
  --ivory:     #f5f0e8;
  --ivory-dim: #c9c2b4;
  --gold:      #f0c040;
  --gold-dim:  #f0c04033;

  /* Colores de categorías */
  --c0: #e74c3c;   /* Historia / Geografía — rojo */
  --c1: #3498db;   /* Ciencia Naturaleza  — azul */
  --c2: #9b59b6;   /* Arte / Literatura   — violeta */
  --c3: #e67e22;   /* Entretenimiento     — naranja */
  --c4: #2ecc71;   /* Deporte / Ocio      — verde */
  --c5: #1abc9c;   /* Ciencia Tecnología  — turquesa */

  --radius:    12px;
  --radius-lg: 20px;
  --shadow:    0 8px 40px rgba(0,0,0,0.5);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--navy);
  color: var(--ivory);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background .3s, color .3s;
}

/* ══════════ MODO DÍA (LIGHT) ══════════ */
body.theme-light {
  --navy:      #f4f1ea;
  --navy2:     #ffffff;
  --navy3:     #ece7da;
  --surface:   #ffffff;
  --ivory:     #1c1c2e;
  --ivory-dim: #5c5a6e;
  --gold:      #c9871f;
  --gold-dim:  #c9871f33;
  --shadow:    0 8px 32px rgba(30,20,10,0.12);
}
body.theme-light .wheel-deco { opacity: .10; }
body.theme-light .logo-title { text-shadow: 0 4px 24px rgba(201,135,31,.18); }
body.theme-light .game-header { background: rgba(244,241,234,.92); }
body.theme-light .toast { box-shadow: 0 8px 32px rgba(30,20,10,.18); }

/* ── TOGGLE DÍA / NOCHE ── */
.theme-toggle {
  position: fixed; bottom: 16px; right: 16px; z-index: 1000;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--navy3); border: 1px solid rgba(255,255,255,.12);
  color: var(--ivory); font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform .2s, background .2s;
  box-shadow: var(--shadow);
}
.theme-toggle:hover { transform: scale(1.08) rotate(15deg); }

/* ── SCREENS ── */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }
#screen-home { align-items: center; justify-content: flex-start; overflow-y: auto; }
#screen-win  { align-items: center; justify-content: center; }

/* ══════════ HOME SCREEN ══════════ */
.home-bg {
  position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0;
}
.wheel-deco {
  position: absolute; right: -120px; top: 50%;
  transform: translateY(-50%);
  width: 500px; opacity: .18;
}
.big-wheel { width: 100%; animation: slowspin 40s linear infinite; }
@keyframes slowspin { to { transform: rotate(360deg); } }

.home-content {
  position: relative; z-index: 1;
  width: 100%; max-width: 860px;
  margin: 0 auto; padding: 48px 24px 80px;
  display: flex; flex-direction: column; gap: 40px;
}

/* Logo */
.logo-block { text-align: center; }
.logo-eyebrow {
  font-family: 'DM Mono', monospace;
  font-size: .78rem; letter-spacing: .18em;
  text-transform: uppercase; color: var(--gold);
  margin-bottom: 12px;
}
.logo-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(3.5rem, 10vw, 7rem);
  font-weight: 900; line-height: .95;
  color: var(--ivory);
  text-shadow: 0 4px 32px rgba(240,192,64,.25);
}
.logo-title em { font-style: italic; color: var(--gold); }
.logo-sub {
  margin-top: 14px;
  font-size: .9rem; color: var(--ivory-dim);
  letter-spacing: .04em;
}

/* Category legend */
.category-legend {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
}
.cat-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--navy3); border: 1px solid rgba(255,255,255,.08);
  border-radius: 20px; padding: 5px 14px;
  font-size: .8rem; font-weight: 500; color: var(--ivory-dim);
}
.cat-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.cat-pill[data-cat="0"] .cat-dot { background: var(--c0); }
.cat-pill[data-cat="1"] .cat-dot { background: var(--c1); }
.cat-pill[data-cat="2"] .cat-dot { background: var(--c2); }
.cat-pill[data-cat="3"] .cat-dot { background: var(--c3); }
.cat-pill[data-cat="4"] .cat-dot { background: var(--c4); }
.cat-pill[data-cat="5"] .cat-dot { background: var(--c5); }

/* Mode cards */
.home-modes {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}
@media(max-width:620px){ .home-modes { grid-template-columns: 1fr; } }

.mode-card {
  background: var(--navy3);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color .2s, transform .15s;
}
.mode-card:hover { border-color: var(--gold); transform: translateY(-3px); }
.mode-icon { font-size: 2rem; }
.mode-card h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem; font-weight: 700;
}
.mode-card p { font-size: .88rem; color: var(--ivory-dim); line-height: 1.5; }

.player-inputs { display: flex; flex-direction: column; gap: 8px; }
.player-input {
  background: var(--navy2); border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px; padding: 9px 14px;
  color: var(--ivory); font-family: 'DM Sans', sans-serif; font-size: .9rem;
  outline: none; transition: border-color .18s;
}
.player-input:focus { border-color: var(--gold); }

.player-count-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.count-btn {
  cursor: pointer; width: 30px; height: 30px;
  border: 1px solid rgba(255,255,255,.15); border-radius: 50%;
  background: transparent; color: var(--ivory-dim);
  font-family: 'DM Sans', sans-serif; font-size: .85rem; font-weight: 700;
  transition: all .18s;
}
.count-btn:hover { border-color: var(--ivory-dim); color: var(--ivory); }
.count-btn.active-count { background: var(--gold); border-color: var(--gold); color: var(--navy); }

/* Difficulty */
.difficulty-row {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  flex-wrap: wrap;
}
.diff-label { font-size: .85rem; color: var(--ivory-dim); }
.diff-btn {
  cursor: pointer; padding: 6px 18px;
  border: 1px solid rgba(255,255,255,.15); border-radius: 20px;
  font-size: .85rem; color: var(--ivory-dim);
  transition: all .18s;
  user-select: none;
}
.diff-btn input { display: none; }
.diff-btn.active-diff, .diff-btn:has(input:checked) {
  background: var(--gold); border-color: var(--gold);
  color: var(--navy); font-weight: 700;
}
.diff-btn:hover:not(.active-diff) { border-color: var(--ivory-dim); color: var(--ivory); }

/* Buttons */
.btn-primary {
  background: var(--gold); color: var(--navy);
  border: none; border-radius: 10px;
  padding: 12px 28px; margin-top: 6px;
  font-family: 'DM Sans', sans-serif; font-size: .95rem; font-weight: 700;
  cursor: pointer; transition: background .18s, transform .12s;
  width: 100%;
}
.btn-primary:hover { background: #f5ce50; transform: translateY(-1px); }
.btn-big { padding: 16px 48px; font-size: 1.1rem; width: auto; }

/* ══════════ GAME SCREEN ══════════ */
#screen-game { background: var(--navy); }

.game-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  background: rgba(13,13,26,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255,255,255,.07);
  gap: 12px;
}
.btn-back {
  background: none; border: 1px solid rgba(255,255,255,.15);
  color: var(--ivory-dim); border-radius: 8px;
  padding: 7px 14px; font-size: .82rem; cursor: pointer;
  transition: all .15s; white-space: nowrap;
}
.btn-back:hover { border-color: var(--ivory); color: var(--ivory); }
.game-meta { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.player-tag {
  font-family: 'Playfair Display', serif;
  font-size: 1rem; font-weight: 700; color: var(--gold);
}
.q-counter { font-size: .75rem; color: var(--ivory-dim); font-family: 'DM Mono', monospace; }

.score-display {
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap; justify-content: flex-end;
}
.player-score {
  display: flex; flex-direction: column; align-items: center;
  font-size: .72rem; color: var(--ivory-dim);
  gap: 2px;
}
.player-score .score-name { font-weight: 600; font-size: .78rem; }

/* ── WEDGE BOARD ── */
.wedge-board {
  display: flex; justify-content: center; gap: 24px; flex-wrap: wrap;
  padding: 16px 20px 8px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.player-wedges { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.player-wedges-name {
  font-size: .72rem; font-weight: 600; color: var(--ivory-dim);
  text-transform: uppercase; letter-spacing: .06em;
}
.wedges-row { display: flex; gap: 6px; }
.wedge {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; transition: all .3s;
  background: rgba(255,255,255,.05);
}
.wedge.earned {
  border-color: currentColor;
  box-shadow: 0 0 8px currentColor;
}
.wedge[data-cat="0"] { color: var(--c0); }
.wedge[data-cat="1"] { color: var(--c1); }
.wedge[data-cat="2"] { color: var(--c2); }
.wedge[data-cat="3"] { color: var(--c3); }
.wedge[data-cat="4"] { color: var(--c4); }
.wedge[data-cat="5"] { color: var(--c5); }
.wedge.earned[data-cat="0"] { background: var(--c0); color: #fff; }
.wedge.earned[data-cat="1"] { background: var(--c1); color: #fff; }
.wedge.earned[data-cat="2"] { background: var(--c2); color: #fff; }
.wedge.earned[data-cat="3"] { background: var(--c3); color: #fff; }
.wedge.earned[data-cat="4"] { background: var(--c4); color: #fff; }
.wedge.earned[data-cat="5"] { background: var(--c5); color: #fff; }

/* ── QUESTION ZONE ── */
.question-zone {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start;
  padding: 24px 20px 16px;
  max-width: 720px; margin: 0 auto; width: 100%;
  position: relative;
}

/* Ilustración decorativa de tablero (estilo Trivial Pursuit) */
.qz-board-deco {
  position: absolute; top: 50%; width: 190px; height: 190px;
  transform: translateY(-50%); opacity: .16; z-index: 0;
  pointer-events: none; animation: slowspin 50s linear infinite;
}
.qz-board-left  { left: -130px; }
.qz-board-right { right: -130px; animation-direction: reverse; }
.question-card, .loading-card, .dice-area { position: relative; z-index: 1; }
@media(max-width: 980px) { .qz-board-deco { display: none; } }

/* Loading card */
.loading-card {
  display: flex; flex-direction: column; align-items: center;
  gap: 20px; padding: 60px 20px;
  color: var(--ivory-dim);
}
.spinner {
  width: 48px; height: 48px;
  border: 3px solid rgba(240,192,64,.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: .9rem; letter-spacing: .03em; }

/* Question card */
.question-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  animation: cardIn .3s ease;
}
@keyframes cardIn { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:none; } }

.question-cat-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
}
.cat-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 14px; border-radius: 20px;
  font-size: .78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
}
.q-difficulty {
  font-family: 'DM Mono', monospace;
  font-size: .72rem; color: var(--ivory-dim);
  text-transform: uppercase; letter-spacing: .08em;
}

.question-text {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.15rem, 3vw, 1.5rem);
  font-weight: 700; line-height: 1.45;
  padding: 20px 24px 24px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

/* Options */
.options-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; padding: 20px 20px 0;
}
@media(max-width:500px){ .options-grid { grid-template-columns: 1fr; } }

.option-btn {
  background: var(--navy3);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--ivory); text-align: left;
  font-family: 'DM Sans', sans-serif; font-size: .9rem; line-height: 1.4;
  cursor: pointer; transition: all .18s;
  display: flex; gap: 10px; align-items: flex-start;
}
.option-btn:hover:not(:disabled) {
  border-color: var(--gold); background: rgba(240,192,64,.08);
}
.option-letter {
  font-family: 'DM Mono', monospace;
  font-size: .78rem; font-weight: 700;
  color: var(--gold); flex-shrink: 0;
  margin-top: 1px;
}
.option-btn.correct {
  background: rgba(46,204,113,.15);
  border-color: #2ecc71; color: #2ecc71;
}
.option-btn.correct .option-letter { color: #2ecc71; }
.option-btn.wrong {
  background: rgba(231,76,60,.15);
  border-color: #e74c3c; color: #e74c3c;
  text-decoration: line-through;
}
.option-btn.wrong .option-letter { color: #e74c3c; }
.option-btn:disabled { cursor: default; }

/* Feedback */
.feedback-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 20px; gap: 12px; flex-wrap: wrap;
}
.feedback-inner {
  display: flex; align-items: center; gap: 8px;
  font-size: .9rem; font-weight: 600;
}
.btn-next {
  background: var(--gold); color: var(--navy);
  border: none; border-radius: 8px;
  padding: 10px 24px;
  font-family: 'DM Sans', sans-serif; font-weight: 700; font-size: .9rem;
  cursor: pointer; transition: background .15s;
  white-space: nowrap;
}
.btn-next:hover { background: #f5ce50; }

/* ── DICE AREA ── */
.dice-area {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  padding: 20px; border-top: 1px solid rgba(255,255,255,.07);
}
.dice-label { font-size: .85rem; color: var(--ivory-dim); }
.dice {
  font-size: 3.5rem; cursor: pointer;
  transition: transform .15s;
  animation: dicebob 2s ease-in-out infinite;
}
@keyframes dicebob {
  0%,100% { transform: translateY(0) rotate(0deg); }
  50%      { transform: translateY(-6px) rotate(10deg); }
}
.dice:hover { transform: scale(1.2); }
.dice.rolling { animation: diceroll .5s ease; }
@keyframes diceroll {
  0%   { transform: rotate(0); }
  25%  { transform: rotate(90deg) scale(1.2); }
  50%  { transform: rotate(180deg) scale(.9); }
  75%  { transform: rotate(270deg) scale(1.1); }
  100% { transform: rotate(360deg) scale(1); }
}

.cat-chooser { text-align: center; }
.cat-chooser p { font-size: .85rem; color: var(--ivory-dim); margin-bottom: 10px; }
.cat-btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.cat-btn {
  border: none; border-radius: 8px;
  padding: 8px 16px; font-family: 'DM Sans', sans-serif;
  font-size: .82rem; font-weight: 700;
  cursor: pointer; color: #fff;
  transition: transform .15s, opacity .15s;
}
.cat-btn:hover { transform: translateY(-2px); opacity: .9; }
.cat-btn[data-cat="0"] { background: var(--c0); }
.cat-btn[data-cat="1"] { background: var(--c1); }
.cat-btn[data-cat="2"] { background: var(--c2); }
.cat-btn[data-cat="3"] { background: var(--c3); }
.cat-btn[data-cat="4"] { background: var(--c4); }
.cat-btn[data-cat="5"] { background: var(--c5); }

/* ══════════ WIN SCREEN ══════════ */
#screen-win {
  background: radial-gradient(ellipse at center, #1c1c38 0%, var(--navy) 70%);
}
.win-content {
  display: flex; flex-direction: column; align-items: center;
  gap: 20px; text-align: center; padding: 40px 24px; max-width: 520px;
}
.win-trophy { font-size: 6rem; animation: trophyPop .6s cubic-bezier(.34,1.56,.64,1); }
@keyframes trophyPop { from { transform: scale(0); opacity:0; } to { transform: scale(1); opacity:1; } }
.win-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(2rem, 7vw, 3.5rem);
  font-weight: 900; color: var(--gold);
}
.win-sub { font-size: 1.05rem; color: var(--ivory-dim); line-height: 1.6; }
.win-stats {
  display: flex; gap: 28px; flex-wrap: wrap; justify-content: center;
}
.win-stat { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.win-stat-val {
  font-family: 'DM Mono', monospace;
  font-size: 2.2rem; font-weight: 700; color: var(--ivory);
}
.win-stat-lbl { font-size: .75rem; color: var(--ivory-dim); text-transform: uppercase; letter-spacing: .06em; }

/* ══════════ TOAST ══════════ */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(10px);
  background: var(--surface); border: 1px solid rgba(255,255,255,.12);
  color: var(--ivory); padding: 12px 24px; border-radius: 10px;
  font-size: .88rem; font-weight: 500;
  opacity: 0; pointer-events: none;
  transition: opacity .22s, transform .22s;
  z-index: 999; white-space: nowrap;
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.correct-t { border-left: 4px solid #2ecc71; }
.toast.wrong-t   { border-left: 4px solid #e74c3c; }

/* ══════════ RESPONSIVE ══════════ */
@media(max-width:480px){
  .game-header { flex-wrap: wrap; gap: 8px; }
  .score-display { width: 100%; justify-content: center; }
  .question-text { padding: 16px; font-size: 1.05rem; }
  .options-grid { padding: 12px 12px 0; gap: 8px; }
  .option-btn { padding: 11px 12px; }
}

/* category bar background colors per data attr */
.question-card[data-cat="0"] .question-cat-bar { background: rgba(231,76,60,.12); }
.question-card[data-cat="1"] .question-cat-bar { background: rgba(52,152,219,.12); }
.question-card[data-cat="2"] .question-cat-bar { background: rgba(155,89,182,.12); }
.question-card[data-cat="3"] .question-cat-bar { background: rgba(230,126,34,.12); }
.question-card[data-cat="4"] .question-cat-bar { background: rgba(46,204,113,.12); }
.question-card[data-cat="5"] .question-cat-bar { background: rgba(26,188,156,.12); }
