/* Fue el Mayordomo · aspecto de novela de misterio clásica: papel crema, burdeos y dorado. */
:root {
  --crema: #f6efe0;
  --crema-2: #efe5cf;
  --papel: #fcf9f0;
  --burdeos: #6e1d2b;
  --burdeos-osc: #521420;
  --dorado: #b8923a;
  --dorado-claro: #e2c98a;
  --tinta: #2a2320;
  --tinta-suave: #5f544b;
  --verde: #2f5d50;
  --rojo: #b3261e;
  --linea: #d9ccb2;
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: only light;
}

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--crema);
  color: var(--tinta);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.4;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; }
a { color: var(--burdeos); }
[hidden] { display: none !important; }

#simbolos { position: absolute; }

/* --- Estructura: cabecera, plano arriba y pistas con su propio desplazamiento --- */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 1040px;
  margin: 0 auto;
}

.cabecera {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(7px + env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 7px max(12px, env(safe-area-inset-left));
  background: var(--burdeos);
  color: var(--crema);
}

.marca {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 700;
  white-space: nowrap;
}
.marca svg { flex: none; width: 30px; height: 18px; fill: var(--dorado-claro); }

.cabecera-derecha { display: flex; align-items: center; gap: 10px; }
.reloj { font-variant-numeric: tabular-nums; font-size: .95rem; opacity: .92; }

.boton-redondo {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  border: 1.5px solid var(--dorado-claro);
  background: transparent;
  color: var(--crema);
  font-family: var(--serif);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
}

.juego { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.zona-plano {
  flex: none;
  padding: 10px max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
}

.plano { width: min(100%, 47dvh); aspect-ratio: 1; margin: 0 auto; }
.cargando { margin: 0; padding: 40% 0; text-align: center; color: var(--tinta-suave); }

.zona-pistas {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px max(14px, env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: var(--papel);
  border-top: 1px solid var(--linea);
  box-shadow: inset 0 6px 6px -6px rgba(42, 35, 32, .18);
}

/* --- El plano (SVG) --- */
.plano-svg {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.rejilla { fill: none; stroke: rgba(42, 35, 32, .2); stroke-width: 1.5; }
.paredes { fill: none; stroke: var(--tinta); stroke-width: 7; stroke-linecap: round; }
.borde-plano { fill: none; stroke: var(--tinta); stroke-width: 8; }
.tapada { fill: rgba(42, 35, 32, .2); }
.rayado { fill: none; stroke: rgba(42, 35, 32, .26); stroke-width: 3; pointer-events: none; }
/* El nombre lleva un halo claro para que se lea encima de un mueble. */
.nombres-hab text { font-family: var(--sans); font-size: 15px; font-weight: 800; fill: #2a2320; paint-order: stroke; stroke: rgba(255, 250, 240, .9); stroke-width: 5px; stroke-linejoin: round; }
.sombra { fill: rgba(42, 35, 32, .1); }
.equis { fill: none; stroke: var(--burdeos); stroke-width: 6.5; stroke-linecap: round; opacity: .62; }

.ficha .disco { stroke: rgba(255, 255, 255, .9); stroke-width: 3; }
.ficha .disco.victima { fill: var(--crema); stroke: var(--tinta); stroke-width: 3.5; stroke-dasharray: 7 6; }
.ficha .letras { font-family: var(--sans); font-weight: 700; fill: #fff; text-anchor: middle; dominant-baseline: central; }
.ficha .letras.victima { fill: var(--tinta); }
.anillo-fija { fill: none; stroke: var(--dorado); stroke-width: 6; }
.anillo-conflicto { fill: rgba(179, 38, 30, .2); stroke: var(--rojo); stroke-width: 5; }
.anillo-seleccion { fill: none; stroke: var(--dorado); stroke-width: 6; stroke-dasharray: 11 8; }

.toque { fill: transparent; cursor: pointer; outline: none; }
.toque:focus-visible { stroke: var(--dorado); stroke-width: 6; }

.destello, .destello-mal { pointer-events: none; stroke-width: 5; animation: destello 1.6s ease-out forwards; }
.destello { fill: rgba(184, 146, 58, .38); stroke: var(--dorado); }
.destello-mal { fill: rgba(179, 38, 30, .28); stroke: var(--rojo); }
@keyframes destello { 0% { opacity: 0; } 15% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }

/* --- La bandeja de fichas --- */
.bandeja { display: flex; justify-content: center; gap: 6px; margin-top: 10px; }

.ficha-btn {
  position: relative;
  flex: 0 1 40px;
  min-width: 0;
  aspect-ratio: 1;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .92);
  background: var(--color, var(--tinta));
  color: #fff;
  font-size: .82rem;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(42, 35, 32, .35);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .12s ease;
}
.ficha-btn.victima { background: var(--crema); color: var(--tinta); border: 2px dashed var(--tinta); }
.ficha-btn.equis-btn { background: var(--papel); color: var(--burdeos); border: 2px solid var(--burdeos); font-size: 1.05rem; }
.ficha-btn.puesta { opacity: .42; }
.ficha-btn.fija::after { content: ''; position: absolute; inset: -5px; border-radius: 50%; border: 2px solid var(--dorado); }
.ficha-btn[aria-pressed='true'] { opacity: 1; transform: translateY(-3px) scale(1.08); outline: 3px solid var(--dorado); outline-offset: 2px; }
.ficha-btn:focus-visible { outline: 3px solid var(--dorado); outline-offset: 2px; }

.aviso {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.7em;
  margin: 6px 0 6px;
  font-size: .86rem;
  line-height: 1.25;
  text-align: center;
  color: var(--tinta-suave);
}
.aviso.mayordomo { color: var(--burdeos); font-family: var(--serif); font-style: italic; font-size: .96rem; }
.aviso.mal { color: var(--rojo); font-weight: 600; }
.aviso.bien { color: var(--verde); font-weight: 700; }

/* --- Botones --- */
.boton {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 14px;
  border: 1.5px solid var(--burdeos);
  border-radius: 10px;
  background: var(--papel);
  color: var(--burdeos);
  font-size: .98rem;
  font-weight: 700;
  line-height: 1.15;
  cursor: pointer;
  touch-action: manipulation;
}
.boton svg { flex: none; width: 24px; height: 14px; fill: var(--dorado); }
.boton.principal { background: var(--burdeos); color: var(--crema); }
.boton:active { transform: translateY(1px); }
.boton:disabled { opacity: .45; cursor: default; }
.boton:focus-visible, .boton-redondo:focus-visible, .enlace:focus-visible { outline: 3px solid var(--dorado); outline-offset: 2px; }
.boton.ancho { width: 100%; }

.acciones { display: flex; gap: 8px; }
.acciones .boton { flex: 1; }
.acciones .principal { flex: 1.4; }

.enlace { border: 0; padding: 8px 4px; background: none; color: var(--tinta-suave); text-decoration: underline; cursor: pointer; font-size: .9rem; }

/* --- El caso y las pistas --- */
/* Botón para leer las pistas a pantalla completa (móvil en vertical). */
.ampliar-caja { position: sticky; top: 0; z-index: 2; display: flex; justify-content: flex-end; height: 0; }
.ampliar {
  flex: none;
  height: 30px;
  margin-top: -4px;
  padding: 0 11px;
  border: 1px solid var(--linea);
  border-radius: 999px;
  background: var(--papel);
  color: var(--burdeos);
  font-size: .78rem;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(42, 35, 32, .15);
  cursor: pointer;
  touch-action: manipulation;
}
.ampliar:focus-visible { outline: 3px solid var(--dorado); outline-offset: 2px; }
.juego.ampliado .zona-plano { display: none; }
.caso-meta { padding-right: 84px; }
.caso-meta { margin: 0; font-size: .78rem; letter-spacing: .02em; color: var(--tinta-suave); }
.caso-titulo { margin: 2px 0 8px; font-family: var(--serif); font-size: 1.35rem; line-height: 1.15; color: var(--burdeos); }
.intro {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-left: 3px solid var(--dorado);
  border-radius: 0 8px 8px 0;
  background: var(--crema-2);
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.45;
}
.titulo-pistas { margin: 0 0 8px; font-family: var(--serif); font-size: 1.05rem; }

.pistas { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.grupo ul { display: grid; gap: 5px; margin: 4px 0 0; padding: 0 0 0 38px; list-style: none; }
.grupo-cabecera {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 2px 0;
  border: 0;
  background: none;
  text-align: left;
  font-weight: 700;
  cursor: pointer;
}
.grupo.sin-pistas .grupo-cabecera { font-weight: 400; color: var(--tinta-suave); }

.ficha-mini {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--color, var(--tinta));
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
}
.ficha-mini.victima { background: var(--crema); color: var(--tinta); border: 1.5px dashed var(--tinta); }

.pista {
  display: block;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--linea);
  border-radius: 8px;
  background: #fff;
  text-align: left;
  font-size: .96rem;
  line-height: 1.3;
  cursor: pointer;
  touch-action: manipulation;
}
.pista[aria-pressed='true'] { background: transparent; color: #9c9186; text-decoration: line-through; }
.pista:focus-visible, .grupo-cabecera:focus-visible { outline: 3px solid var(--dorado); outline-offset: 1px; }
.pie-pistas { margin: 14px 0 0; text-align: center; }
.pie-enlaces { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 16px; margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--linea); font-size: .82rem; }
.pie-enlaces a { color: var(--tinta-suave); }
.extras:empty { display: none; }
.extras { display: grid; gap: 8px; margin: 0 0 14px; }

/* --- Diálogos --- */
.dialogo {
  width: min(92vw, 440px);
  max-height: 90vh;
  max-height: 90dvh;
  padding: 20px 18px 18px;
  border: 0;
  border-radius: 16px;
  background: var(--papel);
  color: var(--tinta);
  box-shadow: 0 14px 44px rgba(0, 0, 0, .4);
  overflow-y: auto;
}
.dialogo::backdrop { background: rgba(42, 35, 32, .6); }
.dialogo:not([open]) { display: none; }
.dialogo h2 { margin: 0 0 2px; font-family: var(--serif); font-size: 1.45rem; line-height: 1.15; color: var(--burdeos); }
.dialogo h3 { margin: 14px 0 6px; font-family: var(--serif); font-size: 1.05rem; }
.subtitulo { margin: 0 0 12px; color: var(--tinta-suave); font-size: .92rem; }

.reglas { margin: 0 0 12px; padding-left: 1.25em; display: grid; gap: 7px; font-size: .95rem; }
.reglas li::marker { color: var(--burdeos); font-weight: 700; }
.gestos { margin: 0 0 16px; padding-left: 1.2em; display: grid; gap: 5px; font-size: .93rem; }

.leyenda { display: grid; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--crema-2); }
.leyenda-titulo { margin: 0 0 4px; font-size: .78rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--tinta-suave); }
.leyenda-fila { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.leyenda-item { display: inline-flex; align-items: center; gap: 4px; font-size: .88rem; color: var(--tinta); }

.sospechosos { display: grid; gap: 8px; margin-bottom: 14px; }
.sospechoso {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 12px;
  border: 1.5px solid var(--linea);
  border-radius: 10px;
  background: #fff;
  text-align: left;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
.sospechoso[aria-pressed='true'] { border-color: var(--burdeos); background: #f7e9e6; box-shadow: inset 0 0 0 1.5px var(--burdeos); }
.fila-botones { display: flex; gap: 8px; }
.fila-botones .boton { flex: 1; }
.fila-botones .principal { flex: 1.6; }

.final { text-align: center; }
.final-pajarita { width: 64px; height: 38px; fill: var(--dorado); }
.sello {
  display: inline-block;
  margin: 6px 0 8px;
  padding: 3px 12px;
  border: 2px solid var(--verde);
  border-radius: 6px;
  color: var(--verde);
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  transform: rotate(-3deg);
}
.frase-mayordomo { margin: 8px 0 14px; font-family: var(--serif); font-style: italic; color: var(--tinta-suave); }
.marcador { display: flex; justify-content: center; gap: 8px; margin: 0 0 16px; }
.marcador > div { flex: 1; max-width: 96px; padding: 8px 4px; border-radius: 10px; background: var(--crema-2); }
.marcador dt { font-size: .7rem; letter-spacing: .05em; text-transform: uppercase; color: var(--tinta-suave); }
.marcador dd { margin: 2px 0 0; font-family: var(--serif); font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.nota { margin: 8px 0; font-size: .88rem; color: var(--tinta-suave); }
.nota:empty { display: none; }
.texto-compartir { width: 100%; padding: 8px; border: 1px solid var(--linea); border-radius: 8px; background: #fff; font: inherit; font-size: .85rem; resize: none; }
.pronto { margin: 12px 0 14px; padding: 10px 12px; border: 1px dashed var(--dorado); border-radius: 10px; font-size: .9rem; text-align: left; }

.sin-js { margin: 24px; text-align: center; }

/* --- La cara del mayordomo --- */
.cara { flex: none; width: 52px; height: 52px; border: 2px solid var(--dorado); border-radius: 50%; background: var(--crema); object-fit: cover; }
.cara-grande { width: 104px; height: 104px; border-width: 3px; box-shadow: 0 3px 10px rgba(42, 35, 32, .22); }
.aviso.mayordomo::before {
  content: '';
  flex: none;
  width: 32px;
  height: 32px;
  margin-right: 8px;
  border: 1.5px solid var(--dorado);
  border-radius: 50%;
  background: var(--crema) url('../img/mayordomo-neutro-192.jpg') center / cover;
}
.aviso.mayordomo.duda::before { background-image: url('../img/mayordomo-esceptico-192.jpg'); }
.aviso.mayordomo { text-align: left; }

/* --- Reto y recompensa: niveles, estrellas y carnet de detective --- */
.chip-carnet {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 10px;
  border: 1.5px solid var(--dorado-claro);
  border-radius: 999px;
  background: transparent;
  color: var(--crema);
  font-size: .9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.chip-carnet svg { width: 15px; height: 15px; fill: var(--dorado-claro); }
.chip-carnet:focus-visible { outline: 3px solid var(--dorado); outline-offset: 2px; }

.niveles { display: flex; gap: 6px; margin: 0 0 8px; }
.nivel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 5px 4px 4px;
  border: 1.5px solid var(--linea);
  border-radius: 10px;
  background: var(--papel);
  color: var(--tinta-suave);
  font-size: .84rem;
  font-weight: 700;
  line-height: 1.1;
  text-decoration: none;
  touch-action: manipulation;
}
.nivel.actual { border-color: var(--burdeos); background: var(--burdeos); color: var(--crema); }
.nivel:focus-visible { outline: 3px solid var(--dorado); outline-offset: 2px; }
.nivel-estrellas { display: inline-flex; gap: 1px; }
.nivel-estrellas svg { width: 12px; height: 12px; }
svg.ganada { fill: var(--dorado); }
svg.vacia { fill: none; stroke: currentColor; stroke-width: 1.6; opacity: .5; }
.nivel.actual svg.ganada { fill: var(--dorado-claro); }

.estrellas { display: flex; justify-content: center; gap: 6px; margin: 2px 0 0; }
.estrellas svg { width: 46px; height: 46px; }
.estrellas svg.vacia { stroke: var(--tinta-suave); stroke-width: 1.1; }
.dialogo[open] .estrellas svg.ganada { animation: estrella .5s cubic-bezier(.2, 1.7, .4, 1) both; transform-origin: center; }
@keyframes estrella { from { opacity: 0; transform: scale(0) rotate(-50deg); } to { opacity: 1; transform: none; } }

.rango-caja { margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; background: var(--crema-2); }
.rango-nuevo {
  display: inline-block;
  margin: 0 0 4px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--dorado);
  color: #fff;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.rango-nombre { margin: 0; font-family: var(--serif); font-size: 1.08rem; font-weight: 700; color: var(--burdeos); }
.rango-barra { height: 8px; margin: 6px 0 4px; border-radius: 4px; background: #fff; overflow: hidden; }
.rango-barra span { display: block; height: 100%; min-width: 4px; border-radius: 4px; background: var(--dorado); transform-origin: left; }
.dialogo[open] .rango-barra span { animation: llenar .8s ease .5s both; }
@keyframes llenar { from { transform: scaleX(0); } }
.rango-faltan { margin: 0; font-size: .8rem; color: var(--tinta-suave); }
#dlg-carnet .rango-barra { background: var(--crema-2); }
.escalera { display: grid; gap: 3px; margin: 12px 0 14px; padding: 0; list-style: none; text-align: left; font-size: .9rem; }
.escalera li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 10px; border-radius: 8px; color: #a39a90; }
.escalera li.hecho { color: var(--tinta); }
.escalera li.actual { background: var(--burdeos); color: var(--crema); font-weight: 700; }
.frase-mayordomo { color: var(--tinta); }
@media (max-width: 349px) { .reloj { display: none; } }

/* --- El caso de prácticas, guiado por el mayordomo --- */
.guia {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1.5px solid var(--dorado);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(42, 35, 32, .12);
}
.guia-cuerpo { flex: 1; min-width: 0; }
.guia-barra { height: 5px; margin: 3px 0 7px; border-radius: 3px; background: var(--crema-2); overflow: hidden; }
.guia-barra span { display: block; height: 100%; width: 0; border-radius: 3px; background: var(--dorado); transition: width .3s ease; }
.solo-lectores { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.guia-texto { margin: 0; font-family: var(--serif); font-size: 1rem; line-height: 1.35; }
.guia .boton { margin-top: 8px; min-height: 40px; padding: 6px 24px; }
.guia.insiste { animation: insiste .45s ease; }
@keyframes insiste {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.objetivo-casilla { fill: rgba(226, 201, 138, .35); stroke: var(--dorado); stroke-width: 7; pointer-events: none; animation: latido 1.1s ease-in-out infinite; }
@keyframes latido { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.ficha-btn.objetivo, .boton.objetivo { animation: llamar 1.1s ease-in-out infinite; }
.ficha-btn.objetivo { opacity: 1; outline: 3px solid var(--dorado); outline-offset: 2px; }
@keyframes llamar { 0%, 100% { box-shadow: 0 0 0 0 rgba(184, 146, 58, .9); } 50% { box-shadow: 0 0 0 9px rgba(184, 146, 58, 0); } }
.pista.objetivo { border-color: var(--dorado); background: #fffaf0; box-shadow: 0 0 0 2px var(--dorado); }
.juego.guiado .plano { width: min(100%, 36dvh); }
.juego.guiado .equis-btn, .juego.guiado #btn-pista, .juego.guiado .pie-pistas, .juego.guiado .intro,
.juego.guiado .ampliar-caja, .juego.guiado .pie-enlaces, .juego.guiado .aviso.normal, .juego.guiado .aviso.bien { display: none; }
.juego.guiado .aviso { min-height: 0; }
.juego.guiado:not(.guiado-acusar) .acciones { display: none; }
.juego.guiado .bandeja { margin-bottom: 8px; }
.juego.guiado .caso-meta { display: none; }
.juego.guiado .caso-titulo { margin-top: 0; font-size: 1.1rem; }
.dialogo .ancho + .ancho { margin-top: 8px; }
a.boton { text-decoration: none; }

/* --- Un poco de vida --- */
/* La ficha recién colocada entra con un saltito. */
.ficha.recien > * { animation: salta .3s cubic-bezier(.3, 1.7, .5, 1) both; transform-box: fill-box; transform-origin: center; }
@keyframes salta { from { transform: scale(.25); opacity: .2; } to { transform: scale(1); opacity: 1; } }
/* Los diálogos aparecen, no saltan de golpe; y el sello del final se estampa. */
.dialogo[open] { animation: aparece .22s ease-out; }
@keyframes aparece { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.dialogo[open] .sello { animation: sella .45s cubic-bezier(.2, 1.5, .4, 1) .18s both; }
@keyframes sella { from { opacity: 0; transform: rotate(-16deg) scale(2.4); } to { opacity: 1; transform: rotate(-3deg) scale(1); } }

/* --- Móvil tumbado, tableta y ordenador: plano a la izquierda y pistas a la derecha --- */
@media (min-aspect-ratio: 1/1) and (min-width: 560px) {
  .juego { flex-direction: row; }
  .zona-plano {
    flex: none;
    width: min(54%, 560px);
    overflow-y: auto;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
  .plano { width: min(100%, max(250px, calc(100dvh - 215px))); }
  .zona-pistas { border-top: 0; border-left: 1px solid var(--linea); box-shadow: inset 6px 0 6px -6px rgba(42, 35, 32, .18); }
  .ampliar-caja { display: none; }
  .caso-meta { padding-right: 0; }
  .juego.ampliado .zona-plano { display: block; }
  .juego.guiado .plano { width: min(100%, max(220px, calc(100dvh - 270px))); }
}

/* Pantallas bajas en vertical (móviles pequeños o con las barras del navegador): todo más justo. */
@media (max-height: 700px) and (max-aspect-ratio: 1/1) {
  .cabecera { padding-top: calc(4px + env(safe-area-inset-top)); padding-bottom: 4px; }
  .boton-redondo { width: 32px; height: 32px; }
  .zona-plano { padding-top: 8px; padding-bottom: 6px; }
  .plano { width: min(100%, 44dvh); }
  .bandeja { margin-top: 7px; }
  .ficha-btn { flex-basis: 36px; font-size: .76rem; }
  .aviso { min-height: 2.5em; margin: 3px 0; font-size: .8rem; }
  .aviso.mayordomo { font-size: .86rem; }
  .acciones .boton { min-height: 40px; padding: 6px 12px; }
  .zona-pistas { padding-top: 9px; }
  .niveles { margin-bottom: 6px; }
  .nivel { flex-direction: row; justify-content: center; gap: 6px; padding: 5px 4px; font-size: .8rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition: none !important; }
}

/* --- Para imprimir: solo el caso, sin botones --- */
@media print {
  .cabecera-derecha, .bandeja, .aviso, .acciones, .pie-pistas, dialog { display: none !important; }
  .app { display: block; height: auto; }
  .juego { display: block; }
  .zona-pistas { overflow: visible; border: 0; box-shadow: none; }
  .plano { width: 70%; }
  .pista { border: 0; padding: 2px 0; }
}

/* El botón de las reglas siempre a la vista, aunque el texto no quepa entero. */
#reglas-cerrar { position: sticky; bottom: 0; box-shadow: 0 -14px 14px 6px var(--papel), 0 18px 0 6px var(--papel); }

/* Quién habla y cómo leer las pistas (tras la primera prueba con una persona) */
.narrador { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: .86rem; font-weight: 700; color: var(--burdeos); }
.cara-mini { width: 34px; height: 34px; }
.chuleta { margin: 0 0 12px; border: 1px solid rgba(42, 35, 32, .16); border-radius: 12px; background: rgba(255, 255, 255, .55); font-size: .9rem; }
.chuleta summary { padding: 9px 12px; font-weight: 700; cursor: pointer; }
.chuleta ul { margin: 0; padding: 0 12px 10px 30px; }
.chuleta li { margin: 4px 0; line-height: 1.35; }
.juego.guiado .narrador, .juego.guiado .chuleta { display: none; }
