/* ==========================================================================
   THE LAST SIGNAL — RETRO SCI-FI SURVIVAL HORROR STYLESHEET
   Atmospheric CRT terminal aesthetic, responsive canvas scaling, custom neon scrollbars,
   glowing holographic UI accents, and mobile touch overlay.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Orbitron:wght@400;700;900&family=VT323&display=swap');

:root {
  --crt-green-bright: #00ff66;
  --crt-green: #00cc55;
  --crt-green-dark: #005522;
  --crt-green-dim: rgba(0, 255, 102, 0.15);

  --cyan-bright: #00f0ff;
  --cyan-mid: #00b4d8;
  --cyan-dark: #004a7c;
  --cyan-dim: rgba(0, 240, 255, 0.15);

  --amber-bright: #ffaa00;
  --amber-mid: #ff8800;
  --amber-dim: rgba(255, 170, 0, 0.15);

  --alert-red-bright: #ff2244;
  --alert-red: #cc1133;
  --alert-red-dim: rgba(255, 34, 68, 0.18);

  --bg-dark: #03060a;
  --bg-panel: rgba(8, 14, 22, 0.92);
  --border-neon: rgba(0, 240, 255, 0.4);

  --font-mono: 'Share Tech Mono', 'Courier New', Courier, monospace;
  --font-display: 'Orbitron', 'Share Tech Mono', sans-serif;
  --font-crt: 'VT323', 'Share Tech Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Custom Neon Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(4, 10, 16, 0.8);
}

::-webkit-scrollbar-thumb {
  background: var(--cyan-dark);
  border: 1px solid var(--cyan-bright);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--cyan-mid);
  box-shadow: 0 0 8px var(--cyan-bright);
}

/* ==========================================================================
   GAME CONTAINER & RESPONSIVE CANVAS BEZEL
   ========================================================================== */

#game-wrapper {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #071018 0%, #020406 100%);
  overflow: hidden;
}

.crt-bezel {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 100vw;
  max-height: 100vh;
  aspect-ratio: 16 / 9;
  box-shadow: 
    0 0 30px rgba(0, 240, 255, 0.12),
    0 0 100px rgba(0, 0, 0, 0.9) inset;
  border: 2px solid rgba(0, 240, 255, 0.25);
  border-radius: 4px;
  overflow: hidden;
  background-color: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game-canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background-color: #020406;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

/* Optional CSS CRT Scanline & Phosphor Overlay */
.crt-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
  background: 
    linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%),
    radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, 0.6) 100%);
  background-size: 100% 4px, 100% 100%;
  opacity: 0.85;
}

.crt-overlay.disabled {
  display: none;
}

/* Subtle CRT Flicker Animation */
@keyframes crt-flicker {
  0% { opacity: 0.97; }
  50% { opacity: 1.0; }
  100% { opacity: 0.98; }
}

.crt-flicker {
  animation: crt-flicker 0.15s infinite;
}

/* ==========================================================================
   MOBILE & TOUCH CONTROLS OVERLAY
   ========================================================================== */

#touch-controls {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
  display: none; /* Enabled dynamically on touch devices */
}

@media (pointer: coarse) {
  #touch-controls {
    display: block;
  }
}

@media (pointer: fine) and (min-width: 1025px) {
  #touch-controls {
    display: none !important;
  }
}

/* Virtual Joystick Zone (Bottom Left) */
.touch-joystick-zone {
  position: absolute;
  bottom: 24px;
  left: 24px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: rgba(0, 240, 255, 0.06);
  border: 2px dashed rgba(0, 240, 255, 0.3);
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.touch-joystick-stick {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(0, 240, 255, 0.3);
  border: 2px solid var(--cyan-bright);
  box-shadow: 0 0 10px var(--cyan-bright);
  transform: translate(0, 0);
  pointer-events: none;
}

/* Touch Action Buttons (Bottom Right & Top Right) */
.touch-action-pad {
  position: absolute;
  bottom: 24px;
  right: 24px;
  display: grid;
  grid-template-columns: repeat(2, 60px);
  gap: 14px;
  pointer-events: auto;
}

.touch-btn {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  background: rgba(6, 14, 22, 0.85);
  border: 1.5px solid var(--cyan-bright);
  color: var(--cyan-bright);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: bold;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.2);
  transition: transform 0.05s, background-color 0.1s;
  pointer-events: auto;
}

.touch-btn:active, .touch-btn.active {
  transform: scale(0.92);
  background: rgba(0, 240, 255, 0.3);
  box-shadow: 0 0 14px var(--cyan-bright);
}

.touch-btn.btn-sprint {
  border-color: var(--amber-bright);
  color: var(--amber-bright);
}

.touch-btn.btn-interact {
  border-color: var(--crt-green-bright);
  color: var(--crt-green-bright);
}

.touch-btn.btn-danger {
  border-color: var(--alert-red-bright);
  color: var(--alert-red-bright);
}

/* Tactical Quick Slots (Top Center) */
.touch-quick-slots {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

.touch-slot-btn {
  padding: 6px 14px;
  border-radius: 4px;
  background: rgba(6, 14, 22, 0.88);
  border: 1px solid var(--cyan-mid);
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
  pointer-events: auto;
}

.touch-slot-btn:active {
  background: var(--cyan-dark);
}

/* ==========================================================================
   LOADING & SPLASH SCREEN
   ========================================================================== */

#splash-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #020508;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease-out;
}

#splash-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.splash-title {
  font-family: var(--font-display);
  font-size: 38px;
  font-weight: 900;
  color: #ffffff;
  letter-spacing: 6px;
  text-shadow: 0 0 12px var(--cyan-bright), 0 0 24px var(--cyan-mid);
  margin-bottom: 8px;
}

.splash-sub {
  font-size: 13px;
  color: var(--cyan-bright);
  letter-spacing: 3px;
  margin-bottom: 30px;
}

.splash-btn {
  padding: 12px 36px;
  background: rgba(0, 240, 255, 0.15);
  border: 2px solid var(--cyan-bright);
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.3);
  transition: all 0.2s ease;
}

.splash-btn:hover {
  background: var(--cyan-bright);
  color: #000000;
  box-shadow: 0 0 24px var(--cyan-bright);
}
