/* Colores de editar_coleccion.py y de la cubierta, para que demo, app y libro se reconozcan. */
:root {
  color-scheme: light;
  --tinta: #1f2c2a;
  --mute: #52615d;
  --teal: #244b45;
  --bosque: #163832;
  --regla: #c7d0c8;
  --palido: #edf2ec;
  --calido: #f7f2e7;
  --cobre: #8e5039;
  --pluma: #1e476b;
  --papel: #f7f0e3;
  --blanco: #fffdf7;
  --victima: #d11f1f;
  --ambar: #e8a200;
  --editorial: Georgia, "Iowan Old Style", "Noto Serif", "Times New Roman", serif;
  --lectura: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  --tecnica: ui-monospace, "Cascadia Mono", Consolas, "Roboto Mono", monospace;
  font: 16px/1.4 var(--lectura);
  color: var(--tinta);
  background: var(--papel);
  -webkit-tap-highlight-color: transparent;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--cobre); outline-offset: 2px; }
svg { display: block; }
b, strong { font-weight: 700; }

/* ---------- Cabecera ---------- */
.cabecera {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 6px 8px 16px;
  max-width: 1120px;
  width: 100%;
  margin: 0 auto;
}
.titulos { flex: 1; min-width: 0; }
.tramo {
  margin: 0;
  font: 10.5px/1.3 var(--tecnica);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--cobre);
}
.tramo > span:first-child { font-weight: 700; }
#crono { color: var(--mute); }
.cabecera h1 {
  margin: 1px 0 0;
  font: 400 clamp(1.15rem, 4.6vw, 1.45rem)/1.15 var(--editorial);
  color: var(--tinta);
}
.icono {
  flex: none;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--tinta);
}
.icono svg { width: 24px; height: 24px; fill: currentColor; }
.icono:hover:not(:disabled) { background: #1f2c2a0f; }
.icono:disabled { color: #1f2c2a42; }

.menu {
  position: absolute;
  z-index: 40;
  top: 52px;
  right: 8px;
  min-width: 230px;
  padding: 6px 0;
  background: var(--blanco);
  border: 1px solid var(--regla);
  border-radius: 10px;
  box-shadow: 0 10px 30px #1f2c2a2e;
}
.menu button {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  padding: 11px 18px;
  border: 0;
  background: none;
  text-align: left;
  font-size: .95rem;
}
.menu button:hover { background: var(--palido); }
.menu .check { color: var(--teal); font-weight: 700; visibility: hidden; }
.menu [aria-checked="true"] .check { visibility: visible; }
.menu hr { border: 0; border-top: 1px solid var(--regla); margin: 5px 0; }

/* ---------- Historia del caso ---------- */
.historia {
  position: relative;
  z-index: 20;
  width: min(100% - 24px, 560px);
  margin: 4px auto 0;
  padding: 18px 20px 16px;
  background: var(--blanco);
  border: 1px solid var(--regla);
  border-radius: 14px;
  box-shadow: 0 12px 34px #1f2c2a2b;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  visibility: hidden;
  transition: max-height .45s ease, opacity .3s ease, visibility 0s .45s, margin .45s;
}
body.intro .historia {
  max-height: 80dvh;
  overflow: auto;
  opacity: 1;
  visibility: visible;
  transition: max-height .45s ease, opacity .35s ease;
}
body:not(.intro) .historia { margin-top: 0; padding-block: 0; border-width: 0; }
.historia h2 {
  margin: 6px 0 10px;
  font: 400 clamp(1.6rem, 7vw, 2rem)/1.12 var(--editorial);
  color: var(--bosque);
}
.historia > p { margin: 0 0 10px; }
#premisa { font-size: 1.02rem; line-height: 1.45; }
.reparto-resumen { font-size: .85rem; color: var(--mute); }
.reparto-resumen strong { color: var(--victima); }
.historia .origen { margin: 12px 0 0; font-size: .8rem; color: var(--mute); text-align: center; }
.leyenda-piezas { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin: 4px 0 14px; }
.leyenda-piezas h3 {
  margin: 0 0 2px;
  font: 700 10.5px/1.3 var(--tecnica);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.leyenda-piezas .si h3 { color: var(--teal); }
.leyenda-piezas .no h3 { color: var(--victima); }
.pieza { display: flex; align-items: center; gap: 8px; font-size: .82rem; line-height: 1.15; margin: 4px 0; }
.pieza span.dibujo-pieza {
  flex: none;
  width: 52px;
  height: 30px;
  display: grid;
  place-items: center;
  background: var(--calido);
  border: 1px solid var(--regla);
  border-radius: 6px;
}
.pieza img { max-width: 48px; max-height: 26px; }

/* El juego se desenfoca y vela mientras la historia está abierta, como en la app. */
.juego { transition: filter .45s ease, opacity .45s ease; }
body.intro .juego { filter: blur(7px); opacity: .45; pointer-events: none; user-select: none; }

/* ---------- Mesa de juego ---------- */
.juego {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.zona-tablero { padding: 2px 10px 0 4px; display: flex; justify-content: center; }
.zona-mando { flex: 1; display: flex; flex-direction: column; min-height: 0; width: min(100%, 560px); margin: 0 auto; }

.tablero {
  --margen-coord: 18px;
  width: min(100%, max(250px, calc(100dvh - 380px)), 560px);
  display: grid;
  grid-template-columns: var(--margen-coord) minmax(0, 1fr);
  grid-template-rows: var(--margen-coord) auto;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.columnas, .filas { display: grid; color: var(--teal); font: 700 11px/1 var(--lectura); }
.columnas { grid-column: 2; grid-template-columns: var(--pista-x); }
.filas { grid-row: 2; grid-template-rows: var(--pista-y); }
.columnas span, .filas span { display: grid; place-items: center; }
.superficie { grid-column: 2; grid-row: 2; position: relative; aspect-ratio: var(--relacion); }
.dibujo, .marcas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.marcas { overflow: visible; }
.casillas {
  position: absolute;
  left: var(--rejilla-x);
  top: var(--rejilla-y);
  width: var(--rejilla-ancho);
  height: var(--rejilla-alto);
  display: grid;
  grid-template-columns: repeat(var(--ancho), 1fr);
  grid-template-rows: repeat(var(--alto), 1fr);
  touch-action: manipulation;
}
.casilla { min-width: 0; min-height: 0; border: 0; padding: 0; background: none; border-radius: 3px; }
.casilla:focus-visible { outline-offset: -3px; }
@media (hover: hover) { .casilla:hover { background: #fffdf759; } }
.superficie.con-lapiz::after {
  content: "";
  position: absolute;
  left: var(--rejilla-x);
  top: var(--rejilla-y);
  width: var(--rejilla-ancho);
  height: var(--rejilla-alto);
  background: #1e476b14;
  outline: 4px solid var(--pluma);
  pointer-events: none;
}

/* Fichas sobre el plano (SVG en unidades del plano). */
.ficha-plano { transform-box: fill-box; transform-origin: center; }
.ficha-plano.nueva { animation: rebote .42s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes rebote { from { transform: scale(.35); } to { transform: scale(1); } }
.marcas text { font-family: var(--lectura); }
.tachada-nueva { animation: trazo .25s ease-out; }
@keyframes trazo { from { opacity: 0; transform: scale(.6); } }
.tachada-nueva { transform-box: fill-box; transform-origin: center; }

/* ---------- Tira de personas ---------- */
.tira { display: flex; justify-content: center; gap: 2px; padding: 6px 6px 0; }
.persona {
  width: 66px;
  display: grid;
  justify-items: center;
  gap: 1px;
  padding: 4px 2px;
  border: 0;
  border-radius: 8px;
  background: none;
}
.persona:hover { background: #1f2c2a0b; }
.medallon { position: relative; width: 50px; height: 50px; }
.medallon img {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1.5px solid var(--regla);
  background: var(--calido);
  transition: border-color .15s, box-shadow .15s;
}
.persona[data-victima="true"] .medallon img { border-color: var(--victima); }
.persona[aria-pressed="true"] .medallon img { border-color: var(--teal); box-shadow: 0 0 0 2px var(--teal); }
.colocada {
  position: absolute;
  top: -2px;
  right: -3px;
  width: 17px;
  height: 17px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--teal);
  border: 1.5px solid var(--papel);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}
.persona .nombre { font-size: 11.5px; line-height: 1.2; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.persona[aria-pressed="true"] .nombre { font-weight: 700; }
.persona[data-victima="true"] .nombre { color: var(--victima); }
.persona .estado { font: 9px/1.2 var(--tecnica); color: var(--mute); min-height: 11px; }
.persona[data-victima="true"] .estado:not(.puesta) { color: var(--victima); }

/* ---------- Panel de pistas ---------- */
.panel {
  flex: 1;
  min-height: 92px;
  margin: 4px 10px;
  background: var(--blanco);
  border: 1px solid var(--regla);
  border-top: 3px solid var(--teal);
  border-radius: 8px;
  padding: 8px 13px 10px;
  overflow: auto;
}
.panel.victima { border-top-color: var(--victima); }
.panel-cabecera { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.panel-cabecera img { width: 34px; height: 34px; border-radius: 50%; }
.panel-cabecera h2 { margin: 0; font: 400 1.3rem/1.1 var(--editorial); }
.etiqueta-victima { font: 700 10px/1 var(--tecnica); letter-spacing: .06em; color: var(--victima); }
.pista { margin: 4px 0; font-size: .97rem; line-height: 1.4; }
.pista.tachada { color: #52615d99; text-decoration: line-through; }
.nota { margin: 6px 0 0; font-size: .78rem; line-height: 1.35; color: var(--mute); }
.termino {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--pluma);
  text-decoration: underline dotted 1.5px;
  text-underline-offset: 3px;
}
.tachada .termino { color: inherit; }

/* ---------- Barra inferior ---------- */
.barra { display: flex; align-items: center; gap: 4px; padding: 6px 10px 10px; }
.boton {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 24px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: .95rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background .15s, color .15s, border-color .15s, transform .1s;
}
.boton:active:not(:disabled) { transform: scale(.97); }
.boton svg { width: 18px; height: 18px; fill: currentColor; }
.boton.principal { background: var(--teal); color: #fff; }
.boton.principal:hover { background: #1b3b36; }
.boton.ancho { width: 100%; font-size: 1rem; }
.boton.secundario { background: var(--blanco); color: var(--teal); border-color: var(--regla); }
.lapiz { flex: 1; min-width: 0; margin-left: 4px; background: var(--blanco); border-color: var(--regla); color: var(--tinta); }
.lapiz span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lapiz[aria-pressed="true"] { background: var(--pluma); border-color: var(--pluma); color: #fff; }
.acusar { margin-left: 6px; background: var(--cobre); color: #fff; }
.acusar:hover:not(:disabled) { background: #793f2c; }
.acusar:disabled { background: var(--regla); color: var(--mute); }
.acusar.lista { animation: latido 1.6s ease-in-out 3; }
@keyframes latido { 50% { box-shadow: 0 0 0 7px #8e503933; } }

/* ---------- Aviso (snackbar) ---------- */
.aviso {
  position: fixed;
  z-index: 60;
  left: 50%;
  bottom: calc(80px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 24px);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 16px;
  border-radius: 6px;
  background: var(--tinta);
  color: var(--papel);
  font-size: .9rem;
  box-shadow: 0 6px 20px #0004;
  animation: sube .2s ease-out;
}
@keyframes sube { from { opacity: 0; transform: translate(-50%, 10px); } }
.aviso button { border: 0; background: none; color: #9fd3c7; font-weight: 700; padding: 4px; text-transform: uppercase; font-size: .82rem; }

/* ---------- Diálogos ---------- */
.dialogo {
  width: min(100% - 32px, 440px);
  max-height: min(88dvh, 720px);
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: var(--blanco);
  color: var(--tinta);
  box-shadow: 0 20px 60px #0005;
}
.dialogo::backdrop { background: #1f2c2a80; }
.dialogo[open] { animation: aparece .2s ease-out; }
@keyframes aparece { from { opacity: 0; transform: scale(.94); } }
.dialogo-cuerpo { padding: 22px 22px 12px; display: flex; flex-direction: column; max-height: inherit; }
#dialogo-contenido { overflow: auto; }
.dialogo h2 { margin: 0 0 12px; font: 400 1.5rem/1.2 var(--editorial); color: var(--tinta); }
.dialogo p { margin: 6px 0; line-height: 1.45; }
.dialogo h3 {
  margin: 16px 0 4px;
  font: 400 11px/1.3 var(--tecnica);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--cobre);
}
.dialogo ol { padding-left: 22px; margin: 6px 0; }
.dialogo li { margin: 6px 0; line-height: 1.4; }
.dialogo-botones { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 4px; padding-top: 12px; }
.enlace {
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 22px;
  background: none;
  color: var(--teal);
  font-weight: 600;
}
.enlace:hover { background: var(--palido); }
.sospechosos { display: grid; gap: 2px; }
.sospechoso {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px;
  border: 0;
  border-radius: 10px;
  background: none;
  font-size: 1.05rem;
  text-align: left;
}
.sospechoso:hover { background: var(--palido); }
.sospechoso img { width: 42px; height: 42px; border-radius: 50%; }
.dibujo-termino { display: flex; justify-content: center; margin: 12px 0 4px; }
.dibujo-termino svg { width: 190px; height: auto; }

.sello {
  display: block;
  width: max-content;
  margin: 4px auto 16px;
  padding: 4px 14px;
  border: 3px solid var(--victima);
  border-radius: 6px;
  color: var(--victima);
  font: 700 1.6rem/1.2 var(--tecnica);
  letter-spacing: .04em;
  transform: rotate(-6deg);
  animation: sello .45s cubic-bezier(.5, 0, .7, .4) both;
}
@keyframes sello {
  0% { transform: rotate(-6deg) scale(2.6); opacity: 0; }
  55% { transform: rotate(-6deg) scale(1); opacity: 1; }
  75% { transform: rotate(-6deg) scale(1.06); }
  100% { transform: rotate(-6deg) scale(1); }
}
.tiempo { font: 13px/1.4 var(--tecnica); color: var(--mute); }
.libro {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 14px;
  align-items: center;
  margin-top: 16px;
  padding: 12px;
  background: var(--calido);
  border: 1px solid var(--regla);
  border-radius: 12px;
}
.libro img { width: 96px; border-radius: 3px; box-shadow: 0 4px 12px #0003; }
.libro p { margin: 0 0 8px; font-size: .92rem; }
.libro .titulo-libro { font: 700 1.15rem/1.15 var(--editorial); color: var(--bosque); margin-bottom: 4px; }
.boton.comprar { background: var(--cobre); color: #fff; text-decoration: none; min-height: 42px; padding: 0 16px; font-size: .9rem; }
.boton.comprar:hover { background: #793f2c; }

/* ---------- Tutorial ---------- */
.capa-guia { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.velo { position: absolute; inset: 0; width: 100%; height: 100%; }
.senal {
  position: absolute;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  border: 3px solid var(--ambar);
  animation: senal 1.3s ease-out infinite;
}
.senal.mantener { animation: mantener 1.6s ease-in-out infinite; background: radial-gradient(circle, #e8a20055 0 40%, transparent 41%); }
@keyframes senal { 0% { transform: scale(.55); opacity: 1; } 100% { transform: scale(1.35); opacity: 0; } }
@keyframes mantener { 0%, 15% { transform: scale(.5); opacity: .4; } 70% { transform: scale(1); opacity: 1; } 100% { transform: scale(1); opacity: 0; } }
.burbuja {
  position: absolute;
  left: 50%;
  width: min(100% - 24px, 400px);
  transform: translateX(-50%);
  padding: 14px 16px 8px;
  background: var(--blanco);
  border-radius: 14px;
  border-top: 4px solid var(--ambar);
  box-shadow: 0 14px 40px #0005;
  pointer-events: auto;
  transition: top .3s ease;
}
.burbuja .paso { margin: 0; font: 10.5px/1.3 var(--tecnica); letter-spacing: .06em; text-transform: uppercase; color: var(--cobre); }
.burbuja h2 { margin: 2px 0 6px; font: 400 1.25rem/1.2 var(--editorial); }
.burbuja p { margin: 0; font-size: .95rem; line-height: 1.42; }
.burbuja-botones { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.burbuja-botones .boton { min-height: 42px; }
.burbuja .enlace { color: var(--mute); font-weight: 500; font-size: .85rem; padding: 0 6px; }
.burbuja.sacude { animation: sacude .35s; }
@keyframes sacude { 25% { margin-left: -6px; } 75% { margin-left: 6px; } }

/* ---------- Pantallas anchas: plano a la izquierda, como la app apaisada ---------- */
@media (min-width: 860px) and (min-aspect-ratio: 1/1) {
  .juego { flex-direction: row; align-items: flex-start; gap: 20px; padding: 8px 20px 20px; }
  .zona-tablero { flex: 1.15; padding: 0; }
  .tablero { width: min(100%, calc(100dvh - 120px), 640px); }
  .zona-mando { flex: 1; width: auto; max-width: 440px; margin: 0; align-self: stretch; }
  .tira { justify-content: flex-start; }
  .panel { flex: 0 1 auto; min-height: 140px; }
  .barra { margin-top: auto; }
  .cabecera { padding-inline: 26px 16px; }
}
@media (max-height: 640px) and (max-width: 859px) {
  .tablero { width: min(100%, max(230px, calc(100dvh - 330px))); }
  .persona { width: 58px; }
  .medallon, .medallon img { width: 42px; height: 42px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
