:root {
  --bg-primary: #000000;
  --bg-secondary: #0a0a0f;
  --bg-tertiary: #14141f;
  --bg-card: #1a1a2e;
  --text-primary: #ffffff;
  --text-secondary: #b0b0c0;
  --text-muted: #707080;
  --accent-primary: #00d4ff;
  --accent-gold: #FFD700;
  --danger: #ff4466;
  --success: #00ff88;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  width: 600px;
  height: 600px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app { width: 100%; height: 100%; position: relative; }

.screen {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  position: absolute; top: 0; left: 0;
}
.screen.hidden { display: none; }

.focusable {
  transition: all 0.15s ease;
  border: 2px solid transparent;
  cursor: pointer;
}
.focusable:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 16px var(--focus-glow);
}
.hidden { display: none !important; }

/* === TITLE SCREEN === */
.title-content {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: linear-gradient(180deg, #0a0a1a 0%, #1a0a0a 50%, #0a0a1a 100%);
  gap: 16px;
}
.title-swords { font-size: 48px; color: #C0C0C0; letter-spacing: 20px; }
.title-name {
  font-size: 44px; font-weight: 900; color: var(--accent-gold);
  text-shadow: 0 0 24px rgba(255,215,0,0.7), 0 2px 6px rgba(0,0,0,0.9), 0 0 3px #000, 0 0 40px rgba(255,215,0,0.3);
  letter-spacing: 4px;
}
.title-sub { font-size: 18px; color: var(--text-secondary); font-style: italic; font-weight: 600; text-shadow: 0 1px 4px #000, 0 0 6px rgba(0,0,0,0.5); }
.title-btn {
  width: 200px; padding: 12px; background: var(--bg-tertiary);
  border-radius: 8px; color: var(--text-primary); font-size: 18px;
  font-weight: 700; text-align: center; text-shadow: 0 1px 2px #000;
  border: 2px solid transparent; cursor: pointer;
}
.title-btn:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 16px var(--focus-glow);
  background: var(--bg-card);
}
#title-music, #title-sfx { font-size: 15px; padding: 10px; width: 180px; }
.title-controls { font-size: 14px; color: var(--text-muted); margin-top: 8px; text-shadow: 0 1px 2px #000; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* === DIFFICULTY SCREEN === */
.difficulty-content {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: linear-gradient(180deg, #0a0a1a 0%, #1a0a0a 50%, #0a0a1a 100%);
  gap: 14px;
}
.diff-title {
  font-size: 32px; font-weight: 900; color: var(--text-primary);
  letter-spacing: 3px; text-shadow: 0 2px 6px #000, 0 0 10px rgba(255,255,255,0.15); margin-bottom: 8px;
}
.diff-btn {
  width: 220px; padding: 16px; background: var(--bg-tertiary);
  border-radius: 8px; color: var(--text-primary);
  font-size: 18px; font-weight: 700; text-align: center;
  border: 2px solid transparent; text-shadow: 0 1px 2px #000;
}
.diff-btn:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 16px var(--focus-glow);
  background: var(--bg-card);
}
.diff-desc {
  font-size: 14px; color: var(--text-secondary); min-height: 20px;
  text-shadow: 0 1px 2px #000; margin-top: 8px;
}
.diff-record {
  font-size: 13px; color: var(--text-muted); min-height: 18px;
  text-shadow: 0 1px 2px #000;
}

/* === GAME SCREEN === */
#game-screen { position: relative; width: 600px; height: 600px; }
#battlefield { position: absolute; top: 0; left: 0; width: 600px; height: 600px; }

/* === HUD BARS === */
.hud-bar {
  position: absolute; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center;
  background: rgba(10, 10, 15, 0.92);
}
.hud-top { top: 0; height: 52px; padding: 6px 10px; gap: 8px; }
.hud-bottom { bottom: 0; flex-direction: column; height: auto; padding: 2px 6px 4px 6px; }
.hud-bottom-gold { display: flex; align-items: center; justify-content: center; gap: 4px; color: #FFD700; font-weight: 800; font-size: 17px; text-shadow: 0 1px 3px #000; padding: 1px 0; }
.hud-bottom-actions { display: flex; gap: 3px; width: 100%; }

.hud-hp-section { display: flex; align-items: center; gap: 4px; min-width: 95px; }
.hud-hp-bar { width: 90px; height: 16px; background: #1a1a2e; border-radius: 8px; overflow: hidden; }
.hud-hp-fill { height: 100%; width: 100%; background: var(--accent-primary); border-radius: 6px; transition: width 0.3s; }
.enemy-hp-fill { background: var(--danger); float: right; }
.hud-hp-label { font-size: 18px; font-weight: 900; color: var(--text-primary); min-width: 36px; text-shadow: 0 1px 4px #000, 0 0 6px rgba(0,0,0,0.5); }
.enemy-label { text-align: right; }

.hud-center { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.hud-gold { display: flex; align-items: center; gap: 4px; color: var(--accent-gold); font-weight: 800; font-size: 20px; text-shadow: 0 1px 3px #000; }
.hud-gold-icon { display: inline-flex; align-items: center; vertical-align: middle; }
.hud-age { font-size: 18px; font-weight: 900; color: var(--accent-primary); text-transform: uppercase; letter-spacing: 1px; text-shadow: 0 1px 4px #000, 0 0 8px rgba(0,212,255,0.3); }
.hud-xp { display: flex; align-items: center; gap: 4px; }
.hud-xp-label { font-size: 16px; color: var(--text-secondary); font-weight: 900; text-shadow: 0 1px 3px #000, 0 0 4px rgba(0,0,0,0.5); }
.hud-xp-bar { width: 100px; height: 8px; background: #1a1a2e; border-radius: 4px; overflow: hidden; }
.hud-xp-fill { height: 100%; width: 0%; background: var(--accent-gold); border-radius: 4px; transition: width 0.2s; }

/* === ACTION BUTTONS === */
.action-btn {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 4px 2px; background: var(--bg-tertiary);
  border-radius: 6px; color: var(--text-primary);
  font-size: 12px; min-height: 48px;
  border: 2px solid transparent;
}
.action-btn:focus { border-color: var(--focus-ring); box-shadow: 0 0 12px var(--focus-glow); background: var(--bg-card); }
.action-btn.cannot-afford { opacity: 0.3; }
.action-btn.on-cooldown .action-cost { color: var(--danger); }
.action-btn.evolve-ready {
  animation: evolve-pulse 0.6s ease-in-out infinite alternate;
  background: rgba(255,215,0,0.15);
}
@keyframes evolve-pulse {
  from { box-shadow: 0 0 8px rgba(255,215,0,0.4); border-color: rgba(255,215,0,0.4); background: rgba(255,215,0,0.1); }
  to { box-shadow: 0 0 25px rgba(255,215,0,0.9); border-color: rgba(255,215,0,0.9); background: rgba(255,215,0,0.25); }
}
.action-name { font-weight: 900; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; text-shadow: 0 1px 3px #000, 0 0 5px rgba(0,0,0,0.5); }
.action-cost { font-size: 13px; color: var(--text-secondary); font-weight: 800; text-shadow: 0 1px 3px #000, 0 0 4px rgba(0,0,0,0.5); }

/* === TURRET MENU OVERLAY === */
.turret-overlay {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.7); z-index: 20;
  display: flex; align-items: center; justify-content: center;
}
.turret-menu {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  background: var(--bg-card); padding: 20px 24px; border-radius: 12px;
  border: 1px solid #333; min-width: 320px;
}
.turret-menu-title { font-size: 28px; font-weight: 900; color: var(--text-primary); letter-spacing: 2px; text-shadow: 0 2px 5px #000, 0 0 8px rgba(255,255,255,0.1); }
.turret-status { font-size: 16px; color: var(--text-secondary); text-align: center; line-height: 1.4; font-weight: 700; text-shadow: 0 1px 2px #000; }
.turret-options { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.turret-row { display: flex; gap: 6px; justify-content: center; }
.turret-opt {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 10px 14px; background: var(--bg-tertiary); border-radius: 8px;
  color: var(--text-primary); font-size: 14px; min-width: 80px; min-height: 52px;
  border: 2px solid transparent;
}
.turret-opt:focus { border-color: var(--focus-ring); box-shadow: 0 0 12px var(--focus-glow); background: var(--bg-card); }
.turret-opt.cannot-afford { opacity: 0.3; }
.topt-name { font-weight: 900; font-size: 16px; text-shadow: 0 1px 3px #000, 0 0 4px rgba(0,0,0,0.5); }
.topt-cost { font-size: 14px; color: var(--text-secondary); font-weight: 800; text-shadow: 0 1px 3px #000, 0 0 4px rgba(0,0,0,0.5); }

/* === PAUSE OVERLAY === */
.pause-overlay {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.75); z-index: 20;
  display: flex; align-items: center; justify-content: center;
}
.pause-content {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  background: var(--bg-card); padding: 32px 48px; border-radius: 12px; border: 1px solid #333;
}
.pause-content h2 { font-size: 30px; color: var(--text-primary); text-shadow: 0 1px 4px #000; }
.pause-btn {
  width: 180px; padding: 14px; background: var(--bg-tertiary); border-radius: 8px;
  color: var(--text-primary); font-size: 17px; font-weight: 700; text-align: center; text-shadow: 0 1px 2px #000;
}
.pause-btn:focus { background: var(--bg-card); }
.pause-btn.danger { background: rgba(255,68,102,0.2); color: var(--danger); }
.pause-btn.danger:focus { background: rgba(255,68,102,0.35); }

/* === RESULT SCREEN === */
.result-content {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: linear-gradient(180deg, #0a0a1a 0%, #0a0a0f 100%);
  gap: 24px;
}
.result-title { font-size: 50px; font-weight: 900; text-shadow: 0 0 30px currentColor, 0 2px 6px #000, 0 0 50px currentColor; }
.result-stats { display: flex; gap: 24px; }
.result-stat {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--bg-card); padding: 12px 20px; border-radius: 8px;
}
.result-label { font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
.result-value { font-size: 22px; font-weight: 900; color: var(--accent-primary); text-shadow: 0 1px 4px #000, 0 0 6px rgba(0,212,255,0.3); }
.result-prompt { font-size: 18px; color: var(--text-secondary); animation: pulse 1.5s ease-in-out infinite; margin-top: 16px; font-weight: 800; text-shadow: 0 1px 4px #000, 0 0 6px rgba(0,0,0,0.5); }
