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

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

:root {
  --bg-dark: #0a0a0f;
  --bg-panel: #12121a;
  --bg-card: #1a1a2e;
  --border: #2a2a4a;
  --text: #e0e0e8;
  --text-dim: #8888aa;
  --accent: #8a2be2;
  --accent-glow: #b44dff;
  --danger: #e74c3c;
  --success: #2ecc71;
  --warning: #f1c40f;
  --breaker: #e74c3c;
  --shadeweaver: #9b59b6;
  --warden: #2ecc71;
  --drifter: #3498db;
}

body {
  background: var(--bg-dark);
  color: var(--text);
  font-family: 'Rajdhani', sans-serif;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  cursor: crosshair;
}

.screen { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; }
.screen.active { display: flex; }

/* ===== LOGIN ===== */
#screen-login {
  justify-content: center;
  align-items: center;
  background: radial-gradient(ellipse at center, #1a0a2e 0%, #0a0a0f 70%);
}
.login-container { position: relative; z-index: 10; text-align: center; }
.logo-text {
  font-family: 'Orbitron', sans-serif;
  font-size: 4rem;
  font-weight: 900;
  color: var(--text);
  letter-spacing: 0.3em;
  text-shadow: 0 0 30px rgba(138,43,226,0.5), 0 0 60px rgba(138,43,226,0.2);
}
.logo-text .accent { color: var(--accent-glow); }
.tagline { color: var(--text-dim); font-size: 1.1rem; margin-top: 0.5rem; letter-spacing: 0.4em; text-transform: uppercase; }

.auth-form {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  width: 300px;
  margin-left: auto; margin-right: auto;
}
.auth-form input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.8rem 1rem;
  border-radius: 4px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 1rem;
  outline: none;
  transition: border 0.3s;
}
.auth-form input:focus { border-color: var(--accent); }
.auth-switch { color: var(--text-dim); font-size: 0.9rem; margin-top: 0.5rem; }
.auth-switch a { color: var(--accent-glow); text-decoration: none; }
.error-msg { color: var(--danger); font-size: 0.85rem; min-height: 1.2rem; }
.hidden { display: none !important; }

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #6a1fb0);
  color: white;
  border: none;
  padding: 0.8rem 1.5rem;
  border-radius: 4px;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.1em;
  transition: all 0.3s;
  text-transform: uppercase;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 4px 20px rgba(138,43,226,0.4); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.6rem 1.2rem;
  border-radius: 4px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s;
}
.btn-secondary:hover { border-color: var(--accent); }
.btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-small { background: none; border: 1px solid var(--border); color: var(--text-dim); padding: 0.3rem 0.8rem; border-radius: 3px; cursor: pointer; font-size: 0.8rem; }
.btn-danger { background: linear-gradient(135deg, #c0392b, #8b0000); color: white; border: none; padding: 0.8rem 1.5rem; border-radius: 4px; font-family: 'Orbitron', sans-serif; font-size: 0.85rem; font-weight: 700; cursor: pointer; letter-spacing: 0.1em; }
.btn-big { padding: 1rem 2rem; font-size: 1.1rem; }

/* ===== SELECT SCREEN ===== */
#screen-select {
  flex-direction: column;
  background: var(--bg-dark);
  overflow-y: auto;
}
.select-container { max-width: 1200px; margin: 0 auto; padding: 1.5rem; width: 100%; }
.select-container h2 {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.8rem;
  text-align: center;
  color: var(--accent-glow);
  letter-spacing: 0.3em;
  margin-bottom: 1rem;
}
.account-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1rem;
  background: var(--bg-panel);
  border-radius: 6px;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
}
.essence-display { color: var(--accent-glow); font-weight: 700; }

.select-panels { display: grid; grid-template-columns: 260px 1fr 300px; gap: 1rem; min-height: 500px; }
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}
.panel h3 { font-family: 'Orbitron', sans-serif; font-size: 0.9rem; color: var(--accent-glow); letter-spacing: 0.1em; margin-bottom: 1rem; text-transform: uppercase; }

/* Character list */
.char-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.7rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
}
.char-card:hover { border-color: var(--accent); }
.char-card.selected { border-color: var(--accent-glow); box-shadow: 0 0 10px rgba(138,43,226,0.3); }
.char-card .char-name { font-weight: 700; font-size: 1rem; }
.char-card .char-class { color: var(--text-dim); font-size: 0.85rem; }
.char-card .char-stats { font-size: 0.75rem; color: var(--text-dim); margin-top: 0.3rem; }

/* Class grid */
.class-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin: 0.8rem 0; }
.class-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 6px;
  padding: 0.8rem;
  cursor: pointer;
  text-align: center;
  transition: all 0.3s;
}
.class-card:hover { transform: translateY(-2px); }
.class-card.selected { box-shadow: 0 0 15px rgba(138,43,226,0.4); }
.class-card .class-name { font-weight: 700; font-size: 0.95rem; }
.class-card .class-role { font-size: 0.75rem; color: var(--text-dim); }

/* Class info */
.class-role { color: var(--text-dim); font-size: 0.9rem; margin-bottom: 0.8rem; }
.stat-bar { display: flex; align-items: center; gap: 0.5rem; margin: 0.3rem 0; font-size: 0.85rem; }
.stat-bar-fill { height: 6px; background: var(--accent); border-radius: 3px; transition: width 0.3s; }
.stat-bar-track { flex: 1; height: 6px; background: var(--bg-card); border-radius: 3px; }
.ability-info { margin-top: 0.5rem; padding: 0.5rem; background: var(--bg-card); border-radius: 4px; }
.ability-info .ability-name { color: var(--accent-glow); font-weight: 600; }
.ability-info .ability-desc { font-size: 0.8rem; color: var(--text-dim); }

/* Lobby */
.lobby-section { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.lobby-join { display: flex; gap: 0.5rem; }
.lobby-join input { flex: 1; background: var(--bg-card); border: 1px solid var(--border); color: var(--text); padding: 0.5rem; border-radius: 4px; font-family: 'Rajdhani', sans-serif; }
#lobby-players { margin: 0.5rem 0; }
.lobby-player { padding: 0.3rem 0.5rem; background: var(--bg-card); border-radius: 4px; margin-bottom: 0.3rem; font-size: 0.9rem; }

/* Leaderboard */
.leaderboard-section { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.leaderboard-tabs { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.lb-tab { background: none; border: 1px solid var(--border); color: var(--text-dim); padding: 0.3rem 0.8rem; border-radius: 3px; cursor: pointer; font-family: 'Rajdhani', sans-serif; }
.lb-tab.active { border-color: var(--accent); color: var(--accent-glow); }
.lb-entry { display: flex; justify-content: space-between; padding: 0.3rem 0; font-size: 0.85rem; border-bottom: 1px solid rgba(42,42,74,0.3); }
.lb-rank { color: var(--accent-glow); width: 30px; }
.lb-value { color: var(--warning); }

/* ===== GAME SCREEN ===== */
#screen-game { background: #000; }
#game-canvas { width: 100%; height: 100%; display: block; }

/* HUD */
#hud { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 100; }
#hud > * { pointer-events: auto; }

#hud-top { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); text-align: center; }
#hud-floor { font-family: 'Orbitron', sans-serif; font-size: 1rem; color: var(--accent-glow); letter-spacing: 0.2em; }
#hud-biome { font-size: 0.8rem; color: var(--text-dim); }
#hud-warp { font-size: 0.8rem; color: var(--warning); margin-top: 2px; padding: 2px 10px; background: rgba(241,196,0,0.1); border-radius: 4px; }

#hud-player { position: absolute; bottom: 20px; left: 20px; }
#hud-hp-bar {
  width: 220px; height: 22px;
  background: rgba(0,0,0,0.7);
  border: 1px solid var(--border);
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}
#hud-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #c0392b, #e74c3c);
  transition: width 0.15s;
  border-radius: 2px;
}
#hud-hp-text {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 0.75rem; font-weight: 700; text-shadow: 1px 1px 2px #000;
}
#hud-resource-bar {
  width: 220px; height: 8px;
  background: rgba(0,0,0,0.7);
  border-radius: 2px;
  margin-top: 3px;
  overflow: hidden;
}
#hud-resource-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width 0.15s; }

#hud-abilities {
  display: flex; gap: 6px; margin-top: 8px;
}
.ability-slot {
  width: 48px; height: 48px;
  background: rgba(0,0,0,0.8);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  position: relative;
  overflow: hidden;
}
.ability-key { font-size: 0.7rem; color: var(--text-dim); font-family: 'Orbitron', sans-serif; z-index: 1; }
.ability-cd {
  position: absolute; bottom: 0; left: 0; width: 100%;
  background: rgba(138,43,226,0.4);
  transition: height 0.1s;
}

#hud-boons { position: absolute; top: 60px; right: 10px; }
#boon-icons { display: flex; flex-direction: column; gap: 4px; }
.boon-icon {
  width: 32px; height: 32px;
  background: rgba(0,0,0,0.8);
  border: 1px solid var(--border);
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  position: relative;
  cursor: default;
}
.boon-icon .boon-tooltip {
  display: none;
  position: absolute; right: 40px; top: 0;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 4px;
  white-space: nowrap;
  font-size: 0.75rem;
  z-index: 200;
}
.boon-icon:hover .boon-tooltip { display: block; }

#hud-stats {
  position: absolute; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
  font-size: 0.85rem; color: var(--text-dim);
}

#minimap-container {
  position: absolute; top: 10px; right: 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  opacity: 0.85;
}
#minimap { display: block; background: rgba(0,0,0,0.8); }

#hud-party {
  position: absolute; top: 60px; left: 20px;
  display: flex; flex-direction: column; gap: 6px;
}
.party-hp-bar {
  width: 140px; height: 14px;
  background: rgba(0,0,0,0.7);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.party-hp-fill { height: 100%; border-radius: 2px; transition: width 0.15s; }
.party-name { position: absolute; left: 4px; top: 50%; transform: translateY(-50%); font-size: 0.65rem; text-shadow: 1px 1px 2px #000; }

/* ===== OVERLAYS ===== */
.overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.85);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 500;
  animation: fadeIn 0.3s;
}
.overlay h2 {
  font-family: 'Orbitron', sans-serif;
  font-size: 2.2rem;
  color: var(--accent-glow);
  letter-spacing: 0.3em;
  margin-bottom: 0.5rem;
  text-shadow: 0 0 30px rgba(138,43,226,0.5);
}
.overlay-subtitle { color: var(--text-dim); margin-bottom: 2rem; letter-spacing: 0.2em; }

/* Boon choices */
#boon-choices { display: flex; gap: 1.5rem; }
.boon-card {
  width: 220px;
  background: var(--bg-panel);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  cursor: pointer;
  text-align: center;
  transition: all 0.3s;
}
.boon-card:hover { transform: translateY(-8px); box-shadow: 0 8px 30px rgba(138,43,226,0.3); }
.boon-card .boon-icon-big { font-size: 2.5rem; margin-bottom: 0.5rem; }
.boon-card .boon-name { font-family: 'Orbitron', sans-serif; font-size: 0.95rem; font-weight: 700; margin-bottom: 0.3rem; }
.boon-card .boon-rarity { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 0.5rem; }
.boon-card .boon-desc { font-size: 0.85rem; color: var(--text-dim); line-height: 1.4; }
.rarity-common { color: #95a5a6; }
.rarity-uncommon { color: #2ecc71; }
.rarity-rare { color: #3498db; }
.rarity-legendary { color: #f1c40f; }

/* Extraction */
#extraction-info { text-align: center; margin-bottom: 1.5rem; }
#extraction-info p { font-size: 1.1rem; margin: 0.3rem 0; }
.extraction-buttons { display: flex; gap: 2rem; }
.btn-extract { font-size: 1rem; padding: 1rem 2.5rem; }
.btn-descend { font-size: 1rem; padding: 1rem 2.5rem; }

/* Death / Victory */
.death-flavor { color: var(--text-dim); font-style: italic; margin-bottom: 1.5rem; }
#death-stats, #victory-stats {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  min-width: 300px;
}
.stat-line { display: flex; justify-content: space-between; padding: 0.4rem 0; border-bottom: 1px solid rgba(42,42,74,0.3); }
.stat-label { color: var(--text-dim); }
.stat-value { font-weight: 700; color: var(--accent-glow); }

/* Chat */
#chat-container {
  position: fixed; bottom: 80px; left: 20px; width: 300px; z-index: 150;
}
#chat-messages {
  max-height: 150px; overflow-y: auto;
  padding: 4px; font-size: 0.8rem;
  scrollbar-width: thin;
}
.chat-msg { padding: 2px 0; color: var(--text-dim); }
.chat-msg .chat-name { color: var(--accent-glow); font-weight: 600; }
#chat-input {
  width: 100%; background: rgba(0,0,0,0.6); border: 1px solid var(--border);
  color: var(--text); padding: 6px 10px; border-radius: 4px;
  font-family: 'Rajdhani', sans-serif; font-size: 0.85rem; outline: none;
  display: none;
}
#chat-input.visible { display: block; }

/* Floor Transition */
#floor-transition {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: var(--bg-dark);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.5s;
}
.floor-transition-text { text-align: center; }
.floor-transition-text h2 {
  font-family: 'Orbitron', sans-serif;
  font-size: 3rem;
  color: var(--accent-glow);
  letter-spacing: 0.3em;
  animation: pulseGlow 1.5s infinite;
}
.floor-transition-text p { color: var(--text-dim); font-size: 1.2rem; letter-spacing: 0.2em; margin-top: 0.5rem; }
.ft-warp { color: var(--warning) !important; font-weight: 600; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulseGlow {
  0%, 100% { text-shadow: 0 0 20px rgba(138,43,226,0.3); }
  50% { text-shadow: 0 0 40px rgba(138,43,226,0.6), 0 0 80px rgba(138,43,226,0.2); }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Background particles (login) */
.bg-particles {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 1;
}

/* Responsive */
@media (max-width: 900px) {
  .select-panels { grid-template-columns: 1fr; }
  .logo-text { font-size: 2.5rem; }
  #boon-choices { flex-direction: column; gap: 1rem; }
  .boon-card { width: 280px; }
}
