* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Pantalla inicial: el juego arranca pausado hasta el primer gesto. */
#start-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  /* Resplandor infernal arriba + viñeta que se hunde en negro por los bordes. */
  background:
    radial-gradient(ellipse 90% 55% at 50% 30%, rgba(120, 26, 4, 0.55) 0%, rgba(0, 0, 0, 0) 60%),
    radial-gradient(ellipse at center, #200500 0%, #000 78%);
  touch-action: none;
  cursor: pointer;
  font-family: 'Courier New', monospace;
  text-align: center;
}

/* Scanlines retro sutiles sobre toda la pantalla de inicio. */
#start-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.22) 0px,
    rgba(0, 0, 0, 0.22) 2px,
    transparent 2px,
    transparent 4px
  );
}

#start-overlay.hidden {
  display: none;
}

#start-overlay h1 {
  color: #d82a10;
  font-size: clamp(2rem, 9vw, 4.5rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  text-shadow: 0 0 18px rgba(216, 42, 16, 0.7), 3px 3px 0 #400;
}

#start-overlay .blink {
  color: #f0d8b0;
  font-size: clamp(1rem, 4vw, 1.6rem);
  letter-spacing: 0.2em;
  animation: blink 1s steps(1) infinite;
}

/* Selector de dificultad: botones grandes (>=48px de alto táctil), estilo
   Courier rojo/ámbar de la pantalla. Tocar uno NO inicia el juego. */
#difficulty {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: min(78vw, 340px);
}

#difficulty button {
  min-height: 48px;
  padding: 8px 16px;
  font-family: 'Courier New', monospace;
  font-weight: 700;
  font-size: clamp(0.7rem, 2.8vw, 1rem);
  letter-spacing: 0.12em;
  color: #c07830;
  background: rgba(30, 8, 2, 0.85);
  border: 2px solid #6a2a10;
  cursor: pointer;
  touch-action: manipulation;
}

#difficulty button.selected {
  color: #ffd870;
  background: rgba(96, 18, 4, 0.9);
  border-color: #d82a10;
  box-shadow: 0 0 14px rgba(216, 42, 16, 0.55);
  text-shadow: 0 0 8px rgba(255, 216, 112, 0.6);
}

/* Teléfono en horizontal (poca altura): botones en fila para que quepa todo. */
@media (max-height: 420px) {
  #start-overlay {
    gap: 8px;
  }

  #difficulty {
    flex-direction: row;
    width: auto;
    max-width: 94vw;
  }

  #difficulty button {
    flex: 1 1 0;
    padding: 6px 8px;
    font-size: clamp(0.55rem, 1.8vw, 0.8rem);
  }
}

#start-overlay .sub {
  color: rgba(240, 216, 176, 0.5);
  font-size: clamp(0.7rem, 2.5vw, 1rem);
  letter-spacing: 0.2em;
}

/* Subtítulo del episodio, justo bajo el logo. */
#start-overlay .episode {
  color: #c07830;
  font-size: clamp(0.75rem, 3vw, 1.25rem);
  font-weight: 700;
  letter-spacing: 0.28em;
  margin-top: -8px;
  text-shadow: 2px 2px 0 #000;
}

/* Línea de 'copyright' falsa, pegada abajo estilo pantalla de título retro. */
#start-overlay .copyright {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(14px, env(safe-area-inset-bottom));
  color: rgba(240, 216, 176, 0.35);
  font-size: clamp(0.55rem, 2vw, 0.8rem);
  letter-spacing: 0.1em;
  padding: 0 12px;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* Aviso discreto en vertical: se recomienda jugar en horizontal. */
#rotate-hint {
  display: none;
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  padding: 6px 12px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(240, 216, 176, 0.4);
  color: #f0d8b0;
  font: 700 12px 'Courier New', monospace;
  letter-spacing: 0.1em;
  pointer-events: none;
  white-space: nowrap;
}

@media (orientation: portrait) {
  #rotate-hint {
    display: block;
  }
}
