/* ============================================================
   ENCOUNTER FORGE — style.css
   ============================================================ */

:root {
  --bg-void:       #0a0806;
  --bg-deep:       #110e09;
  --parchment:     #1e1810;
  --parchment-mid: #271f13;
  --parchment-lt:  #2e2418;
  --gold:          #c9973a;
  --gold-lt:       #e4b654;
  --gold-dk:       #8c6520;
  --bronze:        #a0713a;
  --crimson:       #8b1c1c;
  --crimson-lt:    #c0392b;
  --green-muted:   #3a6b3a;
  --amber:         #c87820;
  --purple-muted:  #5a3070;
  --text-primary:  #e8d5a3;
  --text-secondary:#a89060;
  --text-dim:      #6b5530;
  --border-gold:   1px solid #5a4010;
  --border-gold-glow: 0 0 8px rgba(201,151,58,0.15);
  --radius:        6px;
  --radius-lg:     12px;
  --font-display:  'Cinzel Decorative', 'Cinzel', serif;
  --font-heading:  'Cinzel', serif;
  --font-body:     'Crimson Text', Georgia, serif;
  --transition:    0.25s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background-color: var(--bg-void);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ---- Header ---- */
.site-header {
  text-align: center;
  padding: 0 1.5rem 0.5rem;
  background: linear-gradient(180deg, #0d0800 0%, #1a1005 60%, var(--bg-void) 100%);
  border-bottom: 1px solid var(--gold-dk);
  position: relative;
  overflow: hidden;
}
.site-header::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 800px; height: 300px;
  background: radial-gradient(ellipse, rgba(201,151,58,0.12) 0%, transparent 70%);
  pointer-events: none;
}
.site-logo {
  width: 100%;
  max-width: 820px;
  height: auto;
  display: block;
  margin: -3rem auto -3rem;
  filter: drop-shadow(0 0 40px rgba(201,151,58,0.5)) drop-shadow(0 0 80px rgba(180,80,20,0.3));
}
.site-tagline {
  font-family: var(--font-body);
  font-style: italic;
  color: var(--text-secondary);
  font-size: 1rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin: 0 0 0.3rem;
  opacity: 0.8;
}
.site-subtitle {
  font-family: var(--font-body);
  font-style: italic;
  color: var(--text-secondary);
  font-size: 1.1rem;
  letter-spacing: 0.04em;
}
.header-runes {
  color: var(--gold-dk);
  font-size: 0.9rem;
  letter-spacing: 0.3em;
  margin: 0.4rem 0;
}

/* ---- Layout ---- */
.main-layout {
  display: grid;
  grid-template-columns: 1fr 1.33fr;
  gap: 2rem;
  max-width: 1800px;
  margin: 0 auto;
  padding: 2rem 2.5rem 3rem;
}
@media (max-width: 900px) { .main-layout { grid-template-columns: 1fr; } }

/* ---- Panels ---- */
.panel {
  background: var(--parchment);
  border: 1px solid var(--gold-dk);
  border-radius: var(--radius-lg);
  padding: 2rem 1.75rem;
  box-shadow: 0 4px 24px rgba(0,0,0,0.6), inset 0 1px 0 rgba(201,151,58,0.08), var(--border-gold-glow);
  position: relative;
}
.panel::before, .panel::after {
  content: '✦';
  position: absolute;
  color: var(--gold-dk);
  font-size: 0.7rem;
  opacity: 0.6;
}
.panel::before { top: 10px; left: 14px; }
.panel::after  { bottom: 10px; right: 14px; }
.panel-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  color: var(--gold-lt);
  letter-spacing: 0.08em;
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--gold-dk);
  text-transform: uppercase;
}

/* ---- Inputs ---- */
.input-group { margin-bottom: 1.25rem; }
.group-label {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--bronze);
  margin-bottom: 0.75rem;
}
.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.field { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.85rem; }
.field label {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

input[type="text"], input[type="number"], select {
  background: var(--bg-deep);
  border: 1px solid var(--gold-dk);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 0.55rem 0.75rem;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  cursor: pointer;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M0 0l6 8 6-8z' fill='%238c6520'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2rem;
}
input[type="number"]:focus, select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(201,151,58,0.2);
}
input[type="number"]::-webkit-inner-spin-button { opacity: 0.4; }

.divider {
  text-align: center;
  color: var(--gold-dk);
  font-size: 0.85rem;
  margin: 0.5rem 0 1.25rem;
  position: relative;
}
.divider::before, .divider::after {
  content: '';
  display: inline-block;
  width: 35%;
  height: 1px;
  background: var(--gold-dk);
  vertical-align: middle;
  margin: 0 0.75rem;
  opacity: 0.5;
}

/* ---- Generate Button ---- */
.generate-btn {
  display: block;
  width: 100%;
  margin-top: 1.5rem;
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, #7a4f10 0%, #b07828 50%, #7a4f10 100%);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  color: #fff8e8;
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5), 0 0 20px rgba(201,151,58,0.1), inset 0 1px 0 rgba(255,255,255,0.1);
  position: relative;
  overflow: hidden;
}
.generate-btn::after {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 60%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transition: left 0.6s ease;
}
.generate-btn:hover {
  background: linear-gradient(135deg, #8c5c12 0%, #c98a2e 50%, #8c5c12 100%);
  box-shadow: 0 6px 24px rgba(0,0,0,0.6), 0 0 30px rgba(201,151,58,0.2);
  transform: translateY(-1px);
}
.generate-btn:hover::after { left: 140%; }
.generate-btn:active { transform: translateY(1px); box-shadow: 0 2px 8px rgba(0,0,0,0.5); }
.btn-icon { margin: 0 0.4rem; }

.status-msg {
  margin-top: 0.75rem;
  font-style: italic;
  color: var(--crimson-lt);
  font-size: 0.95rem;
  min-height: 1.4rem;
  text-align: center;
}

/* ---- Output ---- */
.placeholder { text-align: center; padding: 3rem 1rem; color: var(--text-dim); }
.placeholder-icon { font-size: 3.5rem; margin-bottom: 1rem; opacity: 0.4; }
.placeholder p { font-style: italic; line-height: 1.8; }

.narration-box {
  background: var(--parchment-mid);
  border: 1px solid var(--gold-dk);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
  padding: 1.1rem 1.3rem;
  margin-bottom: 1.5rem;
  font-style: italic;
  color: var(--text-primary);
  font-size: 1.05rem;
  line-height: 1.75;
}

.narration-btn {
  display: block;
  width: 100%;
  padding: 0.75rem 1.2rem;
  background: transparent;
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  color: var(--gold);
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 0.5rem;
}
.narration-btn:hover {
  background: rgba(201,151,58,0.1);
  box-shadow: 0 0 12px rgba(201,151,58,0.2);
  transform: translateY(-1px);
}
.narration-btn:active { transform: translateY(1px); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--bg-deep);
  border: 1px solid var(--gold-dk);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  text-align: center;
}
.stat-card .stat-label {
  font-family: var(--font-heading);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  display: block;
  margin-bottom: 0.3rem;
}
.stat-card .stat-value {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--gold-lt);
  font-weight: 600;
}

.difficulty-badge-wrap { text-align: center; margin-bottom: 1.5rem; }
.difficulty-badge {
  display: inline-block;
  padding: 0.4rem 1.4rem;
  border-radius: 50px;
  font-family: var(--font-heading);
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-weight: 700;
  border: 1px solid;
}
.diff-easy      { background: rgba(58,107,58,0.25);  color: #6fcf6f;  border-color: #3a6b3a; }
.diff-medium    { background: rgba(60,90,150,0.25);  color: #7aa8e8;  border-color: #3a5a8a; }
.diff-hard      { background: rgba(200,120,32,0.25); color: #e8a840;  border-color: var(--amber); }
.diff-deadly    { background: rgba(139,28,28,0.3);   color: #e85050;  border-color: var(--crimson); }
.diff-impossible{ background: rgba(90,48,112,0.3);   color: #c070f0;  border-color: var(--purple-muted); }

/* ---- Monster List ---- */
.section-label {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bronze);
  margin-bottom: 0.85rem;
}

.monster-card {
  background: var(--parchment-lt);
  border: 1px solid var(--gold-dk);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 0.75rem;
  position: relative;
  transition: border-color var(--transition), box-shadow var(--transition);
  animation: fadeInUp 0.3s ease both;
}
.monster-card:hover { border-color: var(--gold); box-shadow: 0 0 12px rgba(201,151,58,0.1); }

/* Default card layout — body on top, media below, stacked */
.monster-card-inner {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.monster-card-body { flex: 1; min-width: 0; position: relative; }

.monster-header {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}
.monster-name { font-family: var(--font-heading); font-size: 1.05rem; color: var(--gold-lt); font-weight: 600; }
.monster-qty {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: var(--bg-deep);
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  border: 1px solid var(--gold-dk);
}
.monster-cr { font-family: var(--font-heading); font-size: 0.78rem; color: var(--bronze); margin-left: auto; }
.monster-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.4rem; }
.tag {
  font-family: var(--font-heading);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--bg-deep);
  border: 1px solid var(--gold-dk);
  color: var(--text-secondary);
  padding: 0.15rem 0.55rem;
  border-radius: 3px;
}
.tag.faction { background: rgba(90,48,112,0.2); border-color: var(--purple-muted); color: #b070e0; }
.monster-xp {
  position: absolute;
  top: 0; right: 0;
  font-family: var(--font-heading);
  font-size: 0.72rem;
  color: var(--gold-dk);
  letter-spacing: 0.05em;
}
.monster-img-placeholder {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: var(--gold-dk);
  opacity: 0.4;
}

/* ---- Monster Media — 9:16 portrait, full width, below body ---- */
.monster-media-wrap {
  display: flex;
  width: 100%;
  aspect-ratio: 9 / 16;
  height: auto;
  margin-top: 0.75rem;
  background: #1a1410;
  border-radius: 0 0 var(--radius) var(--radius);
  overflow: hidden;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.monster-video { width: 100%; height: 100%; object-fit: cover; display: block; }
.monster-img   { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---- Stat block open ---- */
.monster-card.stat-open .monster-card-inner {
  flex-direction: column;
}
.monster-card.stat-open .monster-card-body {
  flex: 1;
  min-width: 0;
}

/* Unified Monster Manual layout — image left, stats right */
.sb-unified {
  display: flex;
  gap: 0;
  align-items: flex-start;
  background: #f5ecd7;
  border: 1px solid #8b6914;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 0 0 3px #c9973a33;
  margin-top: 0.75rem;
}

/* Image column — fixed width portrait */
.sb-unified-media {
  width: 380px;
  min-width: 380px;
  flex-shrink: 0;
  background: #f5ecd7;
}
.sb-unified-media .monster-media-wrap {
  width: 380px !important;
  min-width: 380px !important;
  aspect-ratio: 9 / 16 !important;
  height: auto !important;
  margin-top: 0 !important;
  border-radius: 0 !important;
  display: flex !important;
  background: #f5ecd7 !important;
}

/* Stat block column — scrollable */
.sb-unified-block {
  flex: 1;
  min-width: 0;
  max-height: 80vh;
  overflow-y: auto;
}

/* Remove double border from stat block inside unified */
.sb-unified-block .stat-block {
  border: none;
  border-radius: 0;
  box-shadow: none;
}

/* ---- Action buttons ---- */
.monster-action-btns { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.75rem; }
.stat-block-toggle {
  display: inline-block;
  padding: 0.35rem 0.9rem;
  background: transparent;
  border: 1px solid var(--gold-dk);
  border-radius: var(--radius);
  color: var(--gold);
  font-family: var(--font-heading);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: var(--transition);
}
.stat-block-toggle:hover { background: rgba(201,151,58,0.08); border-color: var(--gold); color: var(--gold-lt); }
.stat-block-container { margin-top: 0.9rem; }
.stat-block-coming-soon {
  margin-top: 0.5rem;
  padding: 0.6rem 1rem;
  font-family: var(--font-body);
  font-style: italic;
  color: var(--text-dim);
  font-size: 0.9rem;
  border-left: 2px solid var(--gold-dk);
}

/* ---- Share buttons ---- */
.share-monster-btn {
  display: inline-block;
  padding: 0.35rem 0.9rem;
  background: transparent;
  border: 1px solid var(--gold-dk);
  border-radius: var(--radius);
  color: var(--gold);
  font-family: var(--font-heading);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: var(--transition);
}
.share-monster-btn:hover { background: rgba(201,151,58,0.1); border-color: var(--gold); color: var(--gold-lt); }
.encounter-share-bar { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.encounter-share-btn {
  padding: 0.55rem 1.4rem;
  background: linear-gradient(135deg, var(--gold-dk), var(--gold));
  border: none;
  border-radius: var(--radius);
  color: var(--bg-void);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 2px 12px rgba(201,151,58,0.25);
}
.encounter-share-btn:hover {
  background: linear-gradient(135deg, var(--gold), var(--gold-lt));
  box-shadow: 0 4px 20px rgba(201,151,58,0.4);
  transform: translateY(-1px);
}
.share-toast, .share-toast-inline {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: #6dbf6d;
  font-style: italic;
  animation: toast-fade 2.5s ease forwards;
}
@keyframes toast-fade {
  0%   { opacity: 0; transform: translateY(2px); }
  15%  { opacity: 1; transform: translateY(0); }
  75%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ---- Footer ---- */
.site-footer {
  text-align: center;
  padding: 1.5rem;
  border-top: 1px solid var(--gold-dk);
  color: var(--text-dim);
  font-size: 0.85rem;
  font-style: italic;
  background: var(--bg-deep);
}

/* ---- Animations ---- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.results-content { animation: fadeInUp 0.4s ease; }

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

/* ============================================================
   STAT BLOCK — Classic D&D layout
   ============================================================ */
.stat-block {
  background: #f5ecd7;
  color: #1a0a00;
  border: 1px solid #8b6914;
  border-radius: var(--radius);
  box-shadow: 0 0 0 3px #c9973a33;
  font-family: 'Crimson Text', Georgia, serif;
  font-size: 0.92rem;
  line-height: 1.45;
  overflow: hidden;
}
.sb-header-bar { background: #7b1d1d; padding: 0.55rem 0.9rem 0.45rem; }
.sb-monster-name { font-family: 'Cinzel', serif; font-size: 1.1rem; font-weight: 700; color: #f5ecd7; letter-spacing: 0.03em; line-height: 1.2; }
.sb-type-line { font-style: italic; color: #e8c9a0; font-size: 0.82rem; margin-top: 0.15rem; }
.sb-divider { height: 3px; background: linear-gradient(to right, #7b1d1d, #c9973a, #7b1d1d); margin: 0; }
.sb-basics { padding: 0.5rem 0.9rem 0.4rem; }
.sb-basic-row { display: flex; gap: 0.4rem; margin-bottom: 0.1rem; font-size: 0.88rem; }
.sb-basic-label { font-weight: 700; color: #7b1d1d; min-width: 90px; }
.sb-abilities {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  background: #ede0c3;
  border-top: 1px solid #c9973a55;
  border-bottom: 1px solid #c9973a55;
}
.sb-ability { text-align: center; padding: 0.45rem 0.2rem; border-right: 1px solid #c9973a33; }
.sb-ability:last-child { border-right: none; }
.sb-ability-label { font-family: 'Cinzel', serif; font-size: 0.68rem; font-weight: 700; color: #7b1d1d; display: block; letter-spacing: 0.05em; }
.sb-ability-score { font-size: 1rem; font-weight: 700; color: #1a0a00; display: block; margin-top: 0.05rem; }
.sb-ability-mod { font-size: 0.78rem; color: #5a3010; display: block; }
.sb-details { padding: 0.45rem 0.9rem 0.35rem; }
.sb-detail-row { display: flex; gap: 0.5rem; margin-bottom: 0.12rem; font-size: 0.85rem; flex-wrap: wrap; }
.sb-detail-label { font-weight: 700; color: #7b1d1d; min-width: 130px; flex-shrink: 0; }
.sb-detail-value { color: #1a0a00; flex: 1; }
.sb-section { padding: 0.3rem 0.9rem 0.4rem; }
.sb-section-header { font-family: 'Cinzel', serif; font-size: 0.88rem; font-weight: 700; color: #7b1d1d; border-bottom: 1px solid #c9973a88; padding: 0.35rem 0.9rem 0.2rem; letter-spacing: 0.04em; }
.sb-trait { margin-bottom: 0.4rem; font-size: 0.87rem; }
.sb-trait-name { font-weight: 700; font-style: italic; color: #1a0a00; }
.sb-trait-desc { color: #2a1400; font-size: 0.87rem; }
.sb-action { margin-bottom: 0.4rem; font-size: 0.87rem; }
.sb-action-name { font-weight: 700; font-style: italic; color: #1a0a00; }
.sb-action-desc { color: #2a1400; }
.sb-entry { margin-bottom: 0.45rem; font-size: 0.87rem; line-height: 1.45; }
.sb-entry-name { font-weight: 700; font-style: italic; color: #1a0a00; }
.sb-entry-desc { color: #2a1400; }
.sb-legendary-header { background: #ede0c3; }
.sb-legendary-section { background: #f0e6cc; }
.sb-flavor { padding: 0.5rem 0.9rem 0.6rem; font-style: italic; color: #5a3010; font-size: 0.83rem; border-top: 1px solid #c9973a44; background: #f0e4c8; }

/* ============================================================
   PARTY PANEL
   ============================================================ */
.party-panel {
  border: 1px solid var(--gold-dk);
  border-radius: var(--radius-lg);
  background: var(--bg-deep);
  overflow: hidden;
  margin-bottom: 0.5rem;
}
.party-panel-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  color: var(--gold);
  font-family: var(--font-heading);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
}
.party-panel-toggle:hover { background: rgba(201,151,58,0.06); color: var(--gold-lt); }
.party-toggle-icon { font-size: 0.65rem; color: var(--gold-dk); transition: var(--transition); flex-shrink: 0; }
.party-toggle-hint { margin-left: auto; font-family: var(--font-body); font-size: 0.78rem; color: var(--text-dim); font-style: italic; }
.party-panel-body { padding: 0 1rem 1rem; border-top: 1px solid var(--gold-dk); }
.party-panel-desc { font-family: var(--font-body); font-size: 0.88rem; color: var(--text-secondary); font-style: italic; margin: 0.75rem 0 1rem; line-height: 1.5; }
.no-characters { font-family: var(--font-body); font-style: italic; color: var(--text-dim); font-size: 0.88rem; margin-bottom: 0.75rem; }
.character-card { background: var(--parchment); border: 1px solid var(--gold-dk); border-radius: var(--radius); margin-bottom: 0.75rem; overflow: hidden; }
.character-card-header { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem 0.75rem; background: var(--parchment-mid); border-bottom: 1px solid var(--gold-dk); }
.character-card-title { font-family: var(--font-heading); font-size: 0.85rem; color: var(--gold); display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.character-card-subtitle { font-family: var(--font-body); font-size: 0.78rem; color: var(--text-secondary); font-style: italic; }
.character-remove-btn { background: transparent; border: none; color: var(--text-dim); cursor: pointer; font-size: 0.85rem; padding: 0.1rem 0.3rem; border-radius: 3px; transition: var(--transition); line-height: 1; }
.character-remove-btn:hover { color: var(--crimson-lt); background: rgba(139,28,28,0.12); }
.character-fields { padding: 0.65rem 0.75rem 0.75rem; }
.char-field-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.5rem; margin-bottom: 0.5rem; }
.char-field { display: flex; flex-direction: column; gap: 0.2rem; }
.char-field-full { grid-column: 1 / -1; }
.char-field label { font-family: var(--font-heading); font-size: 0.7rem; color: var(--text-secondary); letter-spacing: 0.05em; text-transform: uppercase; }
.optional-label { font-family: var(--font-body); font-size: 0.75rem; color: var(--text-dim); font-style: italic; text-transform: none; letter-spacing: 0; }
.char-field input, .char-field textarea {
  background: var(--bg-deep);
  border: 1px solid var(--gold-dk);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.88rem;
  padding: 0.35rem 0.55rem;
  transition: var(--transition);
  resize: vertical;
}
.char-field input:focus, .char-field textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 2px rgba(201,151,58,0.15); }
.char-field input::placeholder, .char-field textarea::placeholder { color: var(--text-dim); font-style: italic; }
.add-character-btn {
  display: block; width: 100%; padding: 0.55rem; margin-top: 0.25rem;
  background: transparent; border: 1px dashed var(--gold-dk); border-radius: var(--radius);
  color: var(--text-secondary); font-family: var(--font-heading); font-size: 0.8rem;
  letter-spacing: 0.04em; cursor: pointer; transition: var(--transition);
}
.add-character-btn:hover { border-color: var(--gold); color: var(--gold); background: rgba(201,151,58,0.05); }

/* ============================================================
   MONSTER SEARCH
   ============================================================ */
.monster-search-wrap { position: relative; display: block; }
.monster-search-wrap input {
  width: 100%;
  background: var(--bg-deep);
  border: 1px solid var(--gold-dk);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 0.55rem 2rem 0.55rem 0.75rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.monster-search-wrap input:focus { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(201,151,58,0.2); }
.monster-search-wrap input::placeholder { color: var(--text-dim); font-style: italic; }
.monster-search-clear {
  position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%);
  background: transparent; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 0.8rem; padding: 0.2rem; transition: var(--transition);
}
.monster-search-clear:hover { color: var(--gold); }
.monster-search-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 100;
  background: var(--parchment-mid); border: 1px solid var(--gold-dk);
  border-top: none; border-radius: 0 0 var(--radius) var(--radius);
  max-height: 240px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.monster-search-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.55rem 0.75rem; cursor: pointer; transition: background var(--transition);
  border-bottom: 1px solid rgba(201,151,58,0.08);
}
.monster-search-item:last-child { border-bottom: none; }
.monster-search-item:hover { background: rgba(201,151,58,0.08); }
.monster-search-item-name { font-family: var(--font-heading); font-size: 0.85rem; color: var(--gold-lt); }
.monster-search-item-meta { font-family: var(--font-body); font-size: 0.78rem; color: var(--text-dim); font-style: italic; }
.monster-search-no-results { padding: 0.75rem; font-style: italic; color: var(--text-dim); font-size: 0.88rem; text-align: center; }
.monster-search-selected {
  display: flex; align-items: center; gap: 0.5rem;
  background: rgba(201,151,58,0.1); border: 1px solid var(--gold-dk);
  border-radius: var(--radius); padding: 0.4rem 0.75rem; margin-top: 0.3rem;
}
.monster-search-selected span { font-family: var(--font-heading); font-size: 0.85rem; color: var(--gold-lt); flex: 1; }
.monster-search-selected button { background: transparent; border: none; color: var(--text-dim); cursor: pointer; font-size: 0.8rem; padding: 0.1rem 0.3rem; border-radius: 3px; transition: var(--transition); }
.monster-search-selected button:hover { color: var(--crimson-lt); background: rgba(139,28,28,0.12); }
.monster-search-hint { font-family: var(--font-body); font-size: 0.78rem; color: var(--text-dim); font-style: italic; margin-top: 0.35rem; line-height: 1.4; }

/* ============================================================
   AI NARRATION LOADING
   ============================================================ */
.narration-loading { padding: 0.75rem 0; text-align: center; }
.loading-dots { font-family: var(--font-heading); font-size: 0.88rem; color: var(--gold); letter-spacing: 0.08em; animation: pulse-gold 1.4s ease-in-out infinite; }
@keyframes pulse-gold { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }

/* ============================================================
   MOBILE
   ============================================================ */
@media (max-width: 700px) {
  .monster-card.stat-open .monster-card-inner { flex-direction: column; }
  .sb-unified { flex-direction: column; }
  .sb-unified-media { width: 100% !important; min-width: unset !important; }
  .sb-unified-media .monster-media-wrap { width: 100% !important; min-width: unset !important; aspect-ratio: 9/16 !important; }
  .sb-unified-block { max-height: none; overflow-y: visible; }
  .char-field-row { grid-template-columns: 1fr 1fr; }
  .char-field-row .char-field:last-child { grid-column: 1 / -1; }
  .sb-ability-label { font-size: 0.6rem; }
  .sb-ability-score { font-size: 0.9rem; }
  .sb-ability-mod   { font-size: 0.72rem; }
  .sb-detail-label  { min-width: 100px; }
}

/* ============================================================
   DIFFICULTY METER
   ============================================================ */

.difficulty-meter {
  margin-bottom: 1.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg-deep);
  border: 1px solid var(--gold-dk);
  border-radius: var(--radius);
}

.dm-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.dm-label {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.dm-xp {
  font-family: var(--font-heading);
  font-size: 0.82rem;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
}

.dm-match {
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-style: italic;
  margin-left: auto;
}
.dm-match-yes { color: #6fcf6f; }
.dm-match-no  { color: var(--amber); }

/* Bar container */
.dm-bar-wrap {
  position: relative;
  padding-bottom: 2rem;
}

.dm-bar {
  position: relative;
  height: 18px;
  border-radius: 9px;
  overflow: visible;
  display: flex;
  border: 1px solid rgba(255,255,255,0.05);
}

/* Colored zones */
.dm-zone { height: 100%; }
.dm-trivial { background: #2a3a2a; border-radius: 9px 0 0 9px; }
.dm-easy    { background: #2a4a2a; }
.dm-medium  { background: #1a2a4a; }
.dm-hard    { background: #4a3a10; }
.dm-deadly  { background: #4a1a1a; border-radius: 0 9px 9px 0; }

/* Needle */
.dm-needle {
  position: absolute;
  top: -4px;
  width: 3px;
  height: 26px;
  border-radius: 2px;
  transform: translateX(-50%);
  z-index: 10;
  transition: left 0.4s ease;
}

.dm-needle-label {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-heading);
  font-size: 0.65rem;
  white-space: nowrap;
  letter-spacing: 0.04em;
  background: var(--bg-deep);
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
  border: 1px solid currentColor;
  opacity: 0.85;
}

/* Tier markers */
.dm-markers {
  position: absolute;
  top: 18px;
  left: 0;
  right: 0;
  height: 2rem;
}

.dm-marker {
  position: absolute;
  transform: translateX(-50%);
  text-align: center;
}

.dm-marker-line {
  width: 1px;
  height: 6px;
  background: var(--text-dim);
  margin: 0 auto;
}

.dm-marker-label {
  font-family: var(--font-heading);
  font-size: 0.58rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  line-height: 1.2;
  text-align: center;
  margin-top: 2px;
  white-space: nowrap;
}

/* ============================================================
   QUANTITY CONTROLS
   ============================================================ */

.qty-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.qty-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--gold-dk);
  background: var(--bg-deep);
  color: var(--gold);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  padding: 0;
  font-family: monospace;
}
.qty-btn:hover {
  background: rgba(201,151,58,0.15);
  border-color: var(--gold);
  color: var(--gold-lt);
  transform: scale(1.1);
}
.qty-btn:active { transform: scale(0.95); }
.qty-minus { font-size: 1.1rem; }
.qty-plus  { font-size: 1rem; }

/* ── Docx stat block (mammoth.js rendered) ─────────────────────── */
.docx-statblock {
  background: #F6EAC8;
  padding: 0.7rem 0.9rem;
  border: 1px solid #8A1008;
  font-family: Arial, sans-serif;
  font-size: 0.87rem;
  line-height: 1.5;
  color: #8A1008;
  text-align: left;
}
.docx-statblock p   { margin: 0 0 0.25rem 0; text-align: left; }
.docx-statblock table { width: 100%; border-collapse: collapse; margin: 0.3rem 0; }
.docx-statblock td,
.docx-statblock th  { padding: 2px 6px; text-align: center; color: #8A1008; }
/* Ability score header row */
.docx-statblock .ability-header td {
  font-weight: bold;
  font-size: 0.95rem;
  letter-spacing: 0.05em;
}
.docx-statblock strong { font-weight: bold; }
.docx-statblock em     { font-style: italic; }

/* Monster name — first paragraph */
.sb-doc-name {
  font-family: Georgia, serif;
  font-size: 1.75rem;
  font-weight: bold;
  color: #7A0B06;
  margin: 0 0 0.3rem 0 !important;
  line-height: 1.2;
  border-bottom: 2px solid #8A1008 !important;
  padding-bottom: 6px !important;
  display: block;
}

/* Section headers: ACTIONS, BONUS ACTIONS etc. */
.sb-doc-section {
  font-family: Georgia, serif;
  font-size: 1.1rem;
  font-weight: normal;
  color: #8A1008;
  border-bottom: 1px solid #8A1008;
  margin: 0.6rem 0 0.25rem 0 !important;
  padding-bottom: 2px;
}

/* Empty divider paragraphs */
.sb-doc-divider { display: none; }

/* ── Docx stat block ─────────────────────────────────────────── */
.docx-statblock {
  background: #F6EAC8;
  padding: 0.7rem 0.9rem;
  border: 1px solid #8A1008;
  font-family: Arial, sans-serif;
  font-size: 0.87rem;
  line-height: 1.5;
  color: #8A1008;
  text-align: left;
}
.docx-statblock p {
  margin: 0 0 0.25rem 0;
  font-weight: normal;
  font-style: normal;
}
.docx-statblock strong { font-weight: bold; }
.docx-statblock em     { font-style: italic; }

/* Monster name */
.sb-doc-name {
  font-family: Georgia, serif;
  font-size: 1.75rem;
  font-weight: bold;
  color: #7A0B06;
  margin: 0 0 0.3rem 0 !important;
  line-height: 1.2;
  border-bottom: 2px solid #8A1008 !important;
  padding-bottom: 6px !important;
  display: block;
}

/* Section headers: TRAITS, ACTIONS etc. */
.sb-doc-section {
  font-family: Georgia, serif;
  font-size: 1.1rem;
  font-weight: normal;
  color: #8A1008;
  border-bottom: 1px solid #8A1008;
  margin: 0.6rem 0 0.25rem 0 !important;
  padding-bottom: 2px;
}

/* Empty paragraphs */
.sb-doc-divider { display: none; }

/* Ability score table — built from CSV data */
.ab-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.4rem 0;
  table-layout: fixed;
}
.ab-table td {
  text-align: center;
  padding: 2px 0;
  width: 16.66%;
}
.ab-label {
  font-weight: bold;
  font-size: 0.9rem;
  color: #8A1008;
  display: block;
}
.ab-score {
  font-weight: normal;
  font-size: 0.85rem;
  color: #8A1008;
  display: block;
}

/* ---- Stat Block ---- */
.stat-block {
  background: #F6EAC8;
  border: 1px solid #000;
  font-family: Arial, sans-serif;
  font-size: 0.87rem;
  color: #8A1008;
  line-height: 1.5;
  padding: 0 0.8rem 0.5rem;
}
.sb-gold-top {
  height: 4px;
  background: linear-gradient(90deg, #C9973A, #E8B84B, #C9973A);
  margin: 0 -0.8rem 0.6rem;
}
.sb-gold-bottom {
  height: 4px;
  background: linear-gradient(90deg, #C9973A, #E8B84B, #C9973A);
  margin: 0.6rem -0.8rem 0;
}
.sb-name {
  font-family: Georgia, serif;
  font-size: 1.6rem;
  font-weight: bold;
  color: #7A0B06;
  border-bottom: 2px solid #8A1008;
  padding-bottom: 4px;
  margin-bottom: 2px;
}
.sb-type-line {
  font-style: italic;
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
}
.sb-divider {
  border: none;
  border-top: 1px solid #8A1008;
  margin: 0.4rem 0;
}
.sb-basic-row {
  margin: 0.1rem 0;
}
.sb-basic-label {
  font-weight: bold;
}
.sb-abilities {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  text-align: center;
  margin: 0.3rem 0;
}
.sb-ability-label {
  font-weight: bold;
  font-size: 0.85rem;
}
.sb-ability-score { font-size: 0.85rem; }
.sb-ability-mod   { font-size: 0.82rem; }
.sb-details { margin: 0.2rem 0; }
.sb-detail-row {
  display: flex;
  gap: 0.4rem;
  margin: 0.1rem 0;
}
.sb-detail-label { font-weight: bold; white-space: nowrap; }
.sb-detail-value { flex: 1; }
.sb-section-header {
  font-family: Georgia, serif;
  font-size: 1.05rem;
  color: #8A1008;
  border-bottom: 1px solid #8A1008;
  margin: 0.5rem 0 0.2rem;
  padding-bottom: 1px;
}
.sb-section { margin-bottom: 0.2rem; }
.sb-entry {
  margin: 0 0 0.4rem 0;
  line-height: 1.45;
}
.sb-entry-name {
  font-weight: bold;
  font-style: italic;
}
.stat-block-coming-soon {
  padding: 1rem;
  color: rgba(139,69,19,0.5);
  font-style: italic;
  text-align: center;
}


/* Source filter */
.source-filter-wrap {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.4rem 0;
}
.source-option {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--gold-lt) !important;
  cursor: pointer;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 1 !important;
}
.source-option input[type="radio"] {
  accent-color: var(--gold);
  width: 16px;
  height: 16px;
  cursor: pointer;
  flex-shrink: 0;
}
