/* ==============================================================================
   D&D 5E BESTIARY & COMBAT TRACKER - THEME & STYLES
   TTG Club Theme (5e14.ttg.club Design System)
   Dark Slate & Parchment Book Editions
   ============================================================================== */

:root {
  /* TTG Club Dark Theme (5e14.ttg.club) + Blackwall Translucency */
  --bg-main: #0c1116;
  --bg-card: rgba(23, 32, 38, 0.88);
  --bg-card-hover: rgba(31, 43, 51, 0.92);
  --bg-surface: rgba(26, 33, 39, 0.82);
  --bg-sub-menu: rgba(29, 40, 47, 0.88);
  --bg-input: rgba(14, 20, 24, 0.92);
  --bg-gradient: linear-gradient(135deg, rgba(28, 39, 46, 0.9), rgba(19, 26, 32, 0.9));
  --bg-secondary-gradient: linear-gradient(135deg, rgba(34, 44, 51, 0.9), rgba(23, 32, 38, 0.9));
  --border-color: rgba(255, 255, 255, 0.09);
  --border-hover: #3567c9;
  --border-accent: #3567c9;
  --border-gold: #c99a45;
  --border-gradient: #1c386b;
  --text-main: #ffffff;
  --text-color: #c3d1da;
  --text-muted: #7d8f9c;
  --text-gold: #ffd700;
  --text-crimson: #ff5252;
  
  /* TTG Club Brand Accents */
  --primary: #3567c9;
  --primary-hover: #325cab;
  --primary-active: #2552a5;
  --primary-disabled: #2552a5ab;
  --primary-select: rgba(53, 103, 201, 0.25);
  
  --accent-red: #d36363;
  --accent-red-hover: #e04848;
  --accent-gold: #c99a45;
  --accent-gold-hover: #e5b967;
  --accent-green: #3dd13d;
  --accent-green-hover: #48e648;
  --accent-blue: #3567c9;
  
  --card-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  --statblock-bg: rgba(23, 32, 38, 0.92);
  --statblock-border: #3567c9;
  --statblock-bar: rgba(29, 40, 47, 0.85);
  --radius: 8px;
  
  /* TTG Club Fonts */
  --font-serif: 'Lora', Georgia, 'Times New Roman', serif;
  --font-sans: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
}

[data-theme="parchment"], [data-theme="light"] {
  /* TTG Club Light / Parchment Theme (5e14.ttg.club) */
  --bg-main: #f9f6f1;
  --bg-card: rgba(255, 255, 255, 0.92);
  --bg-card-hover: rgba(243, 241, 219, 0.95);
  --bg-surface: rgba(243, 241, 219, 0.85);
  --bg-sub-menu: rgba(235, 229, 208, 0.9);
  --bg-input: rgba(255, 255, 255, 0.95);
  --bg-gradient: linear-gradient(135deg, #f5f2cf, #f3f1db);
  --bg-secondary-gradient: linear-gradient(135deg, #f5f2cf, #f3f1db);
  --border-color: rgba(0, 0, 0, 0.12);
  --border-hover: #2a57b2;
  --border-accent: #2a57b2;
  --border-gold: #a87320;
  --border-gradient: #b5c7e8;
  --text-main: #1f1c19;
  --text-color: #3c3834;
  --text-muted: #6b635b;
  --text-gold: #966718;
  --text-crimson: #a82424;
  
  --primary: #2a57b2;
  --primary-hover: #204591;
  --primary-active: #173673;
  --primary-disabled: #2a57b2ab;
  --primary-select: rgba(42, 87, 178, 0.2);
  
  --accent-red: #c93030;
  --accent-red-hover: #a82424;
  --accent-gold: #b3822d;
  --accent-gold-hover: #cf9838;
  --accent-green: #0cb70c;
  --accent-green-hover: #0a990a;
  --accent-blue: #2a57b2;
  
  --card-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  --statblock-bg: rgba(255, 253, 250, 0.94);
  --statblock-border: #2a57b2;
  --statblock-bar: rgba(237, 231, 211, 0.88);
}

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

/* TTG Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}
[data-theme="parchment"] ::-webkit-scrollbar-thumb,
[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
}

/* ==============================================================================
   BLACKWALL / MATRIX DIGITAL RAIN BACKDROP (CYBERPUNK 2077 & MATRIX)
   ============================================================================== */
.blackwall-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
  background-color: var(--bg-main);
}

#blackwall-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.55;
  filter: blur(1.5px); /* Softly blurred / defocused as requested */
  transition: opacity 0.4s ease;
}

[data-theme="parchment"] #blackwall-canvas,
[data-theme="light"] #blackwall-canvas {
  opacity: 0.16;
  filter: blur(2px);
}

.blackwall-blur-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backdrop-filter: blur(2.5px);
  -webkit-backdrop-filter: blur(2.5px);
  background: radial-gradient(circle at 50% 50%, rgba(12, 17, 22, 0.22) 0%, rgba(8, 11, 14, 0.78) 100%);
  pointer-events: none;
}

[data-theme="parchment"] .blackwall-blur-overlay,
[data-theme="light"] .blackwall-blur-overlay {
  background: radial-gradient(circle at 50% 50%, rgba(249, 246, 241, 0.12) 0%, rgba(235, 229, 208, 0.72) 100%);
}

.blackwall-vignette {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  box-shadow: inset 0 0 160px rgba(0, 0, 0, 0.85);
  pointer-events: none;
}

[data-theme="parchment"] .blackwall-vignette,
[data-theme="light"] .blackwall-vignette {
  box-shadow: inset 0 0 120px rgba(120, 100, 70, 0.25);
}

#blackwall-words-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  /* Completely sharp and crisp - NO blur */
  opacity: 0.95;
  transition: opacity 0.4s ease;
}

[data-theme="parchment"] #blackwall-words-canvas,
[data-theme="light"] #blackwall-words-canvas {
  opacity: 0.85;
}

body {
  font-family: var(--font-sans);
  background-color: transparent;
  color: var(--text-color);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==============================================================================
   HEADER & NAVBAR (TTG CLUB STYLE)
   ============================================================================== */
.app-header {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.35);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  max-width: 1560px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ttg-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2552a5 0%, #3567c9 100%);
  color: #ffffff;
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.95rem;
  padding: 4px 10px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(53, 103, 201, 0.4);
  letter-spacing: -0.5px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  user-select: none;
}

.logo-text h1 {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: 0.5px;
  margin: 0;
}

.logo-text span {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: block;
}

.nav-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-surface);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.nav-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.18s ease;
}

.nav-tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab-btn.active {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 2px 10px rgba(53, 103, 201, 0.4);
}

.badge-combat-active {
  background: #ff3333;
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 10px;
  font-family: var(--font-mono);
  font-weight: bold;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-icon {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-color);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
  border-color: var(--border-hover);
}

/* ==============================================================================
   LAYOUT & CONTAINER
   ============================================================================== */
.main-content {
  flex: 1;
  max-width: 1560px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Common Buttons (TTG Club Style) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.82rem;
  border-radius: 6px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 2px 10px rgba(53, 103, 201, 0.4);
  transform: translateY(-1px);
}

.btn-primary:active {
  background: var(--primary-active);
  transform: translateY(0);
}

.btn-gold {
  background: linear-gradient(135deg, #a86c14, #d49024);
  color: #fff;
  border-color: #f0ad4e;
  font-weight: 700;
}

.btn-gold:hover {
  background: linear-gradient(135deg, #b87717, #e59d2a);
  box-shadow: 0 2px 10px rgba(212, 144, 36, 0.35);
  transform: translateY(-1px);
}

.btn-green {
  background: #1f6b2f;
  color: #fff;
  border-color: #28a745;
}

.btn-green:hover {
  background: #28a745;
  box-shadow: 0 2px 10px rgba(40, 167, 69, 0.35);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-color);
  border: 1px solid var(--border-color);
}

[data-theme="parchment"] .btn-secondary,
[data-theme="light"] .btn-secondary {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

[data-theme="parchment"] .btn-secondary:hover,
[data-theme="light"] .btn-secondary:hover {
  background: rgba(0, 0, 0, 0.08);
  color: var(--primary);
}

.btn-danger {
  background: #8a1d1d;
  color: #fff;
  border-color: #ab2424;
}

.btn-danger:hover {
  background: #a82424;
  box-shadow: 0 2px 10px rgba(168, 36, 36, 0.35);
  transform: translateY(-1px);
}

/* Form Controls (TTG Club Inputs) */
input[type="text"],
input[type="number"],
input[type="search"],
select,
textarea {
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 12px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  outline: none;
  transition: all 0.18s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-select);
}

/* ==============================================================================
   TAB 1: BESTIARY LAYOUT
   ============================================================================== */
.bestiary-controls {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--card-shadow);
}

.search-filters-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.search-box-wrapper {
  flex: 2;
  min-width: 250px;
  position: relative;
}

.search-box-wrapper input {
  width: 100%;
  padding-left: 36px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-group label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}

.bestiary-actions-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

.bestiary-grid {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 1024px) {
  .bestiary-grid {
    grid-template-columns: 1fr;
  }
}

/* Monsters List Column */
.monsters-list-column {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 14px;
  max-height: calc(100vh - 240px);
  overflow-y: auto;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.monster-item-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  transition: all 0.16s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.monster-item-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  transform: translateX(3px);
}

.monster-item-card.active {
  border-left: 4px solid var(--primary);
  background: rgba(53, 103, 201, 0.12);
  border-color: var(--primary);
  box-shadow: 0 2px 12px rgba(53, 103, 201, 0.2);
}

.monster-item-info h4 {
  font-family: var(--font-sans);
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 3px;
}

.monster-item-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
  align-items: center;
}

.badge-cr {
  background: rgba(53, 103, 201, 0.15);
  color: #88aef9;
  border: 1px solid rgba(53, 103, 201, 0.4);
  padding: 1px 7px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-weight: bold;
}

[data-theme="parchment"] .badge-cr,
[data-theme="light"] .badge-cr {
  background: rgba(42, 87, 178, 0.1);
  color: #2a57b2;
  border-color: rgba(42, 87, 178, 0.3);
}

.badge-horde {
  background: rgba(254, 94, 0, 0.15);
  color: #ff9d5c;
  border: 1px solid rgba(254, 94, 0, 0.4);
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: bold;
}

/* ==============================================================================
   D&D 5E STATBLOCK DISPLAY (TTG CLUB STYLE)
   ============================================================================== */
.statblock-container {
  background: var(--statblock-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: var(--card-shadow);
  padding: 24px;
  position: relative;
}

.statblock-header {
  border-bottom: 2px solid var(--primary);
  padding-bottom: 12px;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.statblock-title-group h2 {
  font-family: var(--font-serif);
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: 0.3px;
  margin: 0;
}

.statblock-subtitle {
  font-style: italic;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.statblock-top-stats {
  background: var(--statblock-bar);
  padding: 10px 14px;
  border-radius: 8px;
  display: flex;
  justify-content: space-around;
  text-align: center;
  margin-bottom: 14px;
  border: 1px solid var(--border-color);
}

.top-stat-item .label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
}

.top-stat-item .val {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-gold);
  font-family: var(--font-mono);
}

/* Abilities Grid */
.statblock-abilities {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  text-align: center;
  margin-bottom: 16px;
  padding: 10px 0;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

.ability-cell {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 4px;
  cursor: pointer;
  transition: all 0.16s ease;
}

.ability-cell:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.ability-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.ability-score {
  font-size: 1.1rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-main);
}

.ability-mod {
  font-size: 0.88rem;
  color: #88aef9;
  font-family: var(--font-mono);
  font-weight: 700;
}

[data-theme="parchment"] .ability-mod,
[data-theme="light"] .ability-mod {
  color: var(--primary);
}

/* Details list (Saves, Skills, Immunities, Senses) */
.statblock-details-list {
  font-size: 0.88rem;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-row b {
  color: var(--primary);
}

[data-theme="parchment"] .detail-row b,
[data-theme="light"] .detail-row b {
  color: var(--primary);
}

.clickable-roll {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(53, 103, 201, 0.18);
  color: #88aef9;
  padding: 2px 8px;
  border-radius: 5px;
  border: 1px solid rgba(53, 103, 201, 0.4);
  cursor: pointer;
  font-family: var(--font-mono);
  font-weight: 700;
  margin: 0 3px;
  transition: all 0.15s ease;
}

[data-theme="parchment"] .clickable-roll,
[data-theme="light"] .clickable-roll {
  background: rgba(42, 87, 178, 0.12);
  color: #2a57b2;
  border-color: rgba(42, 87, 178, 0.35);
}

.clickable-roll:hover {
  background: var(--primary);
  color: #ffffff;
  border-color: #5587e8;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(53, 103, 201, 0.45);
}

/* Interactive Spell Chips */
.clickable-spell {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(155, 89, 182, 0.16);
  color: #d2a4f4;
  padding: 1px 7px;
  border-radius: 5px;
  border: 1px solid rgba(155, 89, 182, 0.45);
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  margin: 1px 3px;
  transition: all 0.18s ease;
  text-decoration: none;
}

[data-theme="parchment"] .clickable-spell,
[data-theme="light"] .clickable-spell {
  background: rgba(125, 45, 155, 0.12);
  color: #7b1fa2;
  border-color: rgba(125, 45, 155, 0.35);
}

.clickable-spell:hover {
  background: #9b59b6;
  color: #ffffff;
  border-color: #be84db;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(155, 89, 182, 0.45);
}

.clickable-spell::before {
  content: "✨";
  font-size: 0.82em;
  opacity: 0.85;
}

/* Spell Modal Styling */
.spell-modal-dialog {
  max-width: 660px;
  border-top: 3px solid #9b59b6;
}

.spell-modal-header {
  border-bottom: 1px solid rgba(155, 89, 182, 0.25);
  padding: 14px 18px;
}

.spell-modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.spell-modal-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: rgba(155, 89, 182, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  border: 1px solid rgba(155, 89, 182, 0.4);
}

.spell-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.spell-meta-cell {
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

[data-theme="parchment"] .spell-meta-cell,
[data-theme="light"] .spell-meta-cell {
  background: rgba(0, 0, 0, 0.025);
}

.spell-meta-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.spell-meta-cell strong {
  font-size: 0.86rem;
  color: var(--text-main);
  line-height: 1.3;
}

.spell-desc-box {
  background: rgba(0, 0, 0, 0.15);
  padding: 14px;
  border-radius: 6px;
  border-left: 3px solid #9b59b6;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-color);
  max-height: 380px;
  overflow-y: auto;
}

[data-theme="parchment"] .spell-desc-box,
[data-theme="light"] .spell-desc-box {
  background: rgba(0, 0, 0, 0.03);
}

.spell-search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  margin-top: 4px;
}

.spell-search-item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.88rem;
  transition: background 0.15s;
}

.spell-search-item:hover {
  background: rgba(155, 89, 182, 0.2);
}

/* Section divider */
.statblock-divider {
  display: flex;
  align-items: center;
  margin: 18px 0 10px 0;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 4px;
}

.statblock-divider h3 {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Trait & Action items */
.statblock-item {
  font-size: 0.88rem;
  margin-bottom: 14px;
  line-height: 1.6;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
  padding: 8px 12px;
  border-left: 3px solid rgba(53, 103, 201, 0.4);
}

[data-theme="parchment"] .statblock-item,
[data-theme="light"] .statblock-item {
  background: rgba(0, 0, 0, 0.02);
  border-left-color: rgba(42, 87, 178, 0.4);
}

.statblock-item-title {
  margin-bottom: 6px;
}

.statblock-item-title strong {
  color: var(--text-main);
  font-family: var(--font-serif);
  font-size: 0.98rem;
  font-weight: 700;
  display: block;
}

.statblock-item-body {
  color: var(--text-color);
  font-size: 0.88rem;
  line-height: 1.6;
}

/* Explicit Block Columns for Multi-line Traits & Blessings */
.statblock-desc-lines {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}

.statblock-desc-line {
  display: block;
  line-height: 1.5;
  color: var(--text-color);
}

.statblock-desc-line.is-list-item {
  padding: 4px 10px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.035);
  border-left: 2px solid rgba(53, 103, 201, 0.35);
  transition: all 0.15s ease;
}

[data-theme="parchment"] .statblock-desc-line.is-list-item,
[data-theme="light"] .statblock-desc-line.is-list-item {
  background: rgba(0, 0, 0, 0.03);
  border-left-color: rgba(42, 87, 178, 0.35);
}

.statblock-desc-line.is-list-item:hover {
  background: rgba(53, 103, 201, 0.12);
  border-left-color: var(--primary);
  transform: translateX(3px);
}

.action-roll-bar {
  margin-top: 6px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ==============================================================================
   SPECIAL HORDE WIDGET
   ============================================================================== */
.horde-widget-panel {
  background: linear-gradient(135deg, rgba(82, 19, 19, 0.4) 0%, rgba(35, 12, 38, 0.5) 100%);
  border: 2px solid #9e2a2b;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: 0 4px 14px rgba(120, 28, 28, 0.25);
}

.horde-widget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.horde-widget-header h3 {
  font-family: var(--font-serif);
  color: #ff8585;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.horde-count-slider-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.horde-count-slider-row input[type="range"] {
  flex: 1;
  accent-color: #e04848;
  height: 8px;
  cursor: pointer;
}

.horde-count-badge {
  font-size: 1.25rem;
  font-weight: bold;
  font-family: var(--font-mono);
  color: #ffdb6e;
  background: rgba(0, 0, 0, 0.4);
  padding: 4px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-gold);
  min-width: 90px;
  text-align: center;
}

.horde-dynamic-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.horde-stat-box {
  background: rgba(0, 0, 0, 0.35);
  padding: 8px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
}

.horde-stat-box .h-title {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.horde-stat-box .h-val {
  font-size: 1.1rem;
  font-weight: bold;
  color: #ffb74d;
  font-family: var(--font-mono);
}

.horde-quick-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ==============================================================================
   TAB 2: COMBAT TRACKER
   ============================================================================== */
.combat-top-toolbar {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  box-shadow: var(--card-shadow);
}

.combat-round-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.round-pill {
  background: var(--primary);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 20px;
  box-shadow: 0 2px 10px rgba(53, 103, 201, 0.4);
}

.turn-pill {
  font-size: 0.95rem;
  color: var(--text-gold);
  font-weight: 600;
}

.combat-controls-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.combatants-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Combatant Card */
.combatant-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 14px 18px;
  box-shadow: var(--card-shadow);
  transition: all 0.2s ease;
  position: relative;
}

.combatant-card.active-turn {
  border: 2px solid var(--primary);
  box-shadow: 0 0 16px rgba(53, 103, 201, 0.45);
  background: rgba(53, 103, 201, 0.08);
}

.combatant-card.dead {
  opacity: 0.55;
  filter: grayscale(0.8);
}

.combatant-main-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
}

.combatant-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 240px;
}

.init-badge-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: 1px solid var(--primary);
  border-radius: 8px;
  padding: 3px 6px;
  min-width: 64px;
  height: 52px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  transition: all 0.2s ease;
  user-select: none;
}

[data-theme="parchment"] .init-badge-container,
[data-theme="light"] .init-badge-container {
  background: #f3f1db;
  border-color: var(--primary);
}

.init-badge-label {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-gold);
  letter-spacing: 0.8px;
  line-height: 1;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.init-input {
  width: 100% !important;
  border: none !important;
  background: transparent !important;
  color: #ffdb6e !important;
  font-family: var(--font-mono) !important;
  font-size: 1.35rem !important;
  font-weight: 800 !important;
  text-align: center !important;
  padding: 0 !important;
  margin: 0 !important;
  outline: none !important;
  box-shadow: none !important;
  line-height: 1 !important;
  -moz-appearance: textfield !important;
}

[data-theme="parchment"] .init-input {
  color: #781c1c !important;
}

.init-input::-webkit-outer-spin-button,
.init-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.init-badge-container:focus-within {
  border-color: #ffaa00;
  box-shadow: 0 0 10px rgba(255, 170, 0, 0.5);
  transform: scale(1.04);
}

.combatant-name-group h3 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  margin: 0;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-role {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-sans);
  text-transform: uppercase;
}

.badge-role.player {
  background: #173b5c;
  color: #7eccff;
  border: 1px solid #2b5f8f;
}

.badge-role.monster {
  background: #421818;
  color: #ffa3a3;
  border: 1px solid #781c1c;
}

.ac-badge {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: bold;
}

/* HP Control Area */
.combatant-hp-zone {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  max-width: 480px;
}

.hp-bar-wrapper {
  flex: 1;
}

.hp-bar-track {
  background: #100d12;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 4px;
}

.hp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #359f5c, #58cc83);
  transition: width 0.3s ease, background 0.3s ease;
}

.hp-bar-fill.mid {
  background: linear-gradient(90deg, #d4821c, #f5a742);
}

.hp-bar-fill.low {
  background: linear-gradient(90deg, #8a1d1d, #cc3b3b);
}

.hp-numbers {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
}

.hp-quick-adjust {
  display: flex;
  gap: 4px;
  align-items: center;
}

.hp-quick-adjust input {
  width: 58px;
  text-align: center;
  padding: 4px 6px;
  font-family: var(--font-mono);
}

/* Status conditions row */
.conditions-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-color);
}

.condition-chip {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.condition-chip:hover {
  border-color: var(--border-gold);
}

.condition-chip.active {
  background: #5c1818;
  color: #ffcccc;
  border-color: #e04848;
  font-weight: bold;
}

/* Embedded Statblock Accordion */
.combatant-details-accordion {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
  display: none;
}

.combatant-details-accordion.open {
  display: block;
}

/* ==============================================================================
   TAB 3: DICE ROLLER & LOG
   ============================================================================== */
.dice-roller-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
}

@media (max-width: 900px) {
  .dice-roller-layout {
    grid-template-columns: 1fr;
  }
}

.dice-tray-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.quick-dice-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.dice-btn {
  background: var(--bg-surface);
  border: 2px solid var(--border-color);
  color: var(--text-gold);
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: bold;
  padding: 12px 6px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.dice-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-gold);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.dice-btn:active {
  transform: translateY(1px);
}

.adv-selector-row {
  display: flex;
  gap: 6px;
}

.adv-btn {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 6px 4px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.15s ease;
}

.adv-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary-hover);
}

.adv-btn.active[data-adv="adv"] {
  background: #1f7a36;
  color: #fff;
  border-color: #3dd13d;
}

.adv-btn.active[data-adv="dis"] {
  background: #8a1d1d;
  color: #fff;
  border-color: #d36363;
}

.formula-input-row {
  display: flex;
  gap: 8px;
}

.formula-input-row input {
  flex: 1;
  font-family: var(--font-mono);
}

.last-roll-card {
  background: var(--bg-surface);
  border: 2px solid var(--border-gold);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.last-roll-total {
  font-size: 3rem;
  font-weight: 800;
  color: var(--text-gold);
  font-family: var(--font-mono);
  line-height: 1;
  margin: 6px 0;
}

.last-roll-breakdown {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Roll Log Column */
.roll-log-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 240px);
}

.roll-log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.roll-log-header h3 {
  font-family: var(--font-serif);
  color: var(--text-main);
  font-size: 1.1rem;
}

.roll-log-stream {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.log-entry {
  background: var(--bg-surface);
  border-left: 3px solid var(--accent-red);
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 0.86rem;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.log-entry-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.log-entry-content {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.log-total {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: bold;
  color: var(--text-gold);
}

.log-entry.crit {
  border-left-color: #ffd700;
  background: rgba(255, 215, 0, 0.08);
}

.log-entry.fumble {
  border-left-color: #e04848;
  background: rgba(224, 72, 72, 0.08);
}

/* ==============================================================================
   TAB 4: AI AGENT GUIDE & IMPORTER
   ============================================================================== */
.ai-guide-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 1024px) {
  .ai-guide-container {
    grid-template-columns: 1fr;
  }
}

.ai-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ai-card h3 {
  font-family: var(--font-serif);
  color: var(--text-crimson);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.prompt-copy-box {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  max-height: 240px;
  overflow-y: auto;
  white-space: pre-wrap;
  color: #8be9fd;
}

/* ==============================================================================
   TAB 5: BACKGROUND PHRASES EDITOR (СЛОВА ФОНА)
   ============================================================================== */
.phrases-editor-container {
  max-width: 1040px;
  margin: 0 auto;
}

.phrases-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.phrases-card h3 {
  font-family: var(--font-serif);
  color: var(--text-main);
  font-size: 1.35rem;
  margin: 0;
}

.phrases-quick-add-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.phrases-tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  padding: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.phrase-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(53, 103, 201, 0.16);
  color: #88aef9;
  border: 1px solid rgba(53, 103, 201, 0.38);
  padding: 5px 12px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 600;
  transition: all 0.15s ease;
}

[data-theme="parchment"] .phrase-tag-chip,
[data-theme="light"] .phrase-tag-chip {
  background: rgba(42, 87, 178, 0.1);
  color: #2a57b2;
  border-color: rgba(42, 87, 178, 0.28);
}

.phrase-tag-chip:hover {
  background: rgba(53, 103, 201, 0.28);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.phrase-delete-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 2px;
  transition: all 0.15s ease;
}

.phrase-delete-btn:hover {
  color: #ff5252;
  transform: scale(1.2);
}

/* ==============================================================================
   MODALS
   ============================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  max-width: 800px;
  width: 95%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-family: var(--font-serif);
  color: var(--text-main);
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close-btn:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Form layout inside modal */
.form-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.form-group {
  flex: 1;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* ==============================================================================
   TOAST NOTIFICATION
   ============================================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border-left: 4px solid var(--accent-gold);
  border-top: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  color: var(--text-main);
  padding: 12px 18px;
  border-radius: 6px;
  font-size: 0.9rem;
  min-width: 260px;
  pointer-events: auto;
  animation: slideIn 0.25s ease forwards;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==============================================================================
   FOLDERS SYSTEM STYLES
   ============================================================================== */
.folder-controls-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 6px;
  flex-wrap: wrap;
}

.folder-controls-row label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-gold);
  display: flex;
  align-items: center;
  gap: 6px;
}

.folder-select {
  flex: 1;
  min-width: 180px;
  font-weight: 600;
}

.badge-folder {
  background: rgba(201, 154, 69, 0.18);
  color: var(--text-gold);
  border: 1px solid rgba(201, 154, 69, 0.4);
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.badge-folder:hover {
  background: rgba(201, 154, 69, 0.35);
  border-color: var(--accent-gold);
  transform: translateY(-1px);
}

.folder-destination-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}

.folder-dest-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
}

.folder-dest-item:hover {
  background: rgba(201, 154, 69, 0.15);
  border-color: var(--accent-gold);
  transform: translateX(3px);
}

.folder-dest-item.active {
  background: rgba(201, 154, 69, 0.22);
  border-color: var(--accent-gold);
  box-shadow: 0 0 10px rgba(201, 154, 69, 0.25);
}

.folder-dest-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.folder-dest-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.25);
  padding: 2px 8px;
  border-radius: 4px;
}

.folder-dest-item.active .folder-dest-badge {
  color: #ffd700;
  font-weight: bold;
}

/* ==============================================================================
   DAMAGE METER & DAMAGE TRACKING STYLES
   ============================================================================== */
.btn-record-dmg {
  background: linear-gradient(135deg, #8a1d1d 0%, #ab2424 100%);
  color: #fff;
  border: 1px solid #d43b3b;
  font-weight: 700;
  padding: 4px 10px;
  font-size: 0.8rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-record-dmg:hover {
  background: linear-gradient(135deg, #a82424 0%, #c93030 100%);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(224, 72, 72, 0.4);
}

.damage-meter-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.damage-stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}

.damage-stat-card .val {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-gold);
  font-family: var(--font-mono);
  line-height: 1.1;
}

.damage-stat-card .lbl {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  margin-top: 4px;
}

.damage-leaderboard {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.player-rank-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.player-rank-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.player-rank-name {
  font-weight: bold;
  font-size: 1rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-rank-dmg {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 800;
  color: #ff9999;
}

.player-rank-bar-bg {
  background: rgba(0, 0, 0, 0.35);
  height: 10px;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.player-rank-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #c99a45, #e04848);
  border-radius: 5px;
  transition: width 0.4s ease;
}

.player-rank-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.damage-events-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  text-align: left;
}

.damage-events-table th {
  background: var(--bg-surface);
  padding: 6px 10px;
  border-bottom: 2px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.74rem;
  text-transform: uppercase;
}

.damage-events-table td {
  padding: 6px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.damage-events-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* ==============================================================================
   ROLE SELECTION SCREEN (МАСТЕР / ИГРОК)
   ============================================================================== */
.role-badge-btn {
  background: rgba(212, 175, 55, 0.12);
  border: 1px solid rgba(212, 175, 55, 0.4);
  color: var(--gold);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.role-badge-btn:hover {
  background: rgba(212, 175, 55, 0.25);
  border-color: var(--gold);
  transform: translateY(-1px);
  box-shadow: 0 2px 10px rgba(212, 175, 55, 0.3);
}

.role-badge-btn.is-player {
  background: rgba(53, 103, 201, 0.15);
  border-color: rgba(53, 103, 201, 0.45);
  color: #79a6f6;
}

.role-badge-btn.is-player:hover {
  background: rgba(53, 103, 201, 0.3);
  border-color: #5587e8;
  box-shadow: 0 2px 10px rgba(53, 103, 201, 0.35);
}

/* Role Modal Overlay */
.role-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at center, rgba(15, 18, 28, 0.96) 0%, rgba(5, 7, 12, 0.99) 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 20px;
}

.role-modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.role-selector-dialog {
  background: rgba(18, 22, 34, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  max-width: 860px;
  width: 100%;
  padding: 32px 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.8), 0 0 40px rgba(53, 103, 201, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  animation: roleDialogPop 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes roleDialogPop {
  0% { transform: scale(0.92) translateY(20px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

.role-selector-header {
  margin-bottom: 28px;
}

.role-selector-emblem {
  font-size: 2.4rem;
  margin-bottom: 8px;
  filter: drop-shadow(0 0 12px rgba(212, 175, 55, 0.4));
}

.role-selector-header h2 {
  font-family: var(--font-serif);
  font-size: 1.8rem;
  color: var(--text-main);
  letter-spacing: 1px;
  margin: 0 0 8px 0;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.role-selector-header p {
  color: var(--text-muted);
  font-size: 0.96rem;
  margin: 0;
  max-width: 580px;
}

.role-cards-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 22px;
  width: 100%;
  margin-bottom: 24px;
}

@media (max-width: 720px) {
  .role-cards-container {
    grid-template-columns: 1fr;
  }
}

.role-card {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.role-card-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  background: rgba(212, 175, 55, 0.18);
  color: var(--gold);
  border: 1px solid rgba(212, 175, 55, 0.35);
}

.role-card-badge.badge-wip {
  background: rgba(53, 103, 201, 0.18);
  color: #8bb2f9;
  border-color: rgba(53, 103, 201, 0.4);
}

.role-card-icon {
  font-size: 2.8rem;
  margin-bottom: 12px;
  transition: transform 0.25s ease;
}

.role-card-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  color: var(--text-main);
  margin: 0 0 4px 0;
}

.role-card-subtitle {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.role-card-features {
  list-style: none;
  padding: 0;
  margin: 0 0 24px 0;
  width: 100%;
  text-align: left;
  font-size: 0.88rem;
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

.role-card-features li {
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  border-left: 2px solid transparent;
  line-height: 1.4;
}

/* Master card specific */
.role-card-dm {
  border-color: rgba(212, 175, 55, 0.25);
}

.role-card-dm .role-card-features li {
  border-left-color: rgba(212, 175, 55, 0.5);
}

.role-card-dm:hover {
  transform: translateY(-4px);
  border-color: var(--gold);
  box-shadow: 0 12px 30px rgba(212, 175, 55, 0.25);
  background: rgba(212, 175, 55, 0.04);
}

.role-card-dm:hover .role-card-icon {
  transform: scale(1.1);
}

/* Player card specific */
.role-card-player {
  border-color: rgba(53, 103, 201, 0.25);
}

.role-card-player .role-card-features li {
  border-left-color: rgba(53, 103, 201, 0.5);
}

.role-card-player:hover {
  transform: translateY(-4px);
  border-color: #5587e8;
  box-shadow: 0 12px 30px rgba(53, 103, 201, 0.25);
  background: rgba(53, 103, 201, 0.04);
}

.role-card-player:hover .role-card-icon {
  transform: scale(1.1);
}

.role-card-btn {
  width: 100%;
  font-size: 1rem;
  padding: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* DM Password Auth Box */
.dm-auth-box {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dm-password-wrap {
  position: relative;
  width: 100%;
}

.dm-password-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.95rem;
  opacity: 0.6;
}

.dm-password-input {
  width: 100%;
  padding-left: 36px !important;
  background: rgba(0, 0, 0, 0.45) !important;
  border: 1px solid rgba(212, 175, 55, 0.35) !important;
  color: #fff !important;
  font-size: 0.92rem;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.dm-password-input:focus {
  border-color: var(--gold) !important;
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.35) !important;
}

.dm-password-input.is-invalid {
  border-color: #ff5252 !important;
  box-shadow: 0 0 12px rgba(255, 82, 82, 0.4) !important;
}

.dm-password-error {
  font-size: 0.8rem;
  color: #ff5252;
  text-align: center;
  font-weight: 600;
  animation: fadeIn 0.2s ease;
}

.shake-anim {
  animation: shakeBox 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shakeBox {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(3px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-5px, 0, 0); }
  40%, 60% { transform: translate3d(5px, 0, 0); }
}

.role-selector-footer {
  font-size: 0.82rem;
  color: var(--text-muted);
  opacity: 0.8;
}

/* ==============================================================================
   ROLE TOGGLE VISIBILITY: PLAYER VS MASTER
   ============================================================================== */
body.role-player .app-header,
body.role-player .main-content {
  display: none !important;
}

body.role-player #player-portal-empty {
  display: flex !important;
}

body.role-dm #player-portal-empty {
  display: none !important;
}

.player-portal-empty {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.player-portal-box {
  background: rgba(18, 22, 34, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 44px 32px;
  text-align: center;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7), 0 0 30px rgba(53, 103, 201, 0.12);
  animation: roleDialogPop 0.35s ease;
}

.player-portal-emblem {
  font-size: 3.2rem;
  margin-bottom: 14px;
  filter: drop-shadow(0 0 16px rgba(53, 103, 201, 0.45));
}

.player-portal-box h2 {
  font-family: var(--font-serif);
  font-size: 1.85rem;
  color: var(--text-main);
  letter-spacing: 1px;
  margin: 0 0 10px 0;
}

.player-portal-box p {
  color: var(--text-color);
  font-size: 1.05rem;
  margin: 0 0 6px 0;
}

.player-portal-subtext {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.player-portal-actions {
  display: flex;
  justify-content: center;
}



