/* ==========================================================================
   ¿Quién conoce más a Celine? — estilos compartidos (jugador + host)
   Mobile-first, alto contraste para leer al sol, tema lila/rosa.
   ========================================================================== */

:root {
  --bg-1: #1e0838;
  --bg-2: #3b0f5c;
  --bg-3: #5b1270;
  --card: rgba(255, 255, 255, 0.1);
  --card-strong: rgba(255, 255, 255, 0.16);
  --line: rgba(255, 255, 255, 0.22);
  --text: #ffffff;
  --muted: #e9d5ff;
  --lila: #c4b5fd;
  --lila-strong: #a855f7;
  --rosa: #ff5fae;
  --rosa-strong: #ec4899;
  --gold: #fcd34d;
  --ok: #22c55e;
  --bad: #ef4444;

  /* Colores de las opciones: blanco sobre ellos ≥ 4.5:1 de contraste */
  --a0: #d6186f; /* rosa    ▲ */
  --a1: #6d28d9; /* violeta ◆ */
  --a2: #0e7490; /* turquesa ● */
  --a3: #b45309; /* ámbar   ■ */

  --radius: 18px;
  --shadow: 0 10px 30px rgba(10, 0, 30, 0.45);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background-color: var(--bg-1);
  background-image:
    radial-gradient(circle at 15% 10%, rgba(255, 95, 174, 0.35) 0, transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(168, 85, 247, 0.4) 0, transparent 45%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2) 55%, var(--bg-3));
  background-attachment: fixed;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

/* Globitos decorativos de fondo */
body::before, body::after {
  content: '';
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(2px);
  opacity: 0.35;
  animation: float 14s ease-in-out infinite;
  pointer-events: none;
}
body::before { width: 90px; height: 110px; left: 6%; bottom: 12%; background: var(--rosa); }
body::after { width: 70px; height: 86px; right: 8%; top: 18%; background: var(--lila-strong); animation-delay: -6s; }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-30px) rotate(4deg); } }

h1, h2, h3 { margin: 0; line-height: 1.15; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ----- Barra superior -------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: rgba(20, 4, 40, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { font-weight: 900; letter-spacing: 0.3px; white-space: nowrap; }
.topbar .brand b { color: var(--rosa); }
.topbar .spacer { flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--card-strong); font-weight: 800; font-size: 0.95rem;
  white-space: nowrap; max-width: 45vw; overflow: hidden; text-overflow: ellipsis;
}
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card);
  font-size: 1.3rem; cursor: pointer; flex: none;
}
.icon-btn:active { transform: scale(0.94); }

/* ----- Layout ---------------------------------------------------------- */
main { width: 100%; max-width: 640px; margin: 0 auto; padding: 18px 16px 40px; }
.screen { animation: enter 0.35s ease both; }
@keyframes enter { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.center { text-align: center; }
.stack > * + * { margin-top: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.hero-title { font-size: clamp(1.9rem, 7vw, 3rem); font-weight: 900; text-align: center; text-wrap: balance; }
.hero-title .accent { color: var(--rosa); }
.badge23 {
  display: inline-grid; place-items: center;
  width: 84px; height: 84px; border-radius: 50%;
  background: conic-gradient(var(--rosa), var(--lila-strong), var(--rosa));
  font-size: 2.2rem; font-weight: 900; box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.15), var(--shadow);
  animation: bob 3s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(-6px) rotate(4deg); } }

.muted { color: var(--muted); }
.big { font-size: 1.25rem; }

/* ----- Formularios ----------------------------------------------------- */
label { display: block; font-weight: 800; margin-bottom: 6px; }
input[type='text'], input[type='password'], input[inputmode='numeric'] {
  width: 100%; padding: 16px; font-size: 1.3rem; font-weight: 700;
  border-radius: 14px; border: 3px solid transparent;
  background: #fff; color: #1e0838;
  outline: none;
}
input:focus { border-color: var(--rosa); }
input.code-input { letter-spacing: 0.5em; text-align: center; font-size: 1.8rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 58px; padding: 14px 22px;
  border: 0; border-radius: 16px; cursor: pointer;
  font-size: 1.25rem; font-weight: 900; letter-spacing: 0.3px;
  color: #fff;
  background: linear-gradient(135deg, var(--rosa-strong), var(--lila-strong));
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.28), var(--shadow);
  transition: transform 0.08s, box-shadow 0.08s, opacity 0.2s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.28); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary { background: var(--card-strong); box-shadow: none; border: 1px solid var(--line); }
.btn.small { min-height: 44px; font-size: 1rem; width: auto; padding: 10px 16px; }

.error {
  min-height: 1.4em; margin-top: 10px; font-weight: 800; color: #fff;
  background: rgba(239, 68, 68, 0.85); border-radius: 10px; padding: 8px 12px;
}
.error:empty { display: none; }

/* ----- Diálogo (confirmaciones y avisos) ------------------------------- */
.btn.danger { background: linear-gradient(135deg, #f43f5e, #be123c); }
.dlg {
  width: min(420px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  padding: 0; border: 1px solid var(--line); border-radius: 24px;
  color: var(--text); background: linear-gradient(160deg, #3b0f5c, #24093f);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  animation: dlg-in 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.25) both;
}
.dlg::backdrop { background: rgba(12, 2, 26, 0.7); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fade 0.2s both; }
.dlg-body { padding: 28px 22px 22px; text-align: center; }
.dlg-icon {
  width: 72px; height: 72px; margin: -2px auto 14px; border-radius: 50%;
  display: grid; place-items: center; font-size: 2.2rem; font-weight: 900;
  background: conic-gradient(var(--rosa), var(--lila-strong), var(--rosa));
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.12);
}
.dlg.danger .dlg-icon { background: linear-gradient(135deg, #fb7185, #be123c); box-shadow: 0 0 0 6px rgba(244, 63, 94, 0.2); }
.dlg-title { font-size: 1.45rem; font-weight: 900; text-wrap: balance; overflow-wrap: anywhere; }
.dlg-text { margin: 10px 0 0; color: var(--muted); font-weight: 700; text-wrap: pretty; }
.dlg-actions { display: flex; gap: 10px; margin-top: 22px; }
.dlg-actions .btn { flex: 1; min-height: 52px; font-size: 1.1rem; padding: 12px 14px; }
.dlg-actions .btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
@media (max-width: 360px) { .dlg-actions { flex-direction: column-reverse; } }
@keyframes dlg-in { from { opacity: 0; transform: translateY(16px) scale(0.92); } }
@keyframes fade { from { opacity: 0; } }

/* ----- Estado de conexión --------------------------------------------- */
.conn {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%);
  z-index: 50; padding: 10px 16px; border-radius: 999px;
  background: #fef3c7; color: #78350f; font-weight: 800; box-shadow: var(--shadow);
}

/* ----- Pregunta -------------------------------------------------------- */
.q-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 800; color: var(--muted); }
.q-text { font-size: clamp(1.35rem, 5.5vw, 2rem); font-weight: 900; text-align: center; text-wrap: balance; margin: 10px 0 14px; }
.q-image {
  display: block; width: 100%; max-height: 22vh; object-fit: contain;
  border-radius: 14px; background: rgba(255, 255, 255, 0.08);
}

.timer {
  --p: 1;
  position: relative; display: grid; place-items: center;
  width: 64px; height: 64px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--rosa) calc(var(--p) * 360deg), rgba(255, 255, 255, 0.15) 0);
  font-weight: 900; font-size: 1.5rem;
}
.timer::before { content: ''; position: absolute; inset: 6px; border-radius: 50%; background: var(--bg-2); }
.timer span { position: relative; }
.timer.urgent { animation: pulse 0.5s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); } }

.bar { height: 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.15); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--rosa), var(--lila)); transform-origin: left; }

/* ----- Opciones -------------------------------------------------------- */
.answers { display: grid; grid-template-columns: 1fr; gap: 12px; }
.answers.n2 { grid-template-columns: 1fr; }
@media (min-width: 420px) { .answers.n3, .answers.n4 { grid-template-columns: 1fr 1fr; } }

.answer {
  position: relative; display: flex; align-items: center; gap: 14px;
  min-height: 84px; padding: 14px 16px; width: 100%;
  border: 0; border-radius: 16px; cursor: pointer; text-align: left;
  color: #fff; font-size: 1.3rem; font-weight: 900;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.3);
  transition: transform 0.1s, opacity 0.3s, filter 0.3s, box-shadow 0.1s;
  touch-action: manipulation;
}
.answer:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3); }
.answer .shape { font-size: 1.7rem; flex: none; width: 1.6em; text-align: center; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); }
.answer .label { flex: 1; overflow-wrap: anywhere; }
.answer .count { font-size: 1.1rem; background: rgba(0, 0, 0, 0.25); border-radius: 999px; padding: 2px 10px; }
.answer:disabled { cursor: default; }
.a0 { background: var(--a0); }
.a1 { background: var(--a1); }
.a2 { background: var(--a2); }
.a3 { background: var(--a3); }
.answer.dim { opacity: 0.35; filter: saturate(0.4); }
.answer.chosen { outline: 4px solid #fff; outline-offset: 3px; }
.answer.correct { outline: 5px solid var(--gold); outline-offset: 3px; animation: pop 0.5s ease; padding-right: 54px; }
.answer.correct::after { content: '✔'; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-size: 1.6rem; }
@keyframes pop { 40% { transform: scale(1.04); } }

/* ----- Resultado jugador ---------------------------------------------- */
.result-icon {
  width: 128px; height: 128px; margin: 0 auto; border-radius: 50%;
  display: grid; place-items: center; font-size: 4.2rem; font-weight: 900;
  animation: pop 0.6s ease;
}
.result-icon.ok { background: var(--ok); box-shadow: 0 0 0 10px rgba(34, 197, 94, 0.25); }
.result-icon.bad { background: var(--bad); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0.25); }
.result-icon.none { background: #64748b; box-shadow: 0 0 0 10px rgba(100, 116, 139, 0.25); }
.points { font-size: 2.6rem; font-weight: 900; color: var(--gold); }
.streak { display: inline-block; padding: 6px 14px; border-radius: 999px; background: rgba(252, 211, 77, 0.18); color: var(--gold); font-weight: 900; }

.stat-row { display: flex; gap: 10px; }
.stat { flex: 1; text-align: center; padding: 14px 8px; border-radius: 14px; background: var(--card-strong); }
.stat b { display: block; font-size: 1.7rem; }
.stat span { color: var(--muted); font-weight: 700; font-size: 0.9rem; }

/* Puntitos de "esperando" */
.dots span { display: inline-block; width: 12px; height: 12px; margin: 0 4px; border-radius: 50%; background: var(--rosa); animation: dot 1.2s infinite ease-in-out; }
.dots span:nth-child(2) { animation-delay: 0.15s; background: var(--lila); }
.dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 0%, 80%, 100% { transform: scale(0.5); opacity: 0.5; } 40% { transform: scale(1); opacity: 1; } }

/* ----- Podio ----------------------------------------------------------- */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 10px; margin: 20px 0 10px; }
.podium .step { flex: 1; max-width: 200px; text-align: center; }
.podium .name { font-weight: 900; font-size: 1.05rem; margin-bottom: 6px; overflow-wrap: anywhere; }
.podium .score { color: var(--muted); font-weight: 800; font-size: 0.9rem; margin-bottom: 6px; }
.podium .block {
  display: grid; place-items: start center; padding-top: 10px;
  border-radius: 14px 14px 4px 4px; font-size: 2rem; font-weight: 900;
  height: 0; transition: height 1.2s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  box-shadow: var(--shadow);
}
.podium .p1 .block { background: linear-gradient(180deg, #fde68a, #f59e0b); color: #78350f; }
.podium .p2 .block { background: linear-gradient(180deg, #f5f3ff, #a78bfa); color: #3b0764; }
.podium .p3 .block { background: linear-gradient(180deg, #fbcfe8, #ec4899); color: #500724; }
.podium .crown { font-size: 2.2rem; animation: bob 2.4s ease-in-out infinite; }

.final-msg {
  font-size: clamp(1.2rem, 4.5vw, 1.8rem); font-weight: 900; text-align: center; text-wrap: balance;
  background: linear-gradient(90deg, #fff, #fbcfe8, #fff); -webkit-background-clip: text; background-clip: text; color: transparent;
}

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 100; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
