/* BrailleQuest — estilo neón geométrico */

:root {
  --bg: #07070f;
  --bg-2: #10101f;
  --line: #2a2a48;
  --text: #ecebff;
  --muted: #8b8ab0;
  --good: #3ddc97;
  --bad: #ff6b4a;
  --accent: #4cc9f0;
  --dot-size: 64px;
  --glow: 1;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background:
    radial-gradient(ellipse at 50% -10%, #1b1b3a 0%, transparent 60%),
    linear-gradient(transparent 0 calc(100% - 1px), #ffffff08 0) 0 0 / 100% 48px,
    linear-gradient(90deg, transparent 0 calc(100% - 1px), #ffffff08 0) 0 0 / 48px 100%,
    var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#fx { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 10; }

/* Mini signo generador con los dígitos en bucle (tecla «-»), debajo del título de la cabecera */
.ticker {
  position: absolute; top: calc(100% + 40px); left: 0; z-index: 20; pointer-events: none;
  display: grid; grid-template-columns: repeat(2, 8px); grid-template-rows: repeat(3, 8px); gap: 4px;
  padding: 6px; border-radius: 8px; border: 1px solid #ffffffb0;
}
.ticker[hidden] { display: none; }
.ticker i { border-radius: 50%; border: 1px solid #ffffff44; }
.ticker i.on { background: var(--c); border-color: var(--c); box-shadow: 0 0 calc(6px * var(--glow)) var(--c); }
.ticker i[data-dot="1"] { --c: var(--dot-1); }
.ticker i[data-dot="2"] { --c: var(--dot-2); }
.ticker i[data-dot="3"] { --c: var(--dot-3); }
.ticker i[data-dot="4"] { --c: var(--dot-4); }
.ticker i[data-dot="5"] { --c: var(--dot-5); }
.ticker i[data-dot="6"] { --c: var(--dot-6); }

kbd {
  font: inherit; font-size: .85em;
  padding: 1px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg-2);
}

/* ---------- HUD ---------- */

.hud {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; border-bottom: 1px solid var(--line);
  background: #07070fcc;
}
.brand { position: relative; font-weight: 800; letter-spacing: .02em; }
.brand span, .logo span { color: var(--accent); text-shadow: 0 0 calc(12px * var(--glow)) var(--accent); }
.hud-block { color: var(--muted); }
.hud-combo { font-weight: 700; color: var(--dot-1); min-width: 90px; }
.hud-combo.hot { text-shadow: 0 0 calc(10px * var(--glow)) var(--dot-1); }
.hud-actions { margin-left: auto; display: flex; gap: 8px; }
body[data-screen="menu"] .hud-block, body[data-screen="menu"] .hud-combo,
body[data-screen="groups"] .hud-block, body[data-screen="groups"] .hud-combo { visibility: hidden; }
body[data-screen="menu"] #btn-menu { display: none; }

.chip {
  font: inherit; color: var(--text); cursor: pointer;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px;
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { border-color: var(--good); color: var(--good); }
.chip.primary { border-color: var(--accent); }

/* ---------- Pantallas ---------- */

main { flex: 1; position: relative; min-height: 0; }
.screen {
  position: absolute; inset: 0; display: none;
  flex-direction: column; align-items: center; justify-content: safe center; gap: 18px;
  padding: 16px; text-align: center; overflow-y: auto;
}
.screen.active { display: flex; }

h1, h2 { margin: 0; }
.logo { font-size: clamp(48px, 9vw, 96px); font-weight: 900; letter-spacing: -.02em; }
.tagline { color: var(--muted); font-size: 20px; margin: 0; }
.press { font-size: 18px; margin: 0; animation: blink 1.6s ease-in-out infinite; }
.muted { color: var(--muted); margin: 0; }

@keyframes blink { 50% { opacity: .45; } }

.start-map { display: flex; align-items: center; gap: 28px; margin: 18px 0; }
.start-map .arrow { font-size: 32px; color: var(--muted); }
.mini-keys { display: grid; grid-template-columns: repeat(2, 44px); gap: 6px; }
.mini-keys b {
  display: grid; place-items: center; height: 44px; border-radius: 8px;
  border: 2px solid; background: var(--bg-2);
}
.mini-keys b:nth-child(1) { color: var(--dot-1); }
.mini-keys b:nth-child(2) { color: var(--dot-4); }
.mini-keys b:nth-child(3) { color: var(--dot-2); margin-left: 12px; margin-right: -12px; }
.mini-keys b:nth-child(4) { color: var(--dot-5); margin-left: 12px; margin-right: -12px; }
.mini-keys b:nth-child(5) { color: var(--dot-3); margin-left: 24px; margin-right: -24px; }
.mini-keys b:nth-child(6) { color: var(--dot-6); margin-left: 24px; margin-right: -24px; }
.mini-cell { display: grid; grid-template-columns: repeat(2, 30px); grid-auto-flow: column; grid-template-rows: repeat(3, 30px); gap: 10px; }
.mini-cell i { border-radius: 50%; box-shadow: 0 0 calc(14px * var(--glow)) currentColor; background: currentColor; }
.mini-cell i:nth-child(1) { color: var(--dot-1); }
.mini-cell i:nth-child(2) { color: var(--dot-2); }
.mini-cell i:nth-child(3) { color: var(--dot-3); }
.mini-cell i:nth-child(4) { color: var(--dot-4); }
.mini-cell i:nth-child(5) { color: var(--dot-5); }
.mini-cell i:nth-child(6) { color: var(--dot-6); }

/* ---------- Combate ---------- */

#screen-battle { gap: 14px; }

.enemy { display: flex; align-items: center; gap: 18px; --enemy: var(--accent); }
.enemy svg { width: 110px; height: 110px; overflow: visible; }
.enemy polygon {
  fill: color-mix(in srgb, var(--enemy) 12%, transparent);
  stroke: var(--enemy); stroke-width: 3;
  filter: drop-shadow(0 0 calc(10px * var(--glow)) var(--enemy));
  transform-origin: center;
}
/* La flotación y la sacudida mueven capas enteras (svg y su envoltorio) con transform:
   la GPU las compone sin volver a pintar el polígono ni su filtro de brillo. */
.enemy svg { animation: float 4s ease-in-out infinite; will-change: transform; }
.enemy-body { will-change: transform; }
/* Jefe: más grande, con un segundo contorno que gira */
.enemy.boss svg { width: 150px; height: 150px; }
.enemy.boss .enemy-name { font-size: 20px; letter-spacing: .04em; }
.enemy.boss .hp { width: 260px; height: 14px; }
.enemy.boss .enemy-body { position: relative; }
.enemy.boss .enemy-body::before {
  content: ''; position: absolute; inset: 8px; border-radius: 50%; pointer-events: none;
  border: 2px dashed color-mix(in srgb, var(--enemy) 60%, transparent);
  animation: boss-orbit 8s linear infinite; will-change: transform;
}
@keyframes boss-orbit { to { transform: rotate(360deg); } }

/* Impacto en dos tiempos: primero el enemigo se congela y flashea (sin moverse, también sin
   flotar) y después sale despedido de golpe, como si el impacto llegara con retraso.
   Las duraciones del congelado están en game.js (FREEZE_MS); los % de abajo las respetan.
   El movimiento es suave (curvas con rebote); solo el destello del congelado va a golpes. */
.enemy.hit svg { animation-play-state: paused; }
.enemy.hit .enemy-body { animation: impact .64s linear; }
.enemy.hit polygon { animation: impact-color .64s linear; }
.enemy.hit.crit .enemy-body { animation: impact-crit .82s linear; }
.enemy.hit.crit polygon { animation: impact-color-crit .82s linear; }
.enemy.defeated polygon { animation: defeat .9s ease-in forwards; }
.enemy-info { text-align: left; }
.enemy-name { font-weight: 700; color: var(--enemy); margin-bottom: 6px; }
.hp { width: 200px; height: 10px; border-radius: 99px; background: var(--bg-2); border: 1px solid var(--line); overflow: hidden; }
.hp-fill { height: 100%; background: var(--enemy); box-shadow: 0 0 10px var(--enemy); transform-origin: left; transition: transform .3s ease-out; }

@keyframes float { 50% { transform: translateY(-6px) rotate(6deg); } }
/* 0–17 % (110 ms): quieto. Luego retroceso rápido con frenada, rebote y asentamiento. */
@keyframes impact {
  0%, 17% { transform: none; animation-timing-function: cubic-bezier(.1, .9, .2, 1); }
  32%  { transform: translate(20px, -15px) scale(.86) rotate(13deg); animation-timing-function: cubic-bezier(.45, 0, .3, 1); }
  58%  { transform: translate(-7px, 4px) scale(1.04) rotate(-5deg); animation-timing-function: cubic-bezier(.45, 0, .3, 1); }
  80%  { transform: translate(2px, -1px) rotate(1.5deg); animation-timing-function: ease-out; }
  100% { transform: none; }
}
/* Crítico: 0–18 % (150 ms) quieto y un retroceso más bestia. */
@keyframes impact-crit {
  0%, 18% { transform: none; animation-timing-function: cubic-bezier(.1, .9, .2, 1); }
  33%  { transform: translate(30px, -24px) scale(.78) rotate(24deg); animation-timing-function: cubic-bezier(.45, 0, .3, 1); }
  56%  { transform: translate(-12px, 7px) scale(1.08) rotate(-9deg); animation-timing-function: cubic-bezier(.45, 0, .3, 1); }
  76%  { transform: translate(4px, -2px) rotate(3deg); animation-timing-function: ease-out; }
  100% { transform: none; }
}
/* Congelado: blanco → invertido → blanco a golpes (steps). Al salir despedido, el relleno
   invertido se apaga de forma suave. */
@keyframes impact-color {
  0%   { fill: #fff; stroke: #fff; animation-timing-function: steps(1, end); }
  6%   { fill: var(--enemy); stroke: var(--bg); animation-timing-function: steps(1, end); }
  12%  { fill: #fff; stroke: #fff; animation-timing-function: steps(1, end); }
  17%  { fill: var(--enemy); stroke: #fff; animation-timing-function: ease-out; }
  70%  { fill: color-mix(in srgb, var(--enemy) 12%, transparent); stroke: var(--enemy); }
}
@keyframes impact-color-crit {
  0%   { fill: #fff; stroke: #fff; animation-timing-function: steps(1, end); }
  5%   { fill: var(--dot-1); stroke: var(--bg); animation-timing-function: steps(1, end); }
  10%  { fill: #fff; stroke: #fff; animation-timing-function: steps(1, end); }
  14%  { fill: var(--enemy); stroke: var(--bg); animation-timing-function: steps(1, end); }
  18%  { fill: var(--dot-1); stroke: #fff; animation-timing-function: ease-out; }
  45%  { fill: var(--enemy); stroke: #fff; animation-timing-function: ease-out; }
  75%  { fill: color-mix(in srgb, var(--enemy) 12%, transparent); stroke: var(--enemy); }
}
@keyframes defeat { to { transform: scale(1.8) rotate(90deg); opacity: 0; } }

/* Golpe: número de daño flotante y temblor de pantalla (más fuerte con combo ≥ 5) */
.enemy { position: relative; }
.damage {
  position: absolute; left: 55px; top: 10px; transform: translateX(-50%);
  font-size: 26px; font-weight: 800; color: #fff; white-space: nowrap; pointer-events: none;
  text-shadow: 0 0 calc(12px * var(--glow)) var(--enemy);
  animation: damage .9s ease-out forwards;
}
.damage.crit { font-size: 34px; color: var(--dot-1); text-shadow: 0 0 calc(18px * var(--glow)) var(--dot-1); }
@keyframes damage {
  0% { transform: translate(-50%, 0) scale(.6); opacity: 0; }
  20% { transform: translate(-50%, -14px) scale(1.25); opacity: 1; }
  100% { transform: translate(-50%, -60px) scale(1); opacity: 0; }
}
#screen-battle.quake { animation: quake .25s ease-out; }
#screen-battle.quake-big { animation: quake-big .4s ease-out; }
@keyframes quake { 25% { transform: translate(-3px, 2px); } 50% { transform: translate(3px, -2px); } 75% { transform: translate(-2px, 1px); } }
@keyframes quake-big {
  15% { transform: translate(-8px, 4px) rotate(-.4deg); } 30% { transform: translate(7px, -5px) rotate(.4deg); }
  45% { transform: translate(-6px, 3px); } 60% { transform: translate(4px, -3px); } 80% { transform: translate(-2px, 1px); }
}

.arena { display: flex; align-items: center; justify-content: center; gap: 48px; }

.prompt { width: 150px; display: flex; flex-direction: column; align-items: center; }
.banner { height: 22px; font-size: 13px; text-transform: uppercase; letter-spacing: .12em; color: var(--dot-1); opacity: 0; }
.banner.show { opacity: 1; }
.target {
  font-size: 120px; font-weight: 800; line-height: 1;
  text-shadow: 0 0 calc(24px * var(--glow)) var(--accent);
}
.target.pop { animation: pop .3s ease-out; }
/* Palabra del jefe: lo escrito en verde, la letra actual resaltada */
.target.word { font-size: 64px; letter-spacing: .04em; white-space: nowrap; }
.target.word span { color: var(--muted); text-shadow: none; }
.target.word span.done { color: var(--good); text-shadow: 0 0 calc(12px * var(--glow)) var(--good); }
.target.word span.current {
  color: var(--text); text-shadow: 0 0 calc(24px * var(--glow)) var(--accent);
  border-bottom: 4px solid var(--dot-1);
}
.prompt:has(.target.word) { width: auto; min-width: 150px; }
/* Práctica de contar: misma pantalla que el combate, sin enemigo ni cristales */
#screen-battle.practice .enemy, #screen-battle.practice .crystals { display: none; }
/* Celdas de un número: signo + dígitos, se van rellenando */
.sequence { display: flex; gap: 6px; min-height: 34px; margin-top: 6px; }
.sequence i {
  width: 26px; height: 34px; border-radius: 6px; border: 1px solid var(--line);
  display: grid; place-items: center; font-style: normal; font-size: 24px; color: var(--good);
}
.sequence i.current { border-color: var(--dot-1); box-shadow: 0 0 calc(8px * var(--glow)) var(--dot-1); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }

/* Celda braille grande */
.cell {
  display: grid; grid-template-columns: repeat(2, var(--dot-size)); grid-template-rows: repeat(3, var(--dot-size));
  gap: 18px; padding: 24px; border-radius: 22px;
  border: 1px solid var(--line); background: #0c0c1a;
}
.cell.success { animation: success .5s ease-out; }
.cell.shake { animation: shake .4s ease-in-out; }
@keyframes success { 30% { box-shadow: 0 0 40px #ffffff55; border-color: #fff; } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

.dot {
  --c: var(--dot-1);
  border-radius: 50%; border: 2px solid color-mix(in srgb, var(--c) 30%, transparent);
  display: grid; place-items: center; transition: background .08s, box-shadow .08s, transform .08s;
}
.dot span { font-size: 13px; color: color-mix(in srgb, var(--c) 60%, transparent); }
.dot.on {
  background: var(--c); border-color: var(--c);
  box-shadow: 0 0 calc(22px * var(--glow)) var(--c), 0 0 calc(44px * var(--glow)) color-mix(in srgb, var(--c) 40%, transparent);
  transform: scale(1.04);
}
.dot.on span { color: #0008; font-weight: 700; }
.dot.ghost { border-style: dashed; border-color: var(--c); animation: ghost 1.1s ease-in-out infinite; }
.dot.ghost span { color: var(--c); }
.dot.wrong { background: transparent; box-shadow: none; border: 3px solid var(--bad); }
.dot.wrong span { color: var(--bad); }
@keyframes ghost { 50% { background: color-mix(in srgb, var(--c) 22%, transparent); } }

.dot[data-dot="1"], .key[data-dot="1"] { --c: var(--dot-1); }
.dot[data-dot="2"], .key[data-dot="2"] { --c: var(--dot-2); }
.dot[data-dot="3"], .key[data-dot="3"] { --c: var(--dot-3); }
.dot[data-dot="4"], .key[data-dot="4"] { --c: var(--dot-4); }
.dot[data-dot="5"], .key[data-dot="5"] { --c: var(--dot-5); }
.dot[data-dot="6"], .key[data-dot="6"] { --c: var(--dot-6); }

/* Teclado en pantalla: escalonado como un teclado real */
.keyboard { display: grid; grid-template-columns: repeat(2, 52px); grid-template-rows: repeat(3, 52px); gap: 8px; padding-right: 32px; }
.key {
  border-radius: 10px; border: 2px solid color-mix(in srgb, var(--c) 45%, transparent);
  background: var(--bg-2); display: flex; flex-direction: column; align-items: center; justify-content: center;
  transition: background .08s, box-shadow .08s;
}
.key[data-dot="2"], .key[data-dot="5"] { transform: translateX(14px); }
.key[data-dot="3"], .key[data-dot="6"] { transform: translateX(28px); }
.key b { font-size: 20px; color: var(--c); }
.key small { font-size: 11px; color: var(--muted); }
.key.on { background: var(--c); box-shadow: 0 0 calc(16px * var(--glow)) var(--c); }
.key.on b, .key.on small { color: #000a; }
.key.ghost { border-style: dashed; border-color: var(--c); }
.key.wrong { border-color: var(--bad); }
body.hide-keyboard .keyboard-wrap { display: none; }

.message { min-height: 26px; margin: 0; font-size: 18px; color: var(--muted); }
.message.good { color: var(--good); font-weight: 700; }
.message.bad { color: var(--bad); }
.message.info { color: var(--text); }
.controls { margin: 0; font-size: 14px; color: var(--muted); }

.crystals { display: flex; gap: 10px; margin-top: 6px; }
.crystal {
  --fill: 0;
  width: 38px; height: 44px; display: grid; place-items: center; font-weight: 700;
  clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  background:
    linear-gradient(to top, color-mix(in srgb, var(--accent) 55%, transparent) calc(var(--fill) * 100%), var(--bg-2) 0);
  color: var(--text);
}
.crystal.locked { color: #ffffff30; background: #ffffff08; }
.crystal.current { color: var(--dot-1); transform: translateY(-5px); transition: transform .2s; }
.crystal.mastered { background: var(--accent); color: #000; filter: drop-shadow(0 0 calc(8px * var(--glow)) var(--accent)); }

/* ---------- Menú y listas de opciones ---------- */

#screen-menu { gap: 14px; }
#screen-menu .start-map { margin: 4px 0; }
.options { display: flex; flex-direction: column; gap: 10px; width: min(520px, 100%); }
.option {
  display: flex; align-items: center; gap: 14px; text-align: left;
  font: inherit; color: var(--text); cursor: pointer;
  padding: 12px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg-2);
}
.option span { display: flex; flex-direction: column; gap: 2px; }
.option small { color: var(--muted); }
.option.selected {
  border-color: var(--accent);
  box-shadow: 0 0 calc(14px * var(--glow)) color-mix(in srgb, var(--accent) 40%, transparent);
}
.option.disabled { opacity: .45; cursor: default; }

/* ---------- Calentamiento ---------- */

#screen-warmup { gap: 12px; }
.chart { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 780px; }
.tile {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 10px;
  font: inherit; color: var(--text); cursor: pointer;
  border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2);
}
.tile.found { border-color: color-mix(in srgb, var(--good) 60%, transparent); }
.tile.match { border-color: var(--accent); box-shadow: 0 0 calc(12px * var(--glow)) var(--accent); }
.cell.mini { --dot-size: 10px; gap: 4px; padding: 6px; border-radius: 6px; }
.cell.mini .dot { border-width: 1px; }
.cell.mini .dot span { display: none; }
.cell.mini .dot.on { box-shadow: 0 0 calc(6px * var(--glow)) var(--c); transform: none; }

/* ---------- Ronda de lectura ---------- */

#screen-reading { gap: 16px; }
#screen-reading .cell .dot span { visibility: hidden; } /* sin números: se lee por la forma */
.cell-row { display: flex; gap: 16px; justify-content: center; }
.typed {
  min-width: 90px; padding: 6px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2);
  font-size: 40px; font-weight: 800; letter-spacing: .1em; color: var(--accent);
}
.typed[hidden] { display: none; }
.cell.pop { animation: pop .3s ease-out; }
.choices { display: flex; gap: 14px; min-height: 64px; }
.choice {
  width: 64px; height: 64px; display: grid; place-items: center;
  font-size: 34px; font-weight: 800; border-radius: 14px;
  border: 2px solid var(--line); background: var(--bg-2);
}
.pips { display: flex; gap: 8px; }
.pips i { width: 12px; height: 12px; border-radius: 50%; background: var(--line); }
.pips i.done { background: var(--good); box-shadow: 0 0 calc(8px * var(--glow)) var(--good); }
.pips i.current { background: transparent; border: 2px solid var(--accent); }

/* ---------- Pausa y final ---------- */

.stats { display: flex; gap: 28px; }
.stats div { display: flex; flex-direction: column; gap: 4px; min-width: 110px; }
.stats b { font-size: 30px; color: var(--accent); }
.stats span { color: var(--muted); font-size: 14px; }

.breath {
  width: 90px; height: 90px; border-radius: 50%;
  border: 2px solid var(--accent); box-shadow: 0 0 calc(24px * var(--glow)) var(--accent);
  animation: breathe 5s ease-in-out infinite;
}
@keyframes breathe { 50% { transform: scale(1.5); opacity: .6; } }

/* ---------- Panel sensorial ---------- */

dialog {
  background: var(--bg-2); color: var(--text); border: 1px solid var(--line); border-radius: 16px;
  padding: 24px; width: min(420px, 92vw);
}
dialog::backdrop { background: #000a; }
dialog h2 { margin-bottom: 12px; }
dialog form { display: flex; flex-direction: column; gap: 8px; }
dialog fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 6px 0 0; }
dialog legend { color: var(--muted); padding: 0 6px; }
.row { display: flex; align-items: center; gap: 10px; padding: 3px 0; }
.row.range input { flex: 1; }
dialog .chip { align-self: flex-end; margin-top: 10px; }
dialog { max-height: 90vh; overflow-y: auto; }

/* Menú de depuración */
.debug { margin-top: 10px; border: 1px dashed var(--line); border-radius: 10px; padding: 8px 12px; }
.debug summary { cursor: pointer; color: var(--muted); }
.debug[open] summary { margin-bottom: 6px; }
.debug h3 { margin: 10px 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.debug p { margin: 4px 0; font-size: 14px; }
.debug-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.debug-grid .chip { align-self: stretch; margin: 0; font-size: 13px; text-align: left; }
.chip.danger { border-color: var(--bad); color: var(--bad); }
.debug-status:empty { display: none; }
.debug-status { color: var(--good); }
.debug-dump {
  max-height: 220px; overflow: auto; margin: 6px 0 0; padding: 8px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--line); font-size: 11px; text-align: left; white-space: pre-wrap;
}

/* ---------- Equipo y botín ---------- */

.rarity-comun { --rarity: #cfd2ff; }
.rarity-rara { --rarity: var(--accent); }
.rarity-epica { --rarity: var(--dot-1); }

/* Cofre en la pausa / final: el cofre tiembla, se abre con un destello y aparece el objeto. */
.loot { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.loot:empty { display: none; }
.level-up { margin: 0; font-size: 22px; font-weight: 800; color: var(--good); text-shadow: 0 0 calc(12px * var(--glow)) var(--good); }
.slot-new { margin: 0; color: var(--text); }
.loot-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 260px; padding: 14px 22px; border-radius: 14px;
  border: 1px solid var(--rarity, var(--line)); background: var(--bg-2);
  box-shadow: 0 0 calc(18px * var(--glow)) color-mix(in srgb, var(--rarity, transparent) 35%, transparent);
}
.loot-card b { font-size: 24px; color: var(--rarity, var(--text)); }
.loot-card small { color: var(--muted); }
.loot-card small.good { color: var(--good); }
.loot-rarity { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--rarity, var(--muted)); }
.chest {
  position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px;
  border: 2px solid var(--rarity); background: color-mix(in srgb, var(--rarity) 15%, var(--bg));
  box-shadow: 0 0 calc(16px * var(--glow)) var(--rarity);
  transform: rotate(45deg); opacity: 0; pointer-events: none;
  animation: chest .9s ease-in-out;
}
.loot-card > :not(.chest) { animation: loot-reveal .4s cubic-bezier(.2, .9, .3, 1.3) .8s backwards; }
.loot-card { animation: loot-card .9s ease-out; }
.loot-card.no-anim, .loot-card.no-anim > *, .loot-card.no-anim .chest { animation: none; }
@keyframes chest {
  0% { opacity: 1; transform: rotate(45deg) scale(.6); }
  14% { transform: rotate(45deg) scale(1); }
  24% { transform: rotate(37deg); } 34% { transform: rotate(53deg); }
  44% { transform: rotate(39deg); } 54% { transform: rotate(51deg); }
  68% { opacity: 1; transform: rotate(45deg) scale(1.15); background: color-mix(in srgb, var(--rarity) 15%, var(--bg)); }
  78% { opacity: 1; transform: rotate(45deg) scale(1.6); background: #fff; border-color: #fff; }
  100% { opacity: 0; transform: rotate(45deg) scale(3.2); }
}
@keyframes loot-card { 0% { border-color: var(--line); box-shadow: none; } 78% { border-color: #fff; } }
@keyframes loot-reveal { from { opacity: 0; transform: translateY(6px) scale(.9); } }

/* Pantalla de equipo */
.gear-summary { display: flex; gap: 14px; }
.gear-summary div {
  display: flex; flex-direction: column; gap: 2px; min-width: 120px; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg-2);
}
.gear-summary span { color: var(--muted); font-size: 13px; }
.gear-summary .locked b { color: var(--muted); }
.gear-options { max-height: 46vh; overflow-y: auto; padding: 4px; }
.option[class*="rarity-"] b { color: var(--rarity); }
.option.equipped { border-color: var(--rarity); }

/* Auras de la celda */
.cell-wrap[class*="aura-"] .cell { position: relative; }
/* Las auras animadas van en pseudo-elementos para no pisar las animaciones de acierto/fallo de .cell */
.aura-pulso .cell::after {
  content: ''; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  border: 1px solid var(--accent);
  box-shadow: 0 0 calc(28px * var(--glow)) color-mix(in srgb, var(--accent) 70%, transparent);
  opacity: 0; animation: aura-pulse 1.6s ease-in-out infinite; will-change: opacity;
}
@keyframes aura-pulse { 50% { opacity: 1; } }
@property --aura-angle { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
.aura-circuito .cell::before {
  content: ''; position: absolute; inset: -5px; border-radius: 26px; padding: 2px; pointer-events: none;
  background: conic-gradient(from var(--aura-angle), transparent 0 65%, var(--accent) 90%, #fff);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  animation: aura-spin 1.8s linear infinite;
}
@keyframes aura-spin { to { --aura-angle: 360deg; } }
.aura-prisma .cell {
  border-color: transparent;
  box-shadow:
    -6px -6px calc(18px * var(--glow)) -4px var(--dot-1), 6px -6px calc(18px * var(--glow)) -4px var(--dot-4),
    -6px 0 calc(18px * var(--glow)) -4px var(--dot-2), 6px 0 calc(18px * var(--glow)) -4px var(--dot-5),
    -6px 6px calc(18px * var(--glow)) -4px var(--dot-3), 6px 6px calc(18px * var(--glow)) -4px var(--dot-6);
}
.aura-eclipse .cell {
  background: #000; border-color: #fff;
  box-shadow: 0 0 0 3px #000, 0 0 calc(26px * var(--glow)) 4px #ffffffaa;
}

/* Sellos: destello suave de pantalla (Nova) y corrupción breve (Glitch). Sin parpadeos repetidos. */
#screen-battle::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 50% 25%, #fff, transparent 70%);
}
#screen-battle.flash-nova::after { animation: nova-flash .45s ease-out; }
@keyframes nova-flash { 0% { opacity: .35; } 100% { opacity: 0; } }
#screen-battle.glitch .arena, #screen-battle.glitch .enemy-info { animation: glitch .32s steps(1, end); }
@keyframes glitch {
  0% { transform: translate(-6px, 0); filter: hue-rotate(90deg) saturate(2); clip-path: inset(10% 0 55% 0); }
  20% { transform: translate(5px, 0); filter: hue-rotate(-60deg); clip-path: inset(45% 0 20% 0); }
  40% { transform: translate(-3px, 0); filter: none; clip-path: inset(0 0 0 0); }
  60% { transform: translate(4px, 0); filter: hue-rotate(180deg) saturate(1.5); clip-path: inset(60% 0 5% 0); }
  80%, 100% { transform: none; filter: none; clip-path: none; }
}

/* ---------- Leer un PDF ---------- */

#screen-pdf { gap: 14px; }
#screen-pdf.dragging { outline: 3px dashed var(--accent); outline-offset: -12px; }
.pdf-pick { width: min(560px, 100%); }
.pdf-work { display: flex; flex-direction: column; align-items: center; gap: 12px; width: min(1180px, 100%); }
.pdf-work[hidden] { display: none; }
.pdf-progress { width: min(420px, 100%); height: 6px; border-radius: 99px; background: var(--bg-2); border: 1px solid var(--line); overflow: hidden; }
.pdf-bar { height: 100%; width: 0; background: var(--good); transition: width .3s; }
.pdf-context { min-height: 3em; color: var(--muted); font-size: 18px; }
.pdf-context p { margin: 0; }
.pdf-line { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px 30px; padding: 8px; }
.pdf-line.shake { animation: shake .4s ease-in-out; }
.pdf-word { display: flex; gap: 6px; }
.pdf-col { display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: pointer; }
.pdf-cells { display: flex; gap: 3px; }
.cell.mini.pdf-cell { --dot-size: 13px; gap: 5px; padding: 7px; }
.pdf-slot {
  min-width: 36px; height: 44px; padding: 0 4px; border-radius: 8px; border: 2px solid var(--line);
  background: var(--bg-2); display: grid; place-items: center; font-size: 26px; font-weight: 700;
}
.pdf-col.current .pdf-slot { border-color: var(--accent); box-shadow: 0 0 calc(12px * var(--glow)) var(--accent); animation: ghost 1.1s ease-in-out infinite; --c: var(--accent); }
.pdf-col.current .pdf-cell { border-color: var(--accent); }
.pdf-col.redo .pdf-slot { border-style: dashed; border-color: var(--bad); }
.pdf-col.ok .pdf-slot { border-color: var(--good); color: var(--good); }
.pdf-col.ko .pdf-slot { border-color: var(--bad); color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, var(--bg-2)); }
.pdf-col.revealed .pdf-slot { border-color: var(--dot-1); color: var(--dot-1); background: color-mix(in srgb, var(--dot-1) 14%, var(--bg-2)); }
.pdf-col.unknown { cursor: default; opacity: .5; }
.pdf-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.pdf-col.unknown .pdf-slot { border-style: dotted; color: var(--muted); }
@media (max-width: 760px) {
  .cell.mini.pdf-cell { --dot-size: 9px; gap: 3px; padding: 5px; }
  .pdf-slot { min-width: 26px; height: 34px; font-size: 20px; }
}

/* ---------- Modo calma y sin efectos ---------- */

body.calm { --glow: 0; }
body.calm *, body.no-fx *, body.calm *::before, body.no-fx *::before,
body.calm *::after, body.no-fx *::after { animation: none !important; }
body.calm .dot, body.calm .key { transition: none; }
body.calm .dot.on { transform: none; }
body.calm .press, body.no-fx .press { opacity: 1; }
body.calm .damage, body.no-fx .damage { display: none; }

/* Pantallas pequeñas: la celda y el teclado se apilan */
@media (max-width: 760px), (max-height: 640px) {
  :root { --dot-size: 48px; }
  .arena { gap: 24px; }
  .target { font-size: 84px; }
  .enemy svg { width: 80px; height: 80px; }
  .enemy.boss svg { width: 110px; height: 110px; }
  .target.word { font-size: 44px; }
}
@media (max-width: 620px) {
  .arena { flex-wrap: wrap; }
}
