/* Player stats top-left */
#player-hud {
  position: absolute;
  /* Bezpośrednio pod radarem (10px + 112px + 8px odstępu) — bez pustej luki. */
  top: 130px;
  right: 10px;
  min-width: 254px;
  width: 254px;
  box-sizing: border-box;
  height: auto;
  max-height: none;
  max-height: calc(100vh - 142px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--ui-scroll-thumb) var(--ui-scroll-track);
}

.hud-title {
  font-size: 12px;
  flex-wrap: wrap;
  font-weight: 700;
  color: #e0e6ed;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.lvl-badge {
  font-size: 10px;
  font-weight: 500;
  color: #8fb8d8;
  background: var(--ui-insert);
  padding: 1px 5px;
  border-radius: 0;
  border: 1px solid #2d3748;
}

/* SŁAWA (Fame) — główny wyznacznik prestiżu, wyeksponowany w nagłówku. */
.fame-badge {
  font-size: 10px;
  font-weight: 700;
  color: #ffe066; /* FAME — żółty (jaśniejsze złoto) */
  background: var(--ui-insert);
  padding: 1px 6px;
  border-radius: 0;
  border: 1px solid #3a4454;
  letter-spacing: 1px;
  white-space: nowrap;
}

/* Dyskretny badge poziomu (POZ) osadzony wewnątrz paska EXP. */
.exp-level-badge {
  position: absolute;
  right: 3px;
  top: 1px;
  font-size: 10px;
  line-height: 10px;
  padding: 0 4px;
  background: rgba(17, 21, 28, 0.78);
  border-color: #2d3748;
  z-index: 2;
}

.bar-container {
  background: #15181f;
  height: 12px;
  border-radius: 0;
  border: 1px solid #2d3748;
  overflow: hidden;
  margin-bottom: 4px;
  position: relative;
}

/* Stonowane, jednolite paski HP / MP / EXP (bez jaskrawych gradientów) */
.hp-bar-fill {
  background: #d3213c; /* Rubin (brandbook) — LIFE wyraźnie czerwone */
  height: 100%;
  width: 100%;
  transition: width 0.08s ease-out;
}

.mp-bar-fill {
  background: #2a6fe0; /* MANA — żywszy, wyraźny błękit */
  height: 100%;
  width: 100%;
  transition: width 0.08s ease-out;
}

.exp-bar-fill {
  background: #3fa34d; /* EXP — trawiasta zieleń */
  height: 100%;
  width: 0%;
  transition: width 0.15s ease-out;
}

/* Poziom MAX (20): EXP zamrożone — pasek pełni rolę paska postępu Sławy
   (klasa „fame-mode" nadawana w updateHUD) i jest żółty 1:1 z badge FAME. */
.exp-bar-fill.fame-mode {
  background: #ffe066;
}

.bar-text.fame-mode {
  color: #ffe066;
}

.bar-text {
  position: absolute;
  width: 100%;
  top: 0;
  left: 0;
  font-size: 10px;
  line-height: 12px;
  text-align: center;
  font-weight: 500;
  color: #e0e6ed;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  letter-spacing: 1px;
}

/* Panel statystyk — domyślnie zwinięty; rozwija się po najechaniu na belkę
   [ 📊 STATYSTYKI ] lub nagłówek HUD. */
.stats-panel {
  position: relative;
}

.stats-toggle {
  font-size: 10px;
  font-weight: 700;
  color: var(--ui-text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 2px 0;
  cursor: help;
  user-select: none;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 8px;
  font-size: 10px;
  color: #a9b1d6;
  background: rgba(20, 22, 29, 0.6);
  border-radius: 0;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  margin: 0;
  padding: 0 5px;
  transition: all 0.2s ease;
}

.stats-panel:hover .stats-grid,
.hud-title:hover ~ .stats-panel .stats-grid {
  max-height: 500px;
  opacity: 1;
  margin-bottom: 4px;
  padding: 3px 5px;
}

.stat-badge {
  display: flex;
  justify-content: space-between;
}

.stat-badge span:first-child {
  color: #8fa3bf;
  font-weight: 700;
}

.stat-badge.maxed span:first-child {
  color: #d8c27a;
}

.stat-badge.maxed span:last-child {
  color: #d8c27a !important;
  font-weight: 700;
  text-shadow: none;
}

/* === KOMPAKTOWY PANEL: ukryj WIS / VIT oraz dublujące się LIFE / MANA. ===
   Pełna lista 8 statystyk z limitami klasowymi dostępna po najechaniu
   myszą na nagłówek "CZARODZIEJ [0/8 MAX]". */
/* LIFE / MANA są redundantne z paskami HP / MP — zostają ukryte. */
#badge-life,
#badge-mana {
  display: none;
}

/* Nagłówek z licznikiem [X/8 MAX] — kursor podpowiada interaktywność. */
.hud-title {
  cursor: help;
}
/* Controls helper top-right */
#controls-panel {
  bottom: 20px;
  left: 20px;
  font-size: 10px;
  color: var(--ui-text-muted);
  line-height: 1.6;
}

#controls-panel kbd {
  background: var(--ui-insert);
  border: 1px solid #3a4454;
  border-radius: 0;
  padding: 1px 5px;
  color: #9aa5b4; /* jasne etykiety klawiszy na ciemnym insert-cie */
  font-family: inherit;
}

#zone-badge {
  /* Nazwa lokacji — pixel-art font nagłówkowy. */
  font-family: 'Press Start 2P', monospace !important;
  font-weight: 400;
  font-size: 12px;
  letter-spacing: 1px;
  color: #8fb8d8;
  display: inline-block;
  margin-bottom: 4px;
}

/* Stonowanie wbudowanego złotego koloru z index.html (licznik lochów) */
#completed-dungeons-badge {
  color: #d8c27a !important;
  font-weight: 700;
}

/* Stonowanie wbudowanych stylów przycisku RESET z index.html */
#reset-character-btn {
  background: #241c20 !important;
  border: 1px solid #5a3a3e !important;
  color: #cf9a9a !important;
  border-radius: 0 !important;
}

#reset-character-btn:hover {
  background: #33262b !important;
  color: #e0e6ed !important;
}

/* Boss HP Bar at Top */
#boss-hud {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 450px;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease-out;
  pointer-events: none;
  z-index: 60;
}

.boss-title {
  /* Nazwa bossa — pixel-art font nagłówkowy. */
  font-family: 'Press Start 2P', monospace !important;
  text-align: center;
  font-weight: 400;
  font-size: 12px;
  color: #c98a4b;
  letter-spacing: 1px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
  margin-bottom: 6px;
}

.boss-bar-wrap {
  background: #15181f;
  border: 1px solid #3a4454;
  height: 20px;
  border-radius: 0;
  box-shadow: none;
  position: relative;
  overflow: hidden;
}

.boss-bar-fill {
  background: #a8552f;
  height: 100%;
  width: 100%;
  transition: width 0.1s ease-out;
}

.boss-bar-text {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  text-align: center;
  line-height: 20px;
  font-size: 10px;
  font-weight: 500;
  color: #e0e6ed;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}

/* Floating combat text layer */
#damage-text-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

/* Pływające liczby — Press Start 2P (pixel-art), stonowane kolory, wyłącznie ciemny cień
   dla czytelności na tle sceny 3D (bez neonowych poświat). */
.floating-damage {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 12px;
  font-weight: 700;
  color: #d3213c; /* Obrażenia zadawane — ten sam czerwień co pasek HP */
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.95);
  white-space: nowrap;
  pointer-events: none;
  will-change: transform, opacity;
}

.floating-damage.player-hurt {
  color: #d3213c; /* Ten sam czerwień co obrażenia/HP */
  font-size: 14px;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.95);
}

.floating-damage.crit {
  font-size: 14px;
  color: #e8d48b;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.95);
}

.floating-damage.exp {
  font-size: 12px;
  color: #3fa34d; /* EXP — zieleń (jak pasek EXP) */
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.95);
}

/* Współdzielone EXP z zabójstw botów — fioletowy akcent. */
.floating-damage.exp-shared {
  font-size: 12px;
  color: #b57fe0;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.95);
}

/* SŁAWA (Fame) z zabójstw — żółty (1:1 z badge FAME w HUD). */
.floating-damage.fame {
  font-size: 12px;
  color: #ffe066;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.95);
}

/* Wypicie mikstury — kolory 1:1 z paskami HUD (HP czerwony / MP niebieski). */
.floating-damage.potion-hp {
  font-size: 14px;
  color: #d3213c;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.95);
}

.floating-damage.potion-mp {
  font-size: 14px;
  color: #2a6fe0;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.95);
}

.floating-damage.heal {
  font-size: 14px;
  color: #d3213c; /* Każde przywrócenie HP — czerwień 1:1 z paskiem HP */
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.95);
}

.floating-damage.stat-boost {
  font-size: 14px;
  color: #d8c27a;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.95);
}

.floating-damage.levelup {
  font-size: 16px;
  letter-spacing: 1px;
  font-weight: 900;
  color: #d8c27a;
  text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.95);
}

/* Portal Interaction Prompt */
#portal-prompt {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(18, 20, 26, 0.95); /* unoszony nad sceną 3D — ciemne celowo (Faza 7.5) */
  border: 1px solid #3a4454;
  color: #e0e6ed;
  padding: 10px 22px;
  border-radius: 0;
  /* "[E] ENTER THE REALM" — pixel-art font nagłówkowy. */
  font-family: 'Press Start 2P', monospace !important;
  font-size: 12px;
  font-weight: 400;
  display: none;
  pointer-events: none;
  box-shadow: none;
  text-shadow: none;
  animation: pulsePortal 1.2s infinite alternate;
}

@keyframes pulsePortal {
  from { transform: translateX(-50%) scale(1.0); }
  to { transform: translateX(-50%) scale(1.06); }
}

/* Death Screen Overlay (Graveyard / Permadeath) */
#death-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 7, 16, 0.94);
  backdrop-filter: blur(8px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 200;
  pointer-events: auto;
}

#death-screen-content {
  background: rgba(18, 20, 26, 0.96);
  border: 1px solid #5a3a3e;
  border-radius: 0;
  padding: 28px 36px;
  min-width: 380px;
  max-width: 440px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7);
  animation: deathModalAppear 0.5s ease-out;
}

@keyframes deathModalAppear {
  0% {
    transform: scale(0.6);
    opacity: 0;
  }
  100% {
    transform: scale(1.0);
    opacity: 1;
  }
}

.death-title {
  font-size: 16px;
  font-weight: 900;
  color: #c0524e;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-shadow: none;
  margin-bottom: 18px;
}

.death-stats {
  background: rgba(20, 22, 29, 0.8);
  border: 1px solid #2d3748;
  border-radius: 0;
  padding: 12px 16px;
  margin-bottom: 14px;
  text-align: left;
}

.death-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  font-size: 10px;
  border-bottom: 1px solid rgba(45, 55, 72, 0.5);
}

.death-stat-row:last-child {
  border-bottom: none;
}

.death-stat-label {
  color: #9aa5b4; /* jasna etykieta na ciemnej wstawce .death-stats (Faza 7.5) */
  font-weight: 500;
  letter-spacing: 1px;
}

.death-stat-value {
  color: #e0e6ed;
  font-weight: 700;
  font-size: 10px;
}

.death-fame {
  color: #d8c27a !important;
  text-shadow: none;
  font-size: 10px;
}

.death-total-fame {
  color: #8fb8d8 !important;
  text-shadow: none;
  font-size: 10px;
}

.death-info {
  font-size: 10px;
  color: var(--ui-text-muted);
  font-style: italic;
  line-height: 1.5;
  margin-bottom: 16px;
  padding: 8px 12px;
  background: rgba(90, 58, 62, 0.15);
  border: 1px solid rgba(90, 58, 62, 0.4);
  border-radius: 0;
}

#death-screen button {
  background: #2a3548;
  border: 1px solid #4a6fa5;
  color: #e0e6ed;
  font-family: inherit;
  font-weight: 700;
  font-size: 12px;
  padding: 12px 28px;
  border-radius: 0;
  cursor: pointer;
  box-shadow: none;
  transition: background 0.2s;
  text-transform: uppercase;
  letter-spacing: 1px;
}

#death-screen button:hover {
  background: #33405a;
  box-shadow: none;
}


/* Hurt Screen Flash */
#hurt-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  box-shadow: inset 0 0 50px rgba(255, 0, 0, 0);
  pointer-events: none;
  transition: box-shadow 0.08s ease-out;
}

/* === WINIETA NISKIEGO POZIOMU ZDROWIA (Low HP Alert, HP <= 25%) ===
   Pulsujący czerwony cień na krawędziach ekranu — nakładany, gdy gracza
   trzeba natychmiast ostrzec (ucieczka klawiszem Nexusa / potka). */
.low-hp-vignette {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(180, 20, 20, 0.55) 100%);
  opacity: 0;
  transition: opacity 0.2s ease-out;
}

.low-hp-vignette.active {
  animation: lowHpVignettePulse 1.1s ease-in-out infinite;
}

@keyframes lowHpVignettePulse {
  0%, 100% { opacity: 0.2; }
  50%      { opacity: 0.6; }
}

/* Custom Crosshair on floor */
/* Celownik: subtelny, jasny (bez złotego glowa); okrągły kształt
   jest celowo zachowany — to wskaźnik celowania, nie panel UI. */
#cursor-reticle {
  position: absolute;
  width: 24px;
  height: 24px;
  margin-left: -12px;
  margin-top: -12px;
  border: 2px solid rgba(224, 230, 237, 0.75);
  border-radius: 50%;
  pointer-events: none;
  box-shadow: none;
  display: none;
}

#cursor-reticle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 4px;
  margin-top: -2px;
  margin-left: -2px;
  background: #e0e6ed;
  border-radius: 50%;
}

/* ===== MINIMAPA (RADAR) — góra-prawa ===== */
#minimap-container {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 10;
  width: 112px;
  height: 112px;
  border: 1px solid #2d3748;
  border-radius: 0;
  background: rgba(18, 20, 26, 0.95);
  box-shadow: none;
  overflow: hidden;
  /* KRYTYCZNE: #ui-container ma pointer-events:none, więc bez tego radar
     nie dostaje hovera ani wheel — scroll-zoom nie działał. */
  pointer-events: auto;
}
#minimap-container:hover {
  border-color: #d8c27a;
  cursor: zoom-in;
}
#minimap-container.minimap-hover #minimap-label {
  color: #d8c27a;
}
#minimap-canvas {
  display: block;
  width: 112px;
  height: 112px;
}
#minimap-label {
  position: absolute;
  top: 4px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 9px;
  font-weight: 500;
  color: #9aa5b4; /* etykieta NA ciemnym canvasie radaru — zostaje jasna (Faza 7.5) */
  text-transform: uppercase;
  letter-spacing: 1px;
  pointer-events: none;
}

/* ===== DŹWIĘK — ikona głośnika obok radaru: wycisza CAŁE audio (SFX + muzyka) ===== */
#bgm-toggle {
  position: absolute;
  top: 10px;
  right: 132px;
  z-index: 20;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: rgba(18, 20, 26, 0.95);
  border: 1px solid #2d3748;
  border-radius: 0;
  color: var(--ui-text-muted);
  cursor: pointer;
  pointer-events: auto;
  box-shadow: none;
}

#bgm-toggle:hover {
  background: var(--ui-btn-hover);
  color: #e0e6ed;
}

#bgm-toggle .bgm-icon {
  display: block;
  pointer-events: none;
}

#bgm-toggle .bgm-icon-muted {
  display: none;
}

#bgm-toggle.muted {
  color: #6f7a8a;
}

#bgm-toggle.muted .bgm-icon-unmuted {
  display: none;
}

#bgm-toggle.muted .bgm-icon-muted {
  display: block;
}

/* ==========================================================================
   QUEST WIDGET (CEL) — niezależny, przypięty w lewym górnym rogu ekranu
   ========================================================================== */
#quest-widget {
  position: fixed;
  top: 16px;
  left: 16px;
  right: auto;
  width: auto;
  min-width: 0;
  max-width: none;
  margin: 0;
  padding: 8px 12px;
  z-index: 100;
  background: rgba(17, 24, 39, 0.85);
  border: 1px solid #374151;
  border-radius: 4px;
  box-shadow: none;
  pointer-events: none;
  display: none;
}

.quest-header {
  font-size: 10px;
  font-weight: 700;
  color: #d8c27a;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 3px;
  text-shadow: none;
}

.quest-target {
  font-size: 10px;
  color: #e0e0e0;
  margin-bottom: 2px;
  line-height: 1.3;
}

#quest-target-name {
  font-weight: 700;
  color: #c98a4b;
  text-shadow: none;
}

/* Separator dystansu — czytelne oddzielenie nazwy celu od odległości. */
#quest-target-name::after {
  content: ' • ';
  color: #a8b2c0;
  font-weight: 500;
}

.quest-dist {
  font-size: 10px;
  color: #a8b2c0;
  font-weight: 700;
}

.quest-arrow-wrap {
  text-align: center;
  height: 20px;
  overflow: visible;
}

/* Wektorowa strzałka nawigacyjna (SVG) — obraca się wokół własnego środka. */
.quest-arrow {
  display: inline-block;
  vertical-align: middle;
  transform-origin: 50% 50%;
  transition: transform 0.1s linear;
}

/* ==========================================================================
   GŁÓWNY EVENT KRAINY — licznik bossów (Władcy Krainy -> super loch)
   ========================================================================== */
#realm-event-widget {
  position: fixed;
  top: 120px;
  left: 16px;
  z-index: 90;
  width: 176px;
  background: rgba(17, 24, 39, 0.85);
  border: 1px solid #4c3a8f;
  border-radius: 4px;
  padding: 8px 12px;
  pointer-events: none;
  display: none;
}

.realm-event-title {
  font-size: 10px;
  font-weight: 700;
  color: #c9b6f0;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 3px;
}

.realm-event-count {
  font-size: 10px;
  font-weight: 900;
  color: #d8c27a;
  margin-bottom: 4px;
}

.realm-event-bar {
  height: 5px;
  background: #15181f;
  border-radius: 2px;
  overflow: hidden;
}

.realm-event-fill {
  height: 100%;
  background: linear-gradient(90deg, #6d28d9, #8b7cf6);
}

/* Pulsująca złota kropka na minimapie dla Mini-Bossa */
@keyframes questDotPulse {
  0%   { opacity: 0.4; transform: scale(0.8); }
  50%  { opacity: 1.0; transform: scale(1.3); }
  100% { opacity: 0.4; transform: scale(0.8); }
}

/* ===== DAWNE BANERY CENTRALNE (.target-eliminated, .realm-event-notification,
   .enrage-warning, .dungeon-cleared) — usunięte. Komunikaty trafiają teraz do
   loga #message-log w lewym dolnym rogu (kolor = kategoria wpisu). ===== */

/* ===== PRZYCISK POWROTU DO MENU (LOGOUT) — obok wyciszenia muzyki ===== */
#logout-btn {
  position: absolute;
  top: 10px;
  right: 170px;
  z-index: 20;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: rgba(18, 20, 26, 0.95);
  border: 1px solid #2d3748;
  border-radius: 0;
  color: var(--ui-text-muted);
  cursor: pointer;
  pointer-events: auto;
  box-shadow: none;
}

#logout-btn:hover {
  background: var(--ui-btn-hover);
  color: #e0e6ed;
}

#logout-btn svg {
  display: block;
  pointer-events: none;
}

/* Koło zębate w stanie „otwarte" (panel rozwinięty) — subtelne podświetlenie. */
#logout-btn.active {
  background: var(--ui-btn-hover);
  color: #e0e6ed;
  border-color: #4a5568;
}

/* ===== PANEL USTAWIEŃ (⚙️) — rozwijany pod kołem zębatym =====
   Trzy pozycje: Dźwięk ON/OFF, Zmień postać, Wyloguj. Ostre kąty i antracyt
   spójne z resztą HUD; własne tło, żeby panel był czytelny nad mapą. */
#settings-menu {
  position: absolute;
  top: 46px;
  right: 170px;
  z-index: 30;
  display: none;
  flex-direction: column;
  min-width: 178px;
  padding: 4px;
  box-sizing: border-box;
  background: rgba(18, 20, 26, 0.97);
  border: 1px solid #2d3748;
  border-radius: 0;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6);
  pointer-events: auto;
}

#settings-menu.open {
  display: flex;
}

.settings-item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 7px 9px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0;
  color: var(--ui-text-muted);
  font-family: inherit;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-align: left;
  text-transform: uppercase;
  cursor: pointer;
}

.settings-item + .settings-item {
  margin-top: 2px;
}

.settings-item:hover {
  background: var(--ui-btn-hover);
  color: #e0e6ed;
}

/* Dźwięk wyłączony — przygaszona czerwień (spójna z istniejącym przełącznikiem). */
.settings-item-off {
  color: #cf9a9a;
}

/* Wylogowanie — akcja destrukcyjna, wyróżniona w palecie „RESET CHARACTER". */
.settings-item-danger {
  color: #cf9a9a;
}

.settings-item-danger:hover {
  background: #241c20;
  border-color: #5a3a3e;
  color: #e8b4b4;
}

/* Suwak głośności muzyki w panelu ustawień ⚙️ (nie jest przyciskiem pozycji,
   więc ma własny blok; klik/drag w suwak NIE zamyka panelu — patrz Hud.js). */
.settings-volume {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 2px;
  padding: 6px 9px 8px;
}

.settings-volume-label {
  font-family: inherit;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ui-text-muted);
}

.settings-volume-label #settings-music-vol-value {
  color: #8fb8d8;
}

#settings-music-volume {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  margin: 2px 0;
  background: #2d3748;
  border: none;
  border-radius: 0;
  outline: none;
  cursor: pointer;
}

#settings-music-volume::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 10px;
  height: 14px;
  background: #9aa5b4;
  border: 1px solid #2d3748;
  border-radius: 0;
  cursor: pointer;
}

#settings-music-volume::-moz-range-thumb {
  width: 10px;
  height: 14px;
  background: #9aa5b4;
  border: 1px solid #2d3748;
  border-radius: 0;
  cursor: pointer;
}

/* ===== OKNO CREDITS (Autorzy / Podziękowania) — otwierane z panelu ⚙️ =====
   Wymóg licencji CC-BY 3.0 dla assetów audio. Ciemne tło + pikselowa ramka
   w stylu gry (ostre kąty, antracyt). Zamknięcie: [ CLOSE / X ], klik poza
   oknem lub Escape — patrz src/ui/Hud.js. */
#credits-modal {
  position: fixed;
  inset: 0;
  z-index: 240;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.62);
  /* #ui-container ma pointer-events:none — bez tego przycisk byłby nieklikalny. */
  pointer-events: auto;
}

#credits-modal.open {
  display: flex;
}

/* Pikselowa ramka: podwójne obramowanie (krawędź + ciemna obwódka + cień). */
.credits-panel {
  position: relative;
  width: 360px;
  max-width: calc(100vw - 32px);
  padding: 16px 16px 14px;
  box-sizing: border-box;
  background: #12141a;
  border: 2px solid #3a4454;
  box-shadow: 0 0 0 2px #12141a, 0 0 0 4px #2d3748, 0 10px 28px rgba(0, 0, 0, 0.7);
  image-rendering: pixelated;
}

.credits-title {
  font-family: 'Press Start 2P', monospace !important;
  font-size: 11px;
  line-height: 1.6;
  color: #d8c27a;
  text-transform: uppercase;
  letter-spacing: 0;
  text-align: center;
  margin: 0 0 14px;
}

.credits-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.credits-section-head {
  font-size: 8px;
  font-weight: 700;
  color: #9aa5b4;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 3px;
}

.credits-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.credits-list li {
  font-size: 9px;
  line-height: 1.5;
  color: #cfc7dd;
  letter-spacing: 0.5px;
}

.credits-close {
  display: block;
  margin: 14px auto 0;
  padding: 6px 14px;
  background: var(--ui-btn);
  border: 1px solid #2d3748;
  border-radius: 0;
  color: var(--ui-text-muted);
  font-family: inherit;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
}

.credits-close:hover {
  background: var(--ui-btn-hover);
  border-color: #3a4454;
  color: #e0e6ed;
}

/* ==========================================================================
   ZLECENIA DNIA (Contracts) — widget celów dobrowolnych, lewy górny róg.
   Zgodny z estetyką HUD: ciemne tło, brak scrollbarów, kompaktowy.
   ========================================================================== */
#contracts-widget {
  position: absolute;
  top: 220px;
  left: 12px;
  z-index: 55;
  width: 208px;
  max-height: calc(100vh - 240px);
  overflow-y: auto;
  background: rgba(18, 20, 26, 0.92);
  border: 1px solid #2d3748;
  border-radius: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  padding: 6px 8px;
  pointer-events: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--ui-scroll-thumb) var(--ui-scroll-track);
}

#contracts-widget .party-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--ui-text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding-bottom: 4px;
  margin-bottom: 4px;
  border-bottom: 1px solid #2d3748;
}

/* Nagłówek akordeonu — klikalny pasek zwijający/rozwijający listę zleceń. */
#contracts-widget .contracts-header {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

#contracts-widget .contracts-header:hover .contracts-title-text {
  color: #e0e6ed;
}

#contracts-widget .contracts-title-text {
  flex: 1 1 auto;
}

/* Licznik aktywnych zleceń (widoczny także po zwinięciu). */
#contracts-widget .contracts-count-badge {
  font-size: 9px;
  font-weight: 700;
  color: #101318;
  background: #d8c27a;
  border: 1px solid #e7d9a6;
  line-height: 13px;
  padding: 0 5px;
}

#contracts-widget .contracts-chevron {
  font-size: 10px;
  color: var(--ui-text-muted);
}

/* Zwinięty: lista zleceń ukryta, nagłówek bez dolnej krawędzi/odstępu. */
#contracts-widget.collapsed .contracts-header {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

#contracts-widget.collapsed .contracts-body {
  display: none;
}

#contracts-widget .contract-card {
  padding: 5px 4px;
  border-bottom: 1px solid #232a37;
}

#contracts-widget .contract-card:last-child {
  border-bottom: none;
}

#contracts-widget .contract-name {
  font-size: 10px;
  font-weight: 700;
  color: #e0e6ed;
}

#contracts-widget .contract-desc {
  font-size: 10px;
  color: var(--ui-text-muted);
  margin: 1px 0 4px;
  line-height: 1.25;
}

#contracts-widget .contract-bar {
  height: 5px;
  background: #15181f;
  border: 1px solid #2d3748;
  border-radius: 0;
  overflow: hidden;
}

#contracts-widget .contract-fill {
  height: 100%;
  background: #d8c27a;
  transition: width 0.2s ease-out;
}

#contracts-widget .contract-foot {
  margin-top: 3px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

#contracts-widget .contract-count {
  font-size: 10px;
  color: #a8b2c0;
  font-weight: 700;
}

#contracts-widget .contract-claimed {
  font-size: 10px;
  color: #7fae95;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

#contracts-widget .contract-claim {
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  color: #171a22;
  background: #d8c27a;
  border: 1px solid #e7d9a6;
  border-radius: 0;
  padding: 3px 8px;
  cursor: pointer;
}

#contracts-widget .contract-claim:hover {
  background: #e7d9a6;
}

/* ==========================================================================
   MUTACJE LOCHU (Dungeon Modifiers) — widget ryzyko/nagroda w lochu.
   ========================================================================== */
#mutations-widget {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 55;
  width: 208px;
  background: rgba(18, 20, 26, 0.92);
  border: 1px solid #2d3748;
  border-radius: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  padding: 6px 8px;
  pointer-events: none;
  display: none;
}

#mutations-widget .party-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--ui-text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding-bottom: 4px;
  margin-bottom: 4px;
  border-bottom: 1px solid #2d3748;
}

#mutations-widget .mutation-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: #e0e6ed;
  padding: 2px 0;
}

#mutations-widget .mutation-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}

#mutations-widget .mutation-bonus {
  margin-top: 5px;
  padding-top: 4px;
  border-top: 1px solid #2d3748;
  font-size: 10px;
  color: #7fae95;
  font-weight: 700;
}

/* Komunikat ukończenia / odbioru zlecenia → wpis success w #message-log. */

/* ==========================================================================
   LEWA KOLUMNA HUD — jeden pionowy stos widgetów (bez nakładania się).
   Kolejność: ZADANIE -> DRUŻYNA -> WŁADCY KRAINY -> ZLECENIA DNIA.
   Widgety mają zmienną wysokość (liczba botów / zleceń), więc flexbox
   dopasowuje pozycje automatycznie — żaden panel nie zasłania drugiego.
   ========================================================================== */
#left-hud-stack {
  position: fixed;
  top: 16px;
  left: 12px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: 224px;
  pointer-events: none;
}

/* Widgety w stosie rezygnują z własnego pozycjonowania — układ steruje flex. */
#left-hud-stack > * {
  position: static !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  left: auto !important;
  margin: 0 !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
  box-sizing: border-box;
  flex: 0 0 auto;
}

/* Panele interaktywne (przyciski zleceń) muszą łapać mysz. */
#left-hud-stack #contracts-widget {
  pointer-events: auto;
}

/* ==========================================================================
   LOG KOMUNIKATÓW (#message-log) — lewy dolny róg, zamiast banerów centralnych.
   Wpisy kolorowane kategoriami (event / warn / success / info), max 6 widocznych
   (bez scrollbarów), fade-out po ~8 s. Stos #left-bottom-stack trzyma log NAD
   #controls-panel (widocznym wyłącznie w Bazie) — wzorem #left-hud-stack.
   ========================================================================== */
#left-bottom-stack {
  position: fixed;
  left: 12px;
  bottom: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: 300px;
  pointer-events: none;
}

/* Dzieci stosu rezygnują z własnego pozycjonowania — układ steruje flex. */
#left-bottom-stack > * {
  position: static !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  left: auto !important;
  margin: 0 !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
  box-sizing: border-box;
  flex: 0 0 auto;
}

/* Panel sterowania w stosie musi łapać mysz (przyciski dźwięku / resetu). */
#left-bottom-stack #controls-panel {
  pointer-events: auto;
}

/* Tutorial (panel sterowania) jest przyciskiem X domykany — panel ustanawia
   kontekst pozycjonowania (nadpisuje „static" ze stosu), aby X trafił w jego
   prawy górny róg, a nie w róg całego stosu. */
#controls-panel {
  position: relative !important;
}

#tutorial-close-btn {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 16px;
  height: 16px;
  line-height: 14px;
  padding: 0;
  font-family: inherit;
  font-size: 9px;
  font-weight: 700;
  color: #9aa5b4;
  background: var(--ui-insert);
  border: 1px solid #3a4454;
  border-radius: 0;
  cursor: pointer;
  text-align: center;
}

#tutorial-close-btn:hover {
  color: #e8b4b4;
  background: #241c20;
  border-color: #5a3a3e;
}

#message-log {
  display: flex;
  flex-direction: column;
  gap: 3px;
  pointer-events: none;
}

.log-entry {
  font-size: 10px;
  line-height: 1.35;
  font-weight: 700;
  color: #e0e6ed;
  background: rgba(18, 20, 26, 0.82);
  border-left: 3px solid #8fa3bf;
  padding: 4px 8px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  overflow-wrap: break-word;
  white-space: normal;
  animation: logFadeOut 8s ease-out forwards;
}

/* Kategorie wpisów — kolory dziedziczą dawne banery centralne. */
.log-entry.log-info {
  border-left-color: #8fa3bf;
  color: #e0e6ed;
}

.log-entry.log-warn {
  border-left-color: #d06a6a;
  color: #d06a6a;
}

.log-entry.log-event {
  border-left-color: #d8c27a;
  color: #d8c27a;
}

.log-entry.log-success {
  border-left-color: #7fae95;
  color: #7fae95;
}

/* Licznik deduplikacji (×N) — dyskretny, przy prawej krawędzi wpisu. */
.log-entry .log-count {
  margin-left: 6px;
  color: #9aa5b4;
  font-size: 10px;
  font-weight: 700;
}

@keyframes logFadeOut {
  0%   { opacity: 0; }
  3%   { opacity: 1; }
  87%  { opacity: 1; }
  100% { opacity: 0; }
}

#player-class-name, #player-maxed-badge { font-family: 'Press Start 2P', monospace !important; }

/* ==========================================================================
   NEARBY PLAYERS (#nearby-panel) — lewy dolny róg, w stosie
   #left-bottom-stack (kolejność: LOG -> NEARBY PLAYERS -> CZAT -> PANEL
   STEROWANIA; montaż: src/ui/NearbyPlayersPanel.js). Lista postaci w zasięgu:
   mini ikonka klasy + nick + odległość; najechanie na wiersz otwiera
   mini-podgląd (poziom, [X/8 MAX], 4 sloty ekwipunku). Dyskretny w spoczynku
   (wzorem .chat-panel), pełna czytelność po najechaniu. Bez scrollbarów.
   ========================================================================== */
.nearby-panel {
  pointer-events: auto; /* #left-bottom-stack ma pointer-events: none */
  border: 1px solid var(--ui-edge);
  background: rgba(18, 20, 26, 0.55);
  padding: 4px 6px 6px;
  font-family: inherit;
  opacity: 0.45;
  transition: opacity 0.15s ease, border-color 0.15s ease;
  -webkit-font-smoothing: none;
  font-smooth: never;
  text-rendering: crispEdges;
}

.nearby-panel:hover {
  opacity: 1;
  border-color: #4a6fa5;
  background: rgba(18, 20, 26, 0.95);
  box-shadow: 0 0 12px rgba(74, 111, 165, 0.35);
}

.nearby-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 8px;
  font-weight: 700;
  color: #d8c27a;
  text-transform: uppercase;
  letter-spacing: 0px;
  margin-bottom: 3px;
}

.nearby-count {
  color: var(--ui-text-muted);
}

.nearby-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nearby-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 4px;
  border-left: 3px solid transparent;
  cursor: default;
}

.nearby-row:hover {
  background: rgba(74, 111, 165, 0.22);
  border-left-color: #4a6fa5;
}

.nearby-thumb {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  image-rendering: pixelated;
  background: var(--ui-slot);
  border: 1px solid #2c2f36;
}

.nearby-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 9px;
  font-weight: 700;
  color: #e0e6ed;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nearby-dist {
  flex: 0 0 auto;
  font-size: 8px;
  color: var(--ui-text-dim);
}

/* ===== TITLE BADGE — tytuł konta (GM/CONTRIBUTOR) w RAMCE przy nicku =====
   Wspólny komponent HUD (NEARBY, podgląd hover) + CZAT (css/chat.css używa
   tej samej klasy). Renderowany przed nickiem („[GM] Nick") — 1:1 z canvasową
   etykietą 3D (src/engine/NameLabel.js): ciemne tło + gruba ramka w kolorze
   tytułu + czarny obrys. Warianty kolorów (shared/playerTitles.js):
   --gm = złoto, --contributor = szmaragd. */
.title-badge {
  display: inline-block;
  flex: 0 0 auto;
  padding: 1px 4px;
  margin-right: 4px;
  font-size: 7px;
  font-weight: 700;
  letter-spacing: 1px;
  line-height: 1.3;
  background: #0b1026;
  border: 2px solid #fbbf24;
  color: #f5d98a;
  box-shadow: 0 0 0 1px #000;
  vertical-align: middle;
  user-select: none;
}

.title-badge--gm {
  border-color: #fbbf24;
  color: #f5d98a;
}

.title-badge--contributor {
  border-color: #48bb78;
  color: #9ae6b4;
}

/* --- MINI-PODGLĄD (hover) — po PRAWEJ stronie panelu, position: fixed z
   clampingiem viewportu (pozycjonowanie: NearbyPlayersPanel._positionPreview).
   Element jest DZIECKIEM panelu, więc hover na podglądzie nie gasi listy. --- */
.nearby-preview {
  position: fixed;
  display: none;
  z-index: 1002;
  min-width: 214px;
  max-width: 252px;
  background: var(--ui-panel);
  border: 1px solid var(--ui-edge);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  padding: 8px 10px;
  pointer-events: none;
  -webkit-font-smoothing: none;
  font-smooth: never;
  text-rendering: crispEdges;
}

.nearby-preview.open {
  display: block;
}

.nearby-pv-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding-bottom: 4px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--ui-edge);
}

.nearby-pv-name {
  font-size: 11px;
  font-weight: 700;
  color: #e0e6ed;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nearby-pv-class {
  flex: 0 0 auto;
  font-size: 8px;
  font-weight: 700;
  color: #8fb8d8;
  text-transform: uppercase;
}

.nearby-pv-meta {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 9px;
  margin-bottom: 6px;
}

.nearby-pv-lvl {
  font-weight: 700;
  color: #cbd5e1;
}

.nearby-pv-maxed {
  font-size: 8px;
  font-weight: 700;
  color: var(--ui-text-muted);
}

.nearby-pv-maxed.full {
  color: #d8c27a;
}

.nearby-pv-gear {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nearby-pv-gearhead {
  font-size: 8px;
  font-weight: 700;
  color: var(--ui-text-muted);
  text-transform: uppercase;
}

.nearby-pv-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nearby-pv-slot {
  position: relative;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--ui-slot);
  border: 1px solid #2c2f36;
}

.nearby-pv-slot.empty {
  background: var(--ui-slot-empty);
  border-color: #23262e;
}

.nearby-pv-slot img {
  width: 18px;
  height: 18px;
  image-rendering: pixelated;
  object-fit: contain;
}

.nearby-pv-tier {
  position: absolute;
  right: -3px;
  bottom: -3px;
  font-size: 7px;
  font-style: normal;
  font-weight: 700;
  background: rgba(12, 13, 17, 0.85);
  padding: 0 2px;
  line-height: 1.2;
}

.nearby-pv-slotlabel {
  width: 46px;
  flex: 0 0 auto;
  font-size: 8px;
  color: var(--ui-text-muted);
  text-transform: uppercase;
}

.nearby-pv-item {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 9px;
  color: #cbd5e1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nearby-pv-item.dim {
  color: var(--ui-text-dim);
}

.nearby-pv-hint {
  font-size: 8px;
  font-style: italic;
  color: var(--ui-text-dim);
}

/* ===== PANEL MOB ARENY (prawa kolumna, pod minimapą) — src/ui/ArenaPanel.js ===== */
#arena-panel {
  position: absolute;
  top: 130px; /* pod minimapą (112px + margines) */
  right: 10px;
  z-index: 10;
  width: 112px;
  background: rgba(18, 20, 26, 0.95);
  border: 1px solid #2d3748;
  padding: 5px 6px;
  font-size: 8px;
  color: var(--ui-text, #aab4c4);
  pointer-events: none;
  box-sizing: border-box;
}
#arena-panel .arena-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #2d3748;
  padding-bottom: 3px;
  margin-bottom: 3px;
}
#arena-panel .arena-panel-title {
  color: #a78bfa;
  font-weight: 700;
  letter-spacing: 0.5px;
}
#arena-panel .arena-panel-phase {
  color: #d8c27a;
  font-size: 7px;
}
#arena-panel .arena-panel-row {
  display: flex;
  justify-content: space-between;
  line-height: 1.6;
}
#arena-panel .arena-panel-row span:last-child {
  color: #ffffff;
  font-weight: 600;
}
#arena-panel .arena-panel-mult {
  justify-content: center;
  color: var(--ui-text-dim, #6f7a8a);
}
#arena-panel.arena-panel-victory {
  border-color: #4ade80;
}
#arena-panel.arena-panel-victory .arena-panel-phase {
  color: #4ade80;
}
#arena-panel.arena-panel-defeat {
  border-color: #ef4444;
}
#arena-panel.arena-panel-defeat .arena-panel-phase {
  color: #ef4444;
}

