/* ==========================================================================
   granja.css — Estilos de La Granja de Noa
   Móvil primero. Sin dependencias. Fuentes locales (licencia OFL).
   ========================================================================== */

@font-face { font-family: "Fredoka"; font-weight: 500; font-display: swap; src: url("../fonts/fredoka-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Fredoka"; font-weight: 600; font-display: swap; src: url("../fonts/fredoka-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Fredoka"; font-weight: 700; font-display: swap; src: url("../fonts/fredoka-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 600; font-display: swap; src: url("../fonts/nunito-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 700; font-display: swap; src: url("../fonts/nunito-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 800; font-display: swap; src: url("../fonts/nunito-latin-800-normal.woff2") format("woff2"); }

:root {
  --tinta: #3a2a4a;
  --tinta-suave: #5d4c6e;
  --crema: #fff8ec;
  --papel: #fffdf7;
  --cielo: #8fd3ff;
  --cielo-claro: #dff3ff;
  --pasto: #6cc24f;
  --pasto-osc: #4a9a35;
  --pasto-claro: #c9ecaf;
  --parcela-a: #c5eaa6;
  --parcela-b: #ddf3c8;
  --tierra: #e3b779;
  --tierra-clara: #f6e7c8;
  --madera: #a8693a;
  --madera-osc: #6e4223;
  --rojo: #e94b5b;
  --naranja: #ff9f43;
  --amarillo: #ffd23f;
  --azul: #3f7fd9;
  --azul-claro: #d6e6ff;
  --verde-ok: #2f9e44;
  --sombra: 0 4px 0 rgba(58, 42, 74, .25);
  --radio: 18px;
  --fuente-titulo: "Fredoka", "Trebuchet MS", "Arial Rounded MT Bold", system-ui, sans-serif;
  --fuente: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --seguro-arriba: env(safe-area-inset-top, 0px);
  --seguro-abajo: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--fuente);
  font-weight: 700;
  color: var(--tinta);
  background: linear-gradient(180deg, var(--cielo-claro) 0%, #eef9e4 55%, #e2f4d2 100%);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
a { color: var(--azul); }
:focus-visible { outline: 3px solid var(--azul); outline-offset: 2px; }
.sin-js { padding: 2rem; text-align: center; }

/* ---------------------------------------------------------- Pantallas -- */
.pantalla { min-height: 100%; display: flex; flex-direction: column; }

/* ---------------------------------------------------------- Botones ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  min-height: 48px; padding: .6em 1.1em; border-radius: 16px;
  border: 3px solid var(--tinta); box-shadow: var(--sombra);
  font-family: var(--fuente-titulo); font-weight: 600; font-size: 1.05rem;
  background: #fff; transition: transform .12s, box-shadow .12s;
  text-decoration: none;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(58, 42, 74, .25); }
.btn-principal {
  flex-direction: column; gap: 0; width: 100%;
  background: linear-gradient(180deg, #ffde59 0%, #ffc21a 100%);
  font-size: 1.7rem; padding: .45em 1em .5em; min-height: 72px;
}
.btn-principal .btn-sub { font-family: var(--fuente); font-size: .9rem; font-weight: 800; opacity: .8; }
.btn-sec { background: #fff; }
.btn-ok { background: linear-gradient(180deg, #8fe06d, #5cbf3e); }
.btn-peligro { background: #ffe1e4; border-color: #a12b3a; color: #8a1f2c; margin-top: 1rem; }
.btn-icono {
  width: 46px; height: 46px; flex: none; display: grid; place-items: center; padding: 0;
  border-radius: 14px; border: 3px solid var(--tinta); background: #fff; box-shadow: var(--sombra);
  font-size: 1.3rem;
}
.btn-icono:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(58, 42, 74, .25); }
.btn-icono svg { width: 24px; height: 24px; fill: none; stroke: var(--tinta); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.btn-icono svg .i-altavoz { fill: var(--tinta); }
.btn-icono .i-mute { display: none; }
.btn-icono[aria-pressed="false"] .i-ondas { display: none; }
.btn-icono[aria-pressed="false"] .i-mute { display: inline; stroke: var(--rojo); }

/* ------------------------------------------------------------ Inicio ---- */
#pantalla-inicio { align-items: center; padding-bottom: var(--seguro-abajo); }
.inicio-cab {
  width: 100%; max-width: 1100px; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--seguro-arriba)) 16px 0; position: relative; z-index: 2;
}
.logo-playlab img { display: block; width: 116px; height: auto; filter: drop-shadow(0 3px 0 rgba(58,42,74,.15)); }
.cab-botones { display: flex; gap: 10px; }

.inicio-hero { position: relative; width: 100%; max-width: 1100px; padding: 0 12px; }
.escena-wrap {
  width: 100%; aspect-ratio: 16 / 10; overflow: hidden; border-radius: 24px;
  border: 3px solid var(--tinta); box-shadow: var(--sombra); background: var(--cielo);
}
.escena-wrap .escena { width: 100%; height: 100%; display: block; }
.inicio-titulo { position: relative; z-index: 2; text-align: center; margin: -6px 0 10px; pointer-events: none; }
.inicio-titulo h1 {
  margin: 0; font-family: var(--fuente-titulo); font-weight: 700; line-height: .95;
  font-size: clamp(2.3rem, 9vw, 4.6rem); color: #fff;
  -webkit-text-stroke: 3px var(--tinta); paint-order: stroke fill;
  text-shadow: 0 5px 0 var(--tinta);
  letter-spacing: .01em;
}
.inicio-titulo h1 .t1 { color: #fff7d6; }
.inicio-titulo h1 .t2 { color: var(--amarillo); }
.inicio-titulo .lema {
  display: inline-block; margin: .5rem 0 0; padding: .25em .9em; border-radius: 999px;
  background: var(--rojo); color: #fff; border: 3px solid var(--tinta); font-family: var(--fuente-titulo);
  font-weight: 600; font-size: clamp(.95rem, 3.4vw, 1.3rem); transform: rotate(-2deg);
}
.inicio-noa { position: absolute; left: 18px; bottom: 3px; display: flex; align-items: flex-end; gap: 4px; pointer-events: none; }
.noa-pos { width: clamp(84px, 17vw, 150px); }
.noa-pos .noa { width: 100%; height: auto; display: block; }
.bocadillo {
  position: relative; margin: 0; background: #fff; border: 3px solid var(--tinta); border-radius: 16px;
  padding: .5em .8em; font-size: .95rem; line-height: 1.3; box-shadow: var(--sombra);
}
.bocadillo-inicio { max-width: 190px; margin-bottom: 62%; font-size: clamp(.82rem, 2.4vw, 1rem); }
.bocadillo-inicio::before {
  content: ""; position: absolute; left: -12px; bottom: 14px; width: 18px; height: 18px; background: #fff;
  border-left: 3px solid var(--tinta); border-bottom: 3px solid var(--tinta); transform: rotate(45deg);
}

.inicio-panel {
  width: 100%; max-width: 560px; padding: 22px 16px 8px; display: flex; flex-direction: column; gap: 14px;
}
.aviso-almacen {
  background: #fff3cd; border: 2px solid #b8860b; border-radius: 12px; padding: .6em .8em; font-size: .9rem;
}
.progreso-inicio { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; font-size: .95rem; }
.chip {
  display: inline-flex; align-items: center; gap: .35em; padding: .25em .7em; border-radius: 999px;
  background: #fff; border: 2px solid var(--tinta); font-weight: 800;
}
.chip .estrella { width: 18px; height: 18px; color: var(--amarillo); }
.fila-botones { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.fila-botones .btn { font-size: .95rem; padding: .5em .4em; }

.selector-modo { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.modo-op {
  display: flex; flex-direction: column; align-items: center; padding: .45em .5em; border-radius: 14px;
  border: 3px solid var(--tinta); background: #fff; box-shadow: var(--sombra); line-height: 1.15;
}
.modo-op strong { font-family: var(--fuente-titulo); font-weight: 600; font-size: 1.05rem; }
.modo-op small { font-size: .78rem; opacity: .8; }
.modo-op[aria-checked="true"] { background: var(--azul-claro); border-color: var(--azul); box-shadow: 0 4px 0 var(--azul); }
.modo-op[aria-checked="true"] strong::before { content: "✓ "; color: var(--azul); }

.pie { margin-top: auto; padding: 12px 16px calc(14px + var(--seguro-abajo)); font-size: .82rem; text-align: center; opacity: .85; }
.pie p { margin: 0; }

/* ------------------------------------------------------------- Barras --- */
.barra {
  display: flex; align-items: center; gap: 10px;
  padding: calc(8px + var(--seguro-arriba)) 12px 8px;
  background: linear-gradient(180deg, #8bd46e, #6cc24f); border-bottom: 3px solid var(--tinta);
  position: sticky; top: 0; z-index: 5;
}
.barra-titulo { flex: 1; margin: 0; font-family: var(--fuente-titulo); font-weight: 700; font-size: 1.35rem; color: #fff; -webkit-text-stroke: 1.5px var(--tinta); paint-order: stroke fill; }
.barra-estrellas { display: flex; align-items: center; gap: 4px; font-family: var(--fuente-titulo); font-size: 1.15rem; background: #fff; border: 2px solid var(--tinta); padding: .15em .6em; border-radius: 999px; }
.barra-estrellas .estrella { width: 20px; height: 20px; color: var(--amarillo); }

/* --------------------------------------------------------------- Mapa --- */
.mapa-cuerpo { width: 100%; max-width: 980px; margin: 0 auto; padding: 12px; display: grid; gap: 14px; }
.mapa {
  position: relative; width: 100%; max-width: 520px; margin: 0 auto; aspect-ratio: 360 / 760; max-height: 1100px;
  border: 3px solid var(--tinta); border-radius: 24px; overflow: hidden; box-shadow: var(--sombra);
}
.mapa-svg, .mapa-svg svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.paradas { list-style: none; margin: 0; padding: 0; }
.parada { position: absolute; transform: translate(-50%, -50%); width: 56%; max-width: 230px; }
.mapa.apaisado { max-width: 1100px; aspect-ratio: 1000 / 520; }
.mapa.apaisado .parada { width: 21%; }
.parada-btn {
  width: 100%; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto auto; column-gap: 8px; align-items: center;
  text-align: left; padding: 8px 10px; border-radius: 18px; border: 3px solid var(--tinta); background: var(--papel);
  box-shadow: var(--sombra); line-height: 1.15;
}
.parada-ic {
  grid-row: 1 / 4; width: 56px; height: 56px; border-radius: 50%; border: 3px solid var(--tinta); background: var(--pasto-claro);
  display: grid; place-items: center; position: relative;
}
.parada-ic svg { width: 46px; height: 46px; }
.parada-num {
  position: absolute; top: -8px; left: -8px; width: 26px; height: 26px; border-radius: 50%; background: var(--amarillo);
  border: 2px solid var(--tinta); display: grid; place-items: center; font-family: var(--fuente-titulo); font-size: .95rem;
}
.parada-nombre { font-family: var(--fuente-titulo); font-weight: 600; font-size: 1rem; line-height: 1.05; }
@media (max-width: 420px) { .parada-nombre { font-size: .92rem; } .parada-ic { width: 48px; height: 48px; } .parada-ic svg { width: 40px; height: 40px; } .parada-btn { padding: 7px 8px; } }
.parada-dif { font-size: .76rem; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.puntos-dif { display: inline-flex; gap: 2px; }
.puntos-dif i { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--tinta); background: #fff; display: inline-block; }
.puntos-dif i.on { background: var(--rojo); }
.parada-est { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-size: .74rem; }
.parada-est .estrella { width: 17px; height: 17px; color: #e3dccd; }
.parada-est .estrella.on { color: var(--amarillo); }
.estado-et { margin-left: 4px; padding: 0 .4em; border-radius: 6px; background: var(--azul-claro); }
.parada.completado .estado-et { background: #d3f9d8; }
.parada.bloqueado .parada-btn { background: #ece7df; padding-right: 30px; }
.parada.bloqueado .parada-ic { background: #d6d1c8; filter: grayscale(.9); }
.parada.bloqueado .estado-et { background: #e9e2d6; }
.parada.bloqueado .parada-btn::after {
  content: ""; position: absolute; right: 8px; top: 8px; width: 22px; height: 22px;
  background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='5' y='10' width='14' height='11' rx='2.5' fill='%23b9b1a4' stroke='%233a2a4a' stroke-width='1.6'/%3E%3Cpath d='M8 10V7.5a4 4 0 0 1 8 0V10' fill='none' stroke='%233a2a4a' stroke-width='2'/%3E%3C/svg%3E");
}
.parada-btn { position: relative; }
.parada.actual .parada-btn { border-color: var(--azul); box-shadow: 0 0 0 4px rgba(63, 127, 217, .35), var(--sombra); animation: latido 1.8s ease-in-out 4; }
.oculto-zorro .parada-btn::before { content: "Próximamente"; }

.mi-granja { background: var(--papel); border: 3px solid var(--tinta); border-radius: var(--radio); padding: 12px 14px; box-shadow: var(--sombra); max-width: 520px; width: 100%; margin: 0 auto; }
.mi-granja h3 { margin: 0; font-family: var(--fuente-titulo); font-weight: 600; font-size: 1.3rem; }
.mi-granja-txt { margin: .2em 0 .6em; font-size: .9rem; }
.recompensas { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.recompensas li { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 12px; border: 2px dashed #bfb6a8; font-size: .85rem; background: #f6f2ea; }
.recompensas li.si { border-style: solid; border-color: var(--pasto-osc); background: #e6f8d9; }
.recompensas .rc-ic { font-size: 1.2rem; }
.recompensas small { display: block; font-size: .72rem; opacity: .8; }

/* ------------------------------------------------------------- Partida -- */
#pantalla-juego { height: 100%; min-height: 0; overflow: hidden; }
.barra-juego { gap: 8px; }
.hud-nivel { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.1; }
.hud-nombre { font-family: var(--fuente-titulo); font-weight: 600; font-size: 1.1rem; color: #fff; -webkit-text-stroke: 1px var(--tinta); paint-order: stroke fill; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-modo { font-size: .75rem; align-self: flex-start; background: #fff; border: 2px solid var(--tinta); border-radius: 999px; padding: 0 .5em; margin-top: 2px; }
.hud-modo.desafio { background: #ffe3e6; }
.hud-modo.practica { background: #fff3cd; }
.hud-dato { display: flex; flex-direction: column; align-items: center; background: #fff; border: 2px solid var(--tinta); border-radius: 12px; padding: 2px 8px; min-width: 62px; line-height: 1.05; }
.hud-et { font-size: .64rem; text-transform: uppercase; letter-spacing: .04em; opacity: .75; }
.hud-dato strong { font-family: var(--fuente-titulo); font-weight: 600; font-size: 1.1rem; font-variant-numeric: tabular-nums; }

.juego-cuerpo {
  flex: 1; min-height: 0; display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: "guia" "tablero" "controles";
  gap: 8px; padding: 8px 10px calc(8px + var(--seguro-abajo));
  width: 100%; max-width: 1200px; margin: 0 auto;
}
.guia { grid-area: guia; display: flex; align-items: flex-start; gap: 8px; min-height: 58px; }
.guia-noa { width: 50px; flex: none; }
.guia-noa .noa { width: 100%; height: auto; display: block; }
.bocadillo-guia { flex: 1; min-height: 50px; max-height: 6.8em; overflow-y: auto; font-size: .92rem; padding: .45em .7em; }
.bocadillo-guia::before {
  content: ""; position: absolute; left: -10px; top: 16px; width: 14px; height: 14px; background: #fff;
  border-left: 3px solid var(--tinta); border-bottom: 3px solid var(--tinta); transform: rotate(45deg);
}
.bocadillo-guia.aviso { background: #fff3f0; }
.bocadillo-guia.aviso::before { background: #fff3f0; }
.bocadillo-guia.exito { background: #ecfbe3; }
.bocadillo-guia.exito::before { background: #ecfbe3; }

.zona-tablero { grid-area: tablero; min-height: 0; min-width: 0; display: grid; place-items: center; }

/* Tablero: la valla de madera separa los corrales (separador grueso) y un
   hueco fino separa las casillas dentro de cada corral. */
.tablero {
  --valla: 7px; --fino: 3px;
  display: grid; gap: var(--valla); padding: var(--valla);
  background: repeating-linear-gradient(90deg, #b9773f 0 14px, #a8693a 14px 28px);
  border: 3px solid var(--madera-osc); border-radius: 16px;
  box-shadow: 0 5px 0 var(--madera-osc), inset 0 0 0 2px #d49a5d;
  width: 320px; height: 320px;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.tablero.t9 { --valla: 5px; --fino: 2px; border-radius: 12px; }
.parcela { display: grid; gap: var(--fino); border-radius: 8px; padding: var(--fino); background: #8fc66e; }
.parcela.par-b { background: #a5d585; }
.celda {
  position: relative; padding: 0; margin: 0; border: 0; border-radius: 7px;
  background: var(--parcela-b); display: grid; place-items: center; overflow: visible;
  box-shadow: inset 0 -3px 0 rgba(74, 154, 53, .25);
  min-width: 0; min-height: 0;
}
.parcela.par-b .celda { background: #e9f8dc; }
.tablero.t9 .celda { border-radius: 5px; }
.celda .animal { width: 86%; height: 86%; pointer-events: none; display: block; }
.celda.fija { background: var(--tierra-clara); box-shadow: inset 0 0 0 2px #d9b77f, inset 0 -3px 0 rgba(168, 105, 58, .3); }
.parcela.par-b .celda.fija { background: #fbefd6; }
.celda.fija::after {
  /* "clavo" de madera: marca de casilla fija que no depende del color */
  content: ""; position: absolute; right: 7%; bottom: 7%; width: 13%; height: 13%; border-radius: 50%;
  background: #b07a45; border: 1.5px solid var(--madera-osc); opacity: .85;
}
.celda.revelada { background: #e8ddff; box-shadow: inset 0 0 0 2px #9775fa; }
.celda.revelada::after {
  content: ""; position: absolute; right: 6%; bottom: 6%; width: 18%; height: 18%;
  background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='10' cy='10' r='6' fill='%23fff' stroke='%236741d9' stroke-width='2.5'/%3E%3Cpath d='M14.5 14.5 20 20' stroke='%236741d9' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
}
.celda:not(.fija):not(.revelada):hover { filter: brightness(1.04); }

/* Resaltados de la selección */
.celda.en-region { background: #d9ecff; }
.parcela.par-b .celda.en-region { background: #e3f0ff; }
.celda.en-linea { background: #fff1b8; }
.parcela.par-b .celda.en-linea { background: #fff4c7; }
.celda.fija.en-linea, .celda.fija.en-region { background: #f5dfb0; }
.celda.mismo::before {
  content: ""; position: absolute; inset: 6%; border-radius: 50%; border: 3px dashed var(--azul); pointer-events: none;
}
.celda.sel { z-index: 2; box-shadow: 0 0 0 3px var(--tinta), 0 0 0 6px var(--amarillo); }
.celda.sel:not(.fija):not(.revelada) { background: #fffbe0; }

/* Notas: mini animales en una cuadrícula */
.notas { position: absolute; inset: 4%; display: grid; pointer-events: none; }
.notas.n4 { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); }
.notas.n6 { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); }
.notas.n9 { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); }
.notas svg { width: 100%; height: 100%; opacity: .85; }
.notas .vacia { visibility: hidden; }

/* Pistas y errores */
.celda.pista-zona { box-shadow: inset 0 0 0 3px var(--azul); }
.celda.pista-foco { z-index: 3; box-shadow: 0 0 0 3px #fff, 0 0 0 7px var(--azul); animation: latido 1.1s ease-in-out 3; }
.celda.pista-descartada::before {
  content: ""; position: absolute; inset: 14%; pointer-events: none; opacity: .75;
  background:
    linear-gradient(45deg, transparent 44%, var(--rojo) 44% 56%, transparent 56%),
    linear-gradient(-45deg, transparent 44%, var(--rojo) 44% 56%, transparent 56%);
}
.celda.conflicto { z-index: 3; box-shadow: 0 0 0 3px #fff, 0 0 0 7px var(--rojo); animation: sacudir .45s ease-in-out 2; }
.celda.conflicto::before {
  content: "✕"; position: absolute; top: -10px; right: -8px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--rojo); color: #fff; border: 2px solid var(--tinta); display: grid; place-items: center;
  font-size: 13px; line-height: 1; font-weight: 900;
}
.celda.atasco { box-shadow: 0 0 0 3px #fff, 0 0 0 7px var(--naranja); animation: latido 1.1s ease-in-out 3; }
.celda.salta .animal { animation: saltito .42s cubic-bezier(.3, 1.6, .5, 1); }
.celda.brilla::after {
  content: ""; position: absolute; inset: -2px; border-radius: inherit; pointer-events: none;
  background: radial-gradient(circle, rgba(255, 255, 255, .95) 0%, rgba(255, 230, 120, .6) 40%, transparent 70%);
  animation: brillo .7s ease-out forwards;
}
.celda.baila .animal { animation: baile .7s ease-in-out infinite alternate; }

/* Controles */
.controles { grid-area: controles; display: flex; flex-direction: column; gap: 8px; }
.paleta { display: grid; gap: 6px; grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr)); }
.ani-btn {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 3px 2px 2px; min-height: 52px; border-radius: 14px; border: 3px solid var(--tinta);
  background: #fff; box-shadow: var(--sombra); line-height: 1;
}
.ani-btn .animal { width: 40px; height: 40px; max-width: 100%; }
.ani-btn .ani-nombre { font-size: .68rem; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ani-btn .ani-tecla { position: absolute; top: 2px; left: 5px; font-size: .62rem; opacity: .5; }
.ani-btn .ani-cuenta { position: absolute; top: 2px; right: 5px; font-size: .62rem; opacity: .65; }
.ani-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(58, 42, 74, .25); }
.ani-btn[aria-pressed="true"] { background: var(--amarillo); box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--azul); }
.ani-btn.completo { background: #e6f8d9; }
.ani-btn.completo .animal { opacity: .45; }
.ani-btn.completo::after { content: "✓"; position: absolute; right: 4px; bottom: 2px; color: var(--verde-ok); font-size: .9rem; font-weight: 900; }
.paleta.modo-notas .ani-btn { background: #eef4ff; border-style: dashed; }
.paleta.t9 .ani-btn { min-height: 46px; border-radius: 11px; border-width: 2.5px; }
.paleta.t9 .ani-btn .animal { width: 32px; height: 32px; }
.paleta.t9 .ani-nombre { display: none; }

.herramientas { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.modo-desafio .herramientas { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.modo-desafio .solo-aprendizaje { display: none; }
.herr {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-height: 50px; padding: 4px 2px; border-radius: 14px; border: 2.5px solid var(--tinta); background: var(--papel);
  box-shadow: 0 3px 0 rgba(58, 42, 74, .22); font-size: .74rem; line-height: 1.1;
}
.herr:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(58, 42, 74, .22); }
.herr-ic { width: 22px; height: 22px; display: grid; place-items: center; }
.herr-ic svg { width: 22px; height: 22px; fill: none; stroke: var(--tinta); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.herr[aria-pressed="true"] { background: var(--azul-claro); border-color: var(--azul); box-shadow: 0 3px 0 var(--azul); }
.herr:disabled { opacity: .45; cursor: not-allowed; }
.herr-cont { position: absolute; top: -7px; right: -4px; min-width: 20px; height: 20px; padding: 0 4px; border-radius: 999px; background: var(--rojo); color: #fff; font-size: .7rem; display: grid; place-items: center; border: 2px solid var(--tinta); }
.herr-cont:empty { display: none; }
.herr-revelar { background: #f3edff; }
.indicadores { margin: 0; display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 14px; font-size: .8rem; }
.indicadores span { white-space: nowrap; }

/* Pantallas anchas: tablero a la izquierda y panel a la derecha */
@media (min-width: 860px) and (min-aspect-ratio: 1/1) {
  .juego-cuerpo {
    grid-template-columns: minmax(0, 1fr) 360px; grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "tablero guia" "tablero controles"; gap: 14px 18px; padding: 14px 18px 18px;
  }
  .guia { flex-direction: column; align-items: center; }
  .guia-noa { width: 120px; }
  .bocadillo-guia { width: 100%; max-height: 12em; font-size: 1rem; min-height: 90px; }
  .bocadillo-guia::before { left: 50%; top: -11px; transform: translateX(-50%) rotate(135deg); }
  .controles { align-self: start; }
  .paleta { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .paleta.t4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ani-btn { min-height: 74px; }
  .ani-btn .animal { width: 50px; height: 50px; }
  .paleta.t9 .ani-btn { min-height: 66px; }
  .paleta.t9 .ani-btn .animal { width: 44px; height: 44px; }
  .paleta.t9 .ani-nombre { display: block; }
  .herramientas, .modo-desafio .herramientas { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .herr { min-height: 58px; font-size: .85rem; }
}
/* Móvil apaisado bajito */
@media (max-height: 520px) and (min-aspect-ratio: 4/3) {
  .juego-cuerpo { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "tablero guia" "tablero controles"; }
  .guia-noa { width: 40px; }
  .bocadillo-guia { max-height: 4.6em; font-size: .85rem; }
  .ani-btn { min-height: 44px; }
  .ani-btn .animal { width: 30px; height: 30px; }
  .ani-nombre { display: none; }
  .herr { min-height: 42px; }
  .herr-txt { font-size: .66rem; }
}
@media (max-width: 380px) {
  .hud-dato { min-width: 54px; padding: 2px 5px; }
  .hud-dato strong { font-size: 1rem; }
  .barra-juego .btn-icono { width: 40px; height: 40px; }
  .herr-txt { font-size: .66rem; }
  .ani-btn .ani-nombre { font-size: .6rem; }
}

/* ------------------------------------------------------------ Overlays -- */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 14px;
  background: rgba(40, 30, 55, .55); overflow-y: auto;
}
.caja {
  position: relative; width: 100%; max-width: 520px; max-height: calc(100% - 8px); overflow-y: auto;
  background: var(--papel); border: 3px solid var(--tinta); border-radius: 24px; padding: 18px 18px 16px;
  box-shadow: 0 8px 0 rgba(58, 42, 74, .35); animation: aparecer .25s ease-out;
}
.caja h2 { margin: 0 0 .4em; font-family: var(--fuente-titulo); font-weight: 700; font-size: 1.45rem; line-height: 1.15; }
.caja h3 { margin: 1em 0 .3em; font-family: var(--fuente-titulo); font-weight: 600; font-size: 1.15rem; }
.caja ul, .caja ol { padding-left: 1.2em; margin: .3em 0; }
.caja li { margin: .25em 0; }
.cerrar {
  position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; border-radius: 12px;
  border: 2.5px solid var(--tinta); background: #fff; font-size: 1.5rem; line-height: 1; display: grid; place-items: center;
}
.caja-cargando { max-width: 320px; text-align: center; }
.cargando-anim { width: 64px; height: 64px; margin: 6px auto 10px; border-radius: 50%; border: 7px solid var(--pasto-claro); border-top-color: var(--pasto-osc); animation: girar 1s linear infinite; }

.vic-cabecera { display: flex; gap: 12px; align-items: center; }
.vic-noa { width: 86px; flex: none; }
.vic-noa .noa { width: 100%; height: auto; display: block; }
.vic-sub { margin: 0; font-size: .95rem; }
.vic-estrellas { display: flex; justify-content: center; gap: 10px; margin: 10px 0 4px; }
.vic-estrellas .estrella { width: 58px; height: 58px; color: #e3dccd; }
.vic-estrellas .estrella.on { color: var(--amarillo); animation: estrellaPop .5s cubic-bezier(.3, 1.7, .5, 1) both; }
.vic-estrellas .estrella.on:nth-child(2) { animation-delay: .25s; }
.vic-estrellas .estrella.on:nth-child(3) { animation-delay: .5s; }
.vic-criterio { text-align: center; margin: 0 0 8px; font-size: .88rem; }
.vic-total { display: flex; justify-content: center; align-items: baseline; gap: 10px; font-family: var(--fuente-titulo); }
.vic-total span { font-size: 1.1rem; }
.vic-total strong { font-size: 2.3rem; color: var(--rojo); -webkit-text-stroke: 1.5px var(--tinta); paint-order: stroke fill; }
.vic-desglose { margin: 6px 0; font-size: .88rem; }
.vic-desglose summary { cursor: pointer; text-align: center; color: var(--azul); }
.vic-desglose table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.vic-desglose td { padding: 3px 4px; border-bottom: 1px dashed #d9cfbf; }
.vic-desglose td:last-child { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.vic-extra { margin: 6px 0; text-align: center; font-size: .95rem; }
.vic-extra:empty { display: none; }
.vic-guardar { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; padding: 12px; border: 2px dashed #cbbfa9; border-radius: 16px; background: #fff; }
.vic-guardar label { font-size: .95rem; }
.vic-guardar label small { font-weight: 600; opacity: .8; }
.vic-fila { display: flex; gap: 8px; }
.vic-fila input { flex: 1; min-width: 0; min-height: 48px; border-radius: 12px; border: 3px solid var(--tinta); padding: 0 12px; font-weight: 800; background: var(--papel); }
.btn-dado { font-size: 1.4rem; }
.btn-guardar { font-size: 1.2rem; min-height: 54px; }
.btn-guardar:disabled { opacity: .6; cursor: default; }
.vic-estado { margin: 0; font-size: .9rem; text-align: center; min-height: 1.2em; }
.vic-estado.ok { color: var(--verde-ok); }
.vic-estado.error { color: #b02a37; }
.vic-botones { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.vic-botones .btn { font-size: .98rem; padding: .5em .4em; }

.rk-filtros { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.segmentos { display: inline-flex; border: 2.5px solid var(--tinta); border-radius: 12px; overflow: hidden; }
.segmentos button { border: 0; background: #fff; padding: .4em .7em; font-size: .9rem; border-right: 2px solid var(--tinta); min-height: 40px; }
.segmentos button:last-child { border-right: 0; }
.segmentos button[aria-checked="true"] { background: var(--amarillo); }
.rk-nivel { display: flex; align-items: center; gap: 6px; font-size: .9rem; }
.rk-nivel select { min-height: 40px; border-radius: 10px; border: 2.5px solid var(--tinta); background: #fff; padding: 0 6px; font-weight: 700; }
.rk-nota { font-size: .85rem; margin: 8px 0 0; min-height: 1em; }
.rk-lista { list-style: none; padding: 0 !important; margin: 8px 0 !important; display: grid; gap: 6px; }
.rk-lista li { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 12px; background: #fff; border: 2px solid #e2d8c6; margin: 0 !important; }
.rk-lista li.yo { border-color: var(--azul); background: var(--azul-claro); }
.rk-pos { font-family: var(--fuente-titulo); font-size: 1.1rem; text-align: center; }
.rk-lista li:nth-child(1) .rk-pos { color: #c99700; }
.rk-nick { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk-nick small { display: block; font-size: .72rem; opacity: .75; font-weight: 600; }
.rk-pts { font-family: var(--fuente-titulo); font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.rk-vacio { text-align: center; padding: 14px; opacity: .8; }
.rk-ayuda { font-size: .78rem; opacity: .8; margin: 4px 0 0; }
.rk-central { width: 100%; margin-top: 10px; }

.ay-intro { display: flex; gap: 10px; align-items: center; }
.ay-noa { width: 70px; flex: none; }
.ay-noa .noa { width: 100%; height: auto; display: block; }
.ay-reglas { list-style: none; padding: 0 !important; }
.ay-reglas li { display: flex; gap: 10px; align-items: center; }
.ay-ic { width: 40px; height: 40px; flex: none; border: 2.5px solid var(--tinta); border-radius: 8px; background: var(--parcela-b); position: relative; overflow: hidden; }
.ay-ic::after { content: ""; position: absolute; background: var(--amarillo); border: 1.5px solid var(--tinta); }
.ay-fila::after { left: 2px; right: 2px; top: 14px; height: 9px; }
.ay-col::after { top: 2px; bottom: 2px; left: 14px; width: 9px; }
.ay-reg::after { left: 2px; top: 2px; width: 17px; height: 17px; background: var(--azul-claro); border-width: 2.5px; border-color: var(--madera); }
.ay-ejemplo { display: flex; justify-content: center; margin: 8px 0; }
.ay-ejemplo .tablero { width: 200px; height: 200px; }
.ay-estrellas { list-style: none; padding: 0 !important; }
.ay-estrellas li { display: flex; align-items: center; gap: 8px; }
.ay-estrellas .est-grupo { display: inline-flex; flex: none; }
.ay-estrellas .estrella { width: 18px; height: 18px; color: var(--amarillo); }
.ay-nota { font-size: .88rem; }

.interruptor { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px dashed #d9cfbf; font-size: 1rem; cursor: pointer; }
.interruptor input { width: 26px; height: 26px; accent-color: var(--pasto-osc); }

/* Confeti */
.confeti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confeti i { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 3px; animation: caer linear forwards; }

/* ---------------------------------------------------------- Animación --- */
@keyframes latido { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
@keyframes sacudir { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@keyframes saltito { 0% { transform: scale(.4) translateY(10%); } 60% { transform: scale(1.12) translateY(-8%); } 100% { transform: scale(1) translateY(0); } }
@keyframes brillo { from { opacity: 1; transform: scale(.6); } to { opacity: 0; transform: scale(1.3); } }
@keyframes baile { from { transform: translateY(0) rotate(-5deg); } to { transform: translateY(-10%) rotate(5deg); } }
@keyframes aparecer { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes estrellaPop { 0% { transform: scale(0) rotate(-60deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes girar { to { transform: rotate(360deg); } }
@keyframes caer { to { transform: translateY(110vh) rotate(720deg); } }
@keyframes aspas { to { transform: rotate(360deg); } }
@keyframes flotar { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.escena .aspas { transform-box: fill-box; transform-origin: center; animation: aspas 9s linear infinite; }
.noa-pos .noa, .guia-noa .noa { animation: flotar 3.2s ease-in-out infinite; }

/* Expresiones de Noa */
.noa .noa-x { display: none; }
.noa[data-expresion="feliz"] .noa-feliz,
.noa[data-expresion="pensando"] .noa-pensando,
.noa[data-expresion="sorpresa"] .noa-sorpresa,
.noa[data-expresion="celebra"] .noa-celebra { display: inline; }

/* Sin efectos (ajuste del jugador o preferencia del sistema) */
.sin-efectos *, .sin-efectos *::before, .sin-efectos *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .confeti { display: none; }
}

/* Salto al contenido para teclado */
.visualmente-oculto { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (min-width: 760px) {
  .logo-playlab img { width: 150px; }
  .inicio-titulo { margin-top: -48px; }
  .escena-wrap { aspect-ratio: 800 / 330; }
  .bocadillo-inicio { max-width: 260px; }
  .selector-modo-mapa { max-width: 520px; width: 100%; justify-self: center; }
  .mi-granja { max-width: 1100px; }
}

/* Ordenador: escena a la izquierda y menú a la derecha */
@media (min-width: 1020px) and (min-aspect-ratio: 5/4) {
  #pantalla-inicio {
    display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(360px, 1fr); grid-template-rows: auto 1fr auto;
    grid-template-areas: "cab cab" "hero panel" "pie pie"; column-gap: 28px; max-width: 1240px; margin: 0 auto; align-items: center;
    padding: 0 20px;
  }
  .inicio-cab { grid-area: cab; max-width: none; padding-left: 0; padding-right: 0; }
  .inicio-hero { grid-area: hero; padding: 0; }
  .inicio-panel { grid-area: panel; padding: 0; max-width: 460px; }
  .pie { grid-area: pie; }
  .escena-wrap { aspect-ratio: 800 / 420; }
}

/* Paleta de 9 animales en pantallas estrechas: sin número de tecla y con el
   contador abajo para que no se amontone */
.paleta.t9 .ani-tecla { display: none; }
.paleta.t9 .ani-cuenta { top: auto; bottom: 1px; right: 0; left: 0; text-align: center; font-size: .56rem; }
.paleta.t9 .ani-btn { padding-bottom: 9px; }
@media (min-width: 860px) and (min-aspect-ratio: 1/1) {
  .paleta.t9 .ani-tecla { display: block; }
  .paleta.t9 .ani-cuenta { top: 2px; bottom: auto; left: auto; right: 5px; text-align: right; font-size: .62rem; }
  .paleta.t9 .ani-btn { padding-bottom: 2px; }
}

@media (max-width: 600px) { .ani-btn .ani-tecla { display: none; } }

/* Navegadores sin aspect-ratio (Safari < 15): alturas de respaldo */
@supports not (aspect-ratio: 1 / 1) {
  .escena-wrap { height: 62vw; max-height: 420px; }
  .mapa { height: 211vw; max-height: 1100px; }
  .mapa.apaisado { height: 52vw; max-height: 572px; }
}
