/* ==========================================================================
   MATEMÁTICAS CON DADOS — ESTILOS

   Orden del archivo:
     1. Variables (colores, tamaños)
     2. Base
     3. Componentes reutilizables (botones, tarjeta, íconos)
     4. Pantalla de inicio
     5. Pantalla de juego
     6. Pantalla final
     7. Panel de ajustes
     8. Pantallas chicas y grandes
     9. Movimiento reducido

   Convención de nombres (BEM simplificado):
     .bloque            → .answer
     .bloque__parte     → .answer__number
     .bloque--variante  → .button--primary
     .is-estado         → .is-correct, .is-selected
   ========================================================================== */

/* 1. VARIABLES ============================================================= */

:root {
  /* Tema de la operación actual. JavaScript los cambia (render.js → applyTheme). */
  --theme-main: #ffa23a;
  --theme-dark: #e07f12;
  --theme-light: #fff0d6;
  --sky-top: #ffe7b8;
  --sky-bottom: #fff8ea;
  --hills: #b9e48f;

  /* Colores fijos */
  --ink: #2b2d42;
  /* Texto sobre el color de la operación: contraste ≥ 4,5 con los 6 temas. */
  --on-theme: #1a1b29;
  /* ≥ 4,5:1 sobre blanco y sobre el cielo de todos los temas. */
  --muted: #5c5f6e;
  --line: #ece7dc;
  --white: #ffffff;
  --gold: #ffc21a;
  --correct-bg: #e4f8dc;
  --correct-shadow: #9fd88a;
  --orange: #ffa23a;
  --orange-dark: #e07f12;
  --blue: #4f8ef7;
  --blue-dark: #2f6fd8;
  --blue-darker: #1f56b3;
  --wood-light: #f3c98d;
  --wood-dark: #e9b673;
  --wood-edge: #c98b45;
  --wood-shadow: #a96f30;

  /* Tamaños */
  --radius-small: 14px;
  --radius: 20px;
  --radius-large: 28px;
  --cap-size: 52px;
  --cap-size-small: 36px;
  --die-size: 74px;

  /* "Botón grueso": la sombra sólida de abajo da sensación de relieve. */
  --press-depth: 6px;

  --font: 'Fredoka', ui-rounded, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}

/* 2. BASE ================================================================== */

/*
  Fredoka, servida desde este sitio (licencia en fonts/OFL.txt).
  Es una fuente variable: un solo archivo trae todos los pesos, de 300 a 700.
  font-display: swap → mientras carga se ve la letra del sistema, nunca texto invisible.
  El número de versión va en el nombre del archivo: si cambia la fuente, cambia el nombre
  y la caché larga (ver _headers) no sirve la vieja.
*/
@font-face {
  font-family: 'Fredoka';
  src: url('../fonts/fredoka-latin-v17.woff2') format('woff2');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bottom) 70%) fixed;
  /* Sin transition: los degradados no se animan, así que no tenía efecto. */
  /* Evita el zoom por doble toque y la selección de texto al tocar rápido. */
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

/* Oculto a la vista pero lo lee el lector de pantalla. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Los títulos reciben el foco al cambiar de pantalla (render.js), pero no son
   botones: no hace falta dibujarles el contorno. */
[tabindex='-1']:focus {
  outline: none;
}

/* fixed: el aviso queda fuera del flujo de la página. Así, cuando main.js lo
   quita, nada se mueve de lugar (sin esto, Lighthouse medía CLS de 0,049). */
.boot-message {
  position: fixed;
  inset: 40px 0 auto;
  z-index: 2;
  max-width: 520px;
  margin: 0 auto;
  padding: 0 16px;
  color: var(--muted);
  text-align: center;
}

.boot-message code {
  color: var(--ink);
  font-weight: 600;
}

.hills {
  position: fixed;
  inset: auto 0 0 0;
  width: 100%;
  height: 28vh;
  z-index: 0;
  pointer-events: none;
}

.hills path {
  fill: var(--hills);
  transition: fill 0.4s;
}

.hills__back {
  opacity: 0.55;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 0 auto;
  padding: 12px 16px 32px;
}

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

.icon {
  display: block;
  flex-shrink: 0;
}

/* 3. COMPONENTES =========================================================== */

/* Botón genérico */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: 0;
  border-radius: 18px;
  background: var(--white);
  color: var(--ink);
  font-size: 18px;
  font-weight: 600;
  box-shadow: 0 5px 0 #d9d2c2;
}

.button:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #d9d2c2;
}

.button--primary {
  /* --blue-dark y no --blue: el texto blanco necesita contraste 4,5:1. */
  background: var(--blue-dark);
  color: var(--white);
  box-shadow: 0 5px 0 var(--blue-darker);
}

.button--primary:active {
  box-shadow: 0 2px 0 var(--blue-darker);
}

.button--ghost {
  box-shadow: none;
  background: transparent;
}

.button--ghost:active {
  box-shadow: none;
}

/* Botón cuadrado naranja (ajustes) */
.icon-button {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  flex-shrink: 0;
  border: 0;
  border-radius: 16px;
  background: var(--orange);
  color: var(--white);
  box-shadow: 0 5px 0 var(--orange-dark);
}

.icon-button:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--orange-dark);
}

.card {
  padding: 18px 14px;
  border-radius: var(--radius-large);
  background: var(--white);
  box-shadow:
    0 6px 0 rgb(0 0 0 / 5%),
    0 10px 24px rgb(0 0 0 / 6%);
}

/* Contorno visible al navegar con teclado (no aparece al tocar con el dedo). */
:focus-visible {
  outline: 4px solid var(--blue);
  outline-offset: 3px;
}

/* 4. PANTALLA DE INICIO ==================================================== */

.home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.logo {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  color: #d46540; /* el naranja de Sumar, un poco más oscuro: 3:1 sobre el cielo */
  text-shadow: 0 3px 0 var(--white);
}

.logo span {
  color: var(--blue);
}

.hero {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hero__mascot {
  width: 110px;
  height: 110px;
  flex-shrink: 0;
  animation: float 3s ease-in-out infinite;
}

.speech-bubble {
  position: relative;
  margin: 0;
  padding: 12px 18px;
  border-radius: 24px;
  background: var(--white);
  font-size: 22px;
  font-weight: 600;
  box-shadow: 0 5px 16px rgb(0 0 0 / 8%);
}

/* El "piquito" del globo, hecho con bordes transparentes. */
.speech-bubble::before {
  content: '';
  position: absolute;
  left: -10px;
  top: 50%;
  margin-top: -10px;
  border: 10px solid transparent;
  border-left: 0;
  border-right-color: var(--white);
}

.level-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.level-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border: 0;
  border-radius: 18px;
  background: var(--white);
  color: var(--muted);
  box-shadow: 0 4px 0 #e6dcc6;
}

.level-button__name {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.level-button__dice {
  font-size: 12px;
}

.level-button.is-selected {
  background: #ffb020;
  color: var(--on-theme); /* texto oscuro: el blanco sobre este amarillo daba 1,8:1 */
  box-shadow: 0 4px 0 var(--orange-dark);
}

.level-button.is-selected .level-button__name {
  color: var(--on-theme);
}

.operation-tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.operation-tile {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  min-height: 132px;
  padding: 14px 16px;
  border: 0;
  border-radius: var(--radius-large);
  background: var(--tile-main);
  /* El color de la tarjeta no cambia (es el ancla del niño); el texto es oscuro
     porque el blanco no llegaba a 3:1 sobre naranja, rosa y verde. */
  color: var(--on-theme);
  text-align: left;
  box-shadow: 0 7px 0 var(--tile-dark);
}

.operation-tile:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 var(--tile-dark);
}

/* Contar ocupa toda la fila: es el primer paso. */
.operation-tile:first-child {
  grid-column: span 2;
  min-height: 120px;
}

/* Círculos decorativos arriba a la izquierda, como tapitas. */
.operation-tile::before {
  content: '';
  position: absolute;
  top: -14px;
  left: -14px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgb(255 255 255 / 22%);
  box-shadow:
    40px 0 0 rgb(255 255 255 / 22%),
    80px 0 0 rgb(255 255 255 / 22%);
}

.operation-tile__icon {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--white);
  color: var(--tile-main);
  box-shadow: 0 4px 0 rgb(0 0 0 / 12%);
}

.operation-tile__name {
  font-size: 24px;
  font-weight: 700;
  text-shadow: 0 2px 0 rgb(255 255 255 / 35%);
}

.operation-tile__dice {
  font-size: 14px;
}

/* 5. PANTALLA DE JUEGO ===================================================== */

/* --- Barra superior --- */

.top-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 58px;
  height: 58px;
  flex-shrink: 0;
  padding: 3px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 4px 0 rgb(0 0 0 / 8%);
}

.avatar.is-bouncing {
  animation: hop 0.6s ease;
}

.progress {
  position: relative;
  flex: 1;
  height: 26px;
  overflow: hidden;
  border: 4px solid var(--white);
  border-radius: 999px;
  background: rgb(255 255 255 / 70%);
}

.progress__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe066, var(--gold));
  transition: width 0.5s ease;
}

.progress__text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  color: #6c530c; /* 4,5:1 sobre el dorado de la barra */
}

/* --- Operación y pregunta --- */

.operation-chip {
  align-self: center;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 5px 16px 5px 6px;
  border-radius: 999px;
  background: var(--theme-main);
  color: var(--on-theme); /* ≥ 4,5:1 con los 6 temas */
  font-size: 16px;
  font-weight: 600;
  box-shadow: 0 4px 0 var(--theme-dark);
}

.operation-chip__icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--white);
  color: var(--theme-main);
}

.prompt {
  align-self: center;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 8px 20px 8px 8px;
  border: 0;
  border-radius: 999px;
  background: var(--white);
  font-size: 20px;
  font-weight: 600;
  text-align: left;
  box-shadow: 0 5px 16px rgb(0 0 0 / 8%);
}

.prompt__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--theme-light);
  color: var(--theme-dark);
}

/* --- Distribución --- */

.game-layout,
.game-layout__main,
.game-layout__side {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --- Dados --- */

.dice-row {
  display: flex;
  flex-wrap: nowrap; /* la operación siempre en una línea; en celular los dados se achican */
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 80px;
}

.dice-row__symbol {
  color: var(--theme-dark);
}

.dice-row__total {
  min-width: 56px;
  font-size: 50px;
  font-weight: 700;
  text-align: center;
  color: var(--theme-dark);
}

.die {
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  width: var(--die-size);
  height: var(--die-size);
  padding: calc(var(--die-size) * 0.1);
  border: calc(var(--die-size) * 0.068) solid var(--edge);
  border-radius: calc(var(--die-size) * 0.27);
  background: var(--white);
  box-shadow: 0 5px 0 #e6e0d3;
}

.die__pip {
  width: calc(var(--die-size) * 0.165);
  height: calc(var(--die-size) * 0.165);
  align-self: center;
  justify-self: center;
  border-radius: 50%;
  background: var(--edge);
  box-shadow: inset 0 -2px 0 rgb(0 0 0 / 18%);
}

.result-box {
  display: grid;
  place-items: center;
  width: 70px;
  height: 70px;
  border: 4px dashed var(--theme-main);
  border-radius: 20px;
  background: var(--theme-light);
  font-size: 38px;
  font-weight: 700;
  color: var(--theme-dark);
}

/* --- Mesa de madera --- */

.wood-table {
  padding: 14px;
  border: 7px solid var(--wood-edge);
  border-radius: 30px;
  /* Tablas: una franja oscura cada 61 px. */
  background: repeating-linear-gradient(90deg, var(--wood-light) 0 58px, var(--wood-dark) 58px 61px);
  box-shadow:
    inset 0 4px 0 rgb(255 255 255 / 35%),
    0 6px 0 var(--wood-shadow);
}

.table {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 130px;
}

.table__symbol {
  color: var(--theme-dark);
}

/* --- Tapitas --- */

.cap-group {
  display: grid;
  grid-template-columns: repeat(var(--columns), auto);
  gap: 8px;
  padding: 10px;
  border: 3px dashed var(--edge);
  border-radius: var(--radius);
  background: rgb(255 255 255 / 62%);
}

.cap {
  display: grid;
  place-items: center;
  width: var(--cap-size);
  height: var(--cap-size);
  padding: 0;
  border: 3px dashed rgb(255 255 255 / 45%);
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--cap-shine), var(--cap-base));
  color: var(--cap-text);
  font-size: 21px;
  font-weight: 700;
  box-shadow:
    0 4px 0 rgb(0 0 0 / 25%),
    inset 0 2px 4px rgb(255 255 255 / 45%);
  transition:
    transform 0.15s ease,
    opacity 0.2s ease;
}

.cap:active {
  transform: scale(0.9);
}

.cap--small {
  width: var(--cap-size-small);
  height: var(--cap-size-small);
  font-size: 15px;
  border-width: 2px;
}

.cap--counted {
  outline: 4px solid var(--gold);
  outline-offset: 2px;
}

.cap--highlighted {
  transform: scale(1.22);
}

.cap--removed {
  opacity: 0.22;
  transform: scale(0.78);
}

/* --- Restar: la caja donde se guardan --- */

.storage-box {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 18px;
  background: var(--white);
  color: #b07a3a;
  font-size: 22px;
  font-weight: 600;
  box-shadow: 0 4px 0 rgb(0 0 0 / 12%);
}

.storage-box span {
  color: var(--ink);
}

/* --- Platos (Multiplicar y Dividir) --- */

.plates {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

.plate {
  display: flex;
  flex: 1 1 30%;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 5px;
  min-width: 96px;
  max-width: 170px;
  min-height: 104px;
  padding: 14px;
  border: 4px solid #dfe3ea;
  border-radius: 999px;
  background: var(--white);
  box-shadow:
    inset 0 0 0 7px #f3f5f8,
    0 4px 0 rgb(0 0 0 / 12%);
  cursor: pointer;
}

/* En Multiplicar el plato lleva el borde del color del dado 1. */
.plate--full {
  flex: 0 1 auto;
  max-width: none;
  gap: 8px;
  border-color: var(--edge);
  background: #fffdf7;
  box-shadow: 0 4px 0 rgb(0 0 0 / 12%);
  cursor: default;
}

.plate--full .cap-group {
  gap: 5px;
  padding: 6px;
}

/* --- Modo tapitas reales --- */

.real-caps {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 460px;
  padding: 14px;
  border-radius: 22px;
  background: rgb(255 255 255 / 80%);
  text-align: center;
}

.real-caps__icon {
  color: #e0a050;
}

.real-caps p {
  margin: 0;
  font-size: 19px;
  font-weight: 500;
}

/* --- Respuestas --- */

.answers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 12px;
  border-radius: 30px;
  background: var(--theme-light);
  box-shadow: 0 6px 0 rgb(0 0 0 / 6%);
}

.answer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 118px;
  padding: 10px 4px 12px;
  border: 0;
  border-radius: 24px;
  background: var(--white);
  color: var(--answer-color);
  box-shadow:
    0 7px 0 #d9d2c2,
    inset 0 -4px 0 #f3eee4;
}

.answer:active {
  transform: translateY(4px);
  box-shadow: 0 3px 0 #d9d2c2;
}

/* aria-disabled y no disabled: un botón disabled pierde el foco del teclado
   mientras la app ayuda, y quien usa teclado tendría que volver a buscarlo. */
.answer[aria-disabled='true'] {
  opacity: 0.55;
  cursor: default;
}

.answer__number {
  font-size: 54px;
  font-weight: 700;
  line-height: 1;
}

/* Puntos debajo del número: en filas de 5, como los dedos de una mano. */
.answer__dots {
  display: grid;
  grid-template-columns: repeat(5, 10px);
  gap: 4px;
  min-height: 10px;
}

.answer__dots i {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.45;
}

.answer.is-correct {
  background: var(--correct-bg);
  box-shadow: 0 7px 0 var(--correct-shadow);
}

.answer.is-pulsing {
  animation: pulse 1.1s ease-in-out infinite;
  box-shadow:
    0 7px 0 var(--gold),
    0 0 0 4px var(--gold);
}

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

/* --- Guía para el adulto --- */

.adult-guide {
  padding: 10px 14px;
  border-radius: 18px;
  background: rgb(255 255 255 / 85%);
  color: #3d4052;
  font-size: 15px;
}

.adult-guide summary {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  cursor: pointer;
  list-style: none; /* oculta el triángulo por defecto */
}

.adult-guide summary::-webkit-details-marker {
  display: none;
}

.adult-guide__chevron {
  margin-left: auto;
  transition: transform 0.2s;
}

.adult-guide[open] .adult-guide__chevron {
  transform: rotate(180deg);
}

.adult-guide ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.adult-guide li {
  margin: 4px 0;
}

/* 6. PANTALLA FINAL ======================================================== */

.screen--end {
  align-items: center;
  justify-content: center;
  min-height: 90dvh;
  text-align: center;
}

.end__mascot {
  width: 150px;
  height: 150px;
  animation: float 3s ease-in-out infinite;
}

.end__stars {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  color: var(--gold);
}

.end__stars .icon {
  fill: var(--gold); /* Lucide dibuja contornos; aquí rellenamos la estrella. */
}

.end__title {
  margin: 0;
  font-size: 34px;
  color: var(--theme-dark);
}

.end__text {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 18px;
  color: var(--muted);
}

/* Los botones aparecen a los 4 segundos (TIMING.endButtonsDelay). */
.end__buttons {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.end__buttons.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* 7. PANEL DE AJUSTES ====================================================== */
/* Sobrio a propósito: es para el adulto, no para el niño. */

.settings {
  width: min(560px, 100% - 24px);
  max-height: 90dvh;
  padding: 0;
  border: 0;
  border-radius: 26px;
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    Arial,
    sans-serif;
  color: var(--ink);
  user-select: text;
}

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

.settings::backdrop {
  background: rgb(15 23 42 / 55%);
}

.settings__header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.settings__header h2 {
  margin: 0;
  font-size: 19px;
}

.settings__body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 20px;
}

.settings__footer {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}

.settings__footer .button--primary {
  flex: 1;
  font-size: 16px;
}

.settings__footer .button {
  font-size: 16px;
  padding: 10px 12px;
}

.settings-section {
  margin: 12px 0;
  padding: 0;
  border: 0;
}

.settings-section legend {
  padding: 0;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.settings-note {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.settings-warning {
  margin: 8px 0 0;
  padding: 8px 12px;
  border-radius: 10px;
  background: #fff4e5;
  color: #7a3e00;
  font-size: 14px;
  font-weight: 600;
}

.settings-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-weight: 600;
}

/* Botones de opción con aspecto de pastilla. El <input> real queda oculto
   pero sigue funcionando con teclado y lector de pantalla. */
.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* relative: el <input> oculto se ubica sobre su propia pastilla. Sin esto, al
   enfocarlo con el teclado el panel podía saltar a otra posición. */
.pill {
  position: relative;
}

.pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pill span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px; /* objetivo táctil del proyecto */
  padding: 7px 14px;
  border: 2px solid var(--line);
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
}

.pill input:checked + span {
  border-color: #4f46e5;
  background: #eef2ff;
  color: #3730a3;
}

.pill input:focus-visible + span {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

.pill.is-disabled span {
  opacity: 0.35;
  cursor: not-allowed;
}

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
  font-weight: 600;
}

.switch input {
  width: 20px;
  height: 20px;
  accent-color: #4f46e5;
}

select {
  padding: 6px 8px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--white);
  font: inherit;
}

.dice-colors,
.inventory {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 14px;
}

.inventory__item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.inventory__swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--cap-shine), var(--cap-base));
  box-shadow: 0 2px 0 rgb(0 0 0 / 20%);
}

.inventory__name {
  flex: 1;
  font-weight: 600;
  font-size: 14px;
}

.inventory output {
  width: 24px;
  font-weight: 700;
  text-align: center;
}

.stepper {
  display: grid;
  place-items: center;
  width: 44px; /* objetivo táctil del proyecto (WCAG 2.2 pide 24 px como mínimo) */
  height: 44px;
  padding: 0;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
}

.link-button {
  margin-top: 8px;
  padding: 0;
  border: 0;
  background: none;
  min-height: 44px;
  color: #4f46e5;
  font-weight: 600;
  text-decoration: underline;
}

/* 8. PANTALLAS CHICAS Y GRANDES ============================================ */

/* Celular angosto */
@media (max-width: 520px) {
  /* Sumar: los grupos se apilan con un "+" entre ellos. */
  .table[data-operation='sumar'] {
    flex-direction: column;
    gap: 6px;
  }

  /* Con 3 o 4 dados, los dados se achican para caber en una línea. */
  .dice-row[data-dice='3'] {
    --die-size: 60px;
    gap: 4px;
  }

  .dice-row[data-dice='4'] {
    --die-size: 42px;
    gap: 2px;
  }

  .dice-row[data-dice='3'] .icon,
  .dice-row[data-dice='4'] .icon {
    width: 22px;
    height: 22px;
  }

  .dice-row[data-dice='3'] .result-box,
  .dice-row[data-dice='4'] .result-box {
    width: 50px;
    height: 50px;
    font-size: 26px;
    border-width: 3px;
    border-radius: 14px;
  }

  .dice-colors,
  .inventory {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 380px) {
  .answer__number {
    font-size: 46px;
  }

  .prompt {
    font-size: 18px;
  }
}

/* Tablet: 3 tarjetas por fila en el inicio */
@media (min-width: 640px) {
  .operation-tiles {
    grid-template-columns: repeat(3, 1fr);
  }

  .operation-tile:first-child {
    grid-column: auto;
    min-height: 132px;
  }

  .hero__mascot {
    width: 130px;
    height: 130px;
  }
}

/* Escritorio: dos columnas en el juego y las 5 tarjetas en una fila */
@media (min-width: 1000px) {
  .app {
    max-width: 1200px;
  }

  .operation-tiles {
    grid-template-columns: repeat(5, 1fr);
  }

  .operation-tile {
    min-height: 170px;
  }

  .operation-tile:first-child {
    min-height: 170px;
  }

  .game-layout {
    display: grid;
    grid-template-columns: 3fr 2fr;
    align-items: start;
    gap: 20px;
  }
}

/* 9. ANIMACIONES Y MOVIMIENTO REDUCIDO ===================================== */

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

@keyframes hop {
  0%,
  100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-12px) rotate(-6deg);
  }
  60% {
    transform: translateY(0) rotate(4deg);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  75% {
    transform: translateX(6px);
  }
}

/* Si el sistema pide menos movimiento, se apagan animaciones y transiciones. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
