/* ==========================================================================
   PIXEL SURVIVORS - CLASSIC DOS / RETRO Arcade CSS DESIGN SYSTEM
   ========================================================================== */

/* 1. RESET & BASE VARIABLES (DOS VGA Colors) */
:root {
  --bg-color: #000000; /* Pure black DOS console background */
  --bg-panel: #121214; /* Dark grey panel */
  --border-color: #7f7f7f; /* VGA Light Grey */
  --text-color: #cbd5e1; /* Off-white text */
  
  /* Authentic 16-color VGA/NES Palette */
  --primary-retro: #00aaaa;    /* VGA Cyan */
  --secondary-retro: #aa00aa;  /* VGA Magenta */
  --gold-retro: #ffaa00;       /* VGA Yellow / Gold */
  --success-retro: #55ff55;    /* VGA Light Green */
  --danger-retro: #ff5555;     /* VGA Light Red */
  --muted-retro: #555555;      /* VGA Dark Grey */
  
  --font-pixel: 'VT323', monospace; /* Classic DOS 80x25 text-mode terminal font */
  --font-sans: 'Noto Sans KR', sans-serif;
}

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

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

/* 2. CRT MONITOR EMULATION OVERLAYS (Slightly stronger scanlines for retro feel) */
.crt-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, 0.5) 100%);
  pointer-events: none;
  z-index: 9999;
}

.crt-scanlines {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    rgba(18, 16, 16, 0) 50%, 
    rgba(0, 0, 0, 0.22) 50%
  );
  background-size: 100% 4px;
  pointer-events: none;
  z-index: 9998;
}

/* Flat 2D Tiled/Gravel Ground Background (No neon lines, no 3D distortion) */
.ambient-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 0;
  background-color: #0a0a0c;
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 32px 32px;
}

/* 3. GAME WINDOW CONTAINER & BOXES (Boxy corners, double outlines) */
.game-container {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
  padding: 10px;
}

.screen {
  display: none;
  width: 100%;
  height: 100%;
  max-height: 700px;
  background: var(--bg-panel);
  /* Classic DOS style double border using double style */
  border: 5px double var(--border-color);
  border-radius: 0px; /* DOS systems had sharp corners */
  padding: 24px;
  box-shadow: 8px 8px 0px #000000; /* Solid flat shadow, no blur */
  backdrop-filter: none;
  flex-direction: column;
  justify-content: space-between;
  animation: screen-pop-instantly 0.1s ease-out; /* Snap quickly */
}

.screen.active {
  display: flex;
}

@keyframes screen-pop-instantly {
  from { opacity: 0.8; transform: scale(0.99); }
  to { opacity: 1; transform: scale(1); }
}

.screen-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 3px double var(--border-color);
  padding-bottom: 12px;
  margin-bottom: 15px;
}

.screen-header h2 {
  font-family: var(--font-pixel);
  font-size: 26px;
  color: var(--primary-retro);
  text-shadow: 2px 2px 0px #000000;
}

/* 4. SOLID FLAT RETRO BUTTONS */
.pixel-btn {
  font-family: var(--font-pixel);
  font-size: 20px;
  padding: 10px 18px;
  background: #222226;
  color: #fff;
  border: 3px solid var(--border-color);
  border-radius: 0px; /* Sharp corners */
  cursor: pointer;
  outline: none;
  text-shadow: 2px 2px 0px #000;
  box-shadow: 4px 4px 0px #000; /* Solid black shadow */
  transition: none; /* Instant feedback */
  position: relative;
  text-align: center;
}

.pixel-btn:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0px #000;
}

.pixel-btn-small {
  font-family: var(--font-pixel);
  font-size: 16px;
  padding: 6px 12px;
  background: #222226;
  color: #fff;
  border: 2px solid var(--border-color);
  border-radius: 0px;
  cursor: pointer;
  text-shadow: 2px 2px 0px #000;
  box-shadow: 3px 3px 0px #000;
  outline: none;
  transition: none;
}

.pixel-btn-small:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0px #000;
}

/* Button Variants */
.btn-primary {
  background: #113f85; /* DOS Dark Blue */
  border-color: #3b82f6;
  color: #fff;
}
.btn-primary:hover {
  background: #1d4ed8;
}

.btn-secondary {
  background: #2e3033;
  border-color: #7f7f7f;
  color: #fff;
}
.btn-secondary:hover {
  background: #4b4d52;
}

.btn-muted {
  background: #1e2022;
  border-color: #4b4d52;
  color: #88888c;
}

.btn-danger {
  background: #7f0000; /* Flat Dark Red */
  border-color: var(--danger-retro);
  color: #fff;
}
.btn-danger:hover {
  background: #b91c1c;
}

.btn-danger-small {
  background: #5c0f0f;
  border-color: #991b1b;
  color: #fca5a5;
}
.btn-danger-small:hover {
  background: #7f1d1d;
  color: #fff;
}

/* 5. MAIN MENU STYLE (DOS Prompt Character) */
#menu-screen {
  align-items: center;
}

.logo-area {
  text-align: center;
  margin-top: 15px;
}

.game-title {
  font-family: var(--font-pixel);
  font-size: 54px; /* VT323 is tall, so bump the size */
  line-height: 1.1;
  color: #ffffff;
  text-shadow: 
    4px 4px 0px #000000;
}

.game-title .highlight {
  color: var(--primary-retro);
  text-shadow: 
    4px 4px 0px #000000;
}

.tagline {
  margin-top: 8px;
  font-family: var(--font-pixel);
  font-size: 18px;
  color: #8a8a92;
  text-transform: uppercase;
}

.stats-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 340px;
  margin: 20px 0;
}

.record-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #000000; /* Pure black text screen box */
  border: 2px solid var(--border-color);
  border-radius: 0px;
  padding: 8px 16px;
}

.record-label {
  font-family: var(--font-pixel);
  font-size: 18px;
  color: #888894;
}

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

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 340px;
  margin-bottom: 10px;
}

.audio-setting-row {
  display: flex;
  justify-content: center;
  margin-top: 5px;
}

/* 6. UPGRADE SHOP STYLE (DOS Interface layout) */
.gold-display {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #000000;
  padding: 4px 14px;
  border-radius: 0px;
  border: 2px solid var(--gold-retro);
}

.gold-display span {
  font-family: var(--font-pixel);
  font-size: 18px;
  color: var(--gold-retro);
}

.shop-content-scroll {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding-right: 5px;
  margin-top: 10px;
}

.shop-content-scroll::-webkit-scrollbar {
  width: 10px;
}
.shop-content-scroll::-webkit-scrollbar-track {
  background: #000;
  border: 1px solid var(--border-color);
}
.shop-content-scroll::-webkit-scrollbar-thumb {
  background: var(--border-color);
}

.shop-desc {
  font-family: var(--font-pixel);
  font-size: 16px;
  color: #888894;
  text-align: center;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.shop-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 15px;
}

.shop-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #000;
  border: 2px solid var(--border-color);
  border-radius: 0px;
  padding: 10px 14px;
}

.shop-item:hover {
  border-color: var(--primary-retro);
}

.shop-item-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.upgrade-icon {
  font-size: 24px;
}

.upgrade-text {
  display: flex;
  flex-direction: column;
}

.upgrade-name {
  font-family: var(--font-pixel);
  font-size: 18px;
  font-weight: bold;
  color: #fff;
}

.upgrade-desc {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}

.upgrade-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.upgrade-level {
  font-family: var(--font-pixel);
  font-size: 14px;
  color: #888894;
}

.btn-upgrade {
  min-width: 90px;
  background: #b57c1e; /* Vintage Gold */
  border-color: var(--gold-retro);
  color: #000;
  font-weight: bold;
  text-shadow: none;
  box-shadow: 2px 2px 0px #4a2f00;
}
.btn-upgrade:active {
  transform: translate(2px, 2px);
  box-shadow: 0px 0px 0px #000;
}

.btn-upgrade:disabled {
  background: #2e3033;
  color: #55555c;
  border-color: #444;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

/* 7. CHARACTER SELECT STYLE */
.char-selection-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  flex: 1;
  margin: 10px 0;
}

.char-card {
  background: #000;
  border: 2px solid var(--border-color);
  border-radius: 0px;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: none;
  position: relative;
}

.char-card:hover {
  transform: none; /* No hover lift, very flat */
  border-color: var(--primary-retro);
}

.char-card.selected {
  border-color: var(--gold-retro);
  background: #111116;
}

.char-card.selected::after {
  content: '[SELECT]';
  position: absolute;
  top: -8px;
  font-family: var(--font-pixel);
  font-size: 12px;
  background: #000;
  color: var(--gold-retro);
  padding: 0px 4px;
  border: 1px solid var(--gold-retro);
}

.char-sprite-container {
  width: 48px;
  height: 48px;
  background: #121214;
  border: 2px solid var(--border-color);
  border-radius: 0px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 8px;
}

.char-sprite-container canvas {
  image-rendering: pixelated;
}

.char-name {
  font-family: var(--font-pixel);
  font-size: 18px;
  color: #fff;
  margin-bottom: 4px;
  text-align: center;
}

.char-weapon {
  font-family: var(--font-pixel);
  font-size: 14px;
  color: var(--gold-retro);
  margin-bottom: 6px;
}

.char-stats {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  border-top: 1px dashed var(--border-color);
  padding-top: 6px;
  margin-bottom: 8px;
}

.c-stat {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-pixel);
  font-size: 14px;
  color: #888894;
}

.c-val {
  color: var(--primary-retro);
}

.char-card[data-char="mage"] .c-val {
  color: var(--secondary-retro);
}
.char-card[data-char="ranger"] .c-val {
  color: var(--success-retro);
}

.char-desc {
  font-size: 10px;
  color: #5c6370;
  text-align: center;
  line-height: 1.3;
}

.char-select-actions {
  display: flex;
  justify-content: center;
  margin-top: 8px;
}

.char-select-actions button {
  width: 100%;
  max-width: 340px;
}

/* 8. GAMEPLAY HUD & CANVAS */
#game-screen {
  padding: 8px;
  justify-content: flex-start;
  gap: 8px;
}

.game-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  background: #000;
  border: 3px double var(--border-color);
  border-radius: 0px;
  padding: 6px 12px;
  position: relative;
  z-index: 110;
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.level-badge {
  font-family: var(--font-pixel);
  font-size: 16px;
  color: #fff;
  background: var(--muted-retro);
  padding: 2px 8px;
  border: 1px solid var(--border-color);
}

.xp-bar-container {
  height: 10px;
  background: #222;
  border-radius: 0px;
  flex: 1;
  max-width: 250px;
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.xp-bar-fill {
  height: 100%;
  background: #2e7d32; /* Classic dark green, no gradients */
  transition: width 0.1s ease;
}

.hud-center {
  margin: 0 10px;
}

.game-timer {
  font-family: var(--font-pixel);
  font-size: 22px;
  color: #fff;
  text-shadow: 2px 2px 0px #000;
}

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

.hud-stat {
  font-family: var(--font-pixel);
  font-size: 16px;
  color: #fff;
}

.hud-pause-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  outline: none;
}

/* Canvas wrapper */
.canvas-wrapper {
  position: relative;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: #000;
  border: 3px solid var(--border-color);
  border-radius: 0px;
  overflow: hidden;
}

#game-canvas {
  width: 100%;
  height: 100%;
  max-width: 580px;
  max-height: 580px;
  aspect-ratio: 1 / 1;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Mobile Virtual Joystick Style */
.joystick-zone {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: transparent;
  border: none;
  border-radius: 0px;
  display: block;
  touch-action: none;
  z-index: 100;
}

#joystick-outer {
  width: 100px;
  height: 100px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: none;
  justify-content: center;
  align-items: center;
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
}

#joystick-handle {
  width: 44px;
  height: 44px;
  background: rgba(127, 127, 127, 0.7); /* Solid grey joystick */
  border: 2px solid #fff;
  border-radius: 50%;
  position: absolute;
}

.mobile-hint {
  display: none;
  position: absolute;
  bottom: 8px;
  font-family: var(--font-pixel);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.3);
  text-align: center;
  width: 100%;
}

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

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

.modal-content {
  background: var(--bg-panel);
  border: 4px double var(--border-color);
  border-radius: 0px;
  width: 100%;
  max-width: 420px;
  padding: 20px;
  box-shadow: 8px 8px 0px #000000;
  text-align: center;
  animation: none; /* No scaling animations, snap instantly */
}

.modal-header h2 {
  font-family: var(--font-pixel);
  font-size: 32px;
  color: var(--gold-retro);
  margin-bottom: 4px;
  text-shadow: 2px 2px 0px #000;
}

.modal-header p {
  font-family: var(--font-pixel);
  font-size: 16px;
  color: #888894;
  margin-bottom: 15px;
}

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

.choice-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #000;
  border: 2px solid var(--border-color);
  border-radius: 0px;
  padding: 10px 14px;
  text-align: left;
  cursor: pointer;
  transition: none;
}

.choice-card:hover {
  border-color: var(--primary-retro);
  background: #111116;
  transform: none;
}

.choice-icon {
  font-size: 24px;
  width: 40px;
  height: 40px;
  background: #121214;
  border: 1px solid var(--border-color);
  border-radius: 0px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.choice-info {
  flex: 1;
}

.choice-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.choice-title {
  font-family: var(--font-pixel);
  font-size: 16px;
  font-weight: bold;
  color: #fff;
}

.choice-action {
  font-family: var(--font-pixel);
  font-size: 12px;
  background: #2e1045;
  color: var(--secondary-retro);
  padding: 1px 4px;
  border: 1px solid var(--secondary-retro);
}

.choice-card:hover .choice-action {
  background: var(--secondary-retro);
  color: #fff;
}

.choice-desc {
  font-size: 10px;
  color: #94a3b8;
  line-height: 1.2;
}

/* Pause Screen */
.pause-content h2 {
  font-family: var(--font-pixel);
  font-size: 28px;
  color: var(--primary-retro);
  margin-bottom: 15px;
}

.pause-stats {
  background: #000;
  border-radius: 0px;
  border: 2px solid var(--border-color);
  padding: 14px;
  margin-bottom: 20px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pause-stats p {
  font-family: var(--font-pixel);
  font-size: 18px;
  color: #888894;
  display: flex;
  justify-content: space-between;
}

.pause-stats span {
  font-weight: bold;
  color: #fff;
}

/* 10. GAME OVER SCREEN STYLE (DOS Defeat layout) */
#gameover-screen {
  align-items: center;
  justify-content: center;
  gap: 15px;
  background: #110000; /* Dark red background */
  border-color: var(--danger-retro);
  box-shadow: 8px 8px 0px #000000;
}

.gameover-title {
  font-family: var(--font-pixel);
  font-size: 54px;
  color: var(--danger-retro);
  text-shadow: 4px 4px 0px #000;
  margin-bottom: 6px;
  animation: none;
}

.gameover-header p {
  font-family: var(--font-pixel);
  font-size: 16px;
  color: #888894;
}

.gameover-summary {
  width: 100%;
  max-width: 340px;
  background: #000;
  border: 2px solid var(--danger-retro);
  border-radius: 0px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-pixel);
  font-size: 16px;
  color: #888894;
}

.summary-row strong {
  font-family: var(--font-pixel);
  font-size: 16px;
  color: #fff;
}

.highlight-row {
  border-top: 1px dashed var(--danger-retro);
  padding-top: 8px;
}

.highlight-row strong {
  color: var(--gold-retro);
}

.highscore-flash {
  font-family: var(--font-pixel);
  font-size: 18px;
  color: var(--gold-retro);
  background: rgba(234, 179, 8, 0.05);
  border: 1px solid var(--gold-retro);
  padding: 6px 16px;
  text-align: center;
  animation: highscore-pulse 1s steps(2, start) infinite; /* Retro step blink animation */
}

@keyframes highscore-pulse {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 1; }
}

.animate-pulse {
  animation: pulse-step 1s steps(2, start) infinite;
}

@keyframes pulse-step {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* 11. RESPONSIVE DESIGN */
@media (max-width: 600px) {
  .screen {
    padding: 12px;
  }
  
  .game-title {
    font-size: 36px;
  }
  
  .char-selection-container {
    grid-template-columns: 1fr;
    max-height: 300px;
    overflow-y: auto;
  }
  
  .char-card {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 6px 10px;
  }
  
  .char-sprite-container {
    margin-bottom: 0;
  }
  
  .char-stats {
    display: none;
  }
  
  .char-name {
    text-align: left;
    margin-bottom: 2px;
  }
  
  .char-desc {
    text-align: left;
  }

  .mobile-hint {
    display: block;
  }
}
