/* Plantilla web de Horizonte 64 Software (misma estética que el sitio) */
:root {
  --cream: #F0E6C8; --yellow: #FFD54A; --red: #E03A2E; --blue: #3A86FF; --cyan: #00C2C7;
  --black: #111111; --navy: #16123a; --navy-2: #0d0b24;
  --pixel: "Press Start 2P", monospace; --term: "VT323", monospace;
  --topbar: 64px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--black); color: var(--cream); font-family: var(--term); font-size: 22px; }

.topbar {
  height: var(--topbar);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 clamp(16px, 4vw, 48px);
  border-bottom: 3px solid var(--navy);
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--cream); text-decoration: none; }
.brand img { width: 40px; height: auto; }
.brand span { font-family: var(--pixel); font-size: 14px; }
.brand b { color: var(--red); font-weight: normal; }
.topbar nav a { font-family: var(--pixel); font-size: 11px; color: var(--cream); text-decoration: none; text-transform: uppercase; }
.topbar nav a::before { content: "> "; color: var(--red); }

.stage { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 16px; }

/* Ventana con el juego en formato horizontal 16:9 que cabe en la pantalla */
.window { border: 3px solid var(--cream); background: var(--navy-2); box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.6); }
.window-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; background: var(--navy); border-bottom: 3px solid var(--cream);
  font-family: var(--pixel); font-size: 11px;
}
.window-buttons button {
  font: inherit; font-size: 14px; line-height: 1; color: var(--cream); background: none;
  border: 2px solid var(--cream); width: 24px; height: 22px; padding: 0; cursor: pointer;
}
.window-buttons button:disabled { opacity: 0.35; cursor: default; }

.screen {
  position: relative;
  /* cabe en el alto de la ventana, pero nunca menos de 480 px (si no cabe, la página hace scroll) */
  width: min(calc(100vw - 40px), calc((100vh - var(--topbar) - 110px) * 16 / 9), 1280px);
  max-width: calc(100vw - 40px);
  aspect-ratio: 16 / 9;
  background: #000;
}
#unity-canvas { width: 100%; height: 100%; display: block; background: #000; outline: none; }

.overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  text-align: center; padding: 24px; background: #000;
}
.overlay[hidden] { display: none; }
.overlay p { margin: 0; text-transform: uppercase; }
.cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0.55; }
.logo, #play, .note { position: relative; }
.logo { width: min(42%, 420px); }
.note { color: var(--yellow); font-size: 20px; }
/* la marca de Horizonte 64 encima del logo del juego */
.marca { position: relative; height: 17%; width: auto; margin-bottom: -6px;
         image-rendering: pixelated; filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.8)); }
.logo { max-height: 38%; object-fit: contain; }
/* en el celular vertical la ventana queda muy baja: la marca no cabe (igual se pide girarlo) */
@media (orientation: portrait) and (pointer: coarse), (max-width: 560px) {
  .marca { display: none; }
  /* la ventana 16:9 queda muy baja: todo más compacto para que los botones quepan */
  #start.overlay { gap: 8px; padding: 8px; }
  #start .btn { font-size: 11px; padding: 9px 14px; gap: 10px; }
  #start .btn-small { font-size: 8px; padding: 7px 10px; white-space: nowrap; }
}

.btn {
  display: inline-flex; align-items: center; gap: 14px; cursor: pointer;
  font-family: var(--pixel); font-size: 14px; text-transform: uppercase;
  padding: 16px 22px; color: var(--cream); background: var(--blue);
  border: 3px solid var(--cream);
  box-shadow: inset -3px -3px 0 rgba(0, 0, 0, 0.35), inset 3px 3px 0 rgba(255, 255, 255, 0.25);
}
.btn:hover { transform: translate(-2px, -2px); }

.bar { width: 70%; height: 22px; border: 2px solid var(--cream); padding: 2px; }
#bar-fill { height: 100%; width: 0; background: repeating-linear-gradient(90deg, var(--blue) 0 10px, transparent 10px 13px); }

.controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 24px; margin: 0; }
.controls div { display: flex; gap: 8px; }
.controls dt { color: var(--cyan); text-transform: uppercase; }
.controls dd { margin: 0; }

/* --- Celular y tablet --- */
#unity-canvas { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.btn-small { font-size: 11px; padding: 12px 16px; position: relative; }
.controls.touch { display: none; }
.is-touch .controls.keys { display: none; }
.is-touch .controls.touch { display: flex; }
.is-touch { overscroll-behavior: none; }

@media (max-width: 600px) {
  :root { --topbar: 48px; }
  .brand img { width: 30px; }
  .stage { padding: 6px 6px 10px; gap: 8px; }
  .window { box-shadow: none; }
  .window-bar { padding: 4px 8px; font-size: 9px; }
  /* el juego ocupa todo el ancho posible sin pasar el alto de la pantalla */
  .screen {
    width: min(calc(100vw - 18px), calc((100svh - var(--topbar) - 70px) * 16 / 9)); height: auto;
    max-width: calc(100vw - 18px);
  }
  .controls { font-size: 18px; }
}

/* Abierto como app instalada: solo el juego */
@media (display-mode: standalone), (display-mode: fullscreen) {
  .topbar, .controls, .window-bar { display: none; }
  .stage { padding: 0; }
  .window { border: 0; box-shadow: none; }
  .screen { width: min(100vw, calc(100svh * 16 / 9)); height: auto; max-width: 100vw; }
}

/* En el celular vertical: invitar a ponerlo horizontal */
.rotate-note { display: none; color: var(--yellow); font-family: var(--pixel); font-size: 10px; text-align: center; }
@media (orientation: portrait) and (pointer: coarse) { .rotate-note { display: block; } }

/* Celular en horizontal: solo el juego, a todo el ancho y alto posibles */
@media (orientation: landscape) and (pointer: coarse) {
  .topbar, .controls, .window-bar { display: none; }
  .stage { padding: 0; gap: 0; }
  .window { border: 0; box-shadow: none; }
  .screen { width: min(100vw, calc(100svh * 16 / 9)); height: auto; max-width: 100vw; }
}
