/* El rancho · HUD con el sistema visual de cesar.fyi: papel, dos tintas azules y un acento bermellón.
   Esquinas rectas, líneas de 1 px, rótulos en JetBrains Mono (versales) y texto en Alpino. */
@font-face { font-family: "Alpino"; font-weight: 400; font-display: swap; src: url(/fonts/Alpino-Regular.otf) format("opentype"); }
@font-face { font-family: "Alpino"; font-weight: 500; font-display: swap; src: url(/fonts/Alpino-Medium.otf) format("opentype"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 400; font-display: swap; src: url(/fonts/jetbrains-mono-latin-400-normal.woff2) format("woff2"); }
:root {
  --papel: #F1EBDD;
  --papel-luz: #FAF6EC;
  --tinta: #1F33C4;
  --texto: #141B4D;
  --tenue: #454C7A;
  --acento: #E4572E;
  --acento-texto: #A83410;
  --velo: color-mix(in srgb, var(--tinta) 10%, var(--papel));
  --linea: 1px solid var(--tinta);
  --cuerpo: "Alpino", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  /* nombres del juego original, para los estilos que arman las features */
  --paper: var(--papel-luz);
  --paper-2: var(--papel);
  --ink: var(--tinta);
  --muted: var(--tenue);
  --coral: var(--acento);
  --teal: var(--tinta);
  --sun: var(--papel);
  --line: var(--linea);
  --shadow: none;
  --font: var(--cuerpo);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--papel);
  color: var(--texto);
  font-family: var(--cuerpo);
  font-size: 15px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--acento); outline-offset: 3px; }

#c {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  outline: none;
}

/* ---------- botones: los del sitio (.boton), versales en mono ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border: var(--linea);
  border-radius: 0;
  background: var(--papel-luz);
  color: var(--tinta);
  font: 400 12px/1.2 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--tinta); color: var(--papel); }
.btn:active { background: var(--texto); color: var(--papel); }
.btn:disabled { color: var(--tenue); border-color: var(--tenue); background: var(--papel); cursor: default; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-icon { width: 44px; padding: 0; justify-content: center; }
.btn-big, .btn-colab { background: var(--tinta); color: var(--papel); }
.btn-big:hover, .btn-colab:hover { background: var(--texto); }
.btn-big { padding: 0 18px; min-height: 48px; }
#btn-snd .snd-on { display: none; }
#btn-snd[aria-pressed="true"] .snd-on { display: inline; }
#btn-snd[aria-pressed="true"] .snd-off { display: none; }
#btn-snd[aria-pressed="false"] { color: var(--tenue); }
#btn-snd[aria-pressed="false"]:hover { color: var(--papel); }
/* Dentro del sitio la navegación ya está en la página: sobra el enlace de regreso. */
.embebido .btn-sitio { visibility: hidden; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
.topbar {
  position: absolute;
  top: calc(10px + var(--sat));
  left: calc(10px + var(--sal));
  right: calc(10px + var(--sar));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none !important;
}
.topbar > * { pointer-events: auto; }
.tools { display: flex; gap: 8px; }

.hint, .me {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100vw - 24px);
  padding: 7px 14px;
  border: var(--linea);
  background: var(--papel-luz);
  font-size: 14px;
  text-align: center;
}
.me { bottom: calc(14px + var(--sab)); padding: 5px 12px; }
.me .clock { display: block; font: 400 11px/1.3 var(--mono); color: var(--tinta); letter-spacing: .08em; text-transform: uppercase; }
.hint { bottom: calc(58px + var(--sab)); background: var(--texto); color: var(--papel); border-color: var(--texto); pointer-events: none !important; transition: opacity .5s; }
.hint.bye { opacity: 0; }

/* joystick (solo touch) */
.joy {
  display: none;
  position: absolute;
  left: calc(18px + var(--sal));
  bottom: calc(22px + var(--sab));
  width: 124px;
  height: 124px;
  border: var(--linea);
  border-radius: 50%;
  background: color-mix(in srgb, var(--papel-luz) 60%, transparent);
  touch-action: none;
}
.joy-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border: var(--linea);
  border-radius: 50%;
  background: var(--tinta);
  will-change: transform;
}
.touch .joy { display: block; }
@media (hover: none) and (pointer: coarse) { .joy { display: block; } }

/* ---------- carga y respaldo sin WebGL ---------- */
.start, .nogl {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(14px + var(--sat)) 16px calc(14px + var(--sab));
  background: var(--papel);
  overflow: auto;
}
.start-card {
  width: min(560px, 100%);
  padding: 20px 22px;
  border: var(--linea);
  background: var(--papel-luz);
  -webkit-user-select: text;
  user-select: text;
}
.start-card .kicker { margin: 0 0 8px; color: var(--tinta); font: 400 12px/1.3 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.start-card h1 { margin: 0 0 8px; font: 500 clamp(24px, 5vw, 34px)/1.12 var(--cuerpo); color: var(--tinta); }
.start-card .sub { margin: 0 0 14px; color: var(--texto); font-size: 17px; }
.start-card p:last-child { margin-bottom: 0; }
.start .start-card { width: auto; }
.start .start-card .sub { margin: 0; color: var(--tenue); }

/* ---------- juegos: avisos, escalada, slackline, dormir ---------- */
.stats {
  position: absolute; left: calc(10px + var(--sal)); top: calc(64px + var(--sat)); z-index: 1;
  display: block; padding: 6px 10px; border: var(--linea); border-radius: 0; background: var(--papel-luz); color: var(--tinta);
  font: 400 11px/1.4 var(--mono); letter-spacing: .06em; text-transform: uppercase; text-align: left; cursor: pointer;
}
.stats b { font-weight: 400; }
.stats b::after { content: " +"; }
.stats.open b::after { content: " −"; }
.stats ul { display: none; list-style: none; margin: 4px 0 0; padding: 4px 0 0; border-top: 1px solid color-mix(in srgb, var(--tinta) 28%, transparent); color: var(--texto); }
.stats.open ul { display: grid; gap: 2px; }
.toast {
  position: absolute; left: 50%; top: 22%; transform: translateX(-50%);
  max-width: min(440px, calc(100vw - 28px)); padding: 9px 16px;
  background: var(--texto); color: var(--papel); text-align: center; font-size: 15px;
  pointer-events: none !important; animation: pop .16s ease-out;
}
@keyframes pop { from { transform: translateX(-50%) translateY(-6px); opacity: 0; } }
.act { position: absolute; left: 50%; bottom: calc(74px + var(--sab)); transform: translateX(-50%); max-width: calc(100vw - 24px); white-space: normal; text-align: left; }
.act kbd { margin-left: 4px; padding: 2px 7px; border: 1px solid currentColor; font: inherit; }
.jump { display: none; position: absolute; right: calc(18px + var(--sar)); bottom: calc(28px + var(--sab)); width: 74px; height: 74px; padding: 0; justify-content: center; border-radius: 50%; touch-action: none; }
.jump svg { width: 28px; height: 28px; }
.touch .jump { display: inline-flex; }
@media (hover: none) and (pointer: coarse) { .jump { display: inline-flex; } }

.climb-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.climb-top b { font: 500 18px/1.2 var(--cuerpo); color: var(--tinta); }
.climb-top span { padding: 2px 8px; border: var(--linea); color: var(--tinta); font: 400 11px/1.3 var(--mono); letter-spacing: .06em; text-transform: uppercase; }
.pump { height: 10px; margin: 8px 0; border: var(--linea); background: var(--papel); overflow: hidden; }
.pump i { display: block; height: 100%; width: 100%; background: var(--tinta); transition: width .12s linear; }
.pump i.mid { background: var(--tenue); }
.pump i.low { background: var(--acento); }
.climb-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; color: var(--tenue); }
.climb-row .btn { min-height: 38px; }
.send {
  position: absolute; left: 50%; top: 36%; transform: translate(-50%, -50%);
  max-width: calc(100vw - 28px); padding: 14px 22px; border: var(--linea);
  background: var(--papel-luz); text-align: center; pointer-events: none !important; animation: pop2 .2s ease-out;
}
@keyframes pop2 { from { opacity: 0; } }
.send b { display: block; font: 500 clamp(22px, 5vw, 32px)/1.12 var(--cuerpo); color: var(--tinta); }
.send span { font-size: 14px; color: var(--tenue); }
.bal {
  position: absolute; left: 50%; top: calc(74px + var(--sat)); transform: translateX(-50%);
  width: min(300px, calc(100vw - 40px)); height: 18px; border: var(--linea);
  background: linear-gradient(90deg, var(--acento) 0 14%, var(--papel) 14% 46%, var(--velo) 46% 54%, var(--papel) 54% 86%, var(--acento) 86%);
  pointer-events: none !important;
}
.bal i { position: absolute; top: -5px; width: 12px; height: 26px; margin-left: -6px; left: 50%; border: 1px solid var(--papel-luz); background: var(--tinta); }
.bal.warn i { background: var(--acento-texto); }
.slots { position: absolute; left: 50%; top: calc(64px + var(--sat)); transform: translateX(-50%); display: grid; gap: 8px; width: min(380px, calc(100vw - 20px)); pointer-events: none !important; }
.slots > .slot { pointer-events: auto; padding: 10px 14px 12px; border: var(--linea); background: var(--papel-luz); }
.slots > .slot.bare { padding: 0; border: 0; background: none; }
.slots .bal { position: relative; left: auto; top: auto; transform: none; width: 100%; }
.buttons { position: absolute; left: 50%; bottom: calc(126px + var(--sab)); transform: translateX(-50%); display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; width: max-content; max-width: calc(100vw - 20px); }

.sleep {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: var(--texto); color: var(--papel); opacity: 0; transition: opacity 1.1s ease; pointer-events: none; z-index: 5;
}
.sleep.on { opacity: 1; pointer-events: auto; }
.sleep.cut { transition: none; }
.sleep p { margin: 0; font-size: 20px; text-align: center; padding: 0 20px; }
.zzz { display: flex; gap: 10px; align-items: flex-end; font: 400 28px/1 var(--mono); }
.zzz span { animation: zz 1.8s ease-in-out infinite; }
.zzz span:nth-child(2) { font-size: 38px; animation-delay: .25s; }
.zzz span:nth-child(3) { font-size: 50px; animation-delay: .5s; }
@keyframes zz { 0%, 100% { transform: translateY(0); opacity: .5; } 50% { transform: translateY(-10px); opacity: 1; } }

@media (max-width: 640px) {
  .btn-sitio span { display: none; }
  .btn-sitio { width: 44px; padding: 0; justify-content: center; }
  .me { font-size: 13px; }
  .touch .me, .touch .hint { left: auto; right: calc(10px + var(--sar)); transform: none; max-width: calc(100vw - 172px); text-align: left; }
  .buttons { bottom: calc(132px + var(--sab)); }
  .toast { top: 30%; font-size: 14px; }
}
@media (max-width: 640px) and (hover: none) and (pointer: coarse) {
  .me { left: calc(10px + var(--sal)); right: calc(10px + var(--sar)); bottom: calc(160px + var(--sab)); max-width: none; transform: none; text-align: center; }
  .hint { left: calc(10px + var(--sal)); right: calc(10px + var(--sar)); top: calc(64px + var(--sat, 0px)); bottom: auto; max-width: none; transform: none; }
  .buttons { bottom: calc(304px + var(--sab)); }
  .act { left: auto; right: calc(10px + var(--sar)); bottom: calc(236px + var(--sab)); transform: none; max-width: calc(100vw - 20px); }
  .act kbd { display: none; }
}
.touch .act kbd { display: none; }
@media (prefers-reduced-motion: reduce) {
  .hint { transition: none; }
  .toast, .send { animation: none; }
  .zzz span { animation: none; }
  .pump i { transition: none; }
}

/* ---------- cámara y dron (features/foto.js trae su propia hoja; aquí solo lo que choca con el sitio) ---------- */
#foto-ui .ft-main { width: auto; height: 44px; min-height: 44px; padding: 0 14px; font: 400 12px/1.2 var(--mono); }
#foto-ui .ft-bar .btn, #foto-ui .ft-row .btn { font-size: 12px; }
#foto-ui .ft-z, #foto-ui .ft-ud { font-size: 16px; }
