/* ==========================================================================
   1. CORE DESIGN SYSTEM & VARIABLES
   ========================================================================== */
:root {
  --color-bg: #0d0714;
  --color-bg-panel: rgba(29, 13, 43, 0.95);
  --color-border: #3b1c59;
  --color-border-glow: #10b981;
  
  /* HSL Tailored Colors */
  --toxic-green: hsl(142, 70%, 50%);
  --toxic-green-glow: hsla(142, 70%, 50%, 0.4);
  --poison-purple: hsl(292, 84%, 60%);
  --gold-yellow: hsl(45, 100%, 50%);
  --blood-red: hsl(0, 84%, 60%);
  --retro-blue: hsl(199, 89%, 48%);
  
  --font-pixel-title: 'Press Start 2P', 'Do Hyeon', sans-serif;
  --font-pixel-value: 'VT323', 'Do Hyeon', sans-serif;
  --font-text: 'Noto Sans KR', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

body, html {
  width: 100%;
  height: 100%;
  background-color: #000;
  color: #fff;
  font-family: var(--font-text);
  font-weight: 700;
  overflow: hidden;
}

/* ==========================================================================
   2. CRT SCANLINE EFFECTS (Retro Vintage Aesthetics)
   ========================================================================== */
.crt-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(18, 16, 16, 0) 60%, rgba(0, 0, 0, 0.8) 100%);
  pointer-events: none;
  z-index: 9999;
}

.crt-scanlines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%, 
    rgba(0, 0, 0, 0.3) 50%
  ), linear-gradient(
    90deg,
    rgba(255, 0, 0, 0.04),
    rgba(0, 255, 0, 0.02),
    rgba(0, 0, 255, 0.04)
  );
  background-size: 100% 4px, 6px 100%;
  pointer-events: none;
  z-index: 9998;
  animation: flicker 0.15s infinite;
}

@keyframes flicker {
  0% { opacity: 0.98; }
  50% { opacity: 1; }
  100% { opacity: 0.99; }
}

/* ==========================================================================
   3. GAME FRAME CONTAINER
   ========================================================================== */
.game-container {
  position: relative;
  width: 100%;
  max-width: 900px;
  height: 100%;
  max-height: 600px;
  margin: 0 auto;
  background-color: var(--color-bg);
  border: 4px solid var(--color-border);
  box-shadow: 0 0 20px rgba(162, 28, 175, 0.3);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

@media (min-width: 900px) and (min-height: 600px) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(#25103a, #07030c);
  }
}

/* Screen States */
.screen {
  display: none;
  width: 100%;
  height: 100%;
  flex-direction: column;
  padding: 20px;
  overflow-y: auto;
}

.screen.active {
  display: flex;
}

/* Scrollbar Styling */
.screen::-webkit-scrollbar {
  width: 8px;
}
.screen::-webkit-scrollbar-track {
  background: #0f0814;
}
.screen::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border: 2px solid #0f0814;
}

/* ==========================================================================
   4. RETRO BUTTONS (TACTILE & PIXELATED)
   ========================================================================== */
.pixel-btn, .pixel-btn-small {
  font-family: var(--font-pixel-title);
  color: #fff;
  background-color: #4b2375;
  border: 4px solid #000;
  box-shadow: inset -4px -4px 0px #2a1144, inset 4px 4px 0px #7b44b8;
  cursor: pointer;
  text-align: center;
  transition: transform 0.05s, box-shadow 0.05s;
  image-rendering: pixelated;
}

.pixel-btn {
  padding: 16px 24px;
  font-size: 14px;
  line-height: 1.2;
}

.pixel-btn-small {
  padding: 8px 12px;
  font-size: 10px;
  line-height: 1;
}

.pixel-btn:active, .pixel-btn-small:active {
  transform: translate(2px, 2px);
  box-shadow: inset 4px 4px 0px #2a1144, inset -4px -4px 0px #7b44b8;
}

.pixel-btn:disabled, .pixel-btn-small:disabled {
  background-color: #444 !important;
  color: #888 !important;
  box-shadow: none !important;
  border-color: #222 !important;
  cursor: not-allowed;
}

/* Button Variants */
.btn-primary {
  background-color: var(--toxic-green);
  box-shadow: inset -4px -4px 0px #15803d, inset 4px 4px 0px #86efac;
  color: #000;
  text-shadow: 1px 1px 0px rgba(255, 255, 255, 0.4);
}
.btn-primary:active {
  box-shadow: inset 4px 4px 0px #15803d, inset -4px -4px 0px #86efac;
}

.btn-secondary {
  background-color: var(--retro-blue);
  box-shadow: inset -4px -4px 0px #0369a1, inset 4px 4px 0px #7dd3fc;
}
.btn-secondary:active {
  box-shadow: inset 4px 4px 0px #0369a1, inset -4px -4px 0px #7dd3fc;
}

.btn-upgrade {
  background-color: var(--poison-purple);
  box-shadow: inset -4px -4px 0px #701a75, inset 4px 4px 0px #f472b6;
}
.btn-upgrade:active {
  box-shadow: inset 4px 4px 0px #701a75, inset -4px -4px 0px #f472b6;
}

.btn-muted {
  background-color: #374151;
  box-shadow: inset -4px -4px 0px #1f2937, inset 4px 4px 0px #6b7280;
}

.btn-block {
  width: 100%;
  display: block;
}

/* ==========================================================================
   5. SCREEN 1: INTRO / MAIN MENU
   ========================================================================== */
#menu-screen {
  justify-content: center;
  align-items: center;
  text-align: center;
  background: radial-gradient(circle, rgba(74, 29, 102, 0.4) 0%, rgba(13, 7, 20, 1) 90%);
}

.logo-area {
  margin-bottom: 40px;
}

.game-title {
  font-family: var(--font-pixel-title);
  font-size: 40px;
  line-height: 1.1;
  color: #fff;
  text-shadow: 6px 6px 0px #000, 10px 10px 0px var(--color-border);
  letter-spacing: 2px;
}

.game-title .highlight {
  color: var(--toxic-green);
  text-shadow: 6px 6px 0px #000, 10px 10px 0px #15803d;
  animation: pulse-glow 2s infinite ease-in-out;
}

@keyframes pulse-glow {
  0% { filter: drop-shadow(0 0 2px var(--toxic-green-glow)); }
  50% { filter: drop-shadow(0 0 15px var(--toxic-green)); }
  100% { filter: drop-shadow(0 0 2px var(--toxic-green-glow)); }
}

.tagline {
  font-family: var(--font-pixel-title);
  font-size: 10px;
  color: var(--poison-purple);
  margin-top: 15px;
  letter-spacing: 1px;
}

.stats-panel {
  display: flex;
  gap: 15px;
  margin-bottom: 40px;
  width: 100%;
  max-width: 600px;
}

.record-box {
  flex: 1;
  background-color: rgba(20, 10, 30, 0.8);
  border: 4px solid var(--color-border);
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.record-label {
  font-family: var(--font-pixel-title);
  font-size: 8px;
  color: #8b5cf6;
}

.record-value {
  font-family: var(--font-pixel-value);
  font-size: 28px;
  color: var(--gold-yellow);
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}

.menu-footer {
  margin-top: 30px;
  font-size: 9px;
  color: #4b3e56;
}

/* ==========================================================================
   6. SCREEN 2: WORLD INFECTION MAP
   ========================================================================== */
.screen-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 4px dashed var(--color-border);
  padding-bottom: 12px;
  margin-bottom: 12px;
}

.screen-header h2 {
  font-family: var(--font-pixel-title);
  font-size: 14px;
  color: var(--toxic-green);
  text-shadow: 2px 2px 0 #000;
  text-align: center;
}

.select-desc {
  font-size: 12px;
  color: #eee;
  text-align: center;
  margin-bottom: 15px;
}

/* The Interactive Map Graphic */
.world-map-container {
  position: relative;
  width: 100%;
  height: 220px;
  background-color: #0c0817;
  border: 4px solid var(--color-border);
  overflow: hidden;
  margin-bottom: 15px;
}

/* Grid Dots background */
.map-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.15;
  background-image: radial-gradient(#8b5cf6 2px, transparent 2px);
  background-size: 12px 12px;
}

/* Node pins on map */
.city-node {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  z-index: 10;
  transform: translate(-50%, -50%);
}

.city-dot {
  width: 12px;
  height: 12px;
  background-color: var(--blood-red);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 8px var(--blood-red);
  transition: transform 0.2s, background-color 0.2s;
}

.city-name {
  font-family: var(--font-pixel-title);
  font-size: 10px;
  color: #fff;
  margin-top: 4px;
  background-color: rgba(0, 0, 0, 0.7);
  padding: 2px 4px;
  border: 1px solid var(--color-border);
  white-space: nowrap;
}

.city-node:hover .city-dot {
  transform: scale(1.3);
  background-color: var(--toxic-green);
  box-shadow: 0 0 12px var(--toxic-green);
}

.city-node.cleared .city-dot {
  background-color: var(--toxic-green);
  box-shadow: 0 0 8px var(--toxic-green);
}

.city-node.selected .city-dot {
  background-color: #fff;
  box-shadow: 0 0 15px #fff;
  animation: pulse-pin 0.8s infinite alternate;
}

@keyframes pulse-pin {
  0% { transform: translate(-50%, -50%) scale(1.0); }
  100% { transform: translate(-50%, -50%) scale(1.3); }
}

/* City List Below Map */
.city-list-wrapper {
  background-color: rgba(20, 20, 20, 0.9);
  border: 4px solid var(--color-border);
  margin-top: 15px;
  padding: 10px;
}

.list-title {
  font-family: var(--font-pixel-title);
  font-size: 10px;
  color: var(--toxic-green);
  margin-bottom: 8px;
  text-align: center;
}

.city-list-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
  padding-right: 5px;
}

.city-list-grid::-webkit-scrollbar {
  width: 6px;
}
.city-list-grid::-webkit-scrollbar-thumb {
  background-color: var(--color-border);
}

.city-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background-color: #333;
  border: 1px solid #444;
  cursor: pointer;
  transition: background-color 0.2s;
}

.city-list-item:hover {
  background-color: #444;
}

.city-list-item.selected {
  background-color: #555;
  border-color: #fff;
}

.city-list-item.cleared .status-dot {
  background-color: var(--toxic-green);
  box-shadow: 0 0 5px var(--toxic-green);
}

.status-dot {
  width: 8px;
  height: 8px;
  background-color: #666;
  border-radius: 50%;
}

.city-label {
  font-size: 11px;
  color: #fff;
  flex: 1;
}

.difficulty {
  font-size: 9px;
  color: var(--gold-yellow);
  letter-spacing: -1px;
}

/* City Info Card below the map */
.city-details-card {
  background-color: var(--color-bg-panel);
  border: 4px solid var(--color-border);
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  display: none; /* Shown dynamically */
}

.city-details-card h3 {
  font-family: var(--font-pixel-title);
  font-size: 12px;
  color: var(--gold-yellow);
  border-bottom: 2px solid var(--color-border);
  padding-bottom: 6px;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 11px;
}

.info-item span {
  color: #ddd;
}

.info-item strong {
  color: #fff;
}

.gold-text {
  color: var(--gold-yellow) !important;
}
.green-text {
  color: var(--toxic-green) !important;
}
.red-text {
  color: var(--blood-red) !important;
}

.info-record-row {
  font-size: 11px;
  border-top: 1px dashed var(--color-border);
  padding-top: 8px;
}

/* ==========================================================================
   7. SCREEN 3: ZOMBIE RESEARCH LAB (UPGRADES)
   ========================================================================== */
.shop-gold-display {
  font-family: var(--font-pixel-value);
  font-size: 26px;
  color: var(--gold-yellow);
  background-color: rgba(0, 0, 0, 0.4);
  padding: 4px 12px;
  border: 2px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 6px;
}

.upgrade-container {
  display: flex;
  flex-direction: column;
  height: calc(100% - 60px);
}

.upgrade-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.tab-btn {
  flex: 1;
  padding: 8px 4px;
  font-family: var(--font-pixel-title);
  font-size: 11px;
  background-color: #211230;
  border: 3px solid var(--color-border);
  color: #ddd;
  cursor: pointer;
  text-align: center;
}

.tab-btn.active {
  background-color: var(--color-border);
  color: #fff;
  border-color: var(--poison-purple);
}

.tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
}

.tab-content.active {
  display: block;
}

.upgrade-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.upgrade-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: rgba(20, 10, 30, 0.7);
  border: 3px solid var(--color-border);
  padding: 12px;
  gap: 15px;
}

.up-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.up-info h4 {
  font-family: var(--font-pixel-title);
  font-size: 11px;
  color: #fff;
}

.up-desc {
  font-size: 11px;
  color: #ddd;
  line-height: 1.3;
}

.level-indicator {
  width: 120px;
  height: 10px;
  background-color: #111;
  border: 2px solid #000;
  margin: 4px 0;
  position: relative;
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  background-color: var(--toxic-green);
  box-shadow: inset 0px 2px 0px rgba(255,255,255,0.3);
}

.up-status {
  font-size: 10px;
  color: #888;
}

.btn-buy {
  min-width: 90px;
}

/* ==========================================================================
   8. SCREEN 4: GAMEPLAY PANEL
   ========================================================================== */
#game-screen {
  padding: 0;
  position: relative;
}

/* Game HUD */
.game-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: rgba(13, 7, 20, 0.95);
  border-bottom: 4px solid var(--color-border);
  padding: 8px 16px;
  height: 60px;
}

.hud-left h3 {
  font-family: var(--font-pixel-title);
  font-size: 12px;
  color: var(--toxic-green);
  margin-bottom: 2px;
}

.virus-charges {
  display: flex;
  align-items: center;
  gap: 4px;
}

.charge-label {
  font-family: var(--font-pixel-title);
  font-size: 7px;
  color: #888;
}

#virus-charge-dots {
  font-size: 11px;
}

.hud-center {
  flex: 1;
  max-width: 400px;
  margin: 0 15px;
}

.progress-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.progress-bar-bg {
  width: 100%;
  height: 14px;
  background-color: #111;
  border: 2px solid var(--color-border);
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #166534, var(--toxic-green));
  box-shadow: inset 0px 2px 0px rgba(255,255,255,0.4);
  width: 0%;
  transition: width 0.2s ease-out;
}

.target-line {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 4px;
  background-color: #fff;
  box-shadow: 0 0 6px #fff;
  z-index: 5;
}

.progress-text {
  font-size: 11px;
  text-align: center;
  color: #fff;
  white-space: nowrap;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hud-gold {
  font-family: var(--font-pixel-value);
  font-size: 26px;
  color: var(--gold-yellow);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Canvas Area */
.canvas-wrapper {
  position: relative;
  width: 100%;
  flex: 1;
  background-color: #111;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#game-canvas {
  width: 100%;
  height: 100%;
  max-width: 100%;
  background-color: #222;
  cursor: crosshair;
  display: block;
}

/* Swipe hint Overlay */
.canvas-hint {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.85);
  border: 2px solid var(--color-border);
  padding: 6px 12px;
  font-size: 10px;
  color: #fff;
  pointer-events: none;
  z-index: 100;
  text-align: center;
  width: 90%;
  max-width: 480px;
  opacity: 1;
  transition: opacity 1s ease;
}

/* Bottom Action Select Panel */
.action-selector-bar {
  display: flex;
  flex-direction: column;
  background-color: rgba(13, 7, 20, 0.95);
  border-top: 4px solid var(--color-border);
  padding: 6px 12px;
}

.selector-title {
  font-family: var(--font-pixel-title);
  font-size: 8px;
  color: #8b5cf6;
  margin-bottom: 4px;
}

.selectors-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.selectors-list::-webkit-scrollbar {
  height: 4px;
}
.selectors-list::-webkit-scrollbar-thumb {
  background: var(--color-border);
}

.selector-btn {
  flex: 1;
  min-width: 80px;
  height: 52px;
  background-color: #1a0b29;
  border: 3px solid var(--color-border);
  color: #ddd;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px;
  gap: 2px;
  position: relative;
  transition: border-color 0.1s, transform 0.1s;
}

.selector-btn.active {
  background-color: #3b145e;
  border-color: var(--toxic-green);
  color: #fff;
  transform: scale(1.03);
  box-shadow: 0 0 6px var(--toxic-green-glow);
}

.sel-icon {
  font-size: 14px;
}

.sel-label {
  font-size: 8px;
  white-space: nowrap;
  transform: scale(0.9);
}

.sel-count {
  font-family: var(--font-pixel-value);
  font-size: 12px;
  color: var(--gold-yellow);
}

.selector-btn.locked {
  background-color: #111;
  border-color: #333;
  color: #555;
  cursor: not-allowed;
}

.selector-btn.locked .sel-count {
  color: var(--blood-red);
}

.selector-btn.disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ==========================================================================
   9. POPUPS & MODALS (OVERLAYS)
   ========================================================================== */
.overlay-modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.overlay-modal.active {
  display: flex;
}

.modal-content {
  background-color: var(--color-bg-panel);
  border: 4px solid var(--color-border);
  width: 100%;
  max-width: 500px;
  box-shadow: 0 0 15px rgba(162, 28, 175, 0.4);
  position: relative;
}

/* Results Screen Card */
.result-card {
  padding: 24px;
  text-align: center;
}

.result-card h2 {
  font-family: var(--font-pixel-title);
  font-size: 20px;
  margin-bottom: 6px;
  text-shadow: 2px 2px 0px #000;
}

.result-stats-table {
  background-color: rgba(0, 0, 0, 0.4);
  border: 2px solid var(--color-border);
  padding: 15px;
  margin: 15px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
}

.result-row span {
  color: #ddd;
}

.total-row {
  border-top: 2px dashed var(--color-border);
  padding-top: 8px;
  margin-top: 4px;
  font-size: 13px;
  font-weight: bold;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* Help Screen Card */
.help-card {
  max-height: 80%;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 3px solid var(--color-border);
}

.modal-header h2 {
  font-family: var(--font-pixel-title);
  font-size: 12px;
  color: var(--toxic-green);
}

.close-x {
  background: none;
  border: none;
  color: var(--blood-red);
  font-family: var(--font-pixel-title);
  font-size: 14px;
  cursor: pointer;
}

.help-scroll-body {
  padding: 20px;
  overflow-y: auto;
  font-size: 11px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.help-scroll-body h3 {
  font-family: var(--font-pixel-title);
  font-size: 9px;
  color: var(--poison-purple);
  margin-bottom: 4px;
  border-left: 3px solid var(--poison-purple);
  padding-left: 6px;
}

.help-scroll-body ol {
  padding-left: 15px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#btn-help-ok {
  margin: 0 20px 20px 20px;
  width: calc(100% - 40px);
}
