/* el juego: escenario a pantalla completa, HUD, controles táctiles */
/* interfaz: tipografía minimalista, siempre en minúscula (el pixel queda solo dentro del juego) */
:root { --font-display: "Inter", ui-sans-serif, system-ui, sans-serif; --font-pixel: "Inter", ui-sans-serif, system-ui, sans-serif; }
body, button, a, h1, h2, h3, p, li, dialog { text-transform: lowercase; }

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--text); overflow: hidden; }
body { font-family: var(--font-display); -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--acid); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.game {
  position: fixed; inset: 0; display: grid; grid-template-rows: auto 1fr auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--ink);
  user-select: none; -webkit-user-select: none; touch-action: none;
}

/* HUD */
.hud { display: flex; align-items: center; gap: 1rem; padding: .7rem clamp(.8rem, 2vw, 1.6rem); z-index: 5; }
.hud__brand { font-weight: 700; font-size: 1.35rem; text-decoration: none; color: var(--text); letter-spacing: -.04em; }
.hud__bits { margin: 0; font-family: var(--font-pixel); font-size: .8rem; color: var(--acid); }
.hud__nav { margin-left: auto; display: flex; gap: .5rem; }
.chip {
  display: inline-flex; align-items: center; gap: .35em; padding: .55em 1em; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--ink-2); color: var(--text); text-decoration: none;
  font: 500 .78rem var(--font-pixel); text-transform: lowercase; letter-spacing: .04em;
  transition: transform var(--duration-fast) var(--ease-out-expo), border-color var(--duration-fast), background var(--duration-fast);
}
.chip:hover { border-color: var(--text); }
.chip:active { transform: translateY(1px); }
.chip--acid { background: var(--text); color: var(--ink); border-color: var(--text); }
.chip--icon { font-size: 1rem; padding: .35em .7em; }

/* escenario: 16:9 entero, pixel nítido */
.stage { position: relative; display: grid; place-items: center; min-height: 0; padding: 0 clamp(.5rem, 2vw, 2rem); }
.screen {
  width: min(100%, calc((100dvh - 7.5rem) * 16 / 9)); aspect-ratio: 16 / 9; height: auto;
  image-rendering: pixelated; image-rendering: crisp-edges;
  border-radius: 6px; box-shadow: 0 0 0 1px var(--line);
  background: var(--ink);
}
.toast {
  position: absolute; left: 50%; top: 1rem; transform: translateX(-50%); margin: 0; max-width: min(92%, 640px);
  padding: .8rem 1.1rem; border-radius: 12px; background: rgb(11 10 15 / .9); border: 1px solid var(--line);
  font-size: .95rem; line-height: 1.4; text-align: center; box-shadow: var(--shadow-card);
  animation: toast-in var(--duration-normal) var(--ease-out-expo);
}
/* salir de un minijuego (El Pechugón) de vuelta a la calle */
.mini-exit { position: absolute; left: 50%; bottom: .9rem; transform: translateX(-50%); z-index: 2; box-shadow: var(--shadow-card); }
.mini-exit:active { transform: translate(-50%, 1px); }
.mini-exit[hidden] { display: none; }
.mini-exit kbd { font: inherit; opacity: .6; border: 1px solid currentColor; border-radius: 4px; padding: 0 .3em; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -10px); } }

.hint { margin: 0; padding: .6rem; text-align: center; font: .68rem var(--font-pixel); color: var(--muted); text-transform: lowercase; }
.hint kbd { font: inherit; color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 0 .3em; }

/* controles táctiles */
.pad { display: none; }
@media (pointer: coarse) {
  .hint { display: none; }
  .pad {
    position: absolute; inset: auto 0 0; display: flex; justify-content: space-between; align-items: end;
    padding: 0 max(1rem, env(safe-area-inset-left)) max(.9rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-right));
    pointer-events: none; z-index: 6;
  }
  .pad button {
    pointer-events: auto; width: 64px; height: 64px; border-radius: 50%; border: 2px solid rgb(255 255 255 / .25);
    background: rgb(20 18 28 / .55); backdrop-filter: blur(4px); font-size: 1.3rem; touch-action: none;
  }
  .pad button.is-down { background: var(--yellow); color: var(--ink); transform: scale(.94); }
  .pad__dir, .pad__act { display: flex; gap: .7rem; align-items: end; }
  .pad__a { width: 76px !important; height: 76px !important; background: var(--red) !important; border-color: var(--red) !important; }
  .pad__b { font-family: var(--font-pixel); font-size: .8rem !important; text-transform: lowercase; margin-bottom: 1.4rem; }
  .screen { width: min(100%, calc((100dvh - 3.5rem) * 16 / 9)); border-radius: 8px; }
}

/* móvil en pantalla completa: el juego ocupa todo */
.game.is-full { grid-template-rows: auto 1fr; }
.game.is-full .hud { position: absolute; inset: 0 0 auto; background: linear-gradient(rgb(11 10 15 / .7), transparent); }
.game.is-full .stage { padding: 0; }
.game.is-full .screen { width: min(100vw, calc(100dvh * 16 / 9)); border-radius: 0; box-shadow: none; }

.start {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 8;
  padding: 0; border: 0; background: none; cursor: pointer; line-height: 0;
  animation: start-pulse 1.6s steps(2, jump-none) infinite;
}
.start__icon { width: clamp(72px, 18vw, 112px); height: auto; image-rendering: pixelated; }
.start:active { transform: translate(-50%, -50%) scale(.92); }
@keyframes start-pulse { 50% { transform: translate(-50%, -50%) scale(1.06); } }
.rotate { display: none; }
@media (pointer: coarse) and (orientation: portrait) {
  .game.is-full .rotate {
    position: absolute; inset: 0; z-index: 9; display: grid; place-items: center; background: var(--ink);
    font: 1rem var(--font-pixel); color: var(--acid); text-transform: lowercase; text-align: center;
  }
  .rotate span { display: block; font-size: 3rem; animation: spin 1.6s var(--ease-in-out) infinite; }
}
@keyframes spin { 50% { transform: rotate(-90deg); } }

.noscript { position: fixed; inset: 0; display: grid; place-items: center; background: var(--ink); z-index: 99; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}

/* HUD compacto en pantallas angostas */
.hud__brand, .chip { white-space: nowrap; }
@media (max-width: 520px) {
  .hud { gap: .6rem; padding: .6rem .8rem; }
  .hud__brand { font-size: 1.1rem; }
  .hud__nav { gap: .35rem; }
  .chip { padding: .45em .75em; font-size: .72rem; }
}
