/* --- Design System & CSS Variables --- */
:root {
  --font-title: 'Space Grotesk', sans-serif;
  --font-body: 'Outfit', sans-serif;

  /* Theme Colors (Cyberpunk Default) */
  --neon-cyan: #00f3ff;
  --neon-pink: #ff007f;
  --neon-blue: #0066ff;
  --bg-dark: #07070a;
  --bg-panel: rgba(10, 10, 18, 0.75);
  --border-color: rgba(255, 255, 255, 0.08);
  
  --shadow-cyan: 0 0 15px rgba(0, 243, 255, 0.35);
  --shadow-pink: 0 0 15px rgba(255, 0, 127, 0.35);
}

/* Theme Adjustments */
body.theme-vaporwave {
  --neon-cyan: #bd00ff;
  --neon-pink: #ffe600;
  --neon-blue: #7000ff;
  --bg-dark: #0f051d;
  --bg-panel: rgba(23, 7, 38, 0.75);
  --shadow-cyan: 0 0 15px rgba(189, 0, 255, 0.35);
  --shadow-pink: 0 0 15px rgba(255, 230, 0, 0.35);
}

body.theme-emerald {
  --neon-cyan: #00ff66;
  --neon-pink: #adff2f;
  --neon-blue: #00aa44;
  --bg-dark: #020a05;
  --bg-panel: rgba(3, 18, 9, 0.8);
  --shadow-cyan: 0 0 15px rgba(0, 255, 102, 0.35);
  --shadow-pink: 0 0 15px rgba(173, 255, 47, 0.35);
}

body.theme-monochrome {
  --neon-cyan: #ffffff;
  --neon-pink: #888888;
  --neon-blue: #aaaaaa;
  --bg-dark: #090909;
  --bg-panel: rgba(20, 20, 20, 0.85);
  --shadow-cyan: 0 0 15px rgba(255, 255, 255, 0.25);
  --shadow-pink: 0 0 15px rgba(136, 136, 136, 0.25);
}

/* --- Base Layout --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-drag: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  font-family: var(--font-body);
  color: #e0e0ea;
  position: relative;
}

#canvas-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* --- Screen Overlay Effects (Vignette & Scanlines) --- */
.screen-effects {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
  background: 
    radial-gradient(circle, transparent 40%, rgba(0, 0, 0, 0.6) 95%),
    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% 100%, 100% 4px, 6px 100%;
}

/* --- UI Overlays & Menus --- */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(4, 4, 6, 0.4);
  backdrop-filter: blur(0px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s cubic-bezier(0.25, 1, 0.5, 1), 
              visibility 0.5s cubic-bezier(0.25, 1, 0.5, 1),
              backdrop-filter 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}

.overlay.active {
  opacity: 1;
  visibility: visible;
  backdrop-filter: blur(12px);
}

.glass-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 
    0 24px 80px rgba(0, 0, 0, 0.7),
    inset 0 1px 1px rgba(255, 255, 255, 0.05);
}

.menu-container {
  width: 90%;
  max-width: 480px;
  padding: 40px;
  text-align: center;
  transform: scale(0.9) translateY(20px);
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.overlay.active .menu-container {
  transform: scale(1) translateY(0);
}

/* --- Typography --- */
.game-title {
  font-family: var(--font-title);
  font-size: 3.5rem;
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: 2px;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.game-subtitle {
  font-size: 1rem;
  font-weight: 300;
  letter-spacing: 4px;
  color: #8c8c9e;
  margin-bottom: 40px;
  text-transform: uppercase;
}

.menu-title {
  font-family: var(--font-title);
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: 24px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.neon-text-cyan {
  color: var(--neon-cyan);
  text-shadow: 0 0 10px rgba(0, 243, 255, 0.5), 0 0 20px rgba(0, 243, 255, 0.2);
}

.neon-text-pink {
  color: var(--neon-pink);
  text-shadow: 0 0 10px rgba(255, 0, 127, 0.5), 0 0 20px rgba(255, 0, 127, 0.2);
}

.logo-3d {
  font-family: var(--font-title);
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--neon-cyan), var(--neon-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-left: 6px;
  border: 1px solid var(--neon-pink);
  padding: 2px 6px;
  border-radius: 4px;
  vertical-align: super;
  box-shadow: 0 0 10px rgba(255, 0, 127, 0.2);
}

/* --- Loader CSS --- */
.loader-content {
  text-align: center;
}
.loader-logo {
  font-size: 3rem;
  margin-bottom: 30px;
}
.loader-bar-container {
  width: 260px;
  height: 4px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 2px;
  overflow: hidden;
  margin: 0 auto 16px auto;
}
.loader-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-pink));
  box-shadow: 0 0 8px var(--neon-cyan);
}
.loader-status {
  font-size: 0.85rem;
  letter-spacing: 1.5px;
  color: #8c8c9e;
  text-transform: uppercase;
}

/* --- Buttons --- */
.btn {
  display: block;
  width: 100%;
  padding: 16px 24px;
  font-family: var(--font-title);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 2px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  text-transform: uppercase;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: #fff;
  color: #000;
  border: none;
}

.btn-secondary {
  background: transparent;
  color: #e0e0ea;
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
}

/* Neon Button Glows */
.btn-glow-cyan:hover {
  background: var(--neon-cyan);
  color: #000;
  box-shadow: var(--shadow-cyan);
  transform: translateY(-2px) scale(1.02);
}

.btn-glow-pink:hover {
  background: var(--neon-pink);
  color: #fff;
  box-shadow: var(--shadow-pink);
  transform: translateY(-2px) scale(1.02);
}

.menu-footer {
  font-size: 0.8rem;
  color: #656578;
  letter-spacing: 1px;
  margin-top: 15px;
}

/* --- HUD Styling --- */
.hud-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 8;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.hud-container.active {
  opacity: 1;
  visibility: visible;
}

.hud-top {
  display: flex;
  gap: 16px;
  pointer-events: auto;
}

.hud-panel {
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  min-width: 120px;
}

.hud-label {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 2px;
  color: #8c8c9e;
  margin-bottom: 4px;
}

.hud-value {
  font-family: var(--font-title);
  font-size: 1.4rem;
  font-weight: 700;
}

.hud-actions {
  position: absolute;
  top: 24px;
  right: 24px;
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

.btn-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  color: #e0e0ea;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: var(--bg-panel);
  transition: all 0.3s ease;
}

.btn-circle:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  transform: translateY(-2px);
  box-shadow: var(--shadow-cyan);
}

/* --- Mobile D-Pad Controls --- */
.mobile-controls-container {
  display: none; /* Only visible on mobile/touch */
  position: absolute;
  bottom: 24px;
  right: 24px;
  pointer-events: auto;
}

.d-pad {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.d-pad-horizontal {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
}

.d-pad-center {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.ctrl-btn {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-panel);
  color: #e0e0ea;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ctrl-btn:active {
  background: var(--neon-cyan);
  color: #000;
  box-shadow: var(--shadow-cyan);
  transform: scale(0.92);
}

/* --- Modals --- */
.modal-container {
  width: 90%;
  max-width: 500px;
  max-height: 85vh;
  padding: 32px;
  display: flex;
  flex-direction: column;
  transform: scale(0.9) translateY(20px);
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

.overlay.active .modal-container {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
}

.modal-title {
  font-family: var(--font-title);
  font-size: 1.5rem;
  letter-spacing: 2px;
}

.btn-close {
  background: transparent;
  border: none;
  font-size: 2rem;
  color: #8c8c9e;
  cursor: pointer;
  line-height: 1;
}

.btn-close:hover {
  color: #fff;
}

.modal-body {
  overflow-y: auto;
  padding-right: 8px;
}

/* Custom Scrollbar for Modal Body */
.modal-body::-webkit-scrollbar {
  width: 6px;
}
.modal-body::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}
.modal-body::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Settings List Elements */
.settings-group {
  margin-bottom: 24px;
}

.settings-group h3 {
  font-size: 0.75rem;
  letter-spacing: 2px;
  color: #8c8c9e;
  margin-bottom: 12px;
  border-left: 2px solid var(--neon-cyan);
  padding-left: 8px;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.setting-row label {
  font-size: 0.9rem;
}

.setting-row select {
  background: #0f0f15;
  border: 1px solid var(--border-color);
  color: #e0e0ea;
  padding: 8px 12px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.3s;
}

.setting-row select:focus {
  border-color: var(--neon-cyan);
}

/* Standard Switch Checkbox styling */
.setting-row input[type="checkbox"] {
  appearance: none;
  width: 44px;
  height: 22px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  transition: background 0.3s;
}

.setting-row input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #8c8c9e;
  transition: transform 0.3s, background 0.3s;
}

.setting-row input[type="checkbox"]:checked {
  background: var(--neon-cyan);
}

.setting-row input[type="checkbox"]:checked::after {
  transform: translateX(22px);
  background: #000;
}

/* Tutorial/How To Play Elements */
.tutorial-step {
  display: flex;
  gap: 20px;
  margin-bottom: 24px;
  align-items: flex-start;
}

.tutorial-num {
  font-family: var(--font-title);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--neon-pink);
  text-shadow: 0 0 8px rgba(255, 0, 127, 0.3);
  border-bottom: 2px solid var(--neon-pink);
}

.tutorial-text h3 {
  font-family: var(--font-title);
  font-size: 1.05rem;
  margin-bottom: 4px;
  letter-spacing: 0.5px;
}

.tutorial-text p {
  font-size: 0.85rem;
  color: #8c8c9e;
  line-height: 1.5;
}

/* --- Game Over & Stats --- */
.game-over-cause {
  font-size: 0.9rem;
  color: #8c8c9e;
  margin-bottom: 24px;
  font-family: monospace;
}

.stats-summary {
  display: flex;
  justify-content: space-around;
  gap: 16px;
  margin-bottom: 32px;
}

.stat-box {
  flex: 1;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  padding: 16px;
  border-radius: 12px;
}

.stat-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: #656578;
  margin-bottom: 8px;
}

.stat-value {
  font-family: var(--font-title);
  font-size: 1.8rem;
  font-weight: 700;
}

/* Pulse Animation */
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); }
  100% { transform: scale(1); }
}

.animate-pulse {
  animation: pulse 2s infinite ease-in-out;
}

/* --- Media Queries --- */
@media (max-width: 600px) {
  .game-title {
    font-size: 2.8rem;
  }
  .menu-container, .modal-container {
    padding: 24px;
  }
  .btn {
    padding: 14px 20px;
    font-size: 0.85rem;
  }
  .mobile-controls-container {
    display: block;
  }
  .hud-top {
    gap: 8px;
  }
  .hud-panel {
    padding: 8px 12px;
    min-width: 90px;
  }
  .hud-value {
    font-size: 1.1rem;
  }
}

@media (pointer: coarse) {
  /* Show D-pad only on touch devices */
  .mobile-controls-container {
    display: block;
  }
}
