@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Montserrat:wght@400;600;700&display=swap');

:root {
  --cyan: #00f0ff;
  --pink: #ff007f;
  --purple: #a200ff;
  --yellow: #ffaa00;
  --red: #ff3300;
  --green: #00ff66;
  --bg: #0a0214;
  --panel: rgba(10, 2, 20, 0.88);
  --panel-border: rgba(0, 240, 255, 0.2);
  --text: #e8e8f0;
  --text-dim: rgba(255,255,255,0.5);
  --glow-cyan: 0 0 8px var(--cyan), 0 0 20px rgba(0,240,255,0.25);
  --glow-pink: 0 0 8px var(--pink), 0 0 20px rgba(255,0,127,0.25);
  --transition: all 0.25s ease;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; -webkit-user-select: none; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg); font-family: 'Montserrat', sans-serif; color: var(--text); -webkit-tap-highlight-color: transparent; touch-action: none; }

/* ===== CANVAS ===== */
#game-canvas { display: block; width: 100%; height: 100%; position: fixed; top: 0; left: 0; z-index: 1; background: var(--bg); }

/* ===== HIDDEN UTILITY ===== */
.hidden { display: none !important; }

/* ===== NEON TEXT ===== */
.neon-glow-cyan { color: var(--cyan); text-shadow: var(--glow-cyan); }
.neon-glow-pink { color: var(--pink); text-shadow: var(--glow-pink); }

/* ===== GLASS PANEL ===== */
.glass-panel { background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--panel-border); border-radius: 16px; box-shadow: 0 8px 40px rgba(0,0,0,0.6); }

/* ===== OVERLAY SCREENS ===== */
.overlay-screen { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; background: rgba(5, 1, 12, 0.85); backdrop-filter: blur(6px); animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ===== MAIN MENU ===== */
.menu-content { padding: 30px 28px; text-align: center; max-width: 420px; width: 92%; display: flex; flex-direction: column; gap: 18px; }
.game-title { font-family: 'Orbitron', sans-serif; font-size: 2.8rem; font-weight: 900; line-height: 1.1; letter-spacing: 3px; }
.game-title span { display: block; font-size: 2.4rem; }
.menu-subtitle { font-size: 0.85rem; color: var(--text-dim); letter-spacing: 2px; text-transform: uppercase; }

.mode-select { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mode-btn { padding: 10px 8px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.1); background: rgba(255,255,255,0.03); color: var(--text-dim); font-family: 'Orbitron', sans-serif; font-size: 0.65rem; font-weight: 700; letter-spacing: 1px; cursor: pointer; transition: var(--transition); display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; }
.mode-btn:hover, .mode-btn.mode-active { border-color: var(--cyan); color: var(--cyan); background: rgba(0,240,255,0.06); box-shadow: 0 0 12px rgba(0,240,255,0.15); }

.btn-glow { padding: 14px 30px; border: 2px solid var(--cyan); border-radius: 10px; background: rgba(0,240,255,0.08); color: var(--cyan); font-family: 'Orbitron', sans-serif; font-weight: 900; font-size: 1rem; letter-spacing: 2px; cursor: pointer; transition: var(--transition); min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; }
.btn-glow:hover { background: var(--cyan); color: #000; box-shadow: 0 0 25px rgba(0,240,255,0.5); }
.btn-glow.btn-secondary { border-color: rgba(255,255,255,0.2); color: var(--text-dim); background: transparent; }
.btn-glow.btn-secondary:hover { border-color: #fff; color: #fff; background: rgba(255,255,255,0.06); box-shadow: none; }

.btn-play { font-size: 1.2rem; padding: 16px; }

.menu-records { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 0.78rem; }
.record-item { display: flex; justify-content: space-between; padding: 6px 10px; background: rgba(255,255,255,0.03); border-radius: 6px; border: 1px solid rgba(255,255,255,0.04); }
.record-item span:first-child { color: var(--text-dim); }
.record-item span:last-child { font-family: 'Orbitron', sans-serif; font-weight: 700; color: var(--cyan); }

.menu-footer { display: flex; justify-content: center; gap: 12px; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.15); background: rgba(255,255,255,0.04); color: var(--text-dim); display: flex; align-items: center; justify-content: center; font-size: 1rem; cursor: pointer; transition: var(--transition); text-decoration: none; }
.icon-btn:hover { border-color: var(--cyan); color: var(--cyan); }

/* ===== HUD ===== */
.hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; padding: 8px; }
.hud-top-bar { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; pointer-events: none; }
.hud-left { display: flex; flex-direction: column; gap: 4px; min-width: 140px; max-width: 200px; flex: 1; }
.hud-right { display: flex; gap: 10px; font-family: 'Orbitron', sans-serif; font-size: 0.65rem; font-weight: 700; flex-shrink: 0; }
.hud-stat { display: flex; align-items: center; gap: 4px; background: rgba(0,0,0,0.5); padding: 4px 8px; border-radius: 6px; backdrop-filter: blur(4px); white-space: nowrap; }
.hud-stat i { color: var(--cyan); font-size: 0.6rem; }

.hud-health-wrap, .hud-xp-wrap { position: relative; }
.hud-health-bar, .hud-xp-bar { height: 14px; background: rgba(255,255,255,0.08); border-radius: 7px; overflow: hidden; border: 1px solid rgba(255,255,255,0.1); }
.hud-health-fill { height: 100%; background: linear-gradient(90deg, var(--red), var(--pink)); border-radius: 7px; width: 100%; transition: width 0.2s ease; }
.hud-xp-fill { height: 100%; background: linear-gradient(90deg, var(--purple), var(--cyan)); border-radius: 7px; width: 0%; transition: width 0.15s ease; }
.hud-xp-bar { height: 10px; }
.hud-health-text, .hud-xp-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-family: 'Orbitron', sans-serif; font-size: 0.5rem; font-weight: 700; text-shadow: 0 1px 3px rgba(0,0,0,0.8); white-space: nowrap; pointer-events: none; }

.hud-controls { position: fixed; top: 8px; right: 8px; z-index: 15; pointer-events: auto; display: flex; gap: 6px; }
.hud-btn { width: 40px; height: 40px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.15); background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); color: #fff; font-size: 0.85rem; cursor: pointer; display: flex; align-items: center; justify-content: center; pointer-events: auto; transition: var(--transition); }
.hud-btn:hover { border-color: var(--cyan); }

.hud-minimap { position: fixed; bottom: 10px; right: 10px; z-index: 12; pointer-events: none; border-radius: 8px; overflow: hidden; border: 1px solid rgba(0,240,255,0.2); box-shadow: 0 0 10px rgba(0,0,0,0.5); }
.hud-minimap canvas { display: block; background: rgba(0,0,0,0.7); }

.hud-weapons { position: fixed; bottom: 10px; left: 50%; transform: translateX(-50%); z-index: 12; display: flex; gap: 4px; pointer-events: none; }
.weapon-icon { width: 34px; height: 34px; border-radius: 6px; border: 1px solid rgba(0,240,255,0.3); background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; font-size: 0.9rem; backdrop-filter: blur(4px); }

/* ===== VIRTUAL JOYSTICK ===== */
.joystick-zone { position: fixed; bottom: 20px; left: 20px; z-index: 20; pointer-events: auto; width: 140px; height: 140px; }
.joystick-base { width: 120px; height: 120px; border-radius: 50%; border: 2px solid rgba(0,240,255,0.25); background: rgba(0,240,255,0.04); position: relative; display: flex; align-items: center; justify-content: center; }
.joystick-thumb { width: 46px; height: 46px; border-radius: 50%; background: rgba(0,240,255,0.2); border: 2px solid rgba(0,240,255,0.5); position: absolute; transition: none; }

/* ===== LEVEL UP SCREEN ===== */
.levelup-content { text-align: center; max-width: 520px; width: 94%; }
.levelup-title { font-family: 'Orbitron', sans-serif; font-size: 2rem; font-weight: 900; margin-bottom: 4px; animation: pulse-glow 1s ease infinite alternate; }
@keyframes pulse-glow { from { text-shadow: var(--glow-cyan); } to { text-shadow: 0 0 15px var(--cyan), 0 0 40px rgba(0,240,255,0.5); } }
.levelup-sub { font-family: 'Orbitron', sans-serif; font-size: 0.85rem; color: var(--text-dim); margin-bottom: 18px; letter-spacing: 2px; }

.upgrade-choices { display: flex; flex-direction: column; gap: 10px; }
.upgrade-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.1); background: var(--panel); cursor: pointer; transition: var(--transition); text-align: left; }
.upgrade-card:hover { border-color: var(--cyan); background: rgba(0,240,255,0.05); transform: scale(1.02); box-shadow: 0 0 18px rgba(0,240,255,0.15); }
.upgrade-card:active { transform: scale(0.98); }

.upgrade-icon { font-size: 1.8rem; width: 48px; height: 48px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.upgrade-info { flex: 1; }
.upgrade-name { font-family: 'Orbitron', sans-serif; font-weight: 700; font-size: 0.85rem; letter-spacing: 1px; }
.upgrade-desc { font-size: 0.75rem; color: var(--text-dim); margin-top: 2px; }
.upgrade-rarity { font-family: 'Orbitron', sans-serif; font-size: 0.55rem; font-weight: 700; letter-spacing: 1px; padding: 2px 8px; border-radius: 4px; display: inline-block; margin-top: 4px; }

.rarity-common .upgrade-icon { background: rgba(255,255,255,0.06); }
.rarity-common .upgrade-name { color: #ccc; }
.rarity-common .upgrade-rarity { background: rgba(255,255,255,0.1); color: #aaa; }

.rarity-rare .upgrade-icon { background: rgba(0,240,255,0.1); border: 1px solid rgba(0,240,255,0.2); }
.rarity-rare .upgrade-name { color: var(--cyan); }
.rarity-rare .upgrade-rarity { background: rgba(0,240,255,0.15); color: var(--cyan); }

.rarity-epic .upgrade-icon { background: rgba(162,0,255,0.12); border: 1px solid rgba(162,0,255,0.25); }
.rarity-epic .upgrade-name { color: var(--purple); }
.rarity-epic .upgrade-rarity { background: rgba(162,0,255,0.15); color: var(--purple); }

.rarity-legendary .upgrade-icon { background: rgba(255,170,0,0.12); border: 1px solid rgba(255,170,0,0.3); }
.rarity-legendary .upgrade-name { color: var(--yellow); }
.rarity-legendary .upgrade-rarity { background: rgba(255,170,0,0.15); color: var(--yellow); }
.rarity-legendary .upgrade-card { border-color: rgba(255,170,0,0.3); }

/* ===== PAUSE SCREEN ===== */
.pause-content { padding: 28px; max-width: 360px; width: 88%; text-align: center; }
.pause-content h2 { font-family: 'Orbitron', sans-serif; font-size: 1.8rem; font-weight: 900; margin-bottom: 16px; }
.pause-stats { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; font-size: 0.8rem; }
.pause-buttons { display: flex; flex-direction: column; gap: 10px; }

/* ===== GAME OVER ===== */
.gameover-content { padding: 28px; max-width: 400px; width: 90%; text-align: center; }
.gameover-content h2 { font-family: 'Orbitron', sans-serif; font-size: 1.6rem; font-weight: 900; margin-bottom: 14px; line-height: 1.2; }
.gameover-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.gameover-stat { padding: 10px; border-radius: 8px; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.06); }
.gameover-stat .stat-val { font-family: 'Orbitron', sans-serif; font-weight: 900; font-size: 1.2rem; color: var(--cyan); display: block; }
.gameover-stat .stat-label { font-size: 0.6rem; color: var(--text-dim); letter-spacing: 1px; text-transform: uppercase; margin-top: 2px; display: block; }
.gameover-best { font-size: 0.8rem; color: var(--yellow); font-weight: bold; margin-bottom: 14px; min-height: 1.2em; }
.gameover-buttons { display: flex; gap: 10px; }
.gameover-buttons .btn-glow { flex: 1; }

/* ===== ACHIEVEMENT TOAST ===== */
.achievement-toast { position: fixed; top: -80px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; align-items: center; gap: 10px; padding: 10px 18px; border-radius: 10px; background: var(--panel); border: 2px solid var(--yellow); box-shadow: 0 0 20px rgba(255,170,0,0.25); transition: top 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); max-width: 90vw; backdrop-filter: blur(10px); }
.achievement-toast.active { top: 14px; }
.toast-icon { font-size: 1.5rem; }
.toast-label { font-family: 'Orbitron', sans-serif; font-size: 0.55rem; color: var(--yellow); letter-spacing: 1px; font-weight: 700; }
.toast-name { font-size: 0.85rem; font-weight: 700; }

/* ===== BOSS WARNING ===== */
.boss-warning { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 50; font-family: 'Orbitron', sans-serif; font-size: 1.4rem; font-weight: 900; color: var(--red); text-shadow: 0 0 15px var(--red), 0 0 40px rgba(255,51,0,0.5); animation: boss-flash 0.3s ease infinite alternate; pointer-events: none; white-space: nowrap; letter-spacing: 3px; }
@keyframes boss-flash { from { opacity: 1; } to { opacity: 0.4; } }

/* ===== RESPONSIVE ===== */
@media (min-width: 600px) {
  .upgrade-choices { flex-direction: row; gap: 12px; }
  .upgrade-card { flex-direction: column; text-align: center; flex: 1; padding: 20px 14px; }
  .upgrade-icon { width: 56px; height: 56px; font-size: 2rem; }
  .game-title { font-size: 3.5rem; }
  .game-title span { font-size: 3rem; }
  .hud-left { max-width: 260px; }
  .joystick-zone { bottom: 30px; left: 30px; width: 160px; height: 160px; }
  .joystick-base { width: 140px; height: 140px; }
  .joystick-thumb { width: 52px; height: 52px; }
}

@media (max-width: 380px) {
  .game-title { font-size: 2rem; }
  .game-title span { font-size: 1.7rem; }
  .hud-right { font-size: 0.55rem; gap: 6px; }
  .hud-stat { padding: 3px 6px; }
  .hud-minimap { display: none; }
}

@media (max-height: 500px) and (orientation: landscape) {
  .menu-content { padding: 16px 20px; gap: 10px; }
  .game-title { font-size: 1.6rem; }
  .game-title span { font-size: 1.4rem; }
  .menu-subtitle { display: none; }
  .menu-records { font-size: 0.7rem; }
  .joystick-zone { bottom: 10px; left: 10px; }
  .joystick-base { width: 100px; height: 100px; }
  .joystick-thumb { width: 38px; height: 38px; }
  .hud-minimap canvas { width: 80px; height: 80px; }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .levelup-title { animation: none; }
  .boss-warning { animation: none; }
  .overlay-screen { animation: none; }
}
