/* La interfaz conserva la paleta, los rótulos y los sprites originales.
   Los textos de juego tienen tamaño de pantalla, independiente del zoom del tablero. */
html.vertical, html.vertical body { height: 100%; overflow: hidden; touch-action: auto; }
.vertical * { box-sizing: border-box; }
.vertical button { font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.vertical button:focus-visible, .vertical summary:focus-visible { outline: 3px solid #fff3ad; outline-offset: 3px; }
.vertical button:disabled { opacity: .45; cursor: default; }
.vertical [hidden] { display: none !important; }
.m-app { --oro: #ffd84a; --borde: #3b3850; color: #e8e6f0; background: #1c1b27;
  font: 16px/1.45 system-ui, sans-serif; position: relative; max-width: 600px; margin: auto;
  height: 100%; height: 100dvh; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  display: grid; grid-template-rows: auto minmax(180px, 1fr) auto minmax(110px, .58fr) auto; }
.m-header { padding: 10px 12px 7px; border-bottom: 2px solid #0f0e16; }
.m-brand { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.m-logo { width: 182px; max-width: 66%; height: auto; image-rendering: pixelated; }
.m-icon, .m-button { min-width: 44px; min-height: 44px; border: 2px solid #3b3850; background: #262433; color: #ffd84a; padding: 9px 12px; border-radius: 3px; }
.m-icon { font-size: 20px !important; padding: 4px 10px; }
.m-button { font: 10px/1.7 "Press Start 2P", monospace !important; }
.m-button.primary { color: #14141c; background: #ffd84a; border-color: #ffd84a; box-shadow: 0 3px 0 #a17b28; }
.m-meta { display: flex; gap: 10px; justify-content: space-between; align-items: baseline; margin-top: 5px; font-size: 13px; }
.m-level { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-count { flex-shrink: 0; color: #d8d3e6; }
.m-board { position: relative; min-height: 0; background: #14141c; overflow: hidden; touch-action: none; }
html.vertical #juego { position: absolute; inset: 0 0 34px; width: 100%; height: auto; }
.m-seats { position: absolute; inset: 0 0 34px; overflow: hidden; pointer-events: none; }
.m-seat { position: absolute; pointer-events: auto; background: transparent; border: 0; padding: 0; border-radius: 4px; touch-action: none; }
.m-seat:focus-visible { background: #ffd84a35; outline-offset: -2px !important; }
.m-table-label { position: absolute; transform: translateX(-50%); padding: 1px 5px; background: #171622dd; color: #eee8d0;
  font-size: 11px; line-height: 16px; white-space: nowrap; pointer-events: none; }
.m-table-label.de-pie { writing-mode: vertical-rl; transform: translate(-50%, -50%); padding: 4px 0; font-size: 10px; line-height: 14px; }
/* Lo que suelta cada uno al sentarse (y lo que se dice en la historia de entrada): a tamaño de pantalla, no al del tablero */
.m-bubble { position: absolute; z-index: 2; margin: 0; max-width: min(240px, calc(100% - 8px)); padding: 6px 10px; background: #f4f1e8; color: #23202e;
  border: 2px solid #23202e; border-radius: 6px; font-size: 14px; line-height: 1.3; text-align: center; pointer-events: none; }
.m-bubble::before, .m-bubble::after { content: ''; position: absolute; left: var(--pico, 50%); border: solid transparent; transform: translateX(-50%); }
.m-bubble::before { top: 100%; border-width: 9px 8px 0; border-top-color: #23202e; }
.m-bubble::after { top: calc(100% - 3px); border-width: 7px 6px 0; border-top-color: #f4f1e8; }
.m-bubble.debajo::before { top: auto; bottom: 100%; border-width: 0 8px 9px; border-color: transparent transparent #23202e; }
.m-bubble.debajo::after { top: auto; bottom: calc(100% - 3px); border-width: 0 6px 7px; border-color: transparent transparent #f4f1e8; }
.m-bubble.piensa { border-radius: 16px; }
.m-bubble.piensa::before { top: calc(100% + 3px); width: 9px; height: 9px; border: 2px solid #23202e; border-radius: 50%; background: #f4f1e8; }
.m-bubble.piensa::after { top: calc(100% + 17px); width: 5px; height: 5px; border: 2px solid #23202e; border-radius: 50%; background: #f4f1e8; }
.m-zoom { position: absolute; top: 6px; right: 8px; display: flex; gap: 4px; }
.m-zoom button { background: #1c1b27ed; min-width: 44px; min-height: 44px; border: 1px solid #676079; color: #ffd84a; font: 18px monospace; border-radius: 3px; }
.m-zoom button:last-child { font-size: 12px; padding: 6px 8px; }
.m-hint { position: absolute; bottom: 0; margin: 0; padding: 7px 12px; width: 100%; height: 34px; background: #14141c; color: #e0d7ab; font-size: 12px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-roster-wrap { padding: 6px 0 5px; border-bottom: 1px solid #3b3850; min-width: 0; }
.m-roster-head { display: flex; justify-content: space-between; align-items: center; min-height: 26px; padding: 0 12px 2px; color: #a9a6bd; font-size: 11px; }
.m-roster-more { margin: -8px -8px -6px 0; padding: 8px; min-height: 40px; background: none; border: 0; color: #ffd84a; font-size: 12px !important; }
.m-everyone h3 { margin: 14px 0 8px; color: #a9a6bd; font: 9px/1.8 "Press Start 2P", monospace; }
.m-everyone h3:first-child { margin-top: 0; }
.m-people { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 6px; }
.m-people .m-person { min-width: 0; }
.m-roster { display: flex; overflow-x: auto; overscroll-behavior-x: contain; gap: 6px; padding: 2px 12px 5px; scrollbar-width: thin; scrollbar-color: #746844 #1c1b27; touch-action: pan-x; }
.m-person { position: relative; flex: 0 0 calc((100% - 24px) / 5); min-width: 62px; min-height: 98px; padding: 0 1px 7px; color: #e8e6f0; background: #262433; border: 2px solid #3b3850; border-radius: 3px; display: flex; flex-direction: column; align-items: center; justify-content: end; }
/* Como en la placa: abajo, el color de su partido */
.m-person::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--partido, transparent); }
.m-person[aria-pressed=true] { border-color: #ffd84a; background: #373126; box-shadow: inset 0 0 0 1px #ffd84a; }
.m-person img { width: auto; height: 67px; max-width: 100%; image-rendering: pixelated; object-fit: contain; }
.m-person-name { display: block; max-width: 100%; font-size: 11px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.m-person-state { position: absolute; top: 1px; right: 3px; background: #1c1b27; font-size: 11px; line-height: 16px; color: #e8e6f0; }
.m-detail { margin: 8px 12px 0; padding: 10px 12px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; background: #262433; border: 1px solid #3b3850; scrollbar-width: thin; }
.m-detail h2 { color: #ffd84a; font: 11px/1.8 "Press Start 2P", monospace; margin: 0; }
.m-detail-head { display: flex; align-items: start; justify-content: space-between; gap: 8px; }
.m-party { flex-shrink: 0; padding: 3px 6px; font-size: 12px; font-weight: 700; }
.m-detail p { margin: 7px 0; }
.m-traits { color: #bcb7ce; font-size: 13px; }
.m-wishes { margin: 8px 0 0; padding: 0; list-style: none; }
.m-wishes li { display: flex; gap: 9px; margin: 5px 0; line-height: 1.4; }
.m-wishes img { width: 14px; height: 14px; flex: 0 0 14px; image-rendering: pixelated; margin-top: 4px; }
.m-detail .m-button { margin-top: 10px; }
.m-vote { position: absolute; top: 6px; left: 8px; z-index: 1; max-width: calc(100% - 200px); min-height: 44px; padding: 4px 8px; background: #14141ceb; border: 1px solid #676079; border-radius: 3px;
  color: #ffd84a; font-size: 12px !important; line-height: 1.4; text-align: left; }
.m-vote span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-vote-count { color: #f08070; }
.m-vote-count.bien { color: #8fe070; }
.m-actions { display: flex; gap: 7px; padding: 9px 12px 10px; }
.m-actions .m-button { flex: 1; }
.m-screen { position: absolute; inset: 0; background: #14141c; z-index: 5; overflow: auto; overscroll-behavior: contain; touch-action: pan-y; padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom)); }
/* La portada: el título arriba, los botones abajo y, en medio, con todo el sitio que quede, el hemiciclo */
.m-home { height: 100%; min-height: 320px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.m-home .m-logo { width: 280px; max-width: 78%; flex-shrink: 0; }
.m-home p { color: #bcb7ce; margin: 0; }
.m-home-hint { font-size: 12px; }
.m-home-actions { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 440px; flex-shrink: 0; }
.m-home-more { display: flex; gap: 8px; }
.m-home-more .m-button { flex: 1; min-width: 0; padding-left: 4px; padding-right: 4px; }
/* El hemiciclo se recorre de lado con el dedo; dentro, la sala es tan ancha como bancadas haya */
.m-hemiciclo { flex: 1 1 0; min-height: 150px; align-self: stretch; margin: 0 -16px; overflow-x: auto; overflow-y: hidden;
  border-block: 2px solid #23202e; overscroll-behavior-x: contain; touch-action: pan-x; scrollbar-width: none; }
.m-hemiciclo::-webkit-scrollbar { display: none; }
.m-hemiciclo-sala { position: relative; height: 100%; background-color: #9a1f2d;
  background-image: radial-gradient(#7d162680 2.5px, transparent 3px); background-size: 44px 22px; }
.m-hemiciclo-sala::before { content: ''; position: absolute; inset: 0 0 auto; height: var(--pared);      /* la pared de madera, con sus columnas */
  background: linear-gradient(transparent calc(100% - 12px), #4d2f1b 0), repeating-linear-gradient(90deg, #d8c9a6 0 9px, #b9a67d 9px 12px, #6b4226 12px 96px); }
.m-escano { position: absolute; width: calc(46px * var(--z)); height: calc(79px * var(--z)); margin-left: calc(-23px * var(--z)); padding: 0; background: none; border: 0; }
.m-escano::before { content: ''; position: absolute; left: calc(6px * var(--z)); top: calc(20px * var(--z)); width: calc(34px * var(--z)); height: calc(34px * var(--z));
  background: linear-gradient(#a8404b 0 28%, #8c2f3a 0); border: 2px solid #23202e; }
.m-escano .m-actor { left: 50%; bottom: calc(13px * var(--z)); }
.m-escano.bote .m-actor { animation: m-pasos calc(6s / var(--ritmo)) steps(6) infinite, m-bote .22s ease-out; }
@keyframes m-bote { 50% { transform: translateY(calc(-6px * var(--z))); } }
.m-pupitre { position: absolute; inset: auto 0 0; height: calc(26px * var(--z)); display: flex; flex-direction: column; justify-content: center; gap: 1px; overflow: hidden;
  padding: calc(5px * var(--z)) 2px 0; background: linear-gradient(#c98f52 0 calc(5px * var(--z)), #8f5f33 0); border: 1px solid #23202e; }
.m-pupitre b { display: block; overflow: hidden; background: #f4f1e8; color: #23202e; font-size: 10px; line-height: 12px; letter-spacing: -.2px; text-overflow: clip; text-transform: uppercase; white-space: nowrap; }
.m-pupitre i { display: block; overflow: hidden; font-size: 9px; font-style: normal; font-weight: 700; line-height: 11px; white-space: nowrap; }
.m-hemiciclo .m-bubble { z-index: 20; max-width: 230px; color: #23202e; }
.m-hemiciclo .m-bubble b { display: block; font-size: 11px; color: #6b6577; }
.m-home small { font: 9px/1.8 "Press Start 2P", monospace; color: #bcb7ce; }
.m-screen-bar { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.m-screen h1 { font: 15px/1.7 "Press Start 2P", monospace; color: #ffd84a; }
.m-screen h2 { font: 11px/1.8 "Press Start 2P", monospace; color: #ffd84a; margin: 24px 0 10px; }
.m-levels { display: grid; gap: 8px; }
.m-level-button { display: grid; grid-template-columns: 30px 1fr auto; gap: 10px; align-items: center; width: 100%; padding: 13px 12px; min-height: 60px; background: #262433; color: #e8e6f0; border: 1px solid #3b3850; text-align: left; }
.m-level-button.current { border: 2px solid #ffd84a; }
.m-level-button b { color: #ffd84a; font: 11px "Press Start 2P", monospace; }
.m-level-button small { color: #a9a6bd; }
.m-level-button.done small { color: #91d773; }
.m-dialog { box-sizing: border-box; width: calc(100% - 24px); max-width: 460px; max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); margin: auto; padding: 20px; background: #262433; color: #e8e6f0; border: 2px solid #ffd84a; font: 16px/1.5 system-ui, sans-serif; overscroll-behavior: contain; touch-action: pan-y; }
.m-dialog::backdrop { background: #0f0e16c9; }
.m-dialog h2 { font: 13px/1.8 "Press Start 2P", monospace; color: #ffd84a; margin: 0 0 12px; }
.m-dialog p { white-space: pre-line; margin: 10px 0; }
.m-dialog .m-dialog-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.m-dialog-actions .m-button { flex: 1; }
/* Un muñeco animado con su hoja original de fondo: --fila dice hacia dónde mira, --ritmo a cuántos fotogramas por segundo */
.m-actor { position: absolute; bottom: 0; width: var(--fw); height: var(--fh); margin-left: calc(var(--fw) / -2); pointer-events: none;
  background-repeat: no-repeat; background-size: calc(var(--fw) * var(--columnas)) calc(var(--fh) * var(--filas));
  background-position: 0 calc(var(--fh) * var(--fila) * -1); image-rendering: pixelated;
  animation: m-pasos calc(6s / var(--ritmo)) steps(6) infinite; }
@keyframes m-pasos { to { background-position-x: calc(var(--fw) * -6); } }
/* La historia de entrada: encima de todo, con el juego entreviéndose detrás */
.m-story { position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column; overflow: hidden; background: #14141cf2;
  padding: max(18px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  transition: opacity .22s; touch-action: manipulation; }
.m-story.fuera { opacity: 0; }
.m-story-head { text-align: center; }
.m-story-head h2 { margin: 0; color: #ffd84a; font: 14px/1.7 "Press Start 2P", monospace; }
.m-story-head .m-traits { margin: 4px 0 12px; }
.m-story-desc { max-width: 34em; margin: 0 auto; }
.m-story-stage { position: relative; flex: 1; min-height: 0; }
.m-story-voice { top: auto; max-width: min(330px, calc(100% - 16px)); padding: 8px 12px; font-size: 16px; }
.m-story-voice b { display: block; margin-bottom: 2px; font-size: 11px; color: #6b6577; }
.m-story-actions { display: flex; gap: 10px; padding-top: 10px; }
.m-story-actions .m-button { flex: 1; }
.m-iris { position: absolute; left: 50%; top: 68%; z-index: 9; width: 2px; height: 2px; border-radius: 50%; transform: translate(-50%, -50%);
  box-shadow: 0 0 0 200vmax #000; pointer-events: none; animation: m-iris 1.3s .25s ease-in forwards; }
@keyframes m-iris { to { width: 260vmax; height: 260vmax; } }
@media (max-height: 600px) {
  .m-story { padding-top: max(8px, env(safe-area-inset-top)); }
  .m-story.hablando .m-story-desc { display: none; }
}
.m-menu { display: grid; gap: 10px; }
.m-credit { text-align: center; }
.m-credit p { white-space: pre-line; }
.m-autor { min-height: 204px; }
.m-autor img { display: block; height: 204px; width: auto; margin: 0 auto; image-rendering: pixelated; }
.m-credit .m-autor-nombre { color: #fff; font: 11px/1.8 "Press Start 2P", monospace; }
.m-credit { padding-bottom: 20px; }
.m-desfile { position: sticky; bottom: calc(-1 * max(20px, env(safe-area-inset-bottom))); height: 84px; margin: 0 -16px; overflow: hidden; pointer-events: none;
  background: #14141c; border-bottom: 2px solid #3b3850; }
.m-desfile .m-actor { left: 0; animation: m-pasos calc(6s / var(--ritmo)) steps(6) infinite, m-desfilar var(--tarda, 11s) linear forwards; }
@keyframes m-desfilar { from { transform: translateX(-40px); } to { transform: translateX(calc(100vw + 40px)); } }
@media (prefers-reduced-motion: reduce) {
  .m-iris { display: none; }
  .m-actor { animation: none; transition: none !important; }
}
.m-app[data-mode=video] { grid-template-rows: auto 1fr auto; }
.m-app[data-mode=video] .m-roster-wrap, .m-app[data-mode=video] .m-detail,
.m-app[data-mode=video] .m-zoom, .m-app[data-mode=video] .m-hint, .m-app[data-mode=video] .m-seats { display: none; }
.m-app[data-mode=video] #juego { inset: 0; }
@media (max-height: 700px) and (orientation: portrait) {
  .m-header { padding-top: 5px; }
  .m-logo { width: 152px; }
  .m-person { min-height: 84px; }
  .m-person img { height: 55px; }
  .m-app { grid-template-rows: auto minmax(155px, 1fr) auto minmax(100px, .6fr) auto; }
  .m-actions { padding-top: 6px; padding-bottom: 6px; }
}
@media (orientation: landscape) and (max-height: 600px) {
  .m-app { max-width: 1100px; grid-template-columns: 56% 44%; grid-template-rows: auto auto minmax(75px, 1fr) auto; }
  .m-header { grid-column: 1 / -1; padding-top: 2px; padding-bottom: 2px; display: flex; gap: 20px; align-items: center; }
  .m-brand { flex: 1; }
  .m-meta { flex: 1; margin: 0; }
  .m-logo { width: 134px; }
  .m-board { grid-column: 1; grid-row: 2 / 5; }
  .m-roster-wrap { grid-column: 2; grid-row: 2; }
  .m-person { min-height: 78px; }
  .m-person img { height: 48px; }
  .m-detail { grid-column: 2; grid-row: 3; margin-top: 4px; }
  .m-actions { grid-column: 2; grid-row: 4; padding-top: 5px; padding-bottom: 5px; }
  .m-home { gap: 6px; }
  .m-home .m-logo { width: 170px; }
  .m-home small, .m-home-hint { display: none; }
  .m-home-actions { flex-direction: row; max-width: none; }
  .m-home-actions > .m-button { flex: 1; }
  .m-home-more { flex: 2; }
  .m-app[data-mode=video] { display: grid; grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .m-app[data-mode=video] .m-board { grid-row: 2; }
  .m-app[data-mode=video] .m-actions { grid-column: 1; grid-row: 3; }
}
