@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Outfit:wght@400;600;700;900&display=swap');

:root {
  --font-retro: 'Press Start 2P', monospace;
  --font-ui: 'Outfit', sans-serif;
  --color-arcade-bg: #0b0f19;
  --color-neon-green: #22c55e;
  --color-neon-blue: #38bdf8;
  --color-neon-pink: #ec4899;
}

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

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--color-arcade-bg);
  font-family: var(--font-ui);
  color: #f8fafc;
  touch-action: none;
}

.font-retro {
  font-family: var(--font-retro);
}

/* CRT Arcade Scanline Effect */
.crt-overlay {
  pointer-events: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%, 
    rgba(0, 0, 0, 0.25) 50%
  ), linear-gradient(
    90deg,
    rgba(255, 0, 0, 0.03),
    rgba(0, 255, 0, 0.01),
    rgba(0, 0, 255, 0.03)
  );
  background-size: 100% 3px, 6px 100%;
  z-index: 40;
  opacity: 0.85;
}

/* Container & Layout */
#app-root {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100dvh;
  max-width: 600px;
  margin: 0 auto;
  position: relative;
  background: #090d16;
  border-left: 1px solid #1e293b;
  border-right: 1px solid #1e293b;
}

/* Top HUD */
.hud-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #0f172a;
  border-bottom: 2px solid #1e293b;
  z-index: 20;
}

/* Mission / Math Objective Banner */
.objective-banner {
  background: linear-gradient(135deg, #1e1b4b, #0f172a);
  border-bottom: 2px solid #38bdf8;
  padding: 6px 12px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.15);
  z-index: 20;
}

/* Canvas Game Stage */
#canvas-container {
  flex: 1;
  position: relative;
  width: 100%;
  min-height: 0; /* Important for flex child */
  background: #070a12;
  overflow: hidden;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* Mobile Dual-Thumb Control Deck */
.control-deck {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px 14px 14px;
  background: #0d121f;
  border-top: 2px solid #1e293b;
  z-index: 30;
  gap: 12px;
}

/* D-PAD (Left Thumb) */
.dpad-container {
  display: grid;
  grid-template-columns: repeat(3, 48px);
  grid-template-rows: repeat(3, 48px);
  gap: 3px;
  align-items: center;
  justify-items: center;
  position: relative;
}

.dpad-btn {
  width: 48px;
  height: 48px;
  background: #1e293b;
  border: 2px solid #334155;
  border-radius: 10px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 0 #0f172a;
  cursor: pointer;
  touch-action: none;
  transition: transform 0.05s, background-color 0.05s, box-shadow 0.05s;
}

.dpad-btn.active-press, .dpad-btn:active {
  background: #22c55e;
  color: #ffffff;
  border-color: #4ade80;
  transform: translateY(3px);
  box-shadow: 0 1px 0 #0f172a, 0 0 14px rgba(34, 197, 94, 0.6);
}

.dpad-center {
  width: 48px;
  height: 48px;
  background: #0f172a;
  border-radius: 8px;
  opacity: 0.3;
}

/* Action Controls (Right Thumb) */
.action-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Arcade CHOMP Button */
.btn-chomp {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #4ade80, #16a34a, #14532d);
  border: 4px solid #86efac;
  box-shadow: 0 6px 0 #052e16, 0 0 20px rgba(34, 197, 94, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  cursor: pointer;
  touch-action: none;
  transition: transform 0.05s, box-shadow 0.05s;
}

.btn-chomp.active-press, .btn-chomp:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #052e16, 0 0 30px rgba(74, 222, 128, 0.8);
  background: radial-gradient(circle at 35% 35%, #86efac, #22c55e, #15803d);
}

/* DASH Button */
.btn-dash {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #38bdf8, #0284c7, #0369a1);
  border: 3px solid #7dd3fc;
  box-shadow: 0 4px 0 #082f49, 0 0 14px rgba(56, 189, 248, 0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  cursor: pointer;
  touch-action: none;
  position: relative;
  overflow: hidden;
  transition: transform 0.05s, box-shadow 0.05s;
}

.btn-dash.active-press, .btn-dash:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #082f49, 0 0 22px rgba(56, 189, 248, 0.7);
}

/* Modals */
.game-modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(7, 10, 18, 0.88);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}

.hidden {
  display: none !important;
}

.arcade-panel {
  background: #0f172a;
  border: 3px solid #38bdf8;
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 440px;
  text-align: center;
  box-shadow: 0 0 30px rgba(56, 189, 248, 0.3), inset 0 0 15px rgba(56, 189, 248, 0.1);
}

/* High Score Pulse */
@keyframes neonPulse {
  0%, 100% { text-shadow: 0 0 8px #facc15, 0 0 16px #facc15; }
  50% { text-shadow: 0 0 16px #facc15, 0 0 28px #eab308; }
}

.pulse-glow {
  animation: neonPulse 1.8s infinite;
}
