/* =============================================================
   Arcane Arena — UI styling (modern fantasy theme)
   - Dark, glassy panels with magical purple/cyan/fire accents
   - The HUD overlay is pointer-events:none so it never blocks the
     game; only the menu overlay is interactive.
   ============================================================= */

:root {
  --bg: #0a0814;
  --panel: rgba(20, 16, 34, 0.85);
  --panel-border: rgba(150, 110, 255, 0.35);
  --magic: #b07bff;
  --magic-glow: #7a3bd0;
  --fire: #ff5a1f;
  --ice: #6fd0ff;
  --lightning: #fff45a;
  --health: #ff4060;
  --mana: #5aa0ff;
  --text: #e8e2ff;
  --text-dim: #9c93b8;
  --font: 'Segoe UI', 'Trebuchet MS', system-ui, sans-serif;
  --font-title: 'Trajan Pro', 'Palatino Linotype', Georgia, serif;
}

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

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  user-select: none;
  cursor: default;
}

#game-canvas { position: fixed; inset: 0; display: block; }

/* ===================== HUD ===================== */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

/* Crosshair */
#crosshair {
  position: absolute; top: 50%; left: 50%;
  width: 26px; height: 26px; transform: translate(-50%, -50%);
}
#crosshair span {
  position: absolute; background: rgba(230, 226, 255, 0.85);
  box-shadow: 0 0 4px rgba(176, 123, 255, 0.9);
}
#crosshair span:nth-child(1) { top: 0; left: 50%; width: 2px; height: 8px; transform: translateX(-50%); }
#crosshair span:nth-child(2) { bottom: 0; left: 50%; width: 2px; height: 8px; transform: translateX(-50%); }
#crosshair span:nth-child(3) { left: 0; top: 50%; height: 2px; width: 8px; transform: translateY(-50%); }
#crosshair span:nth-child(4) { right: 0; top: 50%; height: 2px; width: 8px; transform: translateY(-50%); }
#hit-marker {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(1.4);
  color: #ff5252; font-size: 22px; font-weight: bold; opacity: 0;
  transition: opacity 0.05s; text-shadow: 0 0 6px #ff0000;
}
#hit-marker.show { opacity: 1; }

/* Damage vignette */
#damage-vignette {
  position: absolute; inset: 0; opacity: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(255, 20, 40, 0.55) 100%);
  transition: opacity 0.12s;
}

/* Top bar */
#top-bar {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 28px; align-items: center;
}
#match-timer {
  font-size: 34px; font-weight: 700; letter-spacing: 2px;
  color: #fff; text-shadow: 0 0 12px var(--magic-glow);
  background: var(--panel); border: 1px solid var(--panel-border);
  padding: 4px 18px; border-radius: 10px; min-width: 120px; text-align: center;
}
#score { display: flex; gap: 18px; font-size: 20px; }
.score-kills b { color: var(--lightning); }
.score-deaths b { color: var(--health); }

/* Killfeed */
#killfeed {
  position: absolute; top: 16px; right: 18px; width: 320px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
}
.killfeed-row {
  background: var(--panel); border: 1px solid var(--panel-border);
  padding: 5px 12px; border-radius: 8px; font-size: 15px;
  animation: kfLife 5s forwards;
}
.kf-killer { color: var(--ice); font-weight: 700; }
.kf-victim { color: var(--health); font-weight: 700; }
.kf-spell { font-size: 17px; }
@keyframes kfLife {
  0% { opacity: 0; transform: translateX(30px); }
  8% { opacity: 1; transform: translateX(0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* Active buffs */
#buffs {
  position: absolute; top: 80px; left: 18px;
  display: flex; flex-direction: column; gap: 6px;
}
.buff {
  background: var(--panel); border-left: 4px solid var(--c, var(--magic));
  padding: 4px 12px; border-radius: 6px; font-size: 14px;
  box-shadow: 0 0 12px color-mix(in srgb, var(--c, var(--magic)) 50%, transparent);
}

/* Power-up toast */
#powerup-toast {
  position: absolute; top: 32%; left: 50%; transform: translateX(-50%) scale(0.8);
  font-size: 30px; font-weight: 800; letter-spacing: 1px; opacity: 0;
  color: var(--c, #fff); text-shadow: 0 0 18px var(--c, #fff);
}
#powerup-toast.show { animation: toast 1.6s ease-out forwards; }
@keyframes toast {
  0% { opacity: 0; transform: translateX(-50%) scale(0.6); }
  15% { opacity: 1; transform: translateX(-50%) scale(1.05); }
  70% { opacity: 1; transform: translateX(-50%) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-30px) scale(1); }
}

/* Floating damage numbers */
#damage-numbers { position: absolute; inset: 0; }
.dmg-number {
  position: absolute; transform: translate(-50%, -50%);
  font-size: 20px; font-weight: 800; text-shadow: 0 0 6px rgba(0,0,0,0.9);
  animation: dmgFloat 0.9s ease-out forwards;
}
.dmg-number.crit { font-size: 30px; }
@keyframes dmgFloat {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  20% { opacity: 1; transform: translate(-50%, -70%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -140%) scale(1); }
}

/* Vitals (health + mana) */
#vitals {
  position: absolute; bottom: 22px; left: 22px;
  display: flex; flex-direction: column; gap: 10px; width: 320px;
}
.bar { display: flex; align-items: center; gap: 10px; }
.bar-icon { font-size: 22px; width: 26px; text-align: center; }
.bar-track {
  position: relative; flex: 1; height: 22px; border-radius: 11px;
  background: rgba(0,0,0,0.55); border: 1px solid var(--panel-border);
  overflow: hidden;
}
.bar-fill { height: 100%; width: 100%; transition: width 0.12s linear; border-radius: 11px; }
.health .bar-fill { background: linear-gradient(90deg, #ff2a52, #ff7a90); box-shadow: 0 0 12px var(--health); }
.mana .bar-fill { background: linear-gradient(90deg, #3a6aff, #7ac0ff); box-shadow: 0 0 12px var(--mana); }
.bar-text {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-size: 13px; font-weight: 700; text-shadow: 0 0 4px #000;
}
.bar .bar-text { left: auto; }
.bar-track .bar-text { right: 10px; }
.bar { position: relative; }
.bar .bar-text { position: absolute; right: 10px; }

/* Spell hotbar */
#spellbar {
  position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px;
}
.spell-slot {
  position: relative; width: 66px; height: 66px; border-radius: 12px;
  background: var(--panel); border: 2px solid rgba(255,255,255,0.12);
  overflow: hidden; transition: transform 0.1s, border-color 0.1s;
}
.spell-slot.active {
  border-color: var(--spell-color);
  box-shadow: 0 0 18px var(--spell-color); transform: translateY(-6px);
}
.spell-slot.no-mana { filter: grayscale(0.7) brightness(0.6); }
.spell-icon { font-size: 30px; text-align: center; line-height: 66px; }
.spell-key {
  position: absolute; top: 3px; left: 5px; font-size: 12px; font-weight: 700;
  color: var(--text-dim);
}
.spell-cost {
  position: absolute; bottom: 2px; right: 5px; font-size: 11px; color: var(--mana);
  font-weight: 700;
}
.spell-name {
  position: absolute; bottom: 2px; left: 0; right: 0; text-align: center;
  font-size: 9px; color: var(--text-dim); opacity: 0;
}
.spell-slot.active .spell-name { opacity: 1; }
.spell-cd {
  position: absolute; inset: 0; background: rgba(10, 6, 20, 0.78);
  transform-origin: top; transform: scaleY(0);
}

#hint {
  position: absolute; bottom: 8px; right: 16px; font-size: 12px; color: var(--text-dim);
}

/* Class indicator badge above the hotbar */
#class-indicator {
  position: absolute; bottom: 100px; left: 50%; transform: translateX(-50%);
  font-size: 13px; font-weight: 700; letter-spacing: 1px;
  color: var(--fire); text-shadow: 0 0 8px var(--fire);
  pointer-events: none; white-space: nowrap;
}

/* ===================== Death Overlay ===================== */
#death-overlay {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 15; display: none;
  flex-direction: column; align-items: center; gap: 14px;
  background: rgba(10, 6, 20, 0.82); border: 1px solid var(--panel-border);
  border-radius: 16px; padding: 28px 44px;
  backdrop-filter: blur(5px);
  box-shadow: 0 0 50px rgba(120, 40, 200, 0.4);
  pointer-events: auto; text-align: center;
  animation: panelIn 0.3s ease-out;
}
#death-overlay.show { display: flex; }

#death-overlay-title {
  font-size: 22px; font-weight: 700; letter-spacing: 2px; color: var(--health);
  text-shadow: 0 0 14px var(--health);
}
#death-overlay-timer {
  font-size: 32px; font-weight: 700; color: var(--text-dim); letter-spacing: 1px;
}
#btn-open-class-select {
  font-size: 16px; padding: 11px 26px; margin-top: 4px;
}

/* ===================== Class Select Panel ===================== */
.class-select-panel { width: min(780px, 96vw) !important; }

.class-select-hint {
  color: var(--text-dim); margin-bottom: 22px; font-size: 15px;
}

.class-cards {
  display: flex; gap: 16px; justify-content: center; flex-wrap: wrap;
}

.class-card {
  background: rgba(10, 6, 20, 0.9);
  border: 2px solid var(--panel-border); border-radius: 14px;
  padding: 20px 16px; width: 210px; text-align: center;
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.12s;
  cursor: default;
}
.class-card:hover {
  border-color: var(--magic);
  box-shadow: 0 0 22px rgba(176,123,255,0.35);
  transform: translateY(-3px);
}

.class-preview-canvas {
  display: block; margin: 0 auto 8px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(0,0,0,0.35);
}

.class-card-name { font-size: 15px; font-weight: 700; margin-bottom: 5px; }

.class-card-desc { font-size: 12px; color: var(--text-dim); margin-bottom: 12px; line-height: 1.5; }

.class-card-spells {
  font-size: 11px; color: var(--text-dim); margin-bottom: 12px;
  line-height: 2; text-align: left; padding: 0 4px;
}
.spell-bind {
  display: inline-block; font-size: 10px; font-weight: 700;
  background: rgba(0,0,0,0.5); border: 1px solid var(--panel-border);
  border-radius: 4px; padding: 1px 5px; color: var(--text);
  margin-left: 4px; vertical-align: middle;
}

.class-card-stats {
  display: flex; justify-content: center; gap: 16px;
  font-size: 13px; margin-bottom: 16px; color: var(--text);
}

.class-card .select-class-btn { width: 100%; font-size: 14px; padding: 9px 0; }

#class-respawn-timer {
  margin-top: 20px; font-size: 17px; color: var(--text-dim);
  text-align: center; letter-spacing: 1px;
}

/* ===================== Scoreboard ===================== */
#scoreboard {
  position: fixed; inset: 0; z-index: 20; display: none;
  align-items: center; justify-content: center;
  background: rgba(5, 3, 12, 0.6); backdrop-filter: blur(2px); pointer-events: none;
}
#scoreboard.show { display: flex; }
#scoreboard h2 { text-align: center; margin-bottom: 14px; letter-spacing: 3px; color: var(--magic); }
#scoreboard table, #end-scoreboard table {
  border-collapse: collapse; min-width: 480px;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 12px; overflow: hidden;
}
#scoreboard th, #scoreboard td, #end-scoreboard th, #end-scoreboard td {
  padding: 10px 22px; text-align: left; font-size: 17px;
}
#scoreboard thead, #end-scoreboard thead { background: rgba(150,110,255,0.18); }
#scoreboard tbody tr:nth-child(even), #end-scoreboard tbody tr:nth-child(even) { background: rgba(255,255,255,0.03); }
#scoreboard tr.me, #end-scoreboard tr.me { background: rgba(176,123,255,0.22) !important; font-weight: 700; }
#scoreboard td:nth-child(3), #end-scoreboard td:nth-child(3) { color: var(--lightning); font-weight: 700; }

/* ===================== Menus ===================== */
#menu-overlay {
  position: fixed; inset: 0; z-index: 30; display: none;
  align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(40,20,70,0.55), rgba(5,3,12,0.92));
  backdrop-filter: blur(6px);
}
#menu-overlay.show { display: flex; }

.menu-panel {
  display: none; width: min(640px, 92vw); max-height: 92vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 18px;
  padding: 34px 40px; box-shadow: 0 0 60px rgba(120,60,220,0.4);
  text-align: center;
}
.menu-panel.show { display: block; animation: panelIn 0.25s ease-out; }
@keyframes panelIn { from { opacity: 0; transform: translateY(14px) scale(0.98); } to { opacity: 1; } }

.game-title {
  font-family: var(--font-title); font-size: 64px; letter-spacing: 8px; line-height: 1;
  background: linear-gradient(180deg, #fff, var(--magic)); -webkit-background-clip: text;
  background-clip: text; color: transparent; filter: drop-shadow(0 0 22px var(--magic-glow));
}
.game-title span { display: block; font-size: 40px; letter-spacing: 14px; color: var(--ice);
  -webkit-text-fill-color: var(--ice); filter: drop-shadow(0 0 14px var(--ice)); }
.tagline { color: var(--text-dim); margin: 10px 0 26px; font-size: 16px; }

.setup { display: flex; gap: 18px; justify-content: center; margin-bottom: 24px; flex-wrap: wrap; }
.setup label, .row { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--text-dim); }

select, input[type="range"] {
  font-family: var(--font); font-size: 15px; color: var(--text);
  background: rgba(0,0,0,0.4); border: 1px solid var(--panel-border);
  border-radius: 8px; padding: 8px 12px; cursor: pointer;
}
input[type="range"] { padding: 0; width: 180px; accent-color: var(--magic); }
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--magic); cursor: pointer; }

.menu-buttons { display: flex; flex-direction: column; gap: 12px; margin: 8px auto 0; max-width: 340px; }
button {
  font-family: var(--font); font-size: 17px; font-weight: 600; color: var(--text);
  background: rgba(60,40,110,0.55); border: 1px solid var(--panel-border);
  border-radius: 10px; padding: 12px 20px; cursor: pointer; transition: all 0.12s;
}
button:hover { background: rgba(110,70,200,0.7); box-shadow: 0 0 18px var(--magic-glow); transform: translateY(-2px); }
button.primary {
  background: linear-gradient(135deg, var(--magic-glow), var(--magic));
  border-color: var(--magic); color: #fff;
}
button.primary:hover { box-shadow: 0 0 26px var(--magic); }

.controls-help { margin-top: 28px; text-align: left; }
.controls-help h3, .settings-grid h3 { color: var(--magic); margin-bottom: 12px; letter-spacing: 2px; }
.ctrl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; font-size: 14px; color: var(--text-dim); }
kbd {
  display: inline-block; background: rgba(0,0,0,0.5); border: 1px solid var(--panel-border);
  border-radius: 5px; padding: 2px 8px; margin-right: 6px; font-size: 12px; color: var(--text);
}

.settings-grid { text-align: left; margin-bottom: 20px; }
.settings-grid h3 { margin-top: 18px; }
.row { flex-direction: row; align-items: center; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.06); }
.row span { color: var(--text); }

#match-end h2 { font-size: 34px; margin-bottom: 20px; }
#end-scoreboard { display: flex; justify-content: center; margin-bottom: 18px; }
#end-countdown { color: var(--text-dim); margin-bottom: 18px; }
