: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 === */
.title-content {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: linear-gradient(180deg, #0a0a1a 0%, #1a0a1a 50%, #0a0a1a 100%);
  gap: 12px;
}
.title-icon { font-size: 48px; color: #CC3333; text-shadow: 0 0 20px rgba(200,50,50,0.5); }
.title-name {
  font-size: 36px; font-weight: 900; color: var(--danger);
  text-shadow: 0 0 20px rgba(255,68,102,0.6), 0 0 40px rgba(255,68,102,0.3), 0 2px 4px rgba(0,0,0,0.9);
  letter-spacing: 3px; text-align: center; line-height: 1.2;
}
.title-sub { font-size: 18px; color: var(--text-secondary); font-style: italic; font-weight: 600; text-shadow: 0 2px 4px rgba(0,0,0,0.9); }
.title-btn {
  width: 200px; padding: 12px; background: var(--bg-tertiary);
  border-radius: 8px; color: var(--text-primary); font-size: 18px;
  font-weight: 800; text-align: center; text-shadow: 0 2px 4px rgba(0,0,0,0.9);
  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: 13px; color: var(--text-muted); margin-top: 4px; text-shadow: 0 1px 2px #000; }

/* === CHARACTER SELECT === */
.select-content {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: linear-gradient(180deg, #0a0a1a 0%, #0a1a0a 50%, #0a0a1a 100%);
  gap: 12px;
}
.select-title {
  font-size: 30px; font-weight: 900; color: var(--text-primary);
  letter-spacing: 2px; text-shadow: 0 2px 4px rgba(0,0,0,0.9); margin-bottom: 8px;
}
.char-btn {
  width: 380px; padding: 18px 22px; background: var(--bg-tertiary);
  border-radius: 10px; color: var(--text-primary); text-align: left;
  display: flex; flex-direction: column; gap: 3px;
  border: 2px solid transparent;
}
.char-btn:focus { border-color: var(--focus-ring); box-shadow: 0 0 16px var(--focus-glow); background: var(--bg-card); }
.char-name { font-size: 28px; font-weight: 900; color: var(--accent-primary); text-shadow: 0 2px 4px rgba(0,0,0,0.9); }
.char-weapon { font-size: 18px; color: var(--accent-gold); font-weight: 700; text-shadow: 0 2px 4px rgba(0,0,0,0.9); }
.char-desc { font-size: 17px; color: var(--text-secondary); font-weight: 600; text-shadow: 0 2px 4px rgba(0,0,0,0.9); }

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

/* === HUD === */
.hud-bar {
  position: absolute; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center;
  background: rgba(10, 10, 15, 0.85);
}
.hud-top { top: 0; height: 42px; padding: 6px 12px; gap: 8px; }
.hud-bottom { bottom: 0; height: 34px; padding: 6px 14px; gap: 8px; }
.hud-label { font-size: 12px; font-weight: 700; color: var(--text-muted); letter-spacing: 1px; }
.hud-hp-section { display: flex; align-items: center; gap: 5px; min-width: 120px; }
.hp-track { width: 110px; height: 14px; background: #1a1a2e; border-radius: 5px; overflow: hidden; }
.hp-fill { height: 100%; width: 100%; background: var(--danger); border-radius: 5px; transition: width 0.2s; }
.hp-text { font-size: 20px; font-weight: 900; color: var(--text-primary); text-shadow: 0 2px 4px rgba(0,0,0,0.9); min-width: 50px; }
.hud-center-info { flex: 1; display: flex; justify-content: center; gap: 16px; }
.hud-level-text { font-size: 20px; font-weight: 900; color: var(--accent-gold); text-shadow: 0 2px 4px rgba(0,0,0,0.9); }
.hud-timer-text { font-size: 20px; font-weight: 900; color: var(--text-primary); text-shadow: 0 2px 4px rgba(0,0,0,0.9); }
.hud-kills-section { display: flex; align-items: center; gap: 5px; min-width: 80px; justify-content: flex-end; }
.hud-kills-text { font-size: 20px; font-weight: 900; color: var(--success); text-shadow: 0 2px 4px rgba(0,0,0,0.9); }
.xp-track { flex: 1; height: 14px; background: #1a1a2e; border-radius: 5px; overflow: hidden; }
.xp-fill { height: 100%; width: 0%; background: var(--accent-primary); border-radius: 5px; transition: width 0.15s; }

/* === OVERLAYS === */
.overlay {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.8); z-index: 20;
  display: flex; align-items: center; justify-content: center;
}
.levelup-content, .chest-content {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  background: var(--bg-card); padding: 20px 28px; border-radius: 12px;
  border: 1px solid #444; min-width: 340px;
}
.levelup-title {
  font-size: 28px; font-weight: 900; color: var(--accent-gold);
  text-shadow: 0 0 15px rgba(255,215,0,0.5), 0 2px 4px rgba(0,0,0,0.9); letter-spacing: 2px;
}
.levelup-btn {
  width: 300px; padding: 12px 16px; background: var(--bg-tertiary);
  border-radius: 8px; color: var(--text-primary); text-align: left;
  display: flex; flex-direction: column; gap: 2px;
  border: 2px solid transparent;
}
.levelup-btn:focus { border-color: var(--focus-ring); box-shadow: 0 0 12px var(--focus-glow); background: var(--bg-card); }
.choice-name { font-size: 21px; font-weight: 800; color: var(--accent-primary); text-shadow: 0 2px 4px rgba(0,0,0,0.9); }
.choice-desc { font-size: 16px; color: var(--text-secondary); font-weight: 600; text-shadow: 0 2px 4px rgba(0,0,0,0.9); }
.chest-title {
  font-size: 24px; font-weight: 900; color: var(--accent-gold);
  text-shadow: 0 0 12px rgba(255,215,0,0.5), 0 2px 4px rgba(0,0,0,0.9);
}
.chest-result { font-size: 14px; color: var(--text-primary); text-align: center; line-height: 1.6; }
.chest-prompt { font-size: 14px; color: var(--text-muted); margin-top: 4px; }

/* === PAUSE === */
.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: 32px; font-weight: 900; color: var(--text-primary); text-shadow: 0 2px 4px rgba(0,0,0,0.9); }
.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;
}
.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); }

/* === HOW TO PLAY === */
.howto-content {
  flex: 1; display: flex; flex-direction: column;
  background: linear-gradient(180deg, #0a0a1a 0%, #0a1a1a 50%, #0a0a1a 100%);
  padding: 16px 20px;
}
.howto-title {
  font-size: 30px; font-weight: 900; color: var(--accent-primary);
  letter-spacing: 2px; text-align: center; margin-bottom: 8px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.9);
}
.howto-pages {
  flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 10px;
  padding-right: 4px;
}
.howto-page { display: flex; flex-direction: column; gap: 14px; }
.howto-page.hidden { display: none !important; }
.howto-section h3 { font-size: 22px; font-weight: 800; color: var(--accent-gold); margin-bottom: 3px; letter-spacing: 1px; text-shadow: 0 2px 4px rgba(0,0,0,0.9); }
.howto-section p { font-size: 18px; font-weight: 600; color: var(--text-secondary); line-height: 1.6; text-shadow: 0 2px 4px rgba(0,0,0,0.9); }
.howto-section p b { color: var(--text-primary); }
.howto-nav {
  font-size: 15px; color: var(--text-secondary); text-align: center;
  margin-top: 8px;
}
.howto-back {
  font-size: 16px; color: var(--text-muted); text-align: center;
  margin-top: 8px; padding-top: 8px; border-top: 1px solid #222;
}

/* === DIFFICULTY SELECT === */
.diff-btn {
  width: 300px; padding: 14px 18px; background: var(--bg-tertiary);
  border-radius: 10px; color: var(--text-primary); text-align: left;
  display: flex; flex-direction: column; gap: 3px;
  border: 2px solid transparent;
}
.diff-btn:focus { border-color: var(--focus-ring); box-shadow: 0 0 16px var(--focus-glow); background: var(--bg-card); }
.diff-name { font-size: 22px; font-weight: 900; color: var(--accent-primary); text-shadow: 0 2px 4px rgba(0,0,0,0.9); }
.diff-desc { font-size: 14px; font-weight: 600; color: var(--text-secondary); text-shadow: 0 2px 4px rgba(0,0,0,0.9); }

/* === GAME OVER === */
.result-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: 20px;
}
.result-title {
  font-size: 48px; font-weight: 900;
  text-shadow: 0 0 30px currentColor, 0 0 60px currentColor, 0 2px 4px rgba(0,0,0,0.9);
}
.result-subtitle {
  font-size: 16px; color: #AAAAAA; text-align: center; max-width: 400px; line-height: 1.4;
  text-shadow: 0 2px 4px rgba(0,0,0,0.9); margin: -8px 0 4px 0;
}
.result-stats { display: flex; gap: 20px; }
.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: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
.result-value { font-size: 26px; font-weight: 900; color: var(--accent-primary); text-shadow: 0 2px 4px rgba(0,0,0,0.9); }
.result-prompt {
  font-size: 18px; color: var(--text-secondary);
  animation: pulse 1.5s ease-in-out infinite; margin-top: 12px; font-weight: 600;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
