:root {
  --accent: #39ff14;
  --accent-2: #00e5ff;
  --wrong: #ff1744;
  --text: #f5f7fa;
  --card-bg: rgba(255,255,255,0.06);
  --card-border: rgba(255,255,255,0.14);
}

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

[hidden] { display: none !important; }

html, body {
  height: 100%;
  background: #05070a;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--text);
  overflow: hidden;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

.phone {
  position: relative;
  width: min(430px, 100vw);
  height: min(932px, 100vh);
  overflow: hidden;
  background: #000000;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 60px rgba(0,0,0,0.6);
}

@media (max-width: 430px) {
  .phone { width: 100vw; height: 100vh; box-shadow: none; }
}

/* Paleta vívida por nivel de dificultad (fondo siempre negro, solo cambian los acentos) */
.phone[data-level="facil"]     { --accent:#39ff14; --accent-2:#00e5ff; }
.phone[data-level="medio"]     { --accent:#00e5ff; --accent-2:#2979ff; }
.phone[data-level="avanzado"]  { --accent:#d500f9; --accent-2:#651fff; }
.phone[data-level="dificil"]   { --accent:#ff9100; --accent-2:#ffea00; }
.phone[data-level="experto"]   { --accent:#ff1744; --accent-2:#ff4081; }

.glow {
  position: absolute;
  top: -25%; left: 50%;
  width: 160%; height: 65%;
  transform: translateX(-50%);
  background:
    radial-gradient(ellipse 55% 55% at 30% 20%, var(--accent) 0%, transparent 60%),
    radial-gradient(ellipse 55% 55% at 75% 15%, var(--accent-2) 0%, transparent 60%);
  opacity: 0.35;
  pointer-events: none;
  transition: background 0.8s ease;
  filter: blur(4px);
}

.topbar {
  padding: calc(env(safe-area-inset-top, 0px) + 28px) 20px 10px;
  display: flex;
  justify-content: center;
  z-index: 2;
}

.badge {
  font-size: 14px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--card-bg);
  border: 1px solid var(--accent);
  box-shadow: 0 0 16px color-mix(in srgb, var(--accent) 45%, transparent);
  backdrop-filter: blur(10px);
  letter-spacing: 0.3px;
  transition: all 0.4s ease;
}

/* ---- Idle ---- */
.idle {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  z-index: 2;
  opacity: 0.85;
}
.idle-logo { font-size: 56px; margin-bottom: 6px; filter: drop-shadow(0 0 18px var(--accent)); }
.idle h1 {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.idle p { font-size: 14px; opacity: 0.7; }

/* ---- Pregunta ---- */
.question-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 18px 22px 30px;
  gap: 18px;
  z-index: 2;
}

.progress-bar {
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transform-origin: left;
  transition: width linear;
}

.question {
  font-size: clamp(22px, 6vw, 30px);
  font-weight: 800;
  line-height: 1.3;
  text-shadow: 0 2px 12px rgba(0,0,0,0.4);
  animation: slideFadeIn 0.5s ease both;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 16px;
  border-radius: 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(10px);
  font-size: 16px;
  font-weight: 600;
  animation: slideFadeIn 0.5s ease both;
  transition: transform 0.3s ease, background 0.4s ease, border-color 0.4s ease, opacity 0.4s ease;
}
.option:nth-child(1) { animation-delay: 0.05s; }
.option:nth-child(2) { animation-delay: 0.12s; }
.option:nth-child(3) { animation-delay: 0.19s; }
.option:nth-child(4) { animation-delay: 0.26s; }

.option .letter {
  width: 30px; height: 30px;
  min-width: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  font-size: 13px;
  font-weight: 800;
}

.option.correct {
  background: color-mix(in srgb, var(--accent) 35%, transparent);
  border-color: var(--accent);
  transform: scale(1.03);
  box-shadow: 0 0 24px color-mix(in srgb, var(--accent) 55%, transparent);
  animation: pop 0.4s ease;
}
.option.correct .letter {
  background: var(--accent);
  color: #050505;
}
.option.correct .text::after {
  content: ' ✓';
}
.option.dim { opacity: 0.35; transform: scale(0.98); }

@keyframes slideFadeIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1.03); }
}

/* ---- Congrats ---- */
.congrats {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  z-index: 2;
  animation: slideFadeIn 0.5s ease both;
}
.congrats-emoji { font-size: 72px; animation: pop 0.6s ease; filter: drop-shadow(0 0 20px var(--accent)); }
.congrats h2 {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.congrats p { opacity: 0.75; }

/* ---- Controles ---- */
.controls {
  position: absolute;
  bottom: max(16px, env(safe-area-inset-bottom));
  right: 16px;
  display: flex;
  gap: 10px;
  z-index: 3;
}
.ctrl-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: rgba(0,0,0,0.35);
  color: var(--text);
  font-size: 15px;
  backdrop-filter: blur(8px);
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.ctrl-btn:hover { opacity: 1; transform: scale(1.08); }
.ctrl-btn:disabled { opacity: 0.2; cursor: default; transform: none; }

/* ---- PIN modal ---- */
.pin-modal {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.pin-box {
  width: 80%;
  max-width: 280px;
  background: #12151c;
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 26px 22px;
  text-align: center;
  animation: pop 0.3s ease;
}
.pin-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; }
#pinInput {
  width: 100%;
  font-size: 24px;
  letter-spacing: 10px;
  text-align: center;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  outline: none;
}
#pinInput:focus { border-color: var(--accent); }
#levelSelect {
  width: 100%;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  text-align-last: center;
  padding: 12px 10px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  outline: none;
  appearance: none;
}
#levelSelect:focus { border-color: var(--accent); }
#levelSelect option { background: #12151c; color: var(--text); }
.pin-error { color: var(--wrong); font-size: 12px; margin-top: 8px; }
.pin-actions { display: flex; gap: 10px; margin-top: 18px; }
.pin-btn {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  border: none;
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
}
.pin-btn.primary { background: var(--accent); color: #050505; }
.pin-btn.secondary { background: rgba(255,255,255,0.08); color: var(--text); }

.shake { animation: shake 0.4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}
