/* Plano del juego fiel al libro (portado de la app RobArte): cámaras, leyenda, rosa de los vientos,
   salidas marcadas y acusación final. Se carga después de style.css. */
.game-layout {
  --papel: #fbf8f2; --tinta: #1c1c1d; --tinta-suave: #6b665f; --linea-papel: #d9d0c0;
  --surface: #fffdf8; --surface-2: #f5e7d7; --line: #dcd3c2; --text: #1c1c1d; --muted-txt: #55524c;
  --granate: #b82028; --granate-hi: #921a21; --laton: #17505c; --teal: #17505c; --bg: #fcefe2; --ok: #2e7d32;
  --display: "Source Serif 4", Georgia, serif;
}
   ========================================================= */
:root { --papel: #fbf8f2; --tinta: #1c1c1d; --tinta-suave: #6b665f; --linea-papel: #d9d0c0; --teal: #17505c; }

.ayuda { font-size: 14px; }
.juego { display: grid; gap: 16px; }

/* Bandeja de sospechosos */
.suspect-tray {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
}
.suspect-token {
  flex: none; width: 84px; scroll-snap-align: start;
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  background: var(--surface); border: 2px solid var(--line); border-radius: 10px;
  padding: 8px 6px 7px; cursor: pointer; user-select: none; -webkit-user-select: none;
  transition: border-color .15s ease, opacity .15s ease, transform .12s ease;
}
.suspect-token:active { transform: scale(.96); }
.suspect-token img { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; background: var(--surface-2); border: 2px solid var(--line); }
.suspect-token span { font-size: 11.5px; font-weight: 600; line-height: 1.15; }
.suspect-token span.role { font-size: 10.5px; font-weight: 400; color: var(--muted-txt); }
.suspect-token.armed { border-color: var(--granate); background: #fbeeee; }
.suspect-token.armed img { border-color: var(--granate-hi); }
.suspect-token.placed { opacity: .35; }

/* Plano */
.board-wrap {
  background: var(--papel); color: var(--tinta);
  border-radius: 10px; padding: 12px 4px; overflow-x: auto;
  box-shadow: inset 0 0 0 1px var(--linea-papel);
}
.board { display: grid; gap: 4px; width: max-content; margin: 0 auto; font-size: 11px; position: relative; }
.board .hd { display: flex; align-items: center; justify-content: center; color: var(--tinta-suave); font-weight: 600; font-variant-numeric: tabular-nums; }
.board .cell {
  background: #fff; border: 1px solid var(--linea-papel);
  display: flex; align-items: center; justify-content: center; position: relative; cursor: pointer;
}
.board .cell:active { background: #f3ebe0; }
.board .cell > img { width: 84%; height: 84%; border-radius: 50%; object-fit: cover; border: 2px solid var(--teal); }

.element-box {
  border: 1.5px solid var(--tinta); background: var(--papel); color: var(--tinta);
  font-size: 9px; font-weight: 700; padding: 2px 3px; line-height: 1.1; text-align: center;
  display: flex; align-items: center; justify-content: center; min-width: 60%; max-width: 94%; overflow: hidden;
}
.element-box.wheels { position: relative; margin-bottom: 6px; overflow: visible; }
.element-box.wheels::before, .element-box.wheels::after {
  content: ""; position: absolute; bottom: -6px; width: 5px; height: 5px; border-radius: 50%; background: var(--tinta);
}
.element-box.wheels::before { left: 18%; }
.element-box.wheels::after { right: 18%; }

.plant-icon-wrap { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.plant-icon { width: 60%; height: auto; opacity: .9; }
.camera-icon-wrap { position: absolute; inset: 3px; display: flex; gap: 2px; pointer-events: none; }
.camera-icon-wrap.dir-E { flex-direction: row; justify-content: flex-start; align-items: center; }
.camera-icon-wrap.dir-W { flex-direction: row; justify-content: flex-end; align-items: center; }
.camera-icon-wrap.dir-S { flex-direction: column; justify-content: flex-start; align-items: center; }
.camera-icon-wrap.dir-N { flex-direction: column; justify-content: flex-end; align-items: center; }
.camera-icon { width: 46%; height: auto; flex: none; }
.camera-arrow { width: 42%; height: auto; flex: none; filter: brightness(0) saturate(100%); }

.wall-edge { position: absolute; background: var(--tinta); }
.wall-edge.bottom { left: 0; right: 0; bottom: -3px; height: 4px; }
.wall-edge.right { top: 0; bottom: 0; right: -3px; width: 4px; }
.wall-edge.top { left: 0; right: 0; top: -3px; height: 4px; }
.wall-edge.left { top: 0; bottom: 0; left: -3px; width: 4px; }

.exit-tag {
  font-size: 10px; font-weight: 700; color: var(--granate); letter-spacing: .02em;
  display: flex; align-items: center; justify-content: center; text-align: center; white-space: nowrap; padding: 2px;
}
.exit-tag.side-top, .exit-tag.side-bottom { overflow: hidden; }
.exit-tag.side-top { align-items: flex-end; }
.exit-tag.side-bottom { align-items: flex-start; }
/* En el móvil, las salidas laterales en vertical para dejar sitio a las casillas */
.exit-tag.side-left, .exit-tag.side-right { writing-mode: vertical-rl; width: 16px; padding: 0; }
.exit-tag.side-left { transform: rotate(180deg); }

/* Cuaderno */
.notebook { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.notebook-head {
  padding: 10px 14px; font-size: 11px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase;
  color: var(--laton); border-bottom: 1px solid var(--line);
}
.notebook-row {
  display: grid; grid-template-columns: 1fr 1fr 24px; gap: 6px 8px; align-items: center;
  padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 14px;
}
.notebook-row:last-child { border-bottom: 0; }
.notebook-row > span:first-child { grid-column: 1 / -1; font-weight: 600; }
.notebook-row select {
  width: 100%; min-width: 0; padding: 8px; border-radius: 8px; font: inherit; font-size: 13px;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
}
.result-mark { font-weight: 700; text-align: center; font-size: 16px; }
.result-mark.ok { color: var(--ok); }
.result-mark.bad { color: var(--granate-hi); }

/* Botones y resultado */
.game-actions { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; }
.game-feedback { display: none; padding: 16px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); }
.game-feedback.show { display: block; }
.game-feedback.success { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, var(--surface)); }
.game-feedback.fail { border-color: var(--granate); }
.game-feedback h3 { margin: 0 0 6px; font-family: var(--display); font-size: 22px; font-style: italic; }
.game-feedback p { margin: 0; font-size: 15px; line-height: 1.5; }

/* ---- Ajustes de legibilidad del plano en el móvil ---- */
.game-layout { --cell: 54px; }
.exit-tag.side-left, .exit-tag.side-right {
  writing-mode: horizontal-tb; transform: none; width: 56px; padding: 0 2px; letter-spacing: -.01em;
  white-space: normal; font-size: 8px; line-height: 1.1; hyphens: auto; -webkit-hyphens: auto; overflow-wrap: anywhere;
}
.exit-tag.side-left { justify-content: flex-end; text-align: right; }
.exit-tag.side-right { justify-content: flex-start; text-align: left; }
.exit-tag.side-top, .exit-tag.side-bottom { overflow: visible; font-size: 9px; position: relative; z-index: 1; }
.element-box { font-size: clamp(6.5px, calc(var(--cell) * .19), 10px); padding: 2px 1px; letter-spacing: -.02em; }
.suspect-token img, .board .cell > img { color: transparent; font-size: 0; }
.game-actions { grid-template-columns: 1fr auto; }

/* Banco y estatua con el dibujo del libro */
.board .cell > img.element-icon { width: 70%; height: 70%; object-fit: contain; border: 0; border-radius: 0; }
.board .cell > img.element-estatua { width: 56%; height: 80%; }
.camera-icon-wrap { z-index: 1; }

/* Salidas laterales: ancho de la palabra más larga, sin partir palabras */
.exit-tag.side-left, .exit-tag.side-right {
  width: var(--lateral, 56px); font-size: 8.5px; hyphens: manual; -webkit-hyphens: manual;
  overflow-wrap: normal; word-break: keep-all;
}
/* Banco que comparte casilla con una cámara: abajo, como en el libro */
.board .cell.con-camara > img.element-banco { align-self: flex-end; height: 42%; margin-bottom: 6%; }

/* ---------- v0.9: rosa de los vientos, casillas ocupadas, glosario y pista ---------- */
.rosa { width: 48px; height: 48px; margin: 0 0 -4px 6px; color: var(--tinta); }
.rosa svg { width: 100%; height: 100%; display: block; }
.board .cell.ocupada { cursor: not-allowed; }
.board .cell.ocupada:active { background: #fff; }
.board .cell.rechazo { animation: rechazo .4s ease; }
@keyframes rechazo {
  0%, 100% { transform: none; }
  20% { transform: translateX(-3px); box-shadow: inset 0 0 0 2px var(--granate); }
  40% { transform: translateX(3px); box-shadow: inset 0 0 0 2px var(--granate); }
  60% { transform: translateX(-2px); box-shadow: inset 0 0 0 2px var(--granate); }
  80% { transform: translateX(2px); }
}

/* Bandeja de sospechosos: todas las fichas a la vista (en filas), sin desplazamiento lateral escondido */
.suspect-tray { flex-wrap: wrap; justify-content: center; overflow: visible; scroll-snap-type: none; }
@media (max-width: 767px) {
  .suspect-tray .suspect-token { width: calc((100% - 24px) / 4); min-width: 70px; }
}
/* Etiquetas de elementos en casillas pequeñas: letra más pequeña y partida antes que cortada */
.element-box { font-size: clamp(6px, calc(var(--cell, 48px) * .2), 9px); overflow-wrap: anywhere; letter-spacing: -.02em; padding-inline: 1px; }
.salidas-estrechas .exit-tag.side-left, .salidas-estrechas .exit-tag.side-right { overflow-wrap: normal; word-break: normal; }
.salidas-estrechas .exit-tag.side-left, .salidas-estrechas .exit-tag.side-right { font-size: 7.5px; }

/* ---------- v0.10: objetos por sospechoso y acusación final ---------- */
.notebook-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); align-items: center; }
.notebook-row > span:first-child { grid-column: auto; font-size: 15px; }
.notebook-row > span:first-child::after { content: " —"; color: var(--muted-txt); font-weight: 400; }
@media (min-width: 768px) {
  .notebook-row { grid-template-columns: minmax(140px, 1fr) minmax(0, 1.3fr); }
}
.acusacion {
  margin-top: 4px; padding: 16px; border-radius: 12px;
  background: var(--text); color: var(--bg);
  display: grid; gap: 10px;
}
.acusacion-tit {
  margin: 0 0 2px; font-size: 13px; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: #f3c9cc;
}
.acusacion-campo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 10px; align-items: center; font-weight: 600; font-size: 15px; }
.acusacion-campo select {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid #5a5651; background: var(--surface); color: var(--text); font: inherit; font-weight: 500; font-size: 15px;
}
.acusacion-resumen {
  margin: 4px 0 0; padding: 10px 12px; border-radius: 8px; background: rgba(255,255,255,.08);
  font-size: 15px; line-height: 1.5;
}
.acusacion-resumen strong { color: #fff; }
.acusacion-resumen .falta { color: #f3c9cc; font-style: italic; }
.game-actions .btn-check { font-weight: 700; letter-spacing: .02em; }
.game-feedback ul { margin: 6px 0 0; padding-left: 20px; display: grid; gap: 4px; font-size: 15px; }
.game-feedback .veredicto-resumen { margin: 0 0 12px; font-weight: 500; }
.game-feedback .eyebrow { margin: 0 0 4px; }
@media (max-width: 480px) {
  .acusacion-campo { grid-template-columns: 1fr; gap: 4px; }
  .notebook-row { grid-template-columns: minmax(0, .9fr) minmax(0, 1.5fr); }
}

/* ---------- v0.11: plano fiel al libro ---------- */
/* Cámaras: icono del libro (variante por orientación y pared) en su posición exacta dentro de la casilla */
.board .cell > img.camara {
  position: absolute; transform: translate(-50%, -50%); object-fit: contain;
  border: 0; border-radius: 0; z-index: 2; pointer-events: none;
}
.camara-flecha { position: absolute; transform: translate(-50%, -50%); background: var(--tinta); z-index: 2; pointer-events: none; --punta: max(4px, calc(var(--cell, 48px) * .085)); }
.camara-flecha.dir-E, .camara-flecha.dir-W { height: 1.3px; }
.camara-flecha.dir-N, .camara-flecha.dir-S { width: 1.3px; }
.camara-flecha::after {
  content: ""; position: absolute; width: var(--punta); height: var(--punta);
  border-top: 1.3px solid var(--tinta); border-right: 1.3px solid var(--tinta); box-sizing: border-box;
}
.camara-flecha.dir-E::after { right: 0; top: 50%; transform: translate(0, -50%) rotate(45deg); transform-origin: center; }
.camara-flecha.dir-W::after { left: 0; top: 50%; transform: translate(0, -50%) rotate(-135deg); }
.camara-flecha.dir-N::after { top: 0; left: 50%; transform: translate(-50%, 0) rotate(-45deg); }
.camara-flecha.dir-S::after { bottom: 0; left: 50%; transform: translate(-50%, 0) rotate(135deg); }

/* Ficha o elemento en una casilla con cámara: en la mitad libre, sin taparla */
.board .cell > img.ficha-abajo, .board .cell > img.ficha-arriba { position: absolute; width: 56%; height: 56%; left: 50%; transform: translateX(-50%); }
.board .cell > img.ficha-abajo { bottom: 5%; }
.board .cell > img.ficha-arriba { top: 5%; }
.board .cell > .junto-camara-abajo, .board .cell > .junto-camara-arriba { position: absolute; left: 50%; transform: translateX(-50%); }
.board .cell > img.junto-camara-abajo, .board .cell > img.junto-camara-arriba { width: 66%; height: 36%; }
.board .cell > .junto-camara-abajo { bottom: 10%; }
.board .cell > .junto-camara-arriba { top: 10%; }
.board .cell.con-camara > img.element-banco { align-self: auto; margin: 0; }

/* Elementos gráficos que no ocupan casilla (reloj de pared) */
.grafico { position: absolute; transform: translate(-50%, -50%); aspect-ratio: 1; color: var(--tinta); z-index: 2; pointer-events: none; }
.grafico svg { width: 100%; height: 100%; display: block; }

/* Elemento que no ocupa la casilla (VA, MDE…): solo texto, como en el libro */
.element-texto { font-weight: 700; color: var(--tinta); font-size: clamp(7px, calc(var(--cell, 48px) * .24), 13px); letter-spacing: .02em; }

/* Salida: línea granate centrada en el borde de la casilla */
.salida-marca { position: absolute; background: var(--granate); border-radius: 2px; z-index: 3; pointer-events: none; }
.salida-marca.lado-top, .salida-marca.lado-bottom { left: 50%; width: 46%; height: 4px; transform: translateX(-50%); }
.salida-marca.lado-left, .salida-marca.lado-right { top: 50%; height: 46%; width: 4px; transform: translateY(-50%); }
.salida-marca.lado-top { top: -2.5px; }
.salida-marca.lado-bottom { bottom: -2.5px; }
.salida-marca.lado-left { left: -2.5px; }
.salida-marca.lado-right { right: -2.5px; }

/* Leyenda del plano (debajo de la cuadrícula, dentro del mismo papel) */
.leyenda { margin: 14px 4px 2px; display: grid; gap: 8px; color: var(--tinta); }
.leyenda-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.leyenda-col { border: 1px solid var(--linea-papel); background: #fff; border-radius: 4px; overflow: hidden; }
.leyenda h4 { margin: 0; padding: 5px 6px; background: #ececec; font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; text-align: center; }
.leyenda ul { list-style: none; margin: 0; padding: 6px 7px 7px; display: grid; gap: 3px; font-size: 11px; line-height: 1.3; }
.leyenda li b { font-weight: 700; }
.leyenda li.vineta::before { content: "• "; }
.leyenda-nota { border: 1px solid var(--linea-papel); background: #f6f6f4; border-radius: 4px; padding: 7px 9px; }
.leyenda-nota h4 { background: none; padding: 0 0 3px; text-align: left; font-size: 10px; }
.leyenda-nota p { margin: 0; font-size: 11.5px; line-height: 1.4; }
@media (max-width: 380px) {
  .leyenda ul { font-size: 10.5px; padding: 5px; }
}
@media (min-width: 768px) {
  .leyenda ul { font-size: 12.5px; }
  .leyenda h4 { font-size: 11px; }
  .leyenda-nota p { font-size: 12.5px; }
}
.board .element-box, .board .element-texto { overflow-wrap: normal; word-break: normal; white-space: normal; max-width: 96%; line-height: 1.05; }
/* Recuadro que ocupa dos casillas (vitrina alta, lienzo…) */
.board .cell > .element-doble { position: absolute; left: 9%; top: 50%; transform: translateY(-50%); z-index: 2; max-width: none; justify-content: center; text-align: center; }
/* Rótulo bajo el banco (RA-001) */
.board .cell > img.con-rotulo { height: 46%; margin-bottom: 14%; }
.element-rotulo { position: absolute; bottom: 7%; left: 0; right: 0; text-align: center; font-weight: 700; color: var(--tinta); font-size: clamp(6px, calc(var(--cell, 48px) * .15), 10px); }
/* Línea de salida desplazada para no tapar la cámara */
.salida-marca.desplazada.lado-top, .salida-marca.desplazada.lado-bottom { width: 32%; }
.salida-marca.desplazada.lado-left, .salida-marca.desplazada.lado-right { height: 32%; }
.exit-tag.dos-lineas { white-space: normal; text-align: center; line-height: 1.1; max-width: calc(var(--cell, 48px) * 1.5); justify-self: center; }
.board .element-box, .board .element-texto { overflow: hidden; }
.exit-tag.side-left, .exit-tag.side-right { overflow-wrap: normal; word-break: normal; hyphens: manual; -webkit-hyphens: manual; }

/* Móvil: el plano nunca ensancha la página */
.game-layout > div { min-width: 0; }
.board-wrap { max-width: 100%; overflow-x: auto; }

/* Palabras largas (p. ej. alemán) no deben ensanchar las fichas */
.suspect-token { min-width: 0; }
.suspect-token span { overflow-wrap: anywhere; hyphens: auto; }

/* ---------- Guía rápida (ventana superpuesta) ---------- */
.case-top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.case-top-row .case-tag { margin: 0; }
.guia-btn { white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; font-weight: 700;
  box-shadow: 0 2px 0 rgba(0,0,0,.18), 0 4px 12px rgba(0,0,0,.15); cursor: pointer; }
.guia-btn::before { content: "?"; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; color: var(--ink, #1c1c1d); font-size: .8rem; font-weight: 800; line-height: 1; flex: none; }
.guia-btn:hover { transform: translateY(-1px); }
.guia-btn:focus-visible { outline: 3px solid #b5232f; outline-offset: 3px; }
.guia-modal {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(28, 28, 29, .72);
}
.guia-modal[hidden] { display: none; }
.guia-panel {
  position: relative; width: min(560px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);
  overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--surface); border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35); outline: none;
}
.guia-bar {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.guia-titulo { margin: 0; font-size: 1rem; font-family: inherit; font-weight: 700; }
.guia-cerrar {
  border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; font-weight: 600; font-size: .9rem;
  padding: 8px 14px; border-radius: 8px; cursor: pointer; min-height: 40px;
}
.guia-cerrar:hover { background: var(--surface-2); }
.guia-cerrar:focus-visible { outline: 3px solid var(--granate); outline-offset: 2px; }
.guia-img { display: block; width: 100%; height: auto; }
body.guia-abierta { overflow: hidden; }

/* ---------- Glosario: palabra con asterisco y su aviso ---------- */
.glosa {
  border: 0; background: none; padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer;
  text-decoration: underline dotted var(--laton); text-underline-offset: 3px;
}
.glosa sup { color: var(--granate); font-weight: 700; font-size: .8em; margin-left: 1px; }
.glosa:focus-visible { outline: 2px solid var(--granate); outline-offset: 2px; border-radius: 2px; }
.glosa-toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 210;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 500; max-width: calc(100% - 32px); text-align: center; cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .3);
}
.glosa-toast[hidden] { display: none; }
