/*
 * Componentes: aparato, pantalla LCD, escalera, mando (botones A/B), resultado,
 * avisos, tarjetas de diálogo y estadísticas.
 */

/* ---- Aparato ------------------------------------------------------------ */

.device {
  width: min(100% - 20px, var(--content));
  margin: max(10px, env(safe-area-inset-top)) auto 24px;
  padding: 14px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: linear-gradient(180deg, var(--body-light), var(--body) 30%, var(--body-dark));
  border: 4px solid var(--outline);
  border-radius: 28px 28px 28px 64px;
  box-shadow: 0 8px 0 var(--outline), 0 24px 40px -16px rgba(0, 0, 0, 0.5);
}

/* Las dos mitades de la Pokédex (en móvil, una debajo de otra sin separación). */
.half {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hinge,
.flap-top {
  display: none; /* solo en escritorio (desktop.css) */
}

.device-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 4px solid var(--outline);
}

.lens {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  flex: none;
  border: 4px solid var(--outline);
  border-radius: 50%;
  background: #fff;
}

.lens-glass {
  width: 36px;
  height: 36px;
  border: 3px solid var(--outline);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #bfe3ff 0 18%, var(--blue) 45%, #1360b5);
}

/* Al dibujar algo nuevo, la lente "analiza": tres destellos rápidos. */
.lens-glass.is-scanning {
  animation: scan 0.9s steps(1) 1;
}

@keyframes scan {
  0%, 34%, 68% { background: radial-gradient(circle at 35% 35%, #fff 0 22%, #8fd0ff 55%, var(--blue)); }
  17%, 51%, 85% { filter: brightness(0.9); }
}

.leds {
  display: flex;
  gap: 5px;
  align-self: flex-start;
  margin-top: 4px;
}

.leds i {
  width: 11px;
  height: 11px;
  border: 2px solid var(--outline);
  border-radius: 50%;
  background: #ff6b6b;
}

.leds i:nth-child(2) { background: var(--yellow); }
.leds i:nth-child(3) { background: #5fd35f; }

.logo {
  flex: 1;
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--yellow);
  -webkit-text-stroke: 1.5px var(--outline);
  paint-order: stroke fill;
  text-shadow: 0 3px 0 var(--outline);
}

.top-actions {
  display: flex;
  gap: 6px;
  flex: none;
}

/* Móviles estrechos: el logo cede sitio a los botones. */
@media (max-width: 420px) {
  .leds {
    display: none;
  }

  .logo {
    font-size: 1.3rem;
  }
}

/* Móviles muy estrechos (320-360px): todo más compacto para que la cabecera no se salga. */
@media (max-width: 360px) {
  .device {
    width: calc(100% - 12px);
    padding: 12px 10px 14px;
  }

  .device-top {
    gap: 6px;
  }

  .device-top .lens {
    width: 40px;
    height: 40px;
  }

  .device-top .lens-glass {
    width: 26px;
    height: 26px;
  }

  .device-top .logo {
    font-size: 1.1rem;
  }

  .top-actions {
    gap: 4px;
  }

  .top-actions .round-btn,
  .top-actions .lang-switch {
    width: 32px;
    height: 32px;
  }
  .screen-bezel .screen {
    width: min(100%, max(180px, 100dvh - 400px));
  }
}

.round-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 3px solid var(--outline);
  border-radius: 50%;
  background: var(--panel);
  box-shadow: 0 3px 0 var(--outline);
  cursor: pointer;
  transition: transform 0.08s;
}

.round-btn:hover {
  background: #fff;
}

.round-btn:active {
  transform: translateY(3px);
  box-shadow: none;
}

.round-btn--plain {
  box-shadow: none;
}

/* Cambio de idioma ("ES" / "EN"): un botón redondo más, con texto. */
.lang-switch {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 3px solid var(--outline);
  border-radius: 50%;
  background: var(--panel);
  box-shadow: 0 3px 0 var(--outline);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-decoration: none;
  transition: transform 0.08s;
}

.lang-switch:hover {
  background: #fff;
}

.lang-switch:active {
  transform: translateY(3px);
  box-shadow: none;
}

.modes {
  display: none; /* este juego tiene un único modo */
}

.panel-msg {
  padding: 22px 16px;
  border: 3px solid var(--outline);
  border-radius: var(--radius);
  background: var(--panel);
  font-weight: 700;
  text-align: center;
}

.game {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---- Pantalla LCD ------------------------------------------------------- */

.screen-bezel {
  padding: 12px 12px 14px;
  border: 4px solid var(--outline);
  border-radius: 14px 14px 14px 42px;
  background: #d9d4cc;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12);
}

.screen-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 4px 8px;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #5f5952;
}

.screen-id {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.screen-id svg {
  width: 1.15em;
  height: 1.15em;
  stroke-width: 2.2;
}

.screen-label #circles-label {
  font-family: var(--font-lcd);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--a-btn);
}

.screen {
  position: relative;
  width: min(100%, max(220px, 100dvh - 420px));
  margin: 0 auto;
  border: 4px solid var(--outline);
  border-radius: 8px;
  background-color: var(--lcd-0);
  /* Rejilla de píxeles del LCD */
  background-image:
    linear-gradient(rgba(15, 56, 15, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 56, 15, 0.06) 1px, transparent 1px);
  background-size: 6px 6px;
  box-shadow: inset 0 0 0 3px rgba(155, 188, 15, 0.5), inset 0 6px 14px rgba(15, 56, 15, 0.25);
  overflow: hidden;
}

#canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1;
}

.reveal {
  position: absolute;
  inset: 8%;
  width: 84%;
  height: 84%;
  object-fit: contain;
  opacity: 0;
  transform: scale(0.6) rotate(-8deg);
  transition: opacity 0.5s, transform 0.7s var(--ease);
  filter: drop-shadow(0 6px 0 rgba(15, 56, 15, 0.35));
}

.screen.is-revealed .reveal {
  opacity: 1;
  transform: none;
}

.screen.is-revealed #canvas {
  opacity: 0.25;
  transition: opacity 0.5s;
}

.screen.is-shaking {
  animation: shake 0.35s;
}

.screen.is-celebrating {
  animation: pop 0.6s var(--ease);
}

@keyframes shake {
  20%, 60% { transform: translateX(-7px) rotate(-1deg); }
  40%, 80% { transform: translateX(7px) rotate(1deg); }
}

@keyframes pop {
  40% { transform: scale(1.04); }
}

.palette {
  display: none;
}

/* ---- Escalera de intentos ------------------------------------------------ */

.ladder {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.rung {
  display: grid;
  place-items: center;
  height: 30px;
  border: 3px solid var(--outline);
  border-radius: 999px;
  background: #ece6dc;
  font-size: 0.85rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #7a736a;
  transition: background-color 0.25s, color 0.25s, transform 0.35s var(--ease);
}

/* Lo que aún no se ha visto, en trazo discontinuo; el intento actual, en amarillo y algo más alto. */
.rung:not(.rung--current, .rung--wrong, .rung--skip, .rung--correct) {
  border-style: dashed;
  border-color: rgba(27, 27, 31, 0.45);
}

.rung--current {
  background: var(--yellow);
  color: var(--ink);
  transform: translateY(-3px);
  box-shadow: 0 3px 0 var(--outline);
}

.rung--wrong { background: var(--wrong); color: #fff; }
.rung--skip { background: var(--skip); color: #fff; }
.rung--correct { background: var(--correct); color: #fff; }

/* ---- Mando: buscador y botones A/B -------------------------------------- */

.controls,
.guess {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.combo {
  position: relative;
}

.guess-input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border: 4px solid var(--outline);
  border-radius: var(--radius);
  background: var(--panel);
  font-size: 1.05rem;
  font-weight: 700;
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.08);
}

.guess-input::placeholder {
  color: #8a7558; /* >= 4.5:1 sobre el panel */
  font-weight: 800;
}

.guess-input:focus {
  outline: none;
  background: #fff;
  box-shadow: 0 0 0 4px var(--yellow);
}

.suggestions {
  position: absolute;
  inset: auto 0 calc(100% + 8px) 0;
  z-index: 5;
  max-height: 240px;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  list-style: none;
  border: 4px solid var(--outline);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--hard-shadow);
}

.suggestions li {
  padding: 9px 12px;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
}

.suggestions li[aria-selected="true"] {
  background: var(--yellow);
}

.suggestions small {
  color: var(--muted);
  font-weight: 500;
}

.pad {
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  gap: 18px;
  padding-right: 6px;
}

.key-group {
  display: flex;
  align-items: flex-end;
  gap: 18px;
}

.key {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.key-face {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border: 4px solid var(--outline);
  border-radius: 50%;
  background: var(--a-btn);
  color: #fff;
  font-size: 1.3rem;
  font-weight: 900;
  box-shadow: 0 5px 0 var(--outline);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.2s, background-color 0.2s;
}

.key:hover:not(:disabled) .key-face {
  filter: brightness(1.12);
}

/* A listo para pulsar: se enciende un poco más. */
.key--a:not(:disabled) .key-face {
  background: #c22a6f;
}

.key--b {
  margin-bottom: 18px;
}

.key--b .key-face {
  width: 48px;
  height: 48px;
  background: var(--b-btn);
  font-size: 1.05rem;
}

.key-label {
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 2px 0 var(--outline);
}

.key:active:not(:disabled) .key-face {
  transform: translateY(5px);
  box-shadow: none;
}

.key:disabled {
  cursor: not-allowed;
}

.key:disabled .key-face {
  background: #6e4a59;
  color: rgba(255, 255, 255, 0.55);
}

.key:disabled .key-label {
  opacity: 0.7;
}

/* Registro de fallos: mini pantalla oscura. Se oculta mientras está vacío. */
/* Registro: la segunda pantalla de la Pokédex, verde oscura, con letra de puntos. */
.log {
  padding: 10px 14px 12px;
  border: 4px solid var(--outline);
  border-radius: 12px;
  background-color: var(--lcd-3);
  background-image:
    linear-gradient(rgba(227, 242, 176, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(227, 242, 176, 0.04) 1px, transparent 1px);
  background-size: 4px 4px;
  box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.4);
  font-family: var(--font-lcd);
  color: var(--lcd-0);
}

.log-title {
  margin-bottom: 8px;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--lcd-1);
}

.history:not(:has(.log-row--done))::before {
  content: attr(data-empty); /* texto en la página (site/strings.json: log_empty) */
  color: rgba(227, 242, 176, 0.75);
  font-size: 0.9rem;
}

.kbd-hint {
  display: none; /* solo con teclado y ratón, ver desktop.css */
  font-size: 0.78rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.9);
  text-wrap: balance;
}

kbd {
  padding: 1px 6px;
  border: 2px solid var(--outline);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font-family: var(--font-digits);
  font-size: 0.72rem;
  box-shadow: 0 2px 0 var(--outline);
}

.history {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* En móvil solo se listan los intentos hechos. */
.log-row:not(.log-row--done) {
  display: none;
}

.log-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 1rem;
  color: var(--lcd-0);
}

.log-n {
  min-width: 2ch;
  font-size: 0.75rem;
  text-align: right;
  color: var(--lcd-1);
}

.log-row--wrong .log-text {
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  text-decoration-color: #ff7a6e;
}

.log-row--skip .log-text,
.log-row--pending {
  color: rgba(227, 242, 176, 0.5);
}

.log-row--correct .log-text {
  color: #b6f36a;
}

.log-row--current .log-text {
  animation: caret 1.1s steps(1) infinite;
}

@keyframes caret {
  50% { opacity: 0.25; }
}

/* ---- Resultado ---------------------------------------------------------- */

.result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border: 4px solid var(--outline);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--hard-shadow);
  text-align: center;
  animation: drop 0.5s var(--ease);
}

@keyframes drop {
  from { transform: translateY(-14px) scale(0.96); }
}

.result-kicker {
  font-family: var(--font-lcd);
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.result-answer {
  font-size: clamp(2rem, 9vw, 2.6rem);
  font-weight: 900;
  line-height: 1;
  color: var(--yellow);
  -webkit-text-stroke: 2px var(--outline);
  paint-order: stroke fill;
  text-shadow: 0 4px 0 var(--outline);
}

.result-title {
  font-weight: 900;
  color: var(--wrong);
}

.result--won .result-title {
  color: var(--correct);
}

.result-grid {
  display: flex;
  gap: 5px;
}

.cell {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--outline);
  border-radius: 50%;
  background: #fff;
}

.cell--correct { background: var(--correct); }
.cell--wrong { background: var(--wrong); }
.cell--skip { background: var(--skip); }

.big-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  border: 4px solid var(--outline);
  border-radius: var(--radius);
  background: var(--blue-deep);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 900;
  box-shadow: var(--hard-shadow);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}

.big-btn:hover {
  filter: brightness(1.08);
}

.big-btn:active {
  transform: translateY(4px);
  box-shadow: none;
}

.result-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding-top: 10px;
  border-top: 3px dotted rgba(27, 27, 31, 0.25);
  font-size: 0.88rem;
  font-weight: 700;
}

.text-btn {
  border: 0;
  background: none;
  color: var(--a-btn);
  font-weight: 900;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ---- Pie del aparato ---------------------------------------------------- */

.device-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.88);
}

.speaker {
  width: 46px;
  height: 30px;
  flex: none;
  background: repeating-linear-gradient(90deg, var(--outline) 0 4px, transparent 4px 9px);
  border-radius: 4px;
  transform: skewX(-12deg);
  opacity: 0.6;
}

/* Tabletas en vertical: el aparato crece un poco. */
@media (min-width: 640px) {
  .device {
    width: min(100% - 40px, var(--content-wide));
    margin-top: max(28px, env(safe-area-inset-top));
  }
}

/* ---- Avisos ------------------------------------------------------------- */

.toasts {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  padding: 8px 16px;
  border: 3px solid var(--outline);
  border-radius: 12px;
  background: var(--panel);
  font-weight: 900;
  white-space: nowrap;
  box-shadow: 0 3px 0 var(--outline);
  animation: drop 0.35s var(--ease);
  transition: opacity 0.25s, transform 0.25s;
}

.toast--error { background: var(--wrong); color: #fff; }
.toast--success { background: var(--correct); color: #fff; }

.toast--leaving {
  opacity: 0;
  transform: translateY(-8px);
}

/* ---- Diálogos ----------------------------------------------------------- */

.card {
  width: min(100% - 28px, 400px);
  padding: 20px;
  border: 4px solid var(--outline);
  border-radius: 22px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 6px 0 var(--outline);
}

.card[open] {
  animation: pop-in 0.4s var(--ease); /* sin opacidad: si la animación no corre, se ve igual */
}

@keyframes pop-in {
  from { transform: translateY(-14px) scale(0.96); }
}

.card::backdrop {
  background: rgba(27, 27, 31, 0.55);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.card-header h2 {
  font-size: 1.3rem;
  font-weight: 900;
}

.steps {
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps li {
  position: relative;
  padding-left: 38px;
  counter-increment: step;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -2px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 3px solid var(--outline);
  border-radius: 50%;
  background: var(--yellow);
  font-weight: 900;
  font-size: 0.85rem;
}

/* ---- Estadísticas ------------------------------------------------------- */

.stat-numbers {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 0 0 16px;
  text-align: center;
}

.stat-numbers div {
  display: flex;
  flex-direction: column-reverse;
  padding: 8px 2px;
  border: 3px solid var(--outline);
  border-radius: 12px;
  background: #fff;
}

.stat-numbers dd {
  margin: 0;
  font-family: var(--font-lcd);
  font-size: 1.5rem;
}

.stat-numbers dt {
  font-size: 0.66rem;
  font-weight: 800;
  line-height: 1.15;
  text-wrap: balance;
  color: var(--muted);
}

.stat-heading {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 900;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-bars {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stat-bars li {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 8px;
}

.stat-bar-label {
  font-weight: 900;
  text-align: center;
}

.stat-bar {
  width: max(1.9em, calc(var(--fraction) * 100%));
  padding: 1px 8px;
  border: 2.5px solid var(--outline);
  border-radius: 999px;
  background: #fff;
  font-family: var(--font-lcd);
  font-size: 0.85rem;
  text-align: right;
}

.stat-bar--highlight {
  background: var(--yellow);
}

/* ---- Celebración: racha, confeti y preguntas extra ------------------------- */

.stage.is-celebrating {
  animation: celebrate 0.6s var(--ease);
}

@keyframes celebrate {
  40% { transform: scale(1.03); }
}

.result-streak {
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--panel);
  font-weight: 800;
}

.result-streak.is-new {
  animation: pop 0.5s var(--ease) 0.3s backwards;
}

/* Confeti (ui/confetti.js): papelitos que salen del centro y caen */
.confetti {
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow: hidden;
  pointer-events: none;
}

.confetti i {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 8px;
  height: 12px;
  border-radius: 2px;
  background: var(--color);
  opacity: 0;
  animation: confetti-fall 1.8s cubic-bezier(0.15, 0.6, 0.4, 1) var(--delay) forwards;
}

.confetti i.round {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

@keyframes confetti-fall {
  0% { opacity: 1; transform: translate(0, 0) rotate(0); }
  45% { opacity: 1; transform: translate(var(--dx), var(--dy)) rotate(calc(var(--spin) / 2)); }
  100% { opacity: 0; transform: translate(calc(var(--dx) * 1.2), calc(var(--dy) + 420px)) rotate(var(--spin)); }
}

.big-btn--quiet {
  background: var(--panel-2);
  color: var(--ink);
}

@keyframes row-in {
  from { opacity: 0; transform: translateY(-6px); }
}

/* ---- Texto para leer (y para los buscadores) bajo la Pokédex --------------- */

.about {
  width: min(100% - 20px, var(--content));
  margin: 0 auto max(24px, env(safe-area-inset-bottom));
  padding: 18px 18px 20px;
  border: 3px solid var(--outline);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--hard-shadow);
}

.about h1 {
  font-size: 1.25rem;
  font-weight: 900;
  line-height: 1.2;
  text-wrap: balance;
}

.about-intro {
  margin-top: 8px;
  color: var(--muted);
}

.about h2 {
  margin-top: 18px;
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.about ol {
  margin: 8px 0 0;
  padding-left: 1.3em;
}

.about li + li {
  margin-top: 4px;
}

.about details {
  border-bottom: 2px dashed var(--panel-2);
}

.about summary {
  padding: 10px 0;
  font-weight: 800;
  cursor: pointer;
}

.about details p {
  padding-bottom: 10px;
  color: var(--muted);
}

@media (min-width: 720px) {
  .about {
    width: min(100% - 40px, var(--content-wide));
  }
}

/* ---- Avisos legales ------------------------------------------------------ */

.about-legal {
  margin-top: 18px;
  padding-top: 12px;
  border-top: 2px dashed var(--panel-2);
  font-size: 0.75rem;
  color: var(--muted);
}

.about-legal a,
.device-foot a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.about-legal a {
  color: var(--a-btn);
  font-weight: 800;
}

.legal-page {
  display: block;
  padding: 24px 0;
}

.about.legal {
  width: min(100% - 32px, 720px);
  line-height: 1.55;
}

.legal p,
.legal ul {
  margin: 8px 0 0;
}

.legal ul {
  padding-left: 1.2em;
}

.legal li + li {
  margin-top: 4px;
}

.legal a {
  color: var(--a-btn);
  font-weight: 800;
}

.legal .legal-back {
  margin: 0;
  text-decoration: none;
}

/* ---- Modos: un cartucho por generación ---------------------------------- */

.mode-chip {
  padding: 3px 8px 3px 6px;
  border: 2.5px solid var(--outline);
  border-radius: 999px;
  background: var(--panel);
  box-shadow: 0 2px 0 var(--outline);
  color: var(--ink);
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}

.mode-chip:hover {
  background: #fff;
}

.mode-chip:active {
  transform: translateY(2px);
  box-shadow: none;
}

.mode-chip .mode-chip-chev {
  width: 1em;
  height: 1em;
  stroke-width: 3;
}

.card--wide {
  width: min(100% - 24px, 600px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}

.modes-intro {
  margin: -4px 0 14px;
  color: var(--muted);
  font-weight: 700;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mode-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "kicker kicker" "name name" "detail status";
  align-items: center;
  gap: 2px;
  padding: 0 0 10px;
  overflow: hidden;
  border: 3px solid var(--outline);
  border-radius: 12px 12px 12px 22px;
  background: #d9d4cc;
  box-shadow: 0 4px 0 var(--outline);
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.08s, box-shadow 0.08s;
}

.mode-card:hover {
  background: #e6e1d8;
}

.mode-card:active {
  transform: translateY(4px);
  box-shadow: none;
}

.mode-card:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

/* Ventanita LCD del cartucho */
.mode-kicker {
  grid-area: kicker;
  margin: 8px 8px 4px;
  padding: 4px 8px;
  border: 2.5px solid var(--outline);
  border-radius: 6px;
  background-color: var(--lcd-0);
  background-image:
    linear-gradient(rgba(15, 56, 15, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 56, 15, 0.06) 1px, transparent 1px);
  background-size: 4px 4px;
  color: var(--lcd-3);
  font-family: var(--font-lcd);
  font-size: 1.05rem;
  line-height: 1.2;
}

.mode-name {
  grid-area: name;
  min-width: 0;
  padding: 0 0 0 10px;
  font-size: 1.05rem;
  font-weight: 900;
  line-height: 1.15;
}

.mode-detail {
  grid-area: detail;
  padding: 0 10px;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

/* Cómo te ha ido hoy: solo si ya has jugado esa región (sin jugar no lleva etiqueta). */
.mode-status {
  grid-area: status;
  justify-self: end;
  margin-right: 8px;
  padding: 1px 7px;
  white-space: nowrap;
  border: 2px solid var(--outline);
  border-radius: 999px;
  background: var(--panel);
  font-size: 0.66rem;
  font-weight: 900;
  line-height: 1.4;
}

.mode-status--won { background: var(--correct); color: #fff; }
.mode-status--lost { background: var(--wrong); color: #fff; }
.mode-status--playing { background: var(--yellow); }
.mode-status--new { display: none; }

.mode-card[aria-current="page"] {
  background: #fff6c2;
  box-shadow: 0 0 0 3px var(--yellow), 0 4px 0 3px var(--outline);
}

.mode-card[aria-current="page"] .mode-status--new,
.mode-card[aria-current="page"] .mode-status--playing {
  border-style: solid;
  background: var(--yellow);
  color: var(--ink);
}

/* Todas mezcladas: el cartucho grande y rojo */
.mode-card--all {
  order: -1; /* arriba del todo: el reto grande */
  grid-column: 1 / -1;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "kicker name status" "kicker detail status";
  column-gap: 4px;
  padding: 0;
  background: linear-gradient(90deg, var(--body-dark), var(--body) 60%, var(--body-light));
  color: #fff;
}

.mode-card--all:hover {
  background: linear-gradient(90deg, var(--body-dark), var(--body-light));
}

.mode-card--all .mode-kicker {
  margin: 10px 6px 10px 10px;
  background: var(--yellow);
  color: var(--ink);
}

.mode-card--all .mode-name {
  align-self: end;
  padding-left: 4px;
}

.mode-card--all .mode-detail {
  align-self: start;
  padding-left: 4px;
  color: rgba(255, 255, 255, 0.85);
}

.mode-card--all .mode-status {
  grid-area: status;
  margin-right: 12px;
}

.modes-progress {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
  text-align: center;
}

#other-mode {
  margin-top: -4px;
}

@media (min-width: 560px) {
  .mode-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* ---- Compartir: WhatsApp grande y el resto en pastillas ----------------- */

.share-box {
  display: grid;
  gap: 10px;
  width: 100%;
  padding: 12px;
  border: 3px solid var(--outline);
  border-radius: 18px;
  background: #fff;
  /* Fondo de chat: puntitos suaves */
  background-image: radial-gradient(rgba(27, 27, 31, 0.06) 1.2px, transparent 1.2px);
  background-size: 12px 12px;
}

.share-title {
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}

.share-wa {
  --wa: #1f9e55; /* verde con texto blanco >= 4.5:1 */
  background: var(--wa);
  text-decoration: none;
}

.share-wa svg {
  width: 1.5em;
  height: 1.5em;
  stroke-width: 1.8;
}

.share-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  grid-auto-flow: column;
  gap: 8px;
}

.share-pill {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 56px;
  padding: 6px 4px;
  border: 3px solid var(--outline);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 3px 0 var(--outline);
  color: var(--ink);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}

.share-pill[hidden] {
  display: none;
}

.share-pill svg {
  width: 1.35em;
  height: 1.35em;
  stroke-width: 2;
}

.share-pill:hover {
  background: #fff;
}

.share-pill:active,
.share-wa:active {
  transform: translateY(3px);
  box-shadow: none;
}

.share-pill--tg svg { color: #229ed9; }
.share-pill--x svg { color: var(--ink); }

.share-pill:focus-visible,
.share-wa:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

/* ---- Pista: tecla "select" a la izquierda del mando y lista en el registro ---- */

/* En móvil, la tecla de pista ocupa el hueco de la izquierda (antes vacío). */
.pad {
  justify-content: space-between;
}

.key--hint {
  margin-bottom: 18px;
}

.key--hint .key-face {
  width: 72px;
  height: 40px;
  border-radius: 999px;
  background: var(--blue-deep);
}

.key--hint .key-face svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
}

.key--hint[aria-expanded="true"] .key-face {
  background: var(--yellow);
  color: var(--ink);
  transform: translateY(5px);
  box-shadow: none;
}

.key--hint:disabled .key-face {
  background: #8a4a4a;
}

/* La pista que tocó, fija en lo alto del registro. */
.hint-line {
  margin-bottom: 10px;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--lcd-1);
  color: var(--lcd-3);
  font-size: 1rem;
  line-height: 1.3;
}

.hint-line.is-new {
  animation: hint-in 0.6s steps(4) 1;
}

@keyframes hint-in {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}

/* ---- Pokédex del jugador ------------------------------------------------ */

.result-dex {
  padding: 6px 14px;
  border: 3px solid var(--outline);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 900;
  box-shadow: 0 3px 0 var(--outline);
  cursor: pointer;
}

.result-dex--caught {
  background: var(--yellow);
}

.result-dex:active {
  transform: translateY(3px);
  box-shadow: none;
}

.result-links {
  display: flex;
  gap: 14px;
}

.dex-summary {
  display: flex;
  align-items: baseline;
  gap: 18px;
  margin-bottom: 12px;
  font-weight: 800;
}

.dex-summary p {
  white-space: nowrap;
}

.dex-summary strong {
  font-size: 1.6rem;
  font-weight: 400;
}

.dex-summary p:first-child strong {
  color: var(--correct);
}

.dex-total {
  margin-left: auto;
  color: var(--muted);
}

.dex-tabs {
  display: flex;
  gap: 6px;
  margin: 0 -4px 12px;
  padding: 4px 4px 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.dex-tab {
  display: grid;
  flex: none;
  gap: 1px;
  padding: 5px 10px;
  border: 2.5px solid var(--outline);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1.1;
  text-align: left;
  box-shadow: 0 3px 0 var(--outline);
  cursor: pointer;
}

.dex-tab-count {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--muted);
}

.dex-tab[aria-selected="true"] {
  background: var(--lcd-3);
  color: var(--lcd-0);
  transform: translateY(3px);
  box-shadow: none;
}

.dex-tab[aria-selected="true"] .dex-tab-count {
  color: var(--lcd-1);
}

/* Rejilla tipo LCD: casillas pequeñas; lo capturado a color, lo visto en silueta. */
/* Ocupa casi toda la ventana: cabecera, resumen y pestañas quedan fijos y solo la
   rejilla hace scroll (así se ven muchas casillas a la vez y no hay doble scroll). */
.card--dex {
  width: min(100% - 24px, 1280px);
  height: calc(100dvh - 24px);
  max-width: none;
  max-height: calc(100dvh - 24px);
  overflow: hidden;
}

.card--dex[open] {
  display: flex;
  flex-direction: column;
}

.card--dex > :not(.dex-grid) {
  flex: none;
}

.card--dex .dex-grid {
  flex: 1 1 auto;
  min-height: 0;
  align-content: start;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* El aviso de "aún no hay nada" va en la primera fila, sin la altura de una casilla. */
.dex-grid:has(.dex-empty) {
  grid-template-rows: auto;
}

/* Con un diálogo abierto, la página de detrás no se mueve. */
html:has(dialog[open]) {
  overflow: hidden;
}

dialog {
  overscroll-behavior: contain;
}

@media (min-width: 900px) and (min-height: 540px) {
  .card--dex {
    width: min(100% - 64px, 1280px);
    height: calc(100dvh - 64px);
    max-height: calc(100dvh - 64px);
    padding: 24px 28px;
  }

  .card--dex .dex-grid {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    grid-auto-rows: 124px;
    gap: 8px;
    padding: 10px;
  }

  .card--dex .dex-art {
    width: 72px;
    height: 72px;
  }
}

.dex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  grid-auto-rows: 104px; /* todas iguales: la rejilla no baila entre vistos y vacíos */
  gap: 6px;
  margin: 0;
  padding: 8px;
  list-style: none;
  border: 3px solid var(--outline);
  border-radius: 12px;
  background-color: var(--lcd-0);
  background-image:
    linear-gradient(rgba(15, 56, 15, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 56, 15, 0.06) 1px, transparent 1px);
  background-size: 4px 4px;
  font-family: var(--font-lcd);
  color: var(--lcd-3);
}

.dex-slot {
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: center;
  align-items: center;
  min-width: 0;
  padding: 4px 4px 6px;
  border-radius: 8px;
  text-align: center;
}

.dex-slot--caught {
  background: rgba(255, 255, 255, 0.55);
  box-shadow: inset 0 0 0 2px var(--lcd-2);
}

.dex-slot--seen {
  box-shadow: inset 0 0 0 2px rgba(48, 98, 48, 0.4);
}

.dex-slot--unknown {
  grid-template-rows: 1fr;
  border: 2px dashed rgba(48, 98, 48, 0.3);
  color: rgba(15, 56, 15, 0.45);
}

.dex-num {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.dex-art {
  width: 60px;
  height: 60px;
  object-fit: contain;
}

.dex-slot--seen .dex-art {
  filter: brightness(0) opacity(0.75);
}

.dex-name {
  max-width: 100%;
  overflow: hidden;
  font-size: 0.8rem;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dex-slot--seen .dex-name {
  color: var(--lcd-2);
}

.dex-empty {
  grid-column: 1 / -1;
  grid-row: 1;
  align-self: center;
  order: -1;
  padding: 6px 4px 10px;
  font-size: 0.95rem;
}

/* Móvil estrecho: cabeceras más compactas para que quepan los cuatro botones. */
@media (max-width: 420px) {
  .lens {
    width: 46px;
    height: 46px;
  }

  .lens-glass {
    width: 30px;
    height: 30px;
  }

  .round-btn {
    width: 36px;
    height: 36px;
  }

  .dex-grid {
    grid-template-columns: repeat(auto-fill, minmax(66px, 1fr));
    grid-auto-rows: 92px;
    padding: 6px;
  }

  .dex-art {
    width: 50px;
    height: 50px;
  }

  .dex-name {
    font-size: 0.72rem;
  }

  .dex-summary {
    gap: 12px;
    font-size: 0.92rem;
  }

  .dex-summary strong {
    font-size: 1.35rem;
  }

  /* Pie del resultado: la cuenta atrás en una línea y los enlaces debajo. */
  .result-footer {
    flex-direction: column;
    gap: 8px;
  }
}

/* ---- Menú principal: regiones y tu Pokédex ------------------------------- */

/* Las regiones, en el mismo marco gris que la pantalla de juego. */
.home-modes {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 12px 14px;
  border: 4px solid var(--outline);
  border-radius: 14px 14px 14px 42px;
  background: #d9d4cc;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.12);
}

.home-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 0 4px;
}

.home-head h2 {
  font-size: 1.3rem;
  font-weight: 900;
  line-height: 1.1;
}

.home-modes .modes-progress {
  margin: 0;
  font-family: var(--font-lcd);
  font-weight: 400;
  color: var(--a-btn);
  white-space: nowrap;
}

.home-modes .modes-intro {
  margin: -6px 4px 2px;
  font-size: 0.9rem;
}

/* Tu Pokédex: la segunda pantalla, verde oscura, como el registro. */
.home-dex {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.home-dex-screen {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px 14px;
  border: 4px solid var(--outline);
  border-radius: 12px;
  background-color: var(--lcd-3);
  background-image:
    linear-gradient(rgba(227, 242, 176, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(227, 242, 176, 0.04) 1px, transparent 1px);
  background-size: 4px 4px;
  box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.4);
  font-family: var(--font-lcd);
  color: var(--lcd-0);
}

.home-recent {
  margin-top: auto;
}

.home-dex-screen .log-title {
  margin: 0;
  font-weight: 400;
}

.home-dex-total {
  display: flex;
  align-items: baseline;
  gap: 4px;
  line-height: 1;
}

.home-dex-total strong {
  font-size: 3rem;
  font-weight: 400;
  color: #b6f36a;
}

.home-dex-of {
  font-size: 1.2rem;
  color: var(--lcd-1);
}

.home-dex-bar {
  height: 12px;
  border: 2px solid var(--lcd-1);
  border-radius: 3px;
  background: linear-gradient(
    90deg,
    var(--lcd-1) var(--caught),
    rgba(155, 188, 15, 0.35) var(--caught) var(--seen),
    transparent var(--seen)
  );
}

.home-dex-detail {
  font-size: 0.85rem;
  color: rgba(227, 242, 176, 0.75);
}

.home-gens {
  display: grid;
  gap: 4px;
  margin: 2px 0 0;
  padding: 10px 0 0;
  list-style: none;
  border-top: 1px dashed rgba(155, 188, 15, 0.3);
}

.home-gen {
  display: grid;
  grid-template-columns: minmax(0, 9.5em) 1fr 4.2em;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
}

.home-gen-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Barra por generación: lleno = capturados, tenue = vistos. */
.home-gen-bar {
  height: 8px;
  border-radius: 2px;
  background: linear-gradient(
    90deg,
    var(--lcd-1) var(--caught),
    rgba(155, 188, 15, 0.35) var(--caught) var(--seen),
    rgba(227, 242, 176, 0.1) var(--seen)
  );
}

.home-gen-count {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--lcd-1);
}

.home-recent {
  display: grid;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px dashed rgba(155, 188, 15, 0.3);
}

.home-recent-list {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.home-recent-list:empty::before {
  content: attr(data-empty);
  grid-column: 1 / -1;
  font-size: 0.85rem;
  color: rgba(227, 242, 176, 0.7);
}

.home-recent-item {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 8px;
  background: var(--lcd-0);
  box-shadow: inset 0 0 0 2px var(--lcd-1);
}

.home-recent-item img {
  width: 82%;
  height: 82%;
  object-fit: contain;
}

.home-dex .big-btn svg {
  width: 1.4em;
  height: 1.4em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
}

a.big-btn {
  text-decoration: none;
}

/* Cartuchos estrechos (móvil a 2 columnas): rango y estado caben en la misma línea. */
@media (max-width: 420px) {
  .mode-detail {
    padding-right: 4px;
    font-size: 0.72rem;
  }

  .mode-status {
    margin-right: 6px;
    padding: 1px 5px;
  }
}

/* ---- Apoya al creador: discreto, debajo de compartir ----------------------- */

.donate-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 12px;
  width: 100%;
  text-align: center;
}

.donate-text {
  font-size: 0.8rem;
  color: var(--muted);
}

.donate-btn {
  flex-direction: row;
  gap: 6px;
  min-height: 44px;
  padding: 6px 14px;
  font-size: 0.8rem;
}
