@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&family=Share+Tech+Mono&display=swap');

:root {
  --bg-color: #080710;
  --panel-bg: rgba(255, 255, 255, 0.05);
  --panel-border: rgba(255, 255, 255, 0.1);
  --primary: #ff007f; /* Neon pink */
  --secondary: #00f0ff; /* Neon cyan */
  --accent: #9d00ff; /* Neon purple */
  --text: #ffffff;
  --text-dim: #a0a0a0;
  --success: #39ff14; /* Neon green */
  --warning: #ffb700;
  --danger: #ff3333;
}

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

body {
  background-color: var(--bg-color);
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

#game-wrapper {
  position: relative;
  width: 100vw;
  height: 100vh;
  max-width: 1200px;
  max-height: 800px;
  aspect-ratio: 1.5;
  background-color: #0b0a16;
  border: 2px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(157, 0, 255, 0.2);
  overflow: hidden;
}

/* Common Screen Settings */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 10;
  background: radial-gradient(circle at center, #15122e 0%, #080710 100%);
  transition: opacity 0.5s ease, visibility 0.5s ease;
  padding: 2rem;
}

.screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Background canvas glowing dots */
.glow-bg {
  position: absolute;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(circle at 20% 30%, rgba(255, 0, 127, 0.1) 0%, transparent 40%),
              radial-gradient(circle at 80% 70%, rgba(0, 240, 255, 0.1) 0%, transparent 40%);
}

/* TITLE & HEADER */
.title-container {
  text-align: center;
  margin-bottom: 2rem;
  z-index: 2;
}

.game-title {
  font-size: 3.5rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 4px;
  background: linear-gradient(45deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 10px rgba(255, 0, 127, 0.4));
  margin-bottom: 0.5rem;
  animation: title-pulse 2s infinite alternate;
}

.game-subtitle {
  font-size: 1.1rem;
  color: var(--text-dim);
  letter-spacing: 2px;
}

/* CHARACTER SELECT */
.character-select-container {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  align-items: stretch;
  width: 100%;
  max-width: 1000px;
  margin-bottom: 2.5rem;
  z-index: 2;
}

.char-card {
  flex: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.char-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: transparent;
  transition: background-color 0.3s;
}

.char-card.elena::before { background: var(--primary); }
.char-card.seraphina::before { background: var(--secondary); }
.char-card.sylvia::before { background: var(--success); }
.char-card.kaguya::before { background: var(--warning); }

.char-card:hover {
  transform: translateY(-8px);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
}

.char-card.selected {
  background: rgba(255, 255, 255, 0.09);
  box-shadow: 0 0 25px rgba(157, 0, 255, 0.25);
}
.char-card.selected.elena { border-color: var(--primary); }
.char-card.selected.seraphina { border-color: var(--secondary); }
.char-card.selected.sylvia { border-color: var(--success); }
.char-card.selected.kaguya { border-color: var(--warning); }

/* Character Avatar Illustration */
.char-avatar-container {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  overflow: hidden;
  margin-bottom: 1rem;
  border: 2px solid var(--panel-border);
  background: #141227;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.3s;
}

.char-card.selected .char-avatar-container {
  border-color: inherit;
}

.char-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.char-avatar-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}

.char-name {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.char-title {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 1rem;
}

.char-stats {
  width: 100%;
  font-size: 0.85rem;
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 0.8rem;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.stat-label {
  color: var(--text-dim);
}

.stat-val {
  font-weight: 600;
}

/* BUTTONS */
.btn {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 1px;
  padding: 0.8rem 2.5rem;
  border-radius: 30px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 2;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.btn-primary {
  background: linear-gradient(90deg, var(--primary), var(--accent));
  color: #fff;
}

.btn-primary:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(255, 0, 127, 0.4);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 1px solid var(--panel-border);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.05);
}

/* GAME CANVAS */
#game-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 2;
}

/* HUD Overlay */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 5;
  pointer-events: none;
  display: flex;
  flex-direction: column;
}

/* XP Progress Bar at very top */
.xp-container {
  width: 100%;
  height: 12px;
  background: rgba(0, 0, 0, 0.5);
  position: relative;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.xp-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--secondary), var(--accent));
  box-shadow: 0 0 8px var(--secondary);
  transition: width 0.1s ease;
}

.level-badge {
  position: absolute;
  top: 12px;
  left: 16px;
  background: rgba(11, 10, 22, 0.85);
  border: 1px solid var(--secondary);
  border-radius: 4px;
  padding: 4px 10px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.95rem;
  color: var(--secondary);
  text-shadow: 0 0 5px rgba(0, 240, 255, 0.5);
  backdrop-filter: blur(5px);
  pointer-events: auto;
}

/* Top status panel */
.status-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  width: 100%;
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}

.avatar-hud {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--secondary);
  background: #141227;
}

.avatar-hud img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* HP Bar Container */
.hp-container {
  width: 180px;
  height: 20px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.hp-bar {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ff3366, #ff007f);
  box-shadow: 0 0 6px #ff007f;
  transition: width 0.15s ease;
}

.hp-text {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.hud-center {
  background: rgba(11, 10, 22, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 30px;
  padding: 6px 24px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 1.5rem;
  color: var(--text);
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  backdrop-filter: blur(5px);
}

.hud-right {
  display: flex;
  gap: 15px;
  background: rgba(11, 10, 22, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 6px 16px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 1.1rem;
  backdrop-filter: blur(5px);
  pointer-events: auto;
}

.hud-stat {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-icon {
  font-size: 1.2rem;
}

/* ACTIVE WEAPONS HUD */
#weapons-hud {
  position: absolute;
  bottom: 16px;
  left: 16px;
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.weapon-slot {
  width: 42px;
  height: 42px;
  background: rgba(11, 10, 22, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  font-size: 1.2rem;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.weapon-slot-level {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--secondary);
}

/* Audio control and Pause */
.control-hud {
  position: absolute;
  top: 60px;
  right: 20px;
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.hud-btn {
  background: rgba(11, 10, 22, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.95rem;
}

.hud-btn:hover {
  background: var(--secondary);
  color: var(--bg-color);
  border-color: var(--secondary);
  box-shadow: 0 0 10px var(--secondary);
}

/* LEVEL UP OVERLAY MODAL */
#levelup-modal {
  z-index: 20;
  background: rgba(8, 7, 16, 0.7);
  backdrop-filter: blur(12px);
}

.modal-content {
  background: linear-gradient(135deg, rgba(21, 18, 46, 0.9) 0%, rgba(8, 7, 16, 0.95) 100%);
  border: 1px solid var(--accent);
  border-radius: 20px;
  padding: 2.5rem;
  width: 90%;
  max-width: 650px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(157, 0, 255, 0.3), 0 0 40px rgba(0, 0, 0, 0.8);
  animation: modal-enter 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-title {
  font-size: 2.2rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--secondary);
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.4);
  margin-bottom: 0.5rem;
}

.modal-desc {
  color: var(--text-dim);
  font-size: 0.95rem;
  margin-bottom: 2rem;
}

.upgrade-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.upgrade-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  position: relative;
  overflow: hidden;
}

.upgrade-card:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateX(6px);
}

.upgrade-card.rarity-common { border-left: 4px solid var(--text-dim); }
.upgrade-card.rarity-rare { border-left: 4px solid var(--secondary); }
.upgrade-card.rarity-epic { border-left: 4px solid var(--primary); }
.upgrade-card.rarity-legendary { 
  border-left: 4px solid var(--warning); 
  background: linear-gradient(90deg, rgba(255, 183, 0, 0.04) 0%, rgba(255, 255, 255, 0.04) 100%);
}

.upgrade-card:hover.rarity-common { border-color: var(--text); }
.upgrade-card:hover.rarity-rare { border-color: var(--secondary); box-shadow: 0 0 15px rgba(0, 240, 255, 0.15); }
.upgrade-card:hover.rarity-epic { border-color: var(--primary); box-shadow: 0 0 15px rgba(255, 0, 127, 0.15); }
.upgrade-card:hover.rarity-legendary { border-color: var(--warning); box-shadow: 0 0 20px rgba(255, 183, 0, 0.2); }

.upgrade-icon-wrapper {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  flex-shrink: 0;
}

.upgrade-info {
  flex-grow: 1;
}

.upgrade-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 2px;
}

.upgrade-title {
  font-weight: 600;
  font-size: 1.05rem;
}

.upgrade-rarity-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 1px;
}

.upgrade-card.rarity-common .upgrade-rarity-label { color: var(--text-dim); }
.upgrade-card.rarity-rare .upgrade-rarity-label { color: var(--secondary); }
.upgrade-card.rarity-epic .upgrade-rarity-label { color: var(--primary); }
.upgrade-card.rarity-legendary .upgrade-rarity-label { color: var(--warning); }

.upgrade-description {
  font-size: 0.85rem;
  color: var(--text-dim);
  line-height: 1.2;
}

/* GAME OVER & WIN SCREENS */
.end-screen {
  z-index: 30;
  background: rgba(8, 7, 16, 0.85);
  backdrop-filter: blur(15px);
}

.end-title {
  font-size: 4rem;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
  letter-spacing: 6px;
  text-align: center;
}

.end-title.defeat {
  color: var(--danger);
  text-shadow: 0 0 20px rgba(255, 51, 51, 0.4);
}

.end-title.victory {
  color: var(--success);
  text-shadow: 0 0 20px rgba(57, 255, 20, 0.4);
}

.stats-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1.8rem;
  width: 100%;
  max-width: 450px;
  margin-bottom: 2.5rem;
}

.stats-card h3 {
  font-size: 1.2rem;
  margin-bottom: 1.2rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding-bottom: 8px;
  color: var(--secondary);
}

.stats-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.8rem;
  font-size: 0.95rem;
}

.stats-row:last-child {
  margin-bottom: 0;
}

.stats-label {
  color: var(--text-dim);
}

.stats-value {
  font-weight: 600;
  font-family: 'Share Tech Mono', monospace;
  font-size: 1.15rem;
}

/* DESKTOP GUIDES */
.desktop-controls-guide {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  gap: 12px;
  background: rgba(11, 10, 22, 0.6);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 0.75rem;
  color: var(--text-dim);
  z-index: 5;
  pointer-events: none;
}

.keyboard-key {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  padding: 1px 6px;
  color: #fff;
  font-weight: 600;
}

/* TOUCH CONTROLS (VIRTUAL JOYSTICK) */
#virtual-joystick {
  position: absolute;
  bottom: 40px;
  right: 40px;
  width: 120px;
  height: 120px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  z-index: 10;
  display: none; /* Only activated for touch devices */
  touch-action: none;
  justify-content: center;
  align-items: center;
}

#joystick-knob {
  width: 48px;
  height: 48px;
  background: radial-gradient(circle, var(--secondary) 0%, var(--accent) 100%);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--secondary);
}

/* PAUSE PANEL */
#pause-overlay {
  z-index: 15;
  background: rgba(8, 7, 16, 0.6);
  backdrop-filter: blur(6px);
}

.pause-content {
  text-align: center;
}

.pause-title {
  font-size: 3rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 2rem;
  letter-spacing: 4px;
}

.pause-actions {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* KEYFRAMES Animations */
@keyframes title-pulse {
  from {
    filter: drop-shadow(0 0 10px rgba(255, 0, 127, 0.4));
  }
  to {
    filter: drop-shadow(0 0 20px rgba(0, 240, 255, 0.7));
  }
}

@keyframes modal-enter {
  from {
    opacity: 0;
    transform: scale(0.8) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* RESPONSIVENESS */
@media (max-width: 768px) {
  #game-wrapper {
    aspect-ratio: auto;
    width: 100vw;
    height: 100vh;
    border: none;
    border-radius: 0;
  }
  
  .game-title {
    font-size: 2.2rem;
  }
  
  .character-select-container {
    flex-direction: column;
    gap: 0.8rem;
    overflow-y: auto;
    padding-right: 4px;
    max-height: 55%;
    margin-bottom: 1.5rem;
  }
  
  .char-card {
    padding: 0.8rem;
    flex-direction: row;
    gap: 12px;
    align-items: center;
  }
  
  .char-avatar-container {
    width: 50px;
    height: 50px;
    margin-bottom: 0;
  }
  
  .char-name {
    font-size: 1.05rem;
  }
  
  .char-title {
    font-size: 0.7rem;
    margin-bottom: 0;
  }

  .char-details {
    display: flex;
    flex-direction: column;
  }
  
  .char-stats {
    display: none; /* Hide detailed stats on mobile list */
  }

  .hp-container {
    width: 120px;
  }

  .hud-center {
    font-size: 1.2rem;
    padding: 4px 16px;
  }

  .hud-right {
    font-size: 0.9rem;
    padding: 4px 10px;
  }
  
  #virtual-joystick {
    display: flex; /* Show virtual joystick on mobile */
  }
  
  .desktop-controls-guide {
    display: none;
  }
}
