:root {
  --bg: #0f1110;
  --bg-1: #171a18;
  --bg-2: #232724;
  --fg: #e8e6dc;
  --dim: #9a9a90;
  --accent: #f8d838;
  --alert: #ff5a6a;
  --rule: #2c312d;
  --panel: #171a18;
  --scrim: #0f1110e6;
  --gutter: 16px;
  --pixel: 'Press Start 2P', monospace;
  --display: 'Handjet', system-ui, sans-serif;
  --mono: 'Space Mono', ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--fg); font-family: var(--display); }
a { color: inherit; }
kbd {
  display: inline-block; min-width: 1.5em; padding: 0 .35em; margin: 0 .1em;
  border: 1px solid var(--dim); border-bottom-width: 2px; border-radius: 3px;
  font: inherit; line-height: 1.3; text-align: center;
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Home ---------- */

body.home { height: 100%; overflow: hidden; }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }

body.home { cursor: default; }

.meta {
  position: fixed; inset: 0 0 auto; z-index: 2;
  display: grid; grid-template-columns: 1fr auto; align-items: start; gap: 0 24px;
  padding: var(--gutter) var(--gutter) 0; font-size: 20px; line-height: 1.2; letter-spacing: .02em; pointer-events: none;
}
.meta p { margin: 0; }
.meta__name, .meta__roles span { background: #0f1110c7; justify-self: start; margin-left: -6px; padding: 0 6px; white-space: nowrap; }
.meta__name { grid-column: 1; }
.meta__is, .meta__roles { color: var(--dim); }
.meta__roles { grid-area: 2 / 1; display: grid; }
.meta__links { grid-area: 1 / 2 / span 2; display: grid; justify-items: end; }
.meta__links a { pointer-events: auto; color: var(--dim); text-decoration: none; background: #0f1110c7; margin-right: -6px; padding: 0 6px; }
.meta__links a:hover { color: var(--fg); }

.preloader {
  position: fixed; inset: 0; z-index: 4; display: flex; align-items: center; justify-content: center; gap: .6em; white-space: pre;
  font: 10px/1 var(--pixel); letter-spacing: 1px; background: var(--bg);
  transition: opacity .7s ease;
}
.preloader.done { opacity: 0; pointer-events: none; }

.gate-arrow {
  position: fixed; z-index: 3; width: 64px; height: 64px; image-rendering: pixelated; pointer-events: none;
  transform: translate(8px, -50%); animation: nudge 1s steps(2) infinite;
}
@keyframes nudge { 50% { margin-left: 8px; } }
.gate {
  position: fixed; z-index: 3; max-width: calc(100% - 2 * var(--gutter)); width: max-content;
  padding: 4px 16px; background: var(--scrim); color: #fff; cursor: pointer;
  font-size: 28px; line-height: 32px; transform: translateY(-50%);
}
.gate[hidden], .gate-arrow[hidden] { display: none; }
.gate__steps { counter-reset: step; margin: 0; padding: 0; list-style: none; }
.gate__steps > li { counter-increment: step; text-indent: -1.3em; padding-left: 1.3em; }
.gate__steps > li + li { margin-top: 8px; }
.gate__steps > li::before { content: counter(step) '.'; display: inline-block; width: 1.3em; text-indent: 0; }
.gate__alt { display: block; text-indent: 0; font-size: 22px; line-height: 26px; color: var(--dim); }
.gate__volume { white-space: nowrap; }
.gate__coarse { display: none; }
@media (pointer: coarse) {
  .gate__fine { display: none; }
  .gate__coarse { display: inline; }
}
.gate__speaker { width: 1em; height: 1em; margin-right: 10px; vertical-align: -.2em; }
.gate__wave { animation: wave 1.2s step-end infinite; }
.gate__wave--2 { animation-delay: .3s; }
@keyframes wave { 0% { opacity: 0; } 33% { opacity: 1; } }

/* Teclas: dos paneles a los costados del Game Boy (escritorio) o una barra abajo. */
.keyhint { --cap: 32px; display: contents; color: var(--fg); pointer-events: none; }
.keyhint p, .keyhint ul { margin: 0; padding: 0; list-style: none; }
.keyhint__group {
  position: fixed; top: 50%; z-index: 2; transform: translateY(-50%);
  display: grid; gap: 16px; padding: 12px; background: var(--scrim);
  font-size: 18px; line-height: 1; opacity: 0; transition: opacity .6s linear;
}
.keyhint.on .keyhint__group { opacity: 1; }
.keyhint__group--move { right: calc(100% - var(--shell-l, 22vw) + 32px); justify-items: start; }
.keyhint__group--buttons { left: calc(var(--shell-r, 78vw) + 32px); justify-items: start; }
.keyhint__title { font: 12px/12px var(--pixel); color: var(--dim); }
.keyhint__pads { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }
.keyhint__pad { display: grid; grid-template-columns: repeat(3, var(--cap)); grid-auto-rows: var(--cap); grid-template-areas: '. up .' 'left down right'; gap: 3px; }
.keyhint__cap--up { grid-area: up; }
.keyhint__cap--left { grid-area: left; }
.keyhint__cap--down { grid-area: down; }
.keyhint__cap--right { grid-area: right; }
.keyhint__cap {
  display: inline-grid; place-items: center; min-width: var(--cap); height: var(--cap); padding: 0 8px; margin: 0;
  border: 1px solid var(--dim); border-radius: 0; background: var(--bg-2); color: var(--fg);
  font: 1em/1 var(--display);
}
.keyhint__pad .keyhint__cap { padding: 0; font-size: 20px; }
.keyhint__rows { display: grid; grid-template-columns: auto auto; align-items: center; gap: 10px 14px; }
.keyhint__row { display: contents; }
.keyhint__button { font: 12px/12px var(--pixel); }
.keyhint__keys { display: flex; align-items: center; gap: 6px; }
.keyhint__or { color: var(--dim); }
.keyhint__note { max-width: 18ch; font-size: 20px; line-height: 22px; color: var(--dim); }
.keyhint__group--buttons .keyhint__note { display: none; }

@media (max-width: 1100px) {
  .keyhint {
    --cap: 22px; position: fixed; left: 50%; bottom: var(--gutter); z-index: 2; transform: translateX(-50%);
    display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 24px;
    width: max-content; max-width: calc(100% - 2 * (var(--gutter) + 58px)); padding: 8px 14px;
    background: var(--scrim); font-size: 16px; line-height: 1; opacity: 0; transition: opacity .6s linear;
  }
  .keyhint.on { opacity: 1; }
  .keyhint__group { position: static; transform: none; padding: 0; background: none; gap: 6px; opacity: 1; }
  .keyhint__title { display: none; }
  .keyhint__pads { flex-direction: row; align-items: center; gap: 8px; }
  .keyhint__pad { gap: 2px; }
  .keyhint__pad .keyhint__cap { font-size: 1em; }
  .keyhint__cap { padding: 0 5px; }
  .keyhint__rows { gap: 4px 16px; }
  .keyhint__button { font-size: 8px; }
  .keyhint__group--move .keyhint__note { display: none; }
  .keyhint__group--buttons .keyhint__note { display: block; grid-column: 1 / -1; max-width: none; font-size: 15px; line-height: 16px; }
}

.toggles { position: fixed; right: var(--gutter); bottom: var(--gutter); z-index: 2; }
.toggle {
  display: grid; place-items: center; width: 48px; height: 48px; cursor: pointer;
  background: var(--scrim); color: var(--fg); border: 0; border-radius: 0;
}
.toggle[aria-pressed='true'] { color: var(--dim); }
.toggle[aria-pressed='true'] path { opacity: .35; }

.frame {
  position: fixed; inset: 0; z-index: 5; overflow-y: auto; background: var(--bg);
  opacity: 0; transition: opacity .35s ease;
}
.frame.open { opacity: 1; }
.frame[hidden] { display: none; }

/* ---------- Páginas (standalone y overlay) ---------- */

.back-btn {
  position: fixed; top: 14px; left: 16px; z-index: 6;
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px;
  background: var(--panel); color: var(--fg); border: 1px solid var(--rule); border-radius: 6px;
  font: 20px/1 var(--display); text-decoration: none; cursor: pointer;
}
.back-btn:hover { border-color: var(--dim); }
.back-btn kbd { font-size: 14px; }

.cs {
  max-width: 780px; margin: 0 auto; padding: 96px 20px 80px;
  font: 16px/1.75 var(--mono);
}
.cs-kicker { font: 10px/1.6 var(--pixel); color: var(--accent); text-transform: uppercase; margin: 0; }
.cs h1 { font: clamp(20px, 4.6vw, 34px)/1.35 var(--pixel); margin: .6em 0 .5em; }
.cs-blurb { font: 300 clamp(24px, 4vw, 30px)/1.15 var(--display); color: var(--dim); margin: 0 0 1.6em; }
.cs-meta {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px;
  margin: 0 0 2.4em; padding: 16px 0; border-block: 2px dashed var(--rule);
}
.cs-meta dt { font: 8px/1.6 var(--pixel); color: var(--dim); text-transform: uppercase; }
.cs-meta dd { margin: 6px 0 0; }
.cs-body h2 { font: 13px/1.5 var(--pixel); color: var(--accent); margin: 2.6em 0 .8em; }
.cs-body ul { padding-left: 1.2em; }
.cs-body li { margin: .3em 0; }
.cs-body blockquote {
  margin: 2.4em 0; padding: 16px 20px; border-left: 4px solid var(--accent); background: var(--panel);
  font: 300 24px/1.2 var(--display);
}
.cs-body a { color: var(--accent); }
.timeline { list-style: none; padding: 0 !important; }
.timeline li { padding: 14px 0; border-bottom: 1px solid var(--rule); }
.timeline b { font: 9px/1.6 var(--pixel); color: var(--dim); display: block; }
.timeline span { font-weight: 700; }
.timeline p { margin: .3em 0 0; color: var(--dim); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  display: inline-block; padding: 10px 16px; border: 2px solid var(--fg); border-radius: 4px;
  color: var(--fg) !important; text-decoration: none; font: 20px/1 var(--display);
}
.btn:hover { background: var(--fg); color: var(--bg) !important; }
.btn--alert { border-color: var(--alert); color: var(--alert) !important; }
.btn--alert:hover { background: var(--alert); color: var(--bg) !important; }
.cs-next {
  display: block; margin-top: 4em; padding: 20px; border: 2px solid var(--rule);
  font: 12px/1.6 var(--pixel); text-decoration: none;
}
.cs-next span { display: block; font: 300 18px/1 var(--display); color: var(--dim); margin-bottom: 8px; }
.cs-next:hover { border-color: var(--accent); }
.credits { text-align: center; padding: 24px 16px 40px; color: var(--dim); font-size: 15px; }
.landing-list { max-width: 780px; margin: 0 auto; padding: 120px 20px 40px; font-family: var(--mono); line-height: 1.6; }
.landing-list li { margin: 1em 0; }
.landing-list li p { margin: .2em 0 0; color: var(--dim); }
/* Con JavaScript el Game Boy reemplaza a la lista, que queda para buscadores y lectores de pantalla. */
.js .landing-list { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; padding: 0; }

@media (max-width: 720px) {
  .meta { font-size: 17px; padding: 12px 16px; }
  .keyhint { display: none; }
  .gate { font-size: 22px; line-height: 26px; }
  .gate__alt { font-size: 17px; line-height: 20px; }
}
