/* ═══════════════════════════════════════════════════════════════════
   CRYPTS — Diablo-Style Dark Fantasy Theme
   Fonts: Cinzel (headings), MedievalSharp (flavor), monospace (UI)
   ═══════════════════════════════════════════════════════════════════ */

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

:root {
  --bg:         #0a0a0f;
  --bg2:        #0e0e16;
  --bg3:        #12121e;
  --bg-panel:   #0c0c14;
  --text:       #c4b99a;
  --text-dim:   #6a6452;
  --text-bright:#e8dcc0;
  --gold:       #c9a84c;
  --gold-dim:   #8a6e2c;
  --gold-bright:#f0d060;
  --blood:      #6e1a1a;
  --blood-h:    #8e2a2a;
  --accent:     #4a7a4a;
  --accent-h:   #5a9a5a;
  --border:     #2a2518;
  --border-gold:#4a3e28;
  --radius:     4px;
  --font-title: 'Cinzel', serif;
  --font-flavor:'MedievalSharp', cursive;
  --font-ui:    'Courier New', Courier, monospace;
}

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-user-select: none; user-select: none;
}
input, select, textarea { -webkit-user-select: text; user-select: text; }

/* ─── Ambient ─────────────────────────────────────────────────────── */
#ambient-particles {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse at 20% 80%, rgba(139,90,30,0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(100,40,40,0.04) 0%, transparent 50%);
}

/* ─── Screens ─────────────────────────────────────────────────────── */
.screen {
  position: fixed; inset: 0;
  display: none; align-items: center; justify-content: center;
  background: var(--bg); overflow-y: auto; z-index: 1;
}
.screen.active { display: flex; }

.screen-box {
  width: 100%; max-width: 460px;
  padding: 2rem 1.8rem;
  background:
    linear-gradient(180deg, rgba(14,14,22,0.98) 0%, rgba(10,10,15,0.99) 100%);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius);
  margin: 1rem;
  position: relative;
  box-shadow:
    0 0 60px rgba(0,0,0,0.6),
    inset 0 1px 0 rgba(201,168,76,0.08),
    inset 0 -1px 0 rgba(0,0,0,0.3);
}
.screen-box::before {
  content: '';
  position: absolute; top: -1px; left: 20%; right: 20%; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
}
.screen-box.wide { max-width: 640px; }

/* ─── NAME SCREEN ─────────────────────────────────────────────────── */
.logo-container { text-align: center; margin-bottom: 2rem; }
.logo-icon {
  font-size: 3rem; display: block; margin-bottom: 0.3rem;
  filter: drop-shadow(0 0 15px rgba(201,168,76,0.3));
  animation: iconGlow 3s ease-in-out infinite alternate;
}
@keyframes iconGlow {
  from { filter: drop-shadow(0 0 10px rgba(201,168,76,0.2)); }
  to   { filter: drop-shadow(0 0 25px rgba(201,168,76,0.5)); }
}

.logo-title {
  font-family: var(--font-title);
  font-size: 3.2rem; font-weight: 900;
  letter-spacing: 0.2em;
  color: var(--gold);
  text-shadow:
    0 0 40px rgba(201,168,76,0.3),
    0 2px 4px rgba(0,0,0,0.8),
    0 0 80px rgba(201,168,76,0.1);
  margin: 0;
}

.logo-divider {
  width: 120px; height: 1px; margin: 0.8rem auto;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
}

.logo-tagline {
  font-family: var(--font-flavor);
  font-size: 1rem; color: var(--text-dim);
  letter-spacing: 0.05em;
}

.name-form {
  display: flex; flex-direction: column; gap: 0.8rem;
}

.input-label {
  font-family: var(--font-title);
  font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.25em;
  color: var(--gold-dim);
  text-align: center;
}

.version-tag {
  text-align: center; margin-top: 1.5rem;
  font-size: 0.7rem; color: var(--text-dim);
  letter-spacing: 0.1em; opacity: 0.5;
}

/* ─── INPUTS ──────────────────────────────────────────────────────── */
input[type="text"] {
  width: 100%;
  background: rgba(10,10,16,0.8);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius);
  color: var(--text-bright);
  font-family: var(--font-ui);
  font-size: 1.05rem;
  padding: 0.75rem 1rem;
  outline: none;
  text-align: center;
  letter-spacing: 0.05em;
  transition: border-color 0.3s, box-shadow 0.3s;
}
input[type="text"]:focus {
  border-color: var(--gold);
  box-shadow: 0 0 15px rgba(201,168,76,0.15), inset 0 0 10px rgba(201,168,76,0.05);
}
input[type="text"]::placeholder { color: var(--text-dim); }

select {
  background: var(--bg3); border: 1px solid var(--border-gold);
  border-radius: var(--radius); color: var(--text);
  font-family: var(--font-ui); padding: 0.4rem 0.6rem; cursor: pointer;
}

/* ─── BUTTONS ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.65rem 1.4rem; border: none; border-radius: var(--radius);
  font-family: var(--font-title); font-size: 0.85rem; font-weight: 700;
  letter-spacing: 0.1em; cursor: pointer;
  transition: all 0.2s; text-transform: uppercase;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }

.btn-gold {
  background: linear-gradient(180deg, #5a4a2a 0%, #3a3018 100%);
  color: var(--gold-bright);
  border: 1px solid var(--gold-dim);
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3), inset 0 1px 0 rgba(201,168,76,0.15);
}
.btn-gold:hover {
  background: linear-gradient(180deg, #6a5a3a 0%, #4a4028 100%);
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(201,168,76,0.2), 0 4px 12px rgba(0,0,0,0.3);
}

.btn-stone {
  background: linear-gradient(180deg, #252530 0%, #1a1a24 100%);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.btn-stone:hover {
  background: linear-gradient(180deg, #30303e 0%, #222230 100%);
  border-color: var(--text-dim);
}

.btn-dark {
  background: rgba(20,20,30,0.7);
  color: var(--text-dim); border: 1px solid var(--border);
}
.btn-dark:hover { color: var(--text); border-color: var(--text-dim); }

.btn-blood {
  background: linear-gradient(180deg, var(--blood) 0%, #4a1010 100%);
  color: #cc8888; border: 1px solid #5a2020;
}
.btn-blood:hover {
  background: linear-gradient(180deg, var(--blood-h) 0%, #5a1818 100%);
  color: #ee9999;
}

.btn-lg { width: 100%; padding: 0.85rem; font-size: 0.95rem; }

.btn-icon { font-size: 1.1rem; }

.hidden { display: none !important; }

/* ─── SECTION TITLES ──────────────────────────────────────────────── */
.section-title {
  font-family: var(--font-title);
  font-size: 1.5rem; font-weight: 700;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(201,168,76,0.2);
  letter-spacing: 0.08em;
  margin: 0;
}
.section-subtitle {
  font-family: var(--font-flavor);
  font-size: 0.85rem; color: var(--text-dim);
  margin-top: 0.2rem;
}
.panel-title {
  font-family: var(--font-title);
  font-size: 0.75rem; font-weight: 700;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 0.6rem;
}

/* ─── LOBBY ───────────────────────────────────────────────────────── */
.lobby-header { margin-bottom: 1.2rem; }
.lobby-title-row {
  display: flex; align-items: center; justify-content: space-between;
}
.player-badge {
  background: rgba(201,168,76,0.1);
  border: 1px solid var(--border-gold);
  border-radius: 20px;
  padding: 0.2rem 0.8rem;
  font-size: 0.8rem; font-family: var(--font-title);
  color: var(--gold);
}

.lobby-actions {
  display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.2rem;
}
.lobby-actions .btn { flex: 1; min-width: 100px; }

.create-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius);
  padding: 1rem; margin-bottom: 1rem;
}
.create-panel input { margin-bottom: 0.7rem; text-align: left; }
.row { display: flex; gap: 0.7rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.7rem; }
.row label { display: flex; align-items: center; gap: 0.4rem; color: var(--text-dim); font-size: 0.9rem; }

.room-list-container {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.room-list-header {
  display: grid; grid-template-columns: 1fr 70px 70px 80px;
  padding: 0.4rem 0.6rem;
  font-family: var(--font-title);
  font-size: 0.65rem; font-weight: 700;
  letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--gold-dim);
  border-bottom: 1px solid var(--border);
}
.room-list { max-height: 280px; overflow-y: auto; }

.room-item {
  display: grid; grid-template-columns: 1fr 70px 70px 80px;
  align-items: center; padding: 0.55rem 0.6rem;
  border-bottom: 1px solid rgba(42,37,24,0.4);
  transition: background 0.15s;
}
.room-item:hover { background: rgba(201,168,76,0.03); }
.room-item .room-name { font-weight: bold; color: var(--text-bright); }
.room-item .room-mode { font-size: 0.8rem; color: var(--text-dim); }
.room-item .room-players { font-size: 0.8rem; color: var(--gold-dim); }
.room-item .room-state-playing { color: var(--blood-h); font-size: 0.8rem; }
.room-item .btn { padding: 0.25rem 0.5rem; font-size: 0.7rem; }

.empty-state {
  padding: 2rem 1rem; text-align: center;
  color: var(--text-dim); font-family: var(--font-flavor);
  font-size: 0.9rem;
}
.empty-icon { font-size: 1.8rem; margin-bottom: 0.5rem; opacity: 0.6; }

/* ─── ROOM SCREEN ─────────────────────────────────────────────────── */
.room-header { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 1rem; }
.mode-badge {
  background: rgba(201,168,76,0.1);
  border: 1px solid var(--border-gold);
  padding: 0.15rem 0.6rem; border-radius: 20px;
  font-family: var(--font-title); font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.1em; color: var(--gold);
}

.class-section { margin-bottom: 1.2rem; }
.class-selector {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.btn-class {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  padding: 0.5rem 0.3rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
  -webkit-tap-highlight-color: transparent;
}
.btn-class:hover { border-color: var(--gold-dim); color: var(--text); }
.btn-class.active {
  background: linear-gradient(180deg, #2a2418 0%, #1a1810 100%);
  border-color: var(--gold);
  color: var(--gold-bright);
  box-shadow: 0 0 15px rgba(201,168,76,0.15), inset 0 0 10px rgba(201,168,76,0.05);
}
.class-icon { font-size: 1.3rem; }
.class-name { font-size: 0.7rem; letter-spacing: 0.05em; }

.class-desc {
  font-size: 0.82rem; color: var(--text-dim);
  min-height: 1.4em; line-height: 1.4;
  padding: 0.3rem 0.5rem;
  background: rgba(10,10,15,0.5); border-radius: var(--radius);
}
.class-desc strong { color: var(--gold); }

.players-section { margin-bottom: 1rem; }
.player-list {
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-panel);
}
.player-list li {
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid rgba(42,37,24,0.3);
  display: flex; align-items: center; gap: 0.5rem;
  color: var(--text-bright);
}
.player-list li:last-child { border-bottom: none; }
.player-list .crown { color: var(--gold); }
.player-list .player-class { font-size: 0.8rem; color: var(--text-dim); margin-left: auto; }
.player-list .you-tag { font-size: 0.7rem; color: var(--gold-dim); }

.room-actions { display: flex; gap: 0.7rem; }
.room-actions .btn { flex: 1; }

.waiting-msg {
  margin-top: 0.8rem; font-size: 0.8rem;
  font-family: var(--font-flavor);
  color: var(--text-dim); text-align: center;
  min-height: 1.2em;
}

/* ─── GAME SCREEN ─────────────────────────────────────────────────── */
#screen-game { display: none; position: fixed; inset: 0; background: #06060a; overflow: hidden; }
#screen-game.active { display: block; }
#game-canvas { display: block; width: 100%; height: 100%; image-rendering: pixelated; }

/* Screen shake */
@keyframes shake {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-4px, 2px); }
  50%  { transform: translate(3px, -3px); }
  75%  { transform: translate(-2px, 3px); }
  100% { transform: translate(0, 0); }
}
.screen-shake { animation: shake 0.15s ease-in-out; }

/* HUD */
.hud { position: absolute; top: 10px; left: 10px; z-index: 10; pointer-events: none; user-select: none; }
#minimap { display: block; border: 1px solid var(--border-gold); border-radius: 3px; image-rendering: pixelated; box-shadow: 0 0 10px rgba(0,0,0,0.5); }
#hud-text {
  margin-top: 6px; font-size: 0.8rem; color: var(--text);
  text-shadow: 0 1px 4px #000; line-height: 1.5;
}
#hud-floor { color: var(--gold); font-family: var(--font-title); font-weight: 700; letter-spacing: 0.1em; font-size: 0.85rem; }
#hud-hp { color: #bb5555; }

/* D-Pad */
#dpad { position: fixed; bottom: 100px; right: 24px; z-index: 20; display: flex; flex-direction: column; align-items: center; gap: 2px; touch-action: manipulation; user-select: none; }
.dpad-row { display: flex; gap: 2px; }
.dpad-btn {
  width: 52px; height: 52px;
  background: rgba(12,12,20,0.9);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: 8px; color: var(--text-dim); font-size: 1.2rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent; transition: all 0.1s;
}
.dpad-btn:active, .dpad-btn.pressed {
  background: rgba(201,168,76,0.15);
  border-color: var(--gold-dim);
  color: var(--gold);
}
.dpad-btn:disabled { background: transparent; border-color: transparent; color: transparent; cursor: default; }
#dpad-center { pointer-events: none; opacity: 0; }
@media (min-width: 900px) and (pointer: fine) {
  #dpad { opacity: 0.3; }
  #dpad:hover { opacity: 1; }
}

/* Descend */
.descend-prompt {
  position: fixed; bottom: 130px; left: 50%; transform: translateX(-50%);
  background: rgba(10,10,15,0.95);
  border: 1px solid var(--gold-dim); border-radius: var(--radius);
  padding: 0.7rem 1.2rem; display: flex; align-items: center; gap: 0.8rem;
  z-index: 20; font-size: 0.85rem; white-space: nowrap;
  font-family: var(--font-flavor); color: var(--text);
  box-shadow: 0 0 20px rgba(201,168,76,0.1);
}

/* Floor overlay */
.floor-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.9); display: flex; align-items: center; justify-content: center; z-index: 50; }
.floor-text {
  font-family: var(--font-title); font-size: 2rem; font-weight: 700;
  color: var(--gold);
  text-shadow: 0 0 30px rgba(201,168,76,0.4);
  letter-spacing: 0.15em;
  animation: pulse 0.8s ease-in-out infinite alternate;
}
@keyframes pulse { from { opacity: 0.3; } to { opacity: 1; } }

/* ═══════════════════════════════════════════════════════════════════
   DIABLO-STYLE ACTION BAR
   ═══════════════════════════════════════════════════════════════════ */
.action-bar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; pointer-events: none; }
.action-bar-inner {
  display: flex; align-items: flex-end; justify-content: center;
  gap: 12px; padding: 8px 16px 12px;
  background: linear-gradient(to top,
    rgba(6,6,10,0.97) 0%,
    rgba(6,6,10,0.85) 60%,
    transparent 100%
  );
  pointer-events: auto;
}

/* Orbs */
.orb {
  width: 64px; height: 64px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #14121a 0%, #08080e 100%);
  border: 2px solid var(--border-gold);
  position: relative; overflow: hidden; flex-shrink: 0;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.8), 0 0 12px rgba(0,0,0,0.6);
}
.orb-fill { position: absolute; bottom: 0; left: 0; right: 0; transition: height 0.3s ease; }
.orb-hp .orb-fill { background: radial-gradient(ellipse at center, #44aa44 0%, #1a5a1a 100%); }
.orb-xp .orb-fill { background: radial-gradient(ellipse at center, #4466cc 0%, #1a2a5a 100%); }
.orb-text {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-title); font-size: 13px; font-weight: 700;
  color: #fff; text-shadow: 0 1px 4px #000, 0 0 8px rgba(0,0,0,0.9); z-index: 2;
}
.orb-label {
  position: absolute; bottom: -1px; left: 0; right: 0; text-align: center;
  font-family: var(--font-title); font-size: 8px; font-weight: 700;
  letter-spacing: 0.15em;
  color: rgba(201,168,76,0.5); text-shadow: 0 1px 3px #000; z-index: 2;
}

/* Action Buttons */
.action-buttons { display: flex; gap: 6px; align-items: flex-end; }
.action-btn {
  width: 56px; height: 56px;
  background: linear-gradient(180deg, #1a1820 0%, #0c0a12 100%);
  border: 2px solid var(--border-gold); border-radius: 6px; cursor: pointer;
  position: relative; display: flex; flex-direction: column;
  align-items: center; justify-content: center; transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 2px 10px rgba(0,0,0,0.5), inset 0 1px 0 rgba(201,168,76,0.06);
}
.action-btn:hover {
  border-color: var(--gold);
  background: linear-gradient(180deg, #24202a 0%, #141218 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0,0,0,0.5), 0 0 20px rgba(201,168,76,0.1);
}
.action-btn:active, .action-btn.action-pressed {
  transform: scale(0.9); border-color: var(--gold-bright);
  box-shadow: 0 0 20px rgba(201,168,76,0.3), inset 0 0 12px rgba(201,168,76,0.1);
}
.action-btn.on-cooldown { border-color: #8a2222; box-shadow: 0 0 12px rgba(138,34,34,0.3); }
.action-icon { font-size: 22px; line-height: 1; filter: drop-shadow(0 1px 3px rgba(0,0,0,0.7)); }
.action-key {
  position: absolute; bottom: 2px; right: 4px;
  font-family: var(--font-title); font-size: 8px; font-weight: 700;
  color: var(--text-dim);
}
.cooldown-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.5); border-radius: 4px; pointer-events: none; opacity: 0; transition: opacity 0.1s; }
.potion-count { position: absolute; top: 2px; right: 4px; font-size: 11px; font-weight: bold; color: var(--gold); text-shadow: 0 1px 3px #000; }
.potion-count.empty { color: #cc4444; }

/* Stats bar */
.stats-bar {
  display: flex; justify-content: center; gap: 16px; padding: 2px 0 6px;
  font-family: var(--font-title); font-size: 10px; font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-dim); text-shadow: 0 1px 3px #000;
  pointer-events: auto; background: rgba(6,6,10,0.95);
}
#stat-level { color: var(--gold); }

/* Level Up */
.level-up-popup {
  position: fixed; top: 22%; left: 50%; transform: translateX(-50%);
  z-index: 60; text-align: center; pointer-events: none;
  animation: levelUpFade 3s ease-out forwards;
}
.level-up-popup.hidden { display: none !important; }
.level-up-text {
  font-family: var(--font-title); font-size: 36px; font-weight: 900;
  color: var(--gold-bright);
  text-shadow: 0 0 30px rgba(240,208,96,0.6), 0 0 60px rgba(240,208,96,0.2), 0 2px 4px rgba(0,0,0,0.8);
  letter-spacing: 0.2em;
}
.level-up-detail { font-family: var(--font-flavor); font-size: 20px; color: var(--gold); margin-top: 4px; }
@keyframes levelUpFade {
  0%   { opacity: 0; transform: translateX(-50%) translateY(15px) scale(0.7); }
  12%  { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.15); }
  25%  { transform: translateX(-50%) translateY(0) scale(1); }
  75%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-40px); }
}

/* ─── Scrollbars ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-gold); border-radius: 3px; }

/* ─── Mobile ──────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .screen-box { padding: 1.2rem 1rem; margin: 0.5rem; }
  .logo-title { font-size: 2.4rem; }
  .logo-tagline { font-size: 0.85rem; }
  .room-list-header, .room-item { grid-template-columns: 1fr 55px 55px 65px; font-size: 0.75rem; }
  .dpad-btn { width: 52px; height: 52px; font-size: 1.3rem; }
  .orb { width: 50px; height: 50px; }
  .orb-text { font-size: 12px; }
  .action-btn { width: 48px; height: 48px; }
  .action-icon { font-size: 18px; }
  #dpad { bottom: 90px; }
  .class-selector { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 360px) {
  .action-bar-inner { gap: 6px; padding: 6px 8px 8px; }
  .orb { width: 44px; height: 44px; }
  .action-btn { width: 44px; height: 44px; }
  .logo-title { font-size: 2rem; }
}

/* ═══════════════════════════════════════════════════════════════════
   DEATH SCREEN
   ═══════════════════════════════════════════════════════════════════ */
.death-screen {
  position: fixed; inset: 0; z-index: 100;
  background: radial-gradient(ellipse at center, rgba(20,5,5,0.95) 0%, rgba(0,0,0,0.98) 100%);
  display: flex; align-items: center; justify-content: center;
  animation: deathFadeIn 0.6s ease-out;
}
.death-screen.hidden { display: none !important; }
@keyframes deathFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.death-content { text-align: center; max-width: 400px; padding: 2rem; }
.death-skull {
  font-size: 5rem; margin-bottom: 0.5rem;
  animation: skullPulse 1.5s ease-in-out infinite alternate;
}
@keyframes skullPulse {
  from { filter: drop-shadow(0 0 10px rgba(200,40,40,0.3)); transform: scale(1); }
  to   { filter: drop-shadow(0 0 30px rgba(200,40,40,0.6)); transform: scale(1.05); }
}
.death-title {
  font-family: var(--font-title); font-size: 3rem; font-weight: 900;
  color: #8a2222; letter-spacing: 0.2em;
  text-shadow: 0 0 40px rgba(138,34,34,0.5), 0 2px 4px rgba(0,0,0,0.8);
  margin-bottom: 0.5rem;
}
.death-divider {
  width: 120px; height: 1px; margin: 0.8rem auto;
  background: linear-gradient(90deg, transparent, #5a2020, transparent);
}
.death-stats {
  font-family: var(--font-ui); font-size: 0.9rem; color: var(--text-dim);
  line-height: 1.8;
}
.death-stats .lb-title {
  margin-top: 0.8rem; font-family: var(--font-title); font-size: 0.8rem;
  color: var(--gold); letter-spacing: 0.1em;
}
.death-stats .lb-entry {
  font-size: 0.8rem; color: var(--text-dim);
}
.death-flavor {
  font-family: var(--font-flavor); font-size: 0.9rem;
  color: #5a3030; margin-top: 1rem; font-style: italic;
}

/* ═══════════════════════════════════════════════════════════════════
   GOLD POPUP
   ═══════════════════════════════════════════════════════════════════ */
.gold-popup {
  position: fixed; top: 35%; left: 50%; transform: translateX(-50%);
  z-index: 55; pointer-events: none;
  font-family: var(--font-title); font-size: 22px; font-weight: 700;
  color: #ffd700;
  text-shadow: 0 0 15px rgba(255,215,0,0.4), 0 2px 4px rgba(0,0,0,0.8);
}
.gold-popup.hidden { display: none !important; }
@keyframes goldFloat {
  0%   { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-40px); }
}

/* ═══════════════════════════════════════════════════════════════════
   INVENTORY PANEL
   ═══════════════════════════════════════════════════════════════════ */
.inventory-panel {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 70; width: 340px; max-height: 80vh; overflow-y: auto;
  background: linear-gradient(180deg, rgba(14,14,22,0.98) 0%, rgba(10,10,15,0.99) 100%);
  border: 1px solid var(--border-gold); border-radius: var(--radius);
  padding: 1rem;
  box-shadow: 0 0 60px rgba(0,0,0,0.8), 0 0 30px rgba(201,168,76,0.05);
}
.inventory-panel.hidden { display: none !important; }
.inv-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.8rem;
}
.inv-header h3 {
  font-family: var(--font-title); font-size: 0.85rem; font-weight: 700;
  color: var(--gold); letter-spacing: 0.1em; margin: 0;
}
.inv-close {
  background: none; border: 1px solid var(--border); color: var(--text-dim);
  width: 28px; height: 28px; border-radius: 4px; cursor: pointer;
  font-size: 14px; display: flex; align-items: center; justify-content: center;
}
.inv-close:hover { border-color: var(--gold-dim); color: var(--text); }
.inv-divider {
  height: 1px; margin: 0.6rem 0;
  background: linear-gradient(90deg, transparent, var(--border-gold), transparent);
}

.eq-slot {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.35rem 0.5rem; margin-bottom: 2px;
  background: rgba(10,10,16,0.5); border-radius: 3px;
  border-left: 2px solid transparent;
  font-size: 0.82rem;
}
.eq-slot .eq-icon { font-size: 1rem; width: 24px; text-align: center; }
.eq-slot .eq-name { color: var(--text-dim); flex: 1; }
.eq-slot .eq-stats { font-size: 0.7rem; color: var(--accent); }
.eq-slot.rarity-common  { border-left-color: #888888; }
.eq-slot.rarity-common .eq-name { color: #aaaaaa; }
.eq-slot.rarity-uncommon { border-left-color: #44aa44; }
.eq-slot.rarity-uncommon .eq-name { color: #44cc44; }
.eq-slot.rarity-rare { border-left-color: #aa44ff; }
.eq-slot.rarity-rare .eq-name { color: #cc66ff; }

.inv-item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.3rem 0.5rem; margin-bottom: 2px;
  background: rgba(10,10,16,0.5); border-radius: 3px;
  border-left: 2px solid transparent; font-size: 0.82rem;
}
.inv-item.rarity-common { border-left-color: #888888; }
.inv-item.rarity-uncommon { border-left-color: #44aa44; }
.inv-item.rarity-rare { border-left-color: #aa44ff; }
.inv-item span:first-child { flex: 1; color: var(--text); }
.inv-item-stats { font-size: 0.7rem; color: var(--text-dim); }
.btn-equip {
  background: var(--bg3); border: 1px solid var(--border-gold); border-radius: 3px;
  color: var(--gold); font-family: var(--font-title); font-size: 0.65rem;
  padding: 2px 8px; cursor: pointer; letter-spacing: 0.05em;
}
.btn-equip:hover { border-color: var(--gold); }
.inv-empty {
  padding: 1rem; text-align: center; color: var(--text-dim);
  font-family: var(--font-flavor); font-size: 0.85rem;
}

/* ═══════════════════════════════════════════════════════════════════
   ITEM NOTIFICATION (toast)
   ═══════════════════════════════════════════════════════════════════ */
.item-notification {
  position: fixed; top: 80px; left: 50%; transform: translateX(-50%);
  z-index: 65; padding: 0.4rem 1rem; border-radius: 4px;
  font-family: var(--font-title); font-size: 0.8rem; font-weight: 700;
  letter-spacing: 0.05em;
  background: rgba(10,10,16,0.95); border: 1px solid var(--border-gold);
  box-shadow: 0 0 20px rgba(0,0,0,0.5);
  animation: itemNotifFade 3s ease-out forwards;
  pointer-events: none;
}
.item-notification.rarity-common  { color: #aaaaaa; border-color: #555; }
.item-notification.rarity-uncommon { color: #44cc44; border-color: #2a6a2a; }
.item-notification.rarity-rare { color: #cc66ff; border-color: #6a2a8a; }
@keyframes itemNotifFade {
  0%   { opacity: 0; transform: translateX(-50%) translateY(10px); }
  10%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* ─── Leaderboard Panel ─────────────────────────────────────────── */
.leaderboard-panel {
  margin-top: 0.8rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.8rem;
  max-height: 400px;
  overflow-y: auto;
}
.lb-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
}
.lb-panel-header .panel-title { margin: 0; }
.btn-sm { padding: 0.2rem 0.5rem; font-size: 0.75rem; }
.lb-body { font-size: 0.82rem; }
.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.lb-table th {
  color: var(--gold);
  text-align: left;
  padding: 0.3rem 0.4rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.lb-table td {
  padding: 0.25rem 0.4rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.lb-table tr:hover td {
  background: rgba(255,200,50,0.05);
}
.lb-top td {
  color: var(--gold);
  font-weight: 600;
}

/* ─── Item notification toast ───────────────────────────────────── */
.item-notification {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  background: rgba(20,20,30,0.9);
  border: 1px solid var(--border);
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  color: #fff;
  z-index: 1100;
  animation: itemToastIn 0.3s ease-out, itemToastOut 0.5s ease-in 2.5s forwards;
  pointer-events: none;
}
.item-notification.rarity-uncommon { border-color: #44cc44; color: #66ee66; }
.item-notification.rarity-rare { border-color: #cc66ff; color: #dd88ff; }

@keyframes itemToastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-15px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes itemToastOut {
  from { opacity: 1; }
  to   { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}
