/* ==========================================================================
   estilo.css — la interfaz de FUGA
   Un solo tema, a propósito: es un atardecer, siempre. Los colores salen de
   la paleta del juego (js/config.js) para que HTML y canvas sean lo mismo.
   ========================================================================== */

@font-face {
  font-family: 'Anton';
  src: url('fuentes/anton-latin.woff2') format('woff2');
  font-display: block;
}

:root {
  --noche:   #150f26;
  --noche-2: #1d1535;
  --crema:   #fff4e0;
  --durazno: #ffd9b8;
  --menta:   #3ff2d0;
  --brasa:   #ff7a5c;
  --oro:     #ffd166;
  --display: 'Anton', Impact, 'Arial Narrow Bold', sans-serif;
  --texto:   system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  /* Si queda alguna franja (una tablet 4:3), que continúe el cielo y los techos
     en vez de ser un bloque negro. */
  background: linear-gradient(180deg, #241640 0%, #5a2a66 30%, #8a3868 58%, #3a2250 80%, var(--noche) 88%);
  color: var(--crema);
  font-family: var(--texto);
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#juego {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#juego canvas { display: block; }

/* Sólo se muestra lo que corresponde a cómo está jugando cada uno. */
body:not(.tactil) .solo-tactil { display: none; }
body.tactil .solo-teclado { display: none; }

/* --- Capas ----------------------------------------------------------------- */
.capa {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: max(16px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right))
           max(16px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  text-align: center;
}

#cargando {
  font-family: var(--display);
  font-size: 18px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--durazno);
  opacity: 0.7;
}

.grande {
  font-family: var(--display);
  font-size: clamp(40px, 11vh, 76px);
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.bajada {
  font-size: clamp(14px, 3.4vh, 18px);
  color: var(--durazno);
  max-width: 34ch;
  text-wrap: balance;
}

.cta {
  font-family: var(--display);
  font-size: clamp(20px, 5.4vh, 32px);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--crema);
  animation: latir 1.3s ease-in-out infinite;
}

.record {
  font-size: clamp(13px, 3vh, 16px);
  color: var(--durazno);
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
}

@keyframes latir {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* --- Título ------------------------------------------------------------------
   El juego queda visible detrás. El bloque va a la derecha, sobre el sol,
   para no tapar al corredor ni al que asoma por la izquierda. */
#titulo {
  align-items: flex-end;
  justify-content: center;
  background: linear-gradient(90deg, rgba(21, 15, 38, 0) 38%, rgba(21, 15, 38, 0.62) 100%);
  cursor: pointer;
}

.titulo-bloque {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: clamp(6px, 1.8vh, 12px);
  text-align: right;
  margin-right: clamp(8px, 4vw, 56px);
  margin-top: -6vh;
}

#titulo h1 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(76px, 27vh, 210px);
  line-height: 0.84;
  letter-spacing: 0.01em;
  color: var(--crema);
  text-shadow: 0 5px 0 rgba(21, 15, 38, 0.55);
}

/* La bufanda del corredor, subrayando el nombre. */
#titulo h1::after {
  content: '';
  display: block;
  height: 0.075em;
  width: 1.7em;
  margin: 0.08em 0 0 auto;
  background: var(--menta);
  border-radius: 3px;
  transform: skewX(-24deg);
}

#titulo .bajada { text-align: right; }

.zonas {
  position: absolute;
  left: 0; right: 0;
  bottom: max(12px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 1fr 1fr;
  pointer-events: none;
}
.zona {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.zona + .zona { border-left: 1px dashed rgba(255, 244, 224, 0.28); }
.zona b {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(16px, 4.2vh, 22px);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--menta);
}
.zona span { font-size: 12px; color: var(--durazno); opacity: 0.8; }

.teclas {
  position: absolute;
  bottom: 16px;
  left: 0; right: 0;
  font-size: 14px;
  color: var(--durazno);
  opacity: 0.85;
}

/* --- Botones ----------------------------------------------------------------- */
.esquina {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  display: flex;
  gap: 8px;
}

.boton {
  appearance: none;
  border: 1px solid rgba(255, 244, 224, 0.28);
  background: rgba(21, 15, 38, 0.55);
  color: var(--crema);
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}
.boton.icono { width: 44px; height: 44px; }
.boton.icono svg { width: 22px; height: 22px; }
.boton.texto {
  height: 44px;
  padding: 0 18px;
  font-family: var(--display);
  font-size: 15px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.boton:hover { background: rgba(21, 15, 38, 0.8); }
.boton:focus-visible { outline: 2px solid var(--menta); outline-offset: 2px; }

/* --- Fin de partida ------------------------------------------------------------ */
#fin {
  background: radial-gradient(ellipse at center, rgba(21, 15, 38, 0.8) 0%, rgba(21, 15, 38, 0.55) 70%);
  gap: clamp(2px, 1.2vh, 8px);
  cursor: pointer;
}
.causa {
  font-family: var(--display);
  font-size: clamp(22px, 6.5vh, 40px);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--brasa);
}
.puntos {
  font-family: var(--display);
  font-size: clamp(76px, 26vh, 190px);
  line-height: 0.92;
  color: var(--crema);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 5px 0 rgba(0, 0, 0, 0.35);
}
.detalle {
  font-size: clamp(14px, 3.4vh, 18px);
  color: var(--durazno);
  font-variant-numeric: tabular-nums;
}
#fin .record.nuevo {
  font-family: var(--display);
  font-size: clamp(20px, 5vh, 30px);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--oro);
  opacity: 1;
  animation: latir 0.8s ease-in-out infinite;
}
#fin .cta { margin-top: clamp(8px, 3vh, 20px); }

#pausa { background: rgba(21, 15, 38, 0.7); cursor: pointer; }

/* --- Créditos ------------------------------------------------------------------ */
.panel {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 7, 20, 0.78);
}
.panel-cuerpo {
  width: min(560px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  touch-action: pan-y;
  -webkit-user-select: text;
  user-select: text;
  background: var(--noche-2);
  border: 1px solid rgba(255, 244, 224, 0.14);
  border-radius: 12px;
  padding: 22px 26px 24px;
  font-size: 15px;
  line-height: 1.55;
  color: var(--durazno);
  text-align: left;
}
.panel-cuerpo h2 {
  font-family: var(--display);
  font-weight: 400;
  font-size: 44px;
  line-height: 1;
  color: var(--crema);
  margin-bottom: 4px;
}
.panel-cuerpo h3 {
  font-family: var(--display);
  font-weight: 400;
  font-size: 16px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--menta);
  margin: 18px 0 6px;
}
.panel-cuerpo ul { list-style: none; display: flex; flex-direction: column; gap: 4px; }
.panel-cuerpo li { padding-left: 14px; position: relative; }
.panel-cuerpo li::before {
  content: '';
  position: absolute;
  left: 0; top: 0.72em;
  width: 6px; height: 2px;
  background: var(--menta);
}
.panel-cuerpo b { color: var(--crema); font-weight: 600; }
.panel-cuerpo dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; }
.panel-cuerpo dt { color: var(--crema); font-weight: 600; }
.panel-cuerpo dd { color: var(--durazno); }
.panel-cuerpo .boton { margin-top: 20px; }
@media (max-width: 520px) {
  .panel-cuerpo dl { grid-template-columns: 1fr; gap: 0; }
  .panel-cuerpo dd { margin-bottom: 6px; }
}

/* --- Girá el teléfono ------------------------------------------------------------ */
#gira { z-index: 40; background: var(--noche); gap: 16px; }
.telefono {
  width: 46px;
  height: 78px;
  border: 3px solid var(--menta);
  border-radius: 9px;
  animation: girar 2.4s ease-in-out infinite;
}
@keyframes girar {
  0%, 40%   { transform: rotate(0deg); }
  60%, 100% { transform: rotate(-90deg); }
}

#error { z-index: 50; background: var(--noche); }

@media (prefers-reduced-motion: reduce) {
  .cta, #fin .record.nuevo, .telefono { animation: none; }
}
