/* CHANKAS · Interfaz v2 («más legible»): tejido, quipu y piedra. */
:root {
  /* Color */
  --ground: #16121a;
  --deep: #0b080d;
  --panel: #221b26;
  --panel-2: #1e1822;
  --border: #2e2533;
  --cream: #f2e6cc;
  --muted: #dccfb4;
  --dim: #b3a58a;
  --dim-2: #8a7d66;
  --empty: #4a3f4e;
  --gold: #e9b53b;
  --gold-shadow: #8a6a1e;
  --bronze: #a27c34;
  --cochinilla: #a8301f;
  --red: #d8432f;
  --green: #6e8a47;
  --blue: #5b7bb0;
  --fire: #e9732b;
  --spit: #c3eaa8;
  --spit-dark: #79b46b;
  --ficcion: #e77a6b;
  /* Tipografía */
  --font-display: "Jersey 10", "Pixelify Sans", ui-monospace, monospace;
  --font-pixel: "Pixelify Sans", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --font-body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Tejido (tocapu) */
  --tocapu-16: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='16' shape-rendering='crispEdges'%3E%3Crect width='16' height='16' fill='%23A8301F'/%3E%3Crect x='16' width='16' height='16' fill='%230B080D'/%3E%3Cpath d='M6 2h4v2h2v2h2v4h-2v2h-2v2H6v-2H4v-2H2V6h2V4h2z' fill='%23E9B53B'/%3E%3Crect x='7' y='7' width='2' height='2' fill='%23A8301F'/%3E%3Cpath transform='translate(16 0)' d='M6 2h4v2h2v2h2v4h-2v2h-2v2H6v-2H4v-2H2V6h2V4h2z' fill='%23F2E6CC'/%3E%3Crect x='23' y='7' width='2' height='2' fill='%230B080D'/%3E%3C/svg%3E");
  --tocapu-8: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='8' shape-rendering='crispEdges'%3E%3Crect width='16' height='8' fill='%23A8301F'/%3E%3Cpath d='M3 1h2v1h1v1h1v2H6v1H5v1H3V6H2V5H1V3h1V2h1z' fill='%23E9B53B'/%3E%3Cpath transform='translate(8 0)' d='M3 1h2v1h1v1h1v2H6v1H5v1H3V6H2V5H1V3h1V2h1z' fill='%230B080D'/%3E%3C/svg%3E");
  --tocapu-v: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='32' shape-rendering='crispEdges'%3E%3Crect width='16' height='16' fill='%23A8301F'/%3E%3Crect y='16' width='16' height='16' fill='%230B080D'/%3E%3Cpath d='M6 2h4v2h2v2h2v4h-2v2h-2v2H6v-2H4v-2H2V6h2V4h2z' fill='%23E9B53B'/%3E%3Cpath transform='translate(0 16)' d='M6 2h4v2h2v2h2v4h-2v2h-2v2H6v-2H4v-2H2V6h2V4h2z' fill='%23F2E6CC'/%3E%3C/svg%3E");
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  background: var(--ground);
  /* Sin zoom por doble toque en ninguna parte (el pellizco lo bloquean el viewport y ui.js). */
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
/* El juego no se selecciona, no abre la lupa/menú de iOS y no hace gestos del navegador. */
#game-section {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.stage > canvas,
.stage[data-state="playing"],
.hud,
.controls,
.pad {
  touch-action: none;
}
body {
  margin: 0;
  min-height: 100vh;
  background: var(--ground);
  color: var(--cream);
  font: 16px/1.5 var(--font-body);
  overflow-x: hidden;
}
h1,
h2,
h3,
p {
  margin: 0;
}
a {
  color: var(--gold);
}
a:hover {
  color: var(--cream);
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}
:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
[hidden] {
  display: none !important;
}
.pix,
canvas {
  image-rendering: pixelated;
}

/* Componentes ---------------------------------------------------------- */
.notch {
  box-shadow:
    0 -4px 0 0 var(--deep),
    0 4px 0 0 var(--deep),
    -4px 0 0 0 var(--deep),
    4px 0 0 0 var(--deep);
}
.notch-gold {
  box-shadow:
    0 -4px 0 0 var(--gold),
    0 4px 0 0 var(--gold),
    -4px 0 0 0 var(--gold),
    4px 0 0 0 var(--gold);
}
kbd {
  font-family: var(--font-pixel);
  font-weight: 700;
  font-size: 15px;
  line-height: 1;
  color: var(--ground);
  background: var(--cream);
  padding: 5px 7px 4px;
  box-shadow: 0 3px 0 0 var(--dim-2);
  display: inline-block;
  min-width: 12px;
  text-align: center;
  white-space: nowrap;
}
.tocapu {
  display: block;
  height: 16px;
  background: var(--tocapu-16) repeat-x left top;
  flex: none;
}
.tocapu-sm {
  height: 8px;
  background-image: var(--tocapu-8);
}
.tocapu-v {
  width: 16px;
  background: var(--tocapu-v) repeat-y left top;
  flex: none;
}
.eyebrow {
  font-size: 16px;
  letter-spacing: 0.08em;
  color: var(--gold);
}
.label {
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.2em;
  color: var(--muted);
}
.label.gold {
  color: var(--gold);
}
.label.fiction {
  color: var(--ficcion);
}
.muted {
  color: var(--muted);
}
.dim {
  color: var(--dim);
}
.quipu {
  font-family: var(--font-display);
  font-size: 40px;
  line-height: 0.9;
  color: var(--gold);
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 16px;
  background: var(--panel);
  color: var(--cream);
  border: 0;
  font-family: var(--font-pixel);
  font-size: 15px;
}
.btn:hover {
  background: var(--border);
}
.btn.notch:focus-visible {
  outline-offset: 6px;
}
#nav-map {
  font-family: var(--font-body);
}
#sound .snd-on,
#sound[aria-pressed="true"] .snd-off {
  display: none;
}
#sound[aria-pressed="true"] .snd-on {
  display: inline;
}

/* Página: el juego es el protagonista (sin cabecera grande; el logo va en la franja) ---- */
body {
  --chrome: 252px; /* alto reservado bajo el juego: barra de controles + franja + márgenes */
}
body[data-layout="touch"] {
  --chrome: 74px; /* solo la franja compacta: los mandos van sobre el juego */
}
.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 16px 56px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
body[data-layout="touch"] .page {
  padding-top: 0;
}
body[data-layout="touch"] .game {
  margin-inline: -16px;
}

/* Sección del juego: escenario (con HUD y controles) + franja con la ruta ----------- */
.game {
  background: var(--deep);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.play {
  position: relative;
}

/* HUD superpuesto: vida y provisiones arriba a la izquierda; etapa y pausa a la derecha. */
.hud {
  grid-area: 1 / 1;
  align-self: start;
  position: relative;
  z-index: 1;
  display: none;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  padding: clamp(6px, 1.3cqw, 16px);
  padding-left: max(clamp(6px, 1.3cqw, 16px), env(safe-area-inset-left));
  padding-right: max(clamp(6px, 1.3cqw, 16px), env(safe-area-inset-right));
  font-size: clamp(12px, 1.9cqw, 24px);
  line-height: 1;
  pointer-events: none;
}
.stage[data-state="playing"] .hud,
.stage[data-state="paused"] .hud,
.stage[data-state="lost"] .hud,
.stage[data-state="won"] .hud {
  display: flex;
}
.stage:not([data-state="playing"]) .hud {
  opacity: 0.4;
}
.hud button {
  pointer-events: auto;
}
.hud-left,
.hud-right {
  display: flex;
  flex-direction: column;
  gap: clamp(4px, 0.8cqw, 10px);
  min-width: 0;
}
.hud-right {
  align-items: flex-end;
}
.hud-top {
  display: flex;
  align-items: stretch;
  gap: clamp(4px, 0.8cqw, 10px);
}
.hearts {
  display: flex;
  gap: clamp(2px, 0.4cqw, 6px);
  filter: drop-shadow(0 2px 0 rgba(11, 8, 13, 0.7));
}
.heart svg {
  display: block;
  width: clamp(18px, 3.1cqw, 42px);
  height: auto;
}
.heart .o {
  fill: #1b1210;
}
.heart .f {
  fill: var(--red);
}
.heart .s {
  fill: var(--cochinilla);
}
.heart .h {
  fill: #ffd9c9;
}
.heart.is-empty .f,
.heart.is-empty .s {
  fill: var(--empty);
}
.heart.is-empty .h {
  display: none;
}
/* Paneles oscuros translúcidos con borde de bronce/oro (como el arte clave). */
.hud-panel,
.hud-btn {
  background: rgba(14, 10, 16, 0.8);
  border: 2px solid var(--bronze);
  box-shadow:
    0 0 0 2px rgba(11, 8, 13, 0.85),
    inset 0 0 0 1px rgba(233, 181, 59, 0.2);
  color: var(--cream);
}
.hud-res {
  display: flex;
  align-items: center;
  gap: clamp(8px, 2cqw, 26px);
  padding: clamp(4px, 0.7cqw, 9px) clamp(8px, 1.5cqw, 18px);
}
.res {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.res .ico svg {
  display: block;
  width: 1.35em;
  height: 1.35em;
}
.res .x {
  margin-left: 0.15em;
  font-weight: 400;
  color: var(--muted);
}
.res.is-selected {
  color: var(--gold);
}
.llama-ico {
  color: var(--spit);
}
svg.llama-ico path {
  fill: var(--spit);
}
.hud-stage {
  display: flex;
  align-items: center;
  gap: clamp(6px, 1cqw, 14px);
  padding: clamp(3px, 0.5cqw, 6px) clamp(10px, 2.2cqw, 28px) clamp(3px, 0.5cqw, 6px) clamp(3px, 0.5cqw, 6px);
}
.hud-emblem {
  display: grid;
  place-items: center;
  width: 2.5em;
  height: 2.5em;
  background: var(--deep);
  box-shadow: inset 0 0 0 1px var(--bronze);
}
.hud-emblem svg {
  width: 1.8em;
  height: auto;
}
.hud-stage-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2em;
}
.hud-stage-name {
  font-weight: 700;
  font-size: 1.05em;
  white-space: nowrap;
}
.hud-stage-sub {
  font-size: 0.78em;
  color: var(--muted);
  white-space: nowrap;
}
.hud-btn {
  display: grid;
  place-items: center;
  width: clamp(44px, 5.6cqw, 66px);
  min-height: 44px;
  padding: 0;
}
.hud-btn svg {
  width: 42%;
  height: auto;
}
.hud-btn:hover {
  border-color: var(--gold);
}
.hud-btn:active {
  background: var(--cochinilla);
}
.hud-quipu {
  display: flex;
  align-items: baseline;
  gap: 0.5em;
  padding: 0.15em 0.6em 0.1em;
  font-size: 0.72em;
}
.hud-label {
  letter-spacing: 0.18em;
  color: var(--muted);
}
.hud-quipu .quipu {
  font-size: 1.9em;
}

/* Escenario: canvas 16:9 y pantallas superpuestas en la misma celda ---- */
.stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  background: var(--deep);
  container: stage / inline-size;
  overflow: hidden;
  /* El lienzo 16:9 cabe en la altura de la ventana junto a la barra y la franja. */
  width: min(100%, max(320px, calc((100svh - var(--chrome)) * 16 / 9)));
  margin-inline: auto;
}
.stage[data-state="map"] {
  width: 100%; /* el mapa decide su propio encuadre (apaisado o vertical) */
}
.stage > canvas {
  grid-area: 1 / 1;
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  transition: filter 0.2s;
}
/* Mapa en pantallas estrechas: game.js pasa el canvas a 780×1040 (encuadre vertical 3:4). */
.stage > canvas[data-layout="portrait"] {
  aspect-ratio: 3 / 4;
}
.has-ui .stage[data-state="menu"] > canvas {
  filter: brightness(0.55) saturate(0.85);
}
.has-ui .stage[data-state="paused"] > canvas {
  filter: brightness(0.35) saturate(0.6);
}
.has-ui .stage[data-state="lost"] > canvas,
.has-ui .stage[data-state="won"] > canvas {
  filter: brightness(0.45) saturate(0.75);
}
.screen {
  grid-area: 1 / 1;
  display: none;
  min-width: 0;
  position: relative;
  z-index: 1;
}
.stage[data-state="menu"] .title-screen,
.stage[data-state="paused"] .pause-screen {
  display: flex;
}

/* Menús (título y pausa): la fila «actual» lleva fondo cochinilla y flecha. */
.menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 48px;
  padding: 0 16px;
  background: transparent;
  border: 0;
  color: var(--cream);
  font-size: 20px;
  text-align: left;
}
.menu-item .arrow {
  flex: none;
  visibility: hidden;
}
.menu-item.is-current {
  background: var(--cochinilla);
  font-weight: 700;
}
.menu-item.is-current .arrow {
  visibility: visible;
}
.menu-item:hover:not(.is-current) {
  background: rgba(242, 230, 204, 0.08);
}
.menu-item:focus-visible {
  outline-offset: -3px;
}
.menu-item .value {
  margin-left: auto;
  color: var(--muted);
  font-weight: 400;
}
.menu-quiet {
  color: var(--muted);
}
/* Sobre cochinilla, el texto atenuado no llega a 4.5:1: se usa crema (≈5.5:1). */
.menu-item.is-current,
.menu-item.is-current .value {
  color: var(--cream);
}
/* Sin ui.js (fallback) solo quedan el canvas, la tarjeta clásica y los controles. */
body:not(.has-ui) .hud,
body:not(.has-ui) .pad,
body:not(.has-ui) .screen:not(#overlay),
body:not(.has-ui) .map-cartouche,
body:not(.has-ui) .map-panel,
body:not(.has-ui) .route,
body:not(.has-ui) .touch-pause,
body:not(.has-ui) [data-action] {
  display: none !important;
}

/* Título: el arte clave de fondo (assets/keyart.webp, mismo origen: img-src 'self') con un
   degradado oscuro que garantiza el contraste del menú, a la derecha. */
.title-screen {
  align-items: stretch;
  justify-content: flex-end;
  background:
    linear-gradient(270deg, rgba(11, 8, 13, 0.96) 0%, rgba(11, 8, 13, 0.9) 36%, rgba(11, 8, 13, 0.3) 58%, rgba(11, 8, 13, 0) 78%),
    url("assets/keyart.webp") left center / cover no-repeat,
    var(--deep);
}
.title-panel {
  width: 45.3%;
  min-width: 340px;
  background: transparent;
  padding: clamp(28px, 5.4cqw, 56px);
  padding-bottom: clamp(24px, 3.5cqw, 36px);
  display: flex;
  flex-direction: column;
  gap: clamp(20px, 3.5cqw, 36px);
}
.title-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.title-head .eyebrow,
.title-head .sub {
  font-size: 15px;
}
.title-head .sub {
  letter-spacing: 0.08em;
  color: var(--muted);
}
.title-logo {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(64px, 10cqw, 104px);
  line-height: 0.82;
  letter-spacing: 0.04em;
  color: var(--gold);
}
.title-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
}
.keys-hint {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* Pausa */
.pause-screen {
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.pause-box {
  width: min(800px, 100%);
  background: var(--ground);
  display: flex;
  flex-direction: column;
}
.pause-grid {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
}
.pause-menu {
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  box-shadow: inset -2px 0 0 var(--border);
}
.pause-menu .menu {
  gap: 4px;
}
.pause-menu .menu-item {
  min-height: 44px;
  padding: 0 14px;
  gap: 12px;
  font-size: 18px;
}
.pause-heading {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 64px;
  line-height: 0.85;
  color: var(--gold);
}
.pause-info {
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.pause-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stack.end {
  align-items: flex-end;
  gap: 0;
}
.pause-stage-name {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
}
.inventory {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.inventory li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 10px;
  background: var(--panel);
  font-size: 15px;
  text-align: center;
}
.inv-count {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.pause-hint {
  color: var(--muted);
}

/* Derrota / victoria (tarjeta clásica #overlay con el estilo de la pausa) */
.result-screen {
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.result-box {
  width: min(560px, 100%);
  background: var(--ground);
  padding: 28px 32px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.result-box h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(40px, 6cqw, 56px);
  line-height: 0.9;
  color: var(--gold);
}
.result-box p {
  color: var(--muted);
}
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 6px;
}
.btn-primary,
.btn-secondary {
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  font-size: 18px;
  font-weight: 700;
}
.btn-primary {
  background: var(--gold);
  color: var(--ground);
  box-shadow: 0 4px 0 0 var(--gold-shadow);
}
.btn-primary:hover {
  background: #f2c65a;
}
.btn-secondary {
  background: transparent;
  color: var(--cream);
  box-shadow: inset 0 0 0 2px var(--border);
  font-weight: 400;
}
.btn-secondary:hover {
  background: var(--panel);
}

/* Mapa: cartela y panel «Las cinco cuerdas» ---------------------------- */
.map-cartouche,
.map-panel {
  display: none;
}
.map-cartouche {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 1;
  width: max-content; /* a la medida del texto: nunca lo recorta */
  min-width: 300px;
  max-width: calc(100% / 3 * 2 - 24px);
  min-height: 84px;
  padding: 14px 18px;
  background: var(--deep);
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 4px 0 0 var(--cochinilla);
}
.map-cartouche .label {
  font-size: 13px;
  letter-spacing: 0.14em;
  white-space: nowrap;
}
.map-cartouche-title {
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 0.9;
  color: var(--gold);
}
.stage[data-state="map"] .map-panel {
  display: flex;
}
.map-panel {
  grid-row: 2;
  flex-direction: column;
  gap: 14px;
  padding: 38px 20px 20px;
  background:
    var(--tocapu-16) repeat-x left top / 32px 16px,
    var(--ground);
  min-width: 0;
}
.mp-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mp-head p {
  font-size: 15px;
  color: var(--muted);
}
.mp-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mp-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 6px 10px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 16px;
  text-align: left;
}
.mp-row:hover {
  background: rgba(242, 230, 204, 0.08);
}
.mp-row:focus-visible {
  outline-offset: -3px;
}
.mp-row[aria-current="true"] {
  background: var(--cochinilla);
  color: var(--cream);
  font-weight: 700;
}
.mp-cord {
  width: 4px;
  height: 22px;
  flex: none;
}
.mp-name {
  flex: 1;
  min-width: 0;
}
.mp-status {
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.12em;
  color: var(--cream);
  white-space: nowrap;
}
.mp-status.is-completed {
  color: #a9c77f;
}
.mp-row[aria-current="true"] .mp-status.is-completed {
  color: var(--cream);
}
.mp-text {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
  box-shadow: inset 0 2px 0 var(--border);
}
.mp-text .label {
  font-size: 13px;
  padding-top: 6px;
}
.mp-text h3.label:first-child {
  padding-top: 12px;
}
.mp-text p {
  font-size: 15px;
  line-height: 1.45;
}
.mp-play {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 48px;
  flex: none;
  background: var(--gold);
  color: var(--ground);
  border: 0;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 4px 0 0 var(--gold-shadow);
}
.mp-play kbd {
  font-size: 14px;
  padding: 4px 6px 3px;
}
.mp-play:hover {
  background: #f2c65a;
}
.mp-play[aria-disabled="true"] {
  background: var(--panel);
  color: var(--muted);
  box-shadow: inset 0 0 0 2px var(--border);
}
.mp-play[aria-disabled="true"] kbd {
  display: none;
}
.mp-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}
.mp-hint kbd {
  font-size: 14px;
  padding: 4px 6px 3px;
}
.mp-notice {
  min-height: 0;
  font-size: 14px;
  color: var(--ficcion);
  text-align: center;
}
.mp-notice:empty {
  display: none;
}

/* Escritorio ancho: el panel sustituye a la ficha del canvas (columna derecha). */
@container stage (min-width: 1000px) {
  .stage[data-state="map"] .map-cartouche {
    display: flex;
  }
  .map-panel {
    grid-row: auto; /* en una rejilla, un hijo absoluto con fila usa esa celda como bloque contenedor */
    position: absolute;
    z-index: 1;
    top: 0;
    right: 0;
    bottom: 0;
    width: calc(100% / 3);
    padding: 16px 22px 14px 38px;
    gap: 10px;
    background:
      var(--tocapu-v) repeat-y left top / 16px 32px,
      var(--ground);
    overflow-y: auto;
  }
  .mp-list {
    gap: 0;
  }
  .mp-head p {
    font-size: 14px;
  }
  .mp-text {
    gap: 4px;
  }
  .mp-text p {
    font-size: 14.5px;
    line-height: 1.4;
  }
}

/* Avisos pequeños del escenario */
@container stage (max-width: 700px) {
  .title-panel {
    width: 100%;
    min-width: 0;
  }
  .title-screen .tocapu-v {
    display: none;
  }
  .pause-screen,
  .result-screen {
    padding: 12px;
  }
  .pause-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .pause-menu {
    padding: 20px 18px;
    gap: 14px;
    box-shadow: inset 0 -2px 0 var(--border);
  }
  .pause-heading {
    font-size: 52px;
  }
  .pause-info {
    padding: 20px 18px;
    gap: 14px;
  }
  .inventory {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .inventory li {
    padding: 12px 6px;
    font-size: 14px;
  }
  .result-box {
    padding: 22px 20px 24px;
  }
}

/* Controles en pantalla -------------------------------------------------- */
/* Escritorio (ratón): barra de botones grandes bajo el juego. Son los mismos botones que en
   táctil; el teclado sigue funcionando. Táctil: se superponen al juego (ver más abajo). */
.controls {
  grid-row: 3;
  grid-column: 1;
  display: flex;
  gap: clamp(6px, 1.1cqw, 16px);
  padding: clamp(8px, 1.2cqw, 16px) clamp(8px, 1.4cqw, 18px);
  background: #0f0b12;
  box-shadow: inset 0 2px 0 #241d29;
}
.stage[data-state="map"] .controls {
  display: none;
}
.cbtn {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  min-height: clamp(52px, 6.2cqw, 80px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 4px 6px;
  background: linear-gradient(#231c28, #17121b);
  border: 2px solid #3b3142;
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.6),
    0 2px 0 #000;
  color: var(--cream);
  font: 400 clamp(13px, 1.65cqw, 21px) / 1.1 var(--font-body);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.cbtn:hover {
  border-color: #5b4b63;
}
.cbtn:active {
  background: var(--cochinilla);
}
.cbtn.is-selected {
  border-color: var(--gold);
  box-shadow:
    0 0 0 1px var(--gold-shadow),
    inset 0 0 14px rgba(233, 181, 59, 0.2);
}
.cbtn-move {
  flex-grow: 1.3;
}
.cbtn-move svg {
  width: clamp(14px, 1.9cqw, 24px);
  height: auto;
}
.cico svg {
  display: block;
  width: auto;
  height: clamp(22px, 3cqw, 40px);
  max-width: clamp(28px, 4.2cqw, 54px);
}
.cbadge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 1.5em;
  padding: 1px 4px;
  background: #3b3340;
  color: var(--cream);
  font-weight: 700;
  font-size: 0.8em;
  line-height: 1.25;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.cbadge-green {
  background: #3f7c34;
}
/* Botón de la llama: cargas de escupitajo y la que se recupera (relleno de abajo arriba). */
.touch-spit::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--fill, 0) * 100%);
  background: var(--spit-dark);
  opacity: 0.3;
  transition: height 0.25s linear;
  pointer-events: none;
}
.touch-spit.is-empty {
  color: var(--dim-2);
}
.touch-spit.is-empty .llama-ico {
  color: var(--empty);
}
.touch-spit.is-empty .cbadge {
  background: var(--empty);
  color: var(--muted);
}
.touch-spit.is-hint {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  animation: hint-pulse 0.8s steps(2, jump-none) infinite alternate;
}
@keyframes hint-pulse {
  to {
    outline-color: var(--spit);
  }
}

/* Táctil (puntero grueso): mandos translúcidos que no tapan al héroe ------------------
   Pulgar izquierdo: cruceta abajo a la izquierda. Pulgar derecho: LANZAR (grande, en la
   esquina) y SALTAR justo a su lado, como en un arcade. Encima de LANZAR, una fila corta de
   fichas: arma (tocar = siguiente arma), escupitajo de la llama y Recargar (solo cuando sirve).
   En reposo son translúcidos (~45 %); al pulsar, opacos. Respetan las zonas seguras (notch). */
body[data-layout="touch"] {
  --t-pad: min(30vh, 128px);
  --t-fire: min(25vh, 100px);
  --t-jump: min(21vh, 86px);
  --t-chip: min(11vh, 44px);
  --t-gap: 10px;
  /* Abajo, junto al notch, sobra hueco: los mandos se acercan al borde (notch a media altura). */
  --t-left: max(12px, calc(env(safe-area-inset-left) - 24px));
  --t-right: max(12px, calc(env(safe-area-inset-right) - 24px));
  --t-bottom: max(10px, env(safe-area-inset-bottom));
}
body[data-layout="touch"] .controls {
  grid-area: 1 / 1;
  align-self: end;
  justify-self: end;
  z-index: 2;
  flex-direction: row;
  align-items: flex-end;
  gap: 6px;
  margin: 0 6px calc(var(--t-bottom) + var(--t-fire) + 22px) 0;
  padding: 0;
  background: none;
  box-shadow: none;
  pointer-events: none;
}
body[data-layout="touch"] .stage:not([data-state="playing"]) .controls,
body[data-layout="touch"] .cbtn-move,
body[data-layout="touch"] .cbtn-pause,
body[data-layout="touch"] .cbtn-reload,
body[data-layout="touch"] .controls [data-key="Space"],
body[data-layout="touch"] .cbtn-weapon:not(.is-selected),
body[data-layout="touch"] .controls .clabel {
  display: none;
}
body[data-layout="touch"][data-reload="true"] .cbtn-reload {
  display: flex;
}
body[data-layout="touch"] .cbtn {
  flex: none;
  width: var(--t-chip);
  height: var(--t-chip);
  min-height: 0;
  padding: 0;
  gap: 0;
  border-radius: 12px;
  border: 2px solid rgba(233, 181, 59, 0.45);
  background: rgba(14, 10, 16, 0.5);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
  opacity: 0.62;
  pointer-events: auto;
  transition: opacity 0.12s, transform 0.08s;
}
body[data-layout="touch"] .cbtn:active,
body[data-layout="touch"] .cbtn.is-pressed {
  opacity: 1;
  transform: scale(0.94);
  background: rgba(168, 48, 31, 0.85);
}
/* Arma elegida: sin el marco dorado de escritorio (aquí siempre hay una sola visible). */
body[data-layout="touch"] .cbtn.is-selected {
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
}
body[data-layout="touch"] .cbtn-reload {
  order: -1; /* aparece a la izquierda: arma y llama no se mueven */
  opacity: 0.9;
  border-color: var(--gold);
}
body[data-layout="touch"] .cico svg {
  height: calc(var(--t-chip) * 0.5);
  max-width: calc(var(--t-chip) * 0.66);
}
body[data-layout="touch"] .cbadge {
  top: -6px;
  right: -6px;
  font-size: 11px;
  border-radius: 6px;
}
.pad {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}
body[data-layout="touch"][data-state="playing"] .pad {
  display: block;
}
.dpad,
.pad-btn {
  position: absolute;
  aspect-ratio: 1;
  border-radius: 50%;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  opacity: 0.55;
  transition: opacity 0.12s;
}
.dpad {
  left: var(--t-left);
  bottom: var(--t-bottom);
  width: var(--t-pad);
  background:
    radial-gradient(circle, rgba(233, 181, 59, 0.16) 0 17%, transparent 18%),
    radial-gradient(circle, rgba(20, 15, 24, 0.28) 0 58%, rgba(20, 15, 24, 0.5) 59% 100%);
  border: 2px solid rgba(233, 181, 59, 0.55);
  box-shadow:
    0 0 0 2px rgba(0, 0, 0, 0.4),
    inset 0 0 0 5px rgba(168, 48, 31, 0.28);
}
/* Zona de toque más generosa que el círculo visible (el pulgar no «se sale» de la cruceta). */
.dpad::before {
  content: "";
  position: absolute;
  inset: -22% -26% -14% -18%;
  border-radius: 28%;
}
.dpad[data-dir]:not([data-dir=""]) {
  opacity: 0.95;
}
.dp {
  position: absolute;
  display: grid;
  place-items: center;
  width: 32%;
  height: 32%;
  color: var(--cream);
  opacity: 0.9;
  pointer-events: none;
}
.dp svg {
  width: 56%;
  height: auto;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.7));
}
.dp-up {
  top: 3%;
  left: 34%;
  opacity: 0.55; /* también salta, pero el botón SALTAR es la vía principal */
}
.dp-left {
  left: 3%;
  top: 34%;
}
.dp-right {
  right: 3%;
  top: 34%;
}
.dpad[data-dir~="ArrowLeft"] .dp-left,
.dpad[data-dir~="ArrowRight"] .dp-right,
.dpad[data-dir~="ArrowUp"] .dp-up {
  color: var(--gold);
  opacity: 1;
}
.pad-btn {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  padding: 0;
  color: var(--cream);
  font: 700 clamp(9px, 2.6vh, 12px) / 1 var(--font-body);
  letter-spacing: 0.08em;
}
.pad-btn svg {
  height: auto;
}
.pad-label {
  text-shadow: 0 1px 0 #000;
}
.pad-btn.is-pressed,
.pad-btn:active {
  opacity: 1;
}
.fire-btn {
  right: var(--t-right);
  bottom: calc(var(--t-bottom) + 12px);
  width: var(--t-fire);
  background: radial-gradient(circle, rgba(70, 48, 28, 0.55), rgba(24, 16, 14, 0.7));
  border: 3px solid var(--gold);
  box-shadow:
    0 0 0 2px rgba(0, 0, 0, 0.5),
    inset 0 0 0 3px rgba(168, 48, 31, 0.55);
}
.fire-btn svg {
  width: 46%;
}
.fire-btn.is-pressed,
.fire-btn:active {
  background: radial-gradient(circle, rgba(168, 48, 31, 0.9), rgba(60, 20, 14, 0.95));
}
.jump-btn {
  right: calc(var(--t-right) + var(--t-fire) + var(--t-gap));
  bottom: var(--t-bottom);
  width: var(--t-jump);
  background: radial-gradient(circle, rgba(40, 52, 66, 0.5), rgba(14, 12, 20, 0.7));
  border: 3px solid rgba(242, 230, 204, 0.75);
  box-shadow:
    0 0 0 2px rgba(0, 0, 0, 0.5),
    inset 0 0 0 3px rgba(91, 123, 176, 0.55);
}
.jump-btn svg {
  width: 40%;
}
.jump-btn.is-pressed,
.jump-btn:active {
  background: radial-gradient(circle, rgba(91, 123, 176, 0.9), rgba(20, 24, 40, 0.95));
}

/* Franja inferior: logo, ruta con hitos y lema ------------------------------------- */
.strip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(12px, 2.4vw, 36px);
  padding: 12px clamp(12px, 2vw, 24px);
  padding-left: max(clamp(12px, 2vw, 24px), env(safe-area-inset-left));
  padding-right: max(clamp(12px, 2vw, 24px), env(safe-area-inset-right));
  background: #0e0a10;
  box-shadow: inset 0 2px 0 #241d29;
}
.strip-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  line-height: 0.85;
}
.logo-mountains svg {
  display: block;
  width: clamp(60px, 8vw, 116px);
  height: auto;
  margin-bottom: -2px;
}
.logo-name {
  font-family: var(--font-display);
  font-size: clamp(34px, 4.6vw, 66px);
  letter-spacing: 0.04em;
  color: var(--gold);
  text-shadow:
    0 3px 0 #7a3d12,
    0 5px 0 #2a160c;
}
.logo-sub {
  margin-top: 6px;
  font-family: var(--font-pixel);
  font-size: clamp(9px, 0.95vw, 13px);
  letter-spacing: 0.1em;
  color: var(--gold);
}
.strip-logo:hover .logo-name {
  color: #f2c65a;
}
.route {
  position: relative;
  min-width: 0;
  padding-top: 8px;
}
.route-line,
.route-fill {
  position: absolute;
  top: 14px;
  height: 3px;
}
.route-line {
  left: 10%;
  right: 10%;
  background: #5f5763;
}
.route-fill {
  left: 10%;
  width: 0;
  background: var(--gold);
}
.route-marker {
  position: absolute;
  top: 11px;
  left: 10%;
  z-index: 1;
  width: 9px;
  height: 9px;
  background: var(--cream);
  transform: translateX(-50%) rotate(45deg);
  box-shadow: 0 0 0 2px #0e0a10;
}
.route-stages {
  position: relative;
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(var(--n, 5), minmax(0, 1fr));
}
.route-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 0;
  color: #7a717e;
  text-align: center;
}
.route-node {
  position: relative;
  z-index: 2;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 3px solid currentColor;
  background: #0e0a10;
}
.route-ico svg {
  display: block;
  width: clamp(44px, 5.2vw, 78px);
  height: auto;
}
.route-ico .rt {
  fill: rgba(0, 0, 0, 0.38);
}
.route-ico .rl {
  fill: #f2e6cc;
}
.route-ico .rw {
  fill: #4d6d9c;
}
.route-label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(11px, 1.15vw, 15px);
  color: var(--muted);
}
.route-stage.is-done {
  color: #b39553;
}
.route-stage.is-current,
.route-stage.is-current .route-label {
  color: var(--gold);
}
.route-stage.is-fiction .route-node {
  border-color: var(--blue);
}
.strip-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 18px;
  background: rgba(11, 8, 13, 0.6);
  border: 2px solid var(--gold-shadow);
  box-shadow: inset 0 0 0 1px rgba(233, 181, 59, 0.22);
  text-align: center;
}
.strip-tag {
  max-width: 21ch;
  font-size: clamp(11px, 1.1vw, 15px);
  line-height: 1.25;
  letter-spacing: 0.05em;
  color: var(--gold);
}
.strip-orn svg {
  display: block;
  width: 64px;
  height: auto;
}
.strip-url {
  font-size: clamp(13px, 1.3vw, 18px);
  font-weight: 700;
  color: var(--cream);
}

/* Pantalla completa ---------------------------------------------------------------- */
/* Nativa (Fullscreen API sobre #game-section) o inmersiva (iPhone: fija y a toda la altura). */
#game-section:fullscreen {
  width: 100%;
  height: 100%;
}
#game-section::backdrop {
  background: #000;
}
.is-immersive {
  overflow: hidden;
}
.is-immersive #game-section {
  position: fixed;
  inset: 0;
  z-index: 100;
  height: 100vh;
  height: 100dvh;
  margin: 0;
}
.is-fs #game-section {
  background: #000;
  justify-content: center;
  overflow-y: auto; /* pausa o mapa más altos que la pantalla: se desplazan, no se cortan */
}
.is-fs #game-section .strip {
  display: none;
}
body.is-fs {
  --chrome: 104px; /* escritorio: solo la barra de controles */
}
body.is-fs[data-layout="touch"] {
  --chrome: 0px;
}
.is-fs .stage {
  width: min(
    100vw - env(safe-area-inset-left) - env(safe-area-inset-right),
    max(320px, calc((100dvh - var(--chrome)) * 16 / 9))
  );
}

/* «Gira tu teléfono» (táctil en vertical mientras se juega) ------------------------- */
.rotate-screen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  background: rgba(11, 8, 13, 0.97);
  text-align: center;
}
body[data-rotate="true"] .rotate-screen {
  display: flex;
}
.rotate-screen:focus {
  outline: none;
}
.rotate-screen h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 48px;
  line-height: 0.9;
  color: var(--gold);
}
.rotate-screen p {
  max-width: 30ch;
  color: var(--muted);
}
.rotate-ico {
  animation: rotate-hint 2.4s steps(1, end) infinite;
}
@keyframes rotate-hint {
  50% {
    transform: rotate(-90deg);
  }
}
.fs-hint {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 150;
  max-width: min(520px, calc(100vw - 32px));
  transform: translateX(-50%);
  padding: 10px 14px;
  background: var(--ground);
  border: 2px solid var(--gold);
  font-size: 15px;
}
.fs-hint:empty {
  display: none;
}

/* Leyenda del teclado -------------------------------------------------------------- */
.keys-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 28px;
  align-items: center;
  padding: 18px 20px;
  background: var(--panel-2);
  box-shadow: inset 0 0 0 2px var(--border);
}
.legend-sound svg {
  width: 18px;
  height: auto;
}
.ctl {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.ctl-alt {
  flex-basis: 100%;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 15px;
  color: var(--muted);
}
.ctl-alt kbd {
  font-size: 13px;
  padding: 3px 5px 2px;
}

/* Pie ----------------------------------------------------------------- */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  font-size: 15px;
  color: var(--muted);
}

/* Pantallas bajas (teléfono en horizontal): franja compacta ------------------------- */
@media (max-height: 540px) {
  .strip {
    gap: 14px;
    padding-top: 6px;
    padding-bottom: 6px;
  }
  .logo-mountains svg {
    width: 44px;
  }
  .logo-name {
    font-size: 30px;
  }
  .logo-sub {
    margin-top: 3px;
    font-size: 8px;
  }
  .route {
    padding-top: 4px;
  }
  .route-line,
  .route-fill {
    top: 9px;
  }
  .route-marker {
    top: 6px;
  }
  .route-node {
    width: 12px;
    height: 12px;
    border-width: 2px;
  }
  .route-stage {
    gap: 2px;
  }
  .route-ico svg {
    width: 32px;
  }
  .route-label {
    font-size: 11px;
  }
  .strip-panel {
    padding: 4px 10px;
    gap: 0;
  }
  .strip-orn {
    display: none;
  }
  .strip-tag {
    font-size: 10px;
  }
  .strip-url {
    font-size: 12px;
  }
}

/* Teléfono en vertical / ventanas estrechas ---------------------------------------- */
@media (max-width: 640px) {
  .page {
    padding: 0 12px 40px;
    gap: 22px;
  }
  .game,
  body[data-layout="touch"] .game {
    margin-inline: -12px;
  }
  .controls {
    flex-wrap: wrap;
  }
  .cbtn {
    flex: 1 1 calc(20% - 8px); /* solo icono: 2 filas (5 + 4) */
  }
  .strip {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    gap: 12px;
  }
  .route {
    width: 100%;
  }
  .route-name {
    display: none;
  }
  .keys-legend {
    gap: 12px 18px;
    padding: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/* Modalidades y competencia */
.expedition-options, .traveler-card, .leaderboard-card { background: var(--panel); padding: 24px; box-shadow: inset 0 0 0 2px var(--border); min-width: 0; }
.expedition-options h2, .competition h2 { font-family: var(--font-display); font-weight: 400; font-size: 36px; color: var(--gold); margin-bottom: 14px; }
#difficulty-selector { border: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
#difficulty-selector label { display: grid; grid-template-columns: 22px 1fr; gap: 6px 8px; padding: 16px; background: var(--ground); cursor: pointer; }
#difficulty-selector label:has(input:checked) { outline: 2px solid var(--gold); }
#difficulty-selector input { accent-color: var(--gold); width: 18px; height: 18px; }
#difficulty-selector strong { color: var(--cream); }
#difficulty-selector span { grid-column: 2; font-size: 14px; color: var(--muted); }
#difficulty-selector:disabled label { cursor: default; }
#difficulty-note, #profile-status, .leaderboard-card > p { margin-top: 12px; font-size: 14px; color: var(--muted); }
.competition { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 20px; }
.competition h3 { margin-top: 20px; font-size: 18px; }
#player-xp { color: var(--gold); margin-bottom: 16px; }
.alias-row { display: flex; gap: 8px; margin-top: 6px; }
.competition input, .competition select { background: var(--ground); color: var(--cream); border: 2px solid var(--border); font: inherit; padding: 8px; min-width: 0; min-height: 44px; }
.alias-row input { width: 100%; }
.alias-row button { padding: 0 12px; }
.badge-list { padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.badge-list li { font-size: 14px; padding: 6px 10px; border: 1px solid var(--gold); color: var(--gold); }
#competition-result { margin-top: 18px; color: var(--gold); }
.ranking-filters { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; }
.ranking-filters label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.ranking-table { overflow-x: auto; margin-top: 16px; }
.ranking-table table { width: 100%; border-collapse: collapse; text-align: left; font-variant-numeric: tabular-nums; }
.ranking-table th, .ranking-table td { padding: 10px 8px; border-bottom: 1px solid var(--border); }
.ranking-table th { color: var(--muted); font-size: 14px; }
.ranking-table tr.is-self { background: var(--cochinilla); }
#ranking-personal { color: var(--gold); margin-top: 12px; }
@media (max-width: 720px) { #difficulty-selector, .competition { grid-template-columns: 1fr; } .expedition-options, .traveler-card, .leaderboard-card { padding: 18px; } }

/* Desafío dentro del título (compacto: tres opciones en fila) */
.title-panel .expedition-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0;
  background: none;
  box-shadow: none;
}
.title-panel .expedition-options h3 {
  font-size: 13px;
}
.title-panel #difficulty-selector {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
}
.title-panel #difficulty-selector label {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0 8px;
  min-height: 44px;
  padding: 6px 8px;
  background: rgba(22, 18, 26, 0.88);
  box-shadow: inset 0 0 0 1px var(--border);
}
.title-panel #difficulty-selector input {
  grid-row: span 2;
  margin: 0;
}
.title-panel #difficulty-selector strong {
  font-size: 15px;
  line-height: 1.2;
}
.title-panel #difficulty-selector span {
  font-size: 12px;
  line-height: 1.2;
}
.title-panel #difficulty-note {
  margin: 0;
  font-size: 13px;
}
/* Escenario bajo (teléfono en horizontal): título compacto */
@container stage (max-width: 760px) {
  .title-panel {
    width: 64%;
    min-width: 0;
    padding: 14px 18px;
    gap: 10px;
  }
  .title-head .eyebrow,
  .title-foot,
  .title-panel #difficulty-note,
  .title-panel .expedition-options h3 {
    display: none;
  }
  .title-logo {
    font-size: 52px;
  }
  .title-head .sub {
    font-size: 13px;
  }
  .title-screen .menu {
    gap: 2px;
  }
  .title-screen .menu-item {
    min-height: 44px;
    font-size: 17px;
  }
}
@container stage (max-width: 520px) {
  .title-panel {
    width: 100%;
  }
  .title-screen {
    background:
      linear-gradient(rgba(11, 8, 13, 0.82), rgba(11, 8, 13, 0.92)),
      url("assets/keyart.webp") left center / cover no-repeat,
      var(--deep);
  }
}

.title-screen .tocapu-v {
  display: none;
}
@container stage (max-width: 760px) {
  .title-panel {
    padding: 10px 16px;
    gap: 8px;
  }
  .title-logo {
    font-size: 42px;
  }
  .title-panel #difficulty-selector label {
    padding: 4px 6px;
    gap: 0 6px;
  }
  .title-panel #difficulty-selector strong {
    font-size: 13px;
  }
  .title-panel #difficulty-selector span {
    display: none;
  }
  .title-panel #difficulty-selector input {
    grid-row: auto;
    width: 16px;
    height: 16px;
  }
}
/* HUD en escenarios estrechos: vida, provisiones y botones (la etapa ya está en la franja). */
@container stage (max-width: 560px) {
  .hud-stage,
  .hud-quipu {
    display: none;
  }
  .hud-res {
    gap: 8px;
    padding: 3px 6px;
  }
  .heart svg {
    width: 17px;
  }
}
/* Pantallas bajas: la pausa muestra solo el menú (el inventario ya está en el HUD). */
@media (max-height: 500px) {
  .pause-screen {
    padding: 8px;
  }
  .pause-box > .tocapu {
    display: none;
  }
  .pause-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .pause-info {
    display: none;
  }
  .pause-menu {
    padding: 12px 18px;
    gap: 6px;
    box-shadow: none;
  }
  .pause-heading {
    font-size: 40px;
  }
}

/* Barra de controles (ratón): etiquetas en una sola línea, nunca solapadas. En escenarios
   estrechos los botones quedan solo con icono (aria-label + title como tooltip). */
.clabel {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@container stage (max-width: 800px) {
  body:not([data-layout="touch"]) .clabel {
    display: none;
  }
  body:not([data-layout="touch"]) .cbtn {
    min-height: 48px;
  }
}
/* Pantallas bajas con ratón (portátil pequeño, teléfono horizontal sin táctil): el juego usa
   toda la altura salvo la barra de controles; la franja y lo demás quedan debajo (se desplaza). */
@media (max-height: 540px) {
  body:not([data-layout="touch"]) {
    --chrome: 60px;
  }
  body:not([data-layout="touch"]) .page {
    padding-top: 0;
  }
  body:not([data-layout="touch"]) .controls {
    padding-block: 6px;
  }
  body:not([data-layout="touch"]) .cbtn {
    min-height: 48px;
  }
}
