/* LEVEL UP · arena oscura de juego: rojo ACIEM como energía, oro para premios, colores de rango */
:root {
  --bg: #0b0b0d;
  --panel: #16161b;
  --panel-2: #1f1f26;
  --line: #2c2c35;
  --fg: #ffffff;
  --mut: #a6a6b2;
  --rojo: #c8102e;
  --rojo-neon: #ff3b4e;
  --oro: #ffc23d;
  --ok: #21d47e;
  --mal: #ff3b4e;
  --op-a: #e8213b;
  --op-b: #2f7bff;
  --op-c: #f5a400;
  --op-d: #13b86a;
  --display: 'Poppins', system-ui, sans-serif;
  --mono: 'Space Mono', ui-monospace, monospace;
  --r: 14px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--display);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
.bg-grid {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(circle at 85% -10%, rgba(200, 16, 46, .45), transparent 55%),
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 44px 44px,
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 44px 44px;
  opacity: .5;
}
[hidden] { display: none !important; }
.mono { font-family: var(--mono); letter-spacing: .1em; text-transform: uppercase; font-size: .75rem; }
.rojo { color: var(--rojo-neon); }
.oro { color: var(--oro); }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--oro); outline-offset: 2px; }

.pantalla {
  min-height: 100%;
  padding: calc(env(safe-area-inset-top) + 12px) max(16px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 84px) max(16px, env(safe-area-inset-left));
}
.contenedor { max-width: 520px; margin: 0 auto; padding-block: 16px; }

/* Registro */
.logo { font-size: clamp(4.2rem, 24vw, 7rem); line-height: .82; font-weight: 900; letter-spacing: -.04em; margin: .2em 0 .25em; }
.logo span { color: var(--rojo); text-shadow: 0 0 40px rgba(255, 59, 78, .45); }
.lead { font-size: 1.15rem; font-weight: 600; line-height: 1.35; margin: 0 0 20px; }
.tarjeta { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; font-weight: 600; font-size: .92rem; }
.form small { color: var(--mut); font-weight: 500; }
.form input:not([type=checkbox]):not([type=radio]), .form select, textarea {
  width: 100%; padding: 13px 14px; border-radius: 10px; border: 2px solid var(--line);
  background: var(--panel-2); color: var(--fg); font: 600 1rem var(--display);
}
.form input:focus, .form select:focus, textarea:focus { border-color: var(--rojo-neon); outline: none; }
.fila { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fila > * { min-width: 0; }
.chips { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips legend { font-weight: 600; font-size: .92rem; margin-bottom: 6px; }
.chips label { display: block; }
.chips input { position: absolute; opacity: 0; }
.chips span { display: inline-block; padding: 9px 14px; border-radius: 99px; border: 2px solid var(--line); font-weight: 700; font-size: .9rem; }
.chips input:checked + span { background: var(--rojo); border-color: var(--rojo); }
.chips input:focus-visible + span { outline: 3px solid var(--oro); }
.check { grid-template-columns: auto 1fr !important; align-items: start; font-weight: 500 !important; font-size: .82rem !important; color: var(--mut); }
.check input { width: 22px; height: 22px; accent-color: var(--rojo); margin-top: 2px; }
.nota { color: var(--mut); font-size: .8rem; margin: 0; text-align: center; }

.btn-mega {
  border: 0; border-radius: 12px; padding: 18px; font-weight: 900; font-size: 1.3rem; letter-spacing: .02em;
  background: linear-gradient(180deg, var(--rojo-neon), var(--rojo)); box-shadow: 0 6px 0 #7d0a1d, 0 10px 30px rgba(200, 16, 46, .45);
  transition: transform .1s, box-shadow .1s;
}
.btn-mega:active { transform: translateY(5px); box-shadow: 0 1px 0 #7d0a1d; }
.btn-mega:disabled { filter: grayscale(.8); opacity: .6; }
.btn { border: 2px solid var(--line); background: var(--panel-2); border-radius: 12px; padding: 13px 18px; font-weight: 800; }

/* HUD */
.hud {
  position: sticky; top: env(safe-area-inset-top); z-index: 5; max-width: 520px; margin: 0 auto 14px;
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 14px 0;
  background: rgba(22, 22, 27, .92); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden;
}
.hud-jugador { display: flex; align-items: center; gap: 8px; min-width: 0; }
.alias { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rango { font: 700 .7rem var(--mono); text-transform: uppercase; letter-spacing: .08em; padding: 3px 8px; border-radius: 6px; background: var(--rc, var(--ok)); color: #0b0b0d; white-space: nowrap; }
.hud-xp { grid-row: span 2; text-align: right; align-self: center; }
.xp { font-size: 2.2rem; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1; display: inline-block; }
.hud-xp .mono { color: var(--oro); margin-left: 4px; }
.hud-meta { display: flex; gap: 10px; align-items: center; color: var(--mut); }
.racha { font-weight: 800; color: var(--oro); }
.barra-rango { grid-column: 1 / -1; height: 6px; margin: 8px -14px 0; background: var(--panel-2); }
.barra-rango i { display: block; height: 100%; background: var(--rc, var(--ok)); box-shadow: 0 0 12px var(--rc, var(--ok)); transform-origin: left; transform: scaleX(0); transition: transform .8s var(--ease); }
.pop { animation: pop .5s var(--ease); }
@keyframes pop { 40% { transform: scale(1.25); color: var(--oro); } }

/* Escenario */
.escenario { max-width: 520px; margin: 0 auto; display: grid; gap: 14px; }
.etiqueta { display: flex; justify-content: space-between; align-items: center; }
.etiqueta .mono { color: var(--rojo-neon); font-weight: 700; }
.x2 { font: 700 .75rem var(--mono); color: #111; background: var(--oro); padding: 3px 8px; border-radius: 6px; }
.enunciado { font-size: clamp(1.35rem, 6vw, 1.8rem); font-weight: 800; line-height: 1.2; margin: 0; text-wrap: balance; }

.reloj { height: 12px; border-radius: 99px; background: var(--panel-2); overflow: hidden; border: 1px solid var(--line); }
.reloj i { display: block; height: 100%; background: linear-gradient(90deg, var(--oro), var(--rojo-neon)); transform-origin: left; }
.reloj-num { font: 700 1rem var(--mono); text-align: right; }
.urgente .reloj-num { color: var(--rojo-neon); animation: latido .5s infinite alternate; }
@keyframes latido { to { transform: scale(1.2); } }

.opciones { display: grid; gap: 10px; }
.op {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 14px 16px;
  border: 0; border-radius: 12px; text-align: left; font-weight: 800; font-size: 1.05rem; background: var(--c);
  box-shadow: 0 5px 0 color-mix(in srgb, var(--c) 55%, #000); transition: transform .08s, opacity .2s, filter .2s;
}
.op:active { transform: translateY(4px); box-shadow: 0 1px 0 color-mix(in srgb, var(--c) 55%, #000); }
.op b { font: 700 .9rem var(--mono); width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: rgba(0, 0, 0, .25); flex: none; }
.op:nth-child(1) { --c: var(--op-a); } .op:nth-child(2) { --c: var(--op-b); }
.op:nth-child(3) { --c: var(--op-c); } .op:nth-child(4) { --c: var(--op-d); }
.opciones.fijada .op:not(.elegida) { opacity: .25; filter: grayscale(1); }
.op.elegida { outline: 4px solid #fff; }
.op.correcta { outline: 4px solid var(--ok); opacity: 1 !important; filter: none !important; }

.duelo { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: stretch; }
.duelo .op { min-height: 150px; justify-content: center; text-align: center; font-size: 1.2rem; }
.duelo .op:last-child { --c: var(--op-b); }
.duelo.fijada .op:not(.elegida) { opacity: .25; filter: grayscale(1); }
.vs { align-self: center; font-weight: 900; font-size: 1.6rem; color: var(--oro); text-shadow: 0 0 20px rgba(255, 194, 61, .6); }

.comodin { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border: 2px dashed var(--oro); border-radius: 12px; font-weight: 700; font-size: .9rem; }
.comodin button { border: 0; border-radius: 8px; padding: 8px 14px; font-weight: 900; background: var(--panel-2); color: var(--oro); }
.comodin.activo { background: rgba(255, 194, 61, .12); }
.comodin.activo button { background: var(--oro); color: #111; }

.dos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dos .op { justify-content: center; text-align: center; }
.dos .op:nth-child(1) { --c: var(--op-d); } .dos .op:nth-child(2) { --c: var(--op-a); }
.dos.fijada .op:not(.elegida) { opacity: .3; }
.slider { display: grid; gap: 8px; }
.slider output { font-size: 3rem; font-weight: 900; text-align: center; color: var(--oro); font-variant-numeric: tabular-nums; }
input[type=range] { width: 100%; accent-color: var(--rojo-neon); height: 34px; }

.monedas { font-size: 1.1rem; font-weight: 800; text-align: center; }
.monedas b { font-size: 2.4rem; color: var(--oro); display: block; font-variant-numeric: tabular-nums; }
.reparto { display: grid; gap: 8px; }
.item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.item span { font-weight: 700; font-size: .92rem; min-width: 0; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 40px; height: 40px; border-radius: 10px; border: 0; background: var(--panel-2); font-weight: 900; font-size: 1.2rem; }
.stepper output { width: 38px; text-align: center; font-weight: 900; color: var(--oro); font-variant-numeric: tabular-nums; }
.item.lleno { border-color: var(--oro); }

textarea { min-height: 110px; resize: vertical; }
.contador { text-align: right; color: var(--mut); font: .75rem var(--mono); }

.candidatas { display: grid; gap: 10px; }
.cand { text-align: left; border: 2px solid var(--line); background: var(--panel); border-radius: 12px; padding: 14px; font-weight: 700; }
.cand small { display: block; color: var(--mut); font: .72rem var(--mono); margin-top: 6px; }
.cand.elegida { border-color: var(--oro); background: rgba(255, 194, 61, .1); }

/* Estados */
.espera { text-align: center; padding: 28px 10px; display: grid; gap: 10px; justify-items: center; }
.espera h2 { margin: 0; font-size: 1.6rem; font-weight: 900; text-wrap: balance; }
.espera p { margin: 0; color: var(--mut); }
.radar { width: 74px; height: 74px; border-radius: 50%; border: 3px solid var(--rojo-neon); position: relative; }
.radar::after { content: ''; position: absolute; inset: -3px; border-radius: 50%; border: 3px solid var(--rojo-neon); animation: onda 1.6s infinite; }
@keyframes onda { to { transform: scale(1.8); opacity: 0; } }

.veredicto { text-align: center; padding: 22px 12px; border-radius: var(--r); background: var(--panel); border: 2px solid var(--line); }
.veredicto h2 { margin: 0; font-size: clamp(2.2rem, 12vw, 3.2rem); font-weight: 900; line-height: 1; }
.veredicto .gana { font-size: 1.8rem; font-weight: 900; color: var(--oro); margin-top: 8px; }
.veredicto p { color: var(--mut); margin: 8px 0 0; }
.veredicto.bien { border-color: var(--ok); box-shadow: 0 0 40px rgba(33, 212, 126, .25); }
.veredicto.bien h2 { color: var(--ok); }
.veredicto.mal { border-color: var(--mal); animation: sacudir .4s; }
.veredicto.mal h2 { color: var(--mal); }
@keyframes sacudir { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

.barras { display: grid; gap: 8px; }
.barra { position: relative; padding: 10px 12px; border-radius: 10px; background: var(--panel); overflow: hidden; font-weight: 700; font-size: .9rem; display: flex; justify-content: space-between; gap: 10px; }
.barra i { position: absolute; inset: 0; background: rgba(255, 59, 78, .28); z-index: 0; transform-origin: left; animation: crecer .9s var(--ease) both; }
.barra.top i { background: rgba(33, 212, 126, .35); }
.barra span, .barra b { position: relative; z-index: 1; }
@keyframes crecer { from { transform: scaleX(0); } }

.nube { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.nube span { padding: 6px 12px; border-radius: 99px; background: var(--panel-2); font-weight: 800; }

.ranking { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; counter-reset: pos; }
.ranking li { counter-increment: pos; display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; padding: 10px 12px; background: var(--panel); border-radius: 10px; border-left: 4px solid var(--rc, var(--line)); }
.ranking li::before { content: counter(pos); font: 700 1rem var(--mono); color: var(--mut); }
.ranking li:nth-child(1)::before { content: '🥇'; } .ranking li:nth-child(2)::before { content: '🥈'; } .ranking li:nth-child(3)::before { content: '🥉'; }
.ranking span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.ranking b { font-variant-numeric: tabular-nums; }
.ranking .yo { outline: 2px solid var(--oro); }
.mi-pos { text-align: center; font-weight: 800; }

.secreta { border: 2px solid var(--oro); background: linear-gradient(135deg, rgba(255, 194, 61, .12), transparent); border-radius: var(--r); padding: 16px; display: grid; gap: 10px; }
.secreta h3 { margin: 0; font-size: 1.2rem; font-weight: 900; }
.secreta p { margin: 0; color: var(--mut); font-size: .9rem; }
.candados { font-size: 1.6rem; letter-spacing: .15em; }
.secreta form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.secreta input { padding: 12px; border-radius: 10px; border: 2px solid var(--line); background: var(--panel-2); color: var(--fg); font: 700 1rem var(--display); min-width: 0; }
.secreta button { border: 0; border-radius: 10px; padding: 0 16px; font-weight: 900; background: var(--oro); color: #111; }
.mis-palabras { display: flex; flex-wrap: wrap; gap: 6px; }
.mis-palabras span { background: var(--oro); color: #111; border-radius: 6px; padding: 3px 8px; font-weight: 800; font-size: .8rem; }

/* Dock, hojas, avisos */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; gap: 8px; align-items: center; justify-content: center;
  padding: 10px max(16px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: linear-gradient(transparent, var(--bg) 35%);
}
.dock-btn { border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 10px 16px; font-weight: 800; font-size: .9rem; }
.dock-btn b { color: var(--oro); }
.conexion { color: var(--ok); font-size: .8rem; }
.conexion.caida { color: var(--mal); animation: latido .6s infinite alternate; }

.hoja { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .7); display: grid; align-items: end; }
.hoja-caja { background: var(--panel); border-radius: 20px 20px 0 0; padding: 20px max(16px, env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); max-width: 560px; width: 100%; margin: 0 auto; display: grid; gap: 12px; animation: subir .35s var(--ease); }
.hoja-caja h2 { margin: 0; font-weight: 900; }
.hoja-caja p { margin: 0; color: var(--mut); }
@keyframes subir { from { transform: translateY(100%); } }
.sellos { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sellos li { aspect-ratio: 1; border: 2px dashed var(--line); border-radius: 50%; display: grid; place-content: center; text-align: center; padding: 6px; font-size: .68rem; font-weight: 700; color: var(--mut); }
.sellos li b { display: block; font: 700 .62rem var(--mono); text-transform: uppercase; }
.sellos li.hecho { border: 3px solid var(--rojo-neon); color: var(--fg); background: rgba(200, 16, 46, .18); transform: rotate(-8deg); }

.ios-tip { position: fixed; left: 12px; right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 15; background: var(--oro); color: #111; border-radius: 12px; padding: 12px 40px 12px 14px; font-weight: 600; font-size: .9rem; }
.ios-tip button { position: absolute; top: 6px; right: 6px; border: 0; background: transparent; font-size: 1.1rem; color: #111; }
.toast { position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 30; background: var(--fg); color: #111; padding: 12px 18px; border-radius: 12px; font-weight: 800; max-width: calc(100% - 32px); box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }
.toast.error { background: var(--mal); color: #fff; }

.fx { position: fixed; inset: 0; pointer-events: none; z-index: 25; overflow: hidden; }
.chispa { position: absolute; top: -10px; width: 10px; height: 14px; border-radius: 2px; animation: caer 1.6s ease-in forwards; }
@keyframes caer { to { transform: translateY(105vh) rotate(720deg); } }
.subida { position: fixed; inset: 0; z-index: 26; display: grid; place-content: center; text-align: center; background: rgba(0, 0, 0, .8); animation: aparecer 2.6s forwards; pointer-events: none; }
.subida p { margin: 0; font: 700 .9rem var(--mono); letter-spacing: .2em; color: var(--oro); }
.subida h2 { margin: 6px 0 0; font-size: 3rem; font-weight: 900; color: var(--rc); text-shadow: 0 0 40px var(--rc); }
@keyframes aparecer { 0% { opacity: 0; transform: scale(.7); } 15%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }

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