/* ═══════════════════════════════════════════════════════
   OuchRPG — Light-Hearted Fantasy RPG Stylesheet
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=MedievalSharp&family=Crimson+Text:ital,wght@0,400;0,600;1,400&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── CSS Custom Properties ─────────────────────────── */
:root {
  --clr-bg-deep:       #1a0e2e;
  --clr-bg-mid:        #2d1b4e;
  --clr-bg-light:      #3d2b5e;
  --clr-surface:       #f5e6c8;
  --clr-surface-dark:  #e8d5a8;
  --clr-gold:          #d4a017;
  --clr-gold-light:    #f0c94b;
  --clr-gold-dim:      #a07810;
  --clr-text-dark:     #2c1810;
  --clr-text-body:     #3e2723;
  --clr-accent-green:  #4caf50;
  --clr-accent-red:    #c62828;
  --clr-accent-blue:   #1565c0;
  --clr-accent-purple: #7b1fa2;
  --clr-accent-orange: #e65100;
  --clr-rarity-common:    #9e9e9e;
  --clr-rarity-uncommon:  #4caf50;
  --clr-rarity-rare:      #1565c0;
  --clr-rarity-epic:      #7b1fa2;
  --clr-rarity-legendary: #d4a017;

  --font-heading: 'MedievalSharp', cursive;
  --font-body:    'Crimson Text', Georgia, serif;
  --font-mono:    'JetBrains Mono', monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-card:  0 4px 20px rgba(0,0,0,.35), 0 1px 3px rgba(0,0,0,.2);
  --shadow-glow:  0 0 20px rgba(212,160,23,.25);

  --transition-fast: .15s ease;
  --transition-med:  .3s ease;
}

/* ── Reset & Base ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  color: var(--clr-text-dark);
  background:
    radial-gradient(ellipse at 20% 50%, rgba(123,31,162,.25) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(212,160,23,.15) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 100%, rgba(76,175,80,.15) 0%, transparent 40%),
    var(--clr-bg-deep);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Ambient Canvas (fixed behind everything) ──── */
#ambient-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* ── Floating Particles (Background Magic Dust) ───── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(240,201,75,.6), transparent),
    radial-gradient(1.5px 1.5px at 30% 70%, rgba(240,201,75,.4), transparent),
    radial-gradient(1px 1px at 50% 10%, rgba(240,201,75,.5), transparent),
    radial-gradient(1.5px 1.5px at 70% 50%, rgba(240,201,75,.3), transparent),
    radial-gradient(1px 1px at 90% 80%, rgba(240,201,75,.5), transparent),
    radial-gradient(1px 1px at 15% 90%, rgba(200,180,255,.4), transparent),
    radial-gradient(1.5px 1.5px at 85% 30%, rgba(200,180,255,.3), transparent),
    radial-gradient(1px 1px at 45% 55%, rgba(180,255,200,.3), transparent);
  animation: particlesDrift 60s linear infinite;
}

@keyframes particlesDrift {
  from { transform: translateY(0); }
  to   { transform: translateY(-100px); }
}

/* ── Layout Container ─────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem 1.5rem;
  position: relative;
  z-index: 1;
}

.container.game-mode {
  padding-top: 0.5rem;
}

/* ═══════════════════════════════════════════════════
   HEADER / TITLE BANNER
   ═══════════════════════════════════════════════════ */
.game-header {
  text-align: center;
  padding: 1.5rem 1.5rem 1rem;
  margin-bottom: 1rem;
  background:
    linear-gradient(180deg, rgba(45,27,78,.9) 0%, rgba(26,14,46,.95) 100%);
  border: 2px solid var(--clr-gold-dim);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card), inset 0 1px 0 rgba(240,201,75,.15);
  position: relative;
  overflow: hidden;
}

.game-header::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(from 0deg, transparent, rgba(212,160,23,.06), transparent, rgba(123,31,162,.06), transparent);
  animation: headerShimmer 20s linear infinite;
  pointer-events: none;
}

@keyframes headerShimmer {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.game-header h1 {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 5vw, 3.2rem);
  position: relative;
  color: var(--clr-gold-light);
  text-shadow:
    0 0 30px rgba(240,201,75,.4),
    0 2px 4px rgba(0,0,0,.6);
  letter-spacing: .04em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .35em;
}

/* Subtitle Skull (small death-skull emoji) */
.game-header .subtitle .subtitle-skull {
  font-size: 1.1rem;
  margin-left: 0.3em;
  opacity: 0.75;
  vertical-align: middle;
}

.game-header .subtitle {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 1.1rem;
  color: rgba(245,230,200,.7);
  margin-top: .5rem;
  position: relative;
}

.game-header .header-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: .5rem;
  position: relative;
  animation: floatIcon 3s ease-in-out infinite;
}

@keyframes floatIcon {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

/* ── Logo Image ─────────────────────────────────── */
.header-knight {
  position: absolute;
  right: -10px;
  bottom: -20px;
  height: calc(100% + 20px);
  width: auto;
  opacity: 0.18;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 0 20px rgba(240,201,75,.15));
}

.game-logo {
  width: clamp(80px, 18vw, 140px);
  height: auto;
  display: block;
  position: relative;
  filter: drop-shadow(0 0 20px rgba(240,201,75,.35)) drop-shadow(0 4px 8px rgba(0,0,0,.5));
  animation: logoFloat 4s ease-in-out infinite;
}

.logo-wrapper {
  position: relative;
  display: flex;
  justify-content: center;
  margin: 0 auto .75rem;
}

.game-header .beta-badge {
  display: inline-block;
  font-family: var(--font-heading);
  font-size: 0.38em;
  font-weight: 900;
  letter-spacing: 0.2em;
  color: #fff;
  background: linear-gradient(135deg, #ff4444 0%, #ff6b35 50%, #ff4444 100%);
  padding: 0.15em 0.5em;
  border-radius: 0.15em;
  margin-left: 0.4em;
  vertical-align: 0.55em;
  transform: rotate(-5deg);
  text-shadow: 0 0 8px rgba(255,255,255,0.8);
  box-shadow:
    0 0 6px rgba(255,68,68,0.7),
    0 0 16px rgba(255,68,68,0.45),
    0 0 32px rgba(255,68,68,0.25),
    inset 0 1px 0 rgba(255,255,255,0.3);
  animation: betaGlow 2s ease-in-out infinite;
  pointer-events: none;
  user-select: none;
}

@keyframes betaGlow {
  0%, 100% {
    box-shadow:
      0 0 6px rgba(255,68,68,0.7),
      0 0 16px rgba(255,68,68,0.45),
      0 0 32px rgba(255,68,68,0.25),
      inset 0 1px 0 rgba(255,255,255,0.3);
    filter: brightness(1);
  }
  50% {
    box-shadow:
      0 0 10px rgba(255,68,68,0.9),
      0 0 28px rgba(255,68,68,0.65),
      0 0 50px rgba(255,68,68,0.4),
      inset 0 1px 0 rgba(255,255,255,0.3);
    filter: brightness(1.15);
  }
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-8px) scale(1.02); }
}

/* ── Desktop Edition Badge ─────────────────────── */
.desktop-badge {
  display: inline-block;
  margin: 0.5rem auto 0;
  padding: 0.35rem 1rem;
  background: linear-gradient(135deg, #1a0e2e 0%, #2d1b4e 100%);
  color: var(--clr-gold-light);
  font-family: var(--font-heading);
  font-size: 0.95rem;
  text-decoration: none;
  border: 1px solid var(--clr-gold-dim);
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0,0,0,.4), 0 0 12px rgba(212,160,23,.2);
  transition: var(--transition-fast);
  animation: badgePulse 3s ease-in-out infinite;
  position: relative;
  z-index: 10;
  cursor: pointer;
}
.desktop-badge:hover {
  background: linear-gradient(135deg, #2d1b4e 0%, #3d2b5e 100%);
  box-shadow: 0 4px 16px rgba(0,0,0,.5), 0 0 20px rgba(212,160,23,.35);
  transform: translateY(-1px) scale(1.03);
  color: var(--clr-gold);
}
@keyframes badgePulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(0,0,0,.4), 0 0 12px rgba(212,160,23,.2); }
  50%      { box-shadow: 0 2px 12px rgba(0,0,0,.5), 0 0 20px rgba(212,160,23,.4); }
}

/* ── Donate Seal (Header) ──────────────────────── */
.donate-seal {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 10;
  text-decoration: none;
  cursor: pointer;
  transform: rotate(-8deg);
}

.seal-outer {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #3d2b1f, #1a0e08 70%);
  border: 2px solid var(--clr-gold-dim);
  box-shadow: 0 2px 10px rgba(0,0,0,.5), inset 0 0 12px rgba(212,160,23,.15), 0 0 16px rgba(212,160,23,.12);
  position: relative;
  transition: transform .2s ease, box-shadow .2s ease;
  animation: sealPulse 3s ease-in-out infinite;
}

.seal-outer::before {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  border: 1px dashed rgba(240,201,75,.25);
  pointer-events: none;
}

.seal-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  line-height: 1;
}

.seal-icon-img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(0 0 4px rgba(240,201,75,.3));
}

.seal-text {
  font-family: var(--font-heading);
  font-size: .5rem;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--clr-gold-light);
  opacity: .8;
}

.donate-seal:hover .seal-outer {
  transform: scale(1.15);
  box-shadow: 0 2px 14px rgba(0,0,0,.6), inset 0 0 16px rgba(212,160,23,.25), 0 0 24px rgba(212,160,23,.25);
  border-color: var(--clr-gold);
}

@keyframes sealPulse {
  0%, 100% { box-shadow: 0 2px 10px rgba(0,0,0,.5), inset 0 0 12px rgba(212,160,23,.15), 0 0 16px rgba(212,160,23,.12); }
  50%      { box-shadow: 0 2px 14px rgba(0,0,0,.6), inset 0 0 16px rgba(212,160,23,.25), 0 0 24px rgba(212,160,23,.22); }
}

/* ═══════════════════════════════════════════════════
   PARCHMENT PANELS (Cards)
   ═══════════════════════════════════════════════════ */
.panel {
  background:
    linear-gradient(135deg, #f7ecd5 0%, #f0dfb8 40%, #e8d5a8 100%);
  border: 2px solid var(--clr-gold-dim);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  position: relative;
}

.panel::before {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(212,160,23,.2);
  border-radius: calc(var(--radius-md) - 2px);
  pointer-events: none;
}

.panel-title {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  color: var(--clr-text-dark);
  margin-bottom: 1rem;
  padding-bottom: .5rem;
  border-bottom: 2px solid var(--clr-gold-dim);
  display: flex;
  align-items: center;
  gap: .5rem;
}

.panel-title .icon {
  font-size: 1.3rem;
}

/* ═══════════════════════════════════════════════════
   CHARACTER CREATION FORM
   ═══════════════════════════════════════════════════ */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--clr-text-dark);
  margin-bottom: .4rem;
}

.form-group input[type="text"],
.form-group select {
  width: 100%;
  padding: .65rem 1rem;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--clr-text-dark);
  background: rgba(255,255,255,.7);
  border: 2px solid var(--clr-gold-dim);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--clr-gold);
  box-shadow: 0 0 0 3px rgba(212,160,23,.2);
}

/* ── Class Selection Grid ─────────────────────────── */
.class-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .75rem;
  margin-top: .5rem;
}

.class-card {
  background: rgba(255,255,255,.5);
  border: 2px solid var(--clr-gold-dim);
  border-radius: var(--radius-sm);
  padding: .85rem .6rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.class-card:hover {
  background: rgba(255,255,255,.75);
  border-color: var(--clr-gold);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}

.class-card.selected {
  background: linear-gradient(135deg, rgba(212,160,23,.2), rgba(240,201,75,.15));
  border-color: var(--clr-gold);
  box-shadow: 0 0 12px rgba(212,160,23,.3);
}

.class-card .class-icon {
  font-size: 1.8rem;
  display: block;
  margin-bottom: .3rem;
}

.class-card .class-name {
  font-family: var(--font-heading);
  font-size: .95rem;
  color: var(--clr-text-dark);
}

.class-card .class-desc {
  font-size: .78rem;
  color: rgba(62,39,35,.65);
  margin-top: .2rem;
  line-height: 1.3;
}

/* ═══════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .7rem 1.5rem;
  font-family: var(--font-heading);
  font-size: 1.05rem;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  line-height: 1.3;
}

.btn-primary {
  background: linear-gradient(180deg, var(--clr-gold-light) 0%, var(--clr-gold) 60%, var(--clr-gold-dim) 100%);
  color: var(--clr-text-dark);
  border-color: var(--clr-gold-dim);
  box-shadow: 0 3px 8px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(212,160,23,.4), inset 0 1px 0 rgba(255,255,255,.3);
}

.btn-primary:active {
  transform: translateY(1px);
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
}

.btn-secondary {
  background: linear-gradient(180deg, rgba(255,255,255,.7) 0%, rgba(230,210,170,.8) 100%);
  color: var(--clr-text-dark);
  border-color: var(--clr-gold-dim);
}

.btn-secondary:hover {
  background: linear-gradient(180deg, rgba(255,255,255,.9) 0%, rgba(240,220,180,.9) 100%);
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(180deg, #ef5350 0%, var(--clr-accent-red) 100%);
  color: white;
  border-color: #8e0000;
}

.btn-danger:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(198,40,40,.35);
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none !important;
}

.btn-block {
  width: 100%;
}

/* ═══════════════════════════════════════════════════
   GAME LOG (Scrollable Narrative Output)
   ═══════════════════════════════════════════════════ */
.game-log-panel {
  background:
    linear-gradient(135deg, #f7ecd5 0%, #f0dfb8 40%, #e8d5a8 100%);
  border: 2px solid var(--clr-gold-dim);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  margin-bottom: 0.75rem;
  overflow: hidden;
  position: relative;
}

.game-log-panel::before {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(212,160,23,.2);
  border-radius: calc(var(--radius-md) - 2px);
  pointer-events: none;
}

.game-log-panel .panel-title {
  padding: 0.75rem 1.25rem 0.5rem;
  margin-bottom: 0;
  border-bottom: none;
  font-size: 1.1rem;
}

.game-log-scroll {
  padding: 0.25rem 1.25rem 1rem;
  max-height: 180px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.game-log-scroll::-webkit-scrollbar { width: 8px; }
.game-log-scroll::-webkit-scrollbar-track { background: rgba(0,0,0,.05); border-radius: 4px; }
.game-log-scroll::-webkit-scrollbar-thumb { background: var(--clr-gold-dim); border-radius: 4px; }

.log-entry {
  padding: .5rem 0;
  border-bottom: 1px solid rgba(160,120,16,.15);
  animation: fadeInUp .3s ease;
}

.log-entry:last-child { border-bottom: none; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.log-entry.narrative {
  font-style: italic;
  color: var(--clr-text-body);
  line-height: 1.7;
}

.log-entry.system {
  font-family: var(--font-mono);
  font-size: .85rem;
  color: rgba(62,39,35,.55);
  padding: .3rem .75rem;
  background: rgba(0,0,0,.04);
  border-radius: var(--radius-sm);
  display: inline-block;
}

.log-entry.combat {
  color: var(--clr-accent-red);
  font-weight: 600;
}

/* Bold numbers in combat/narrative (damage, HP, rolls) get emphasis */
.log-entry.combat b,
.log-entry.narrative b,
.log-entry.success b {
  font-size: 1.2em;
}

.log-entry.loot {
  color: var(--clr-gold-dim);
  font-weight: 600;
}

.log-entry.success {
  color: var(--clr-accent-green);
  font-weight: 600;
}

/* Item left behind — pack full, inline Take button */
.log-entry.left-behind-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .75rem;
  margin: .25rem 0;
  background: rgba(220,53,69,.1);
  border: 1px solid rgba(220,53,69,.2);
  border-radius: var(--radius-sm);
  font-size: .85rem;
  color: var(--clr-text-dim);
}

.log-entry.left-behind-row .action-btn {
  font-size: .8rem;
  padding: .3rem .7rem;
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════
   STATS BAR
   ═══════════════════════════════════════════════════ */
.stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.25rem;
  padding: .85rem 1.25rem;
  background: rgba(255,255,255,.4);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

.stat {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-family: var(--font-mono);
  font-size: .9rem;
}

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

.stat-value {
  font-weight: 700;
  color: var(--clr-text-dark);
}

.stat-label {
  color: rgba(62,39,35,.55);
  font-size: .8rem;
}

/* ── Health / Mana Bars ──────────────────────────── */
.bar-container {
  width: 100%;
  height: 14px;
  background: rgba(0,0,0,.15);
  border-radius: 7px;
  overflow: hidden;
  margin-top: .2rem;
}

.bar-fill {
  height: 100%;
  border-radius: 7px;
  transition: width .4s ease;
  position: relative;
}

.bar-fill::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,.3), transparent);
  border-radius: 7px 7px 0 0;
}

.bar-hp .bar-fill { background: linear-gradient(90deg, #c62828, #e53935, #ef5350); }
.bar-mp .bar-fill { background: linear-gradient(90deg, #1565c0, #1e88e5, #42a5f5); }
.bar-xp .bar-fill { background: linear-gradient(90deg, #d4a017, #f0c94b, #ffee58); }

/* ═══════════════════════════════════════════════════
   ACTION PANEL
   ═══════════════════════════════════════════════════ */
.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin-bottom: 1rem;
}

.action-btn {
  padding: .55rem 1.1rem;
  font-family: var(--font-heading);
  font-size: .95rem;
  background: linear-gradient(180deg, rgba(255,255,255,.6) 0%, rgba(230,210,170,.7) 100%);
  border: 2px solid var(--clr-gold-dim);
  border-radius: var(--radius-sm);
  color: var(--clr-text-dark);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.action-btn:hover {
  background: linear-gradient(180deg, rgba(255,255,255,.85) 0%, rgba(245,230,200,.9) 100%);
  border-color: var(--clr-gold);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0,0,0,.12);
}

.action-btn:active { transform: translateY(0); }

.action-btn .action-icon { margin-right: .3rem; }

/* ── Free-Text Input ─────────────────────────────── */
.input-row {
  display: flex;
  gap: .5rem;
}

.input-row input[type="text"] {
  flex: 1;
  padding: .65rem 1rem;
  font-family: var(--font-body);
  font-size: 1rem;
  background: rgba(255,255,255,.7);
  border: 2px solid var(--clr-gold-dim);
  border-radius: var(--radius-sm);
  color: var(--clr-text-dark);
}

.input-row input:focus {
  outline: none;
  border-color: var(--clr-gold);
  box-shadow: 0 0 0 3px rgba(212,160,23,.2);
}

/* ═══════════════════════════════════════════════════
   INVENTORY GRID
   ═══════════════════════════════════════════════════ */
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .6rem;
}

.inv-item {
  background: rgba(255,255,255,.45);
  border: 1px solid var(--clr-gold-dim);
  border-radius: var(--radius-sm);
  padding: .65rem;
  text-align: center;
  transition: all var(--transition-fast);
}

.inv-item:hover {
  background: rgba(255,255,255,.7);
  transform: translateY(-1px);
}

.inv-item .item-icon { font-size: 1.5rem; }
.inv-item .item-name {
  font-family: var(--font-heading);
  font-size: .85rem;
  margin-top: .2rem;
}
.inv-item .item-desc {
  font-size: .75rem;
  color: rgba(62,39,35,.8);
}

/* ── Stack Count Badge ─────────────────────────── */
.stack-count {
  display: inline-block;
  background: var(--clr-gold);
  color: #1a0e08;
  font-family: var(--font-mono);
  font-size: .7rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.1em 0.35em;
  border-radius: 3px;
  margin-left: 0.25rem;
  vertical-align: middle;
}

/* ── Inventory Slot Counter ────────────────────── */
.inventory-slot-count {
  text-align: center;
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--clr-text-dark);
  opacity: 0.7;
  margin-top: 0.5rem;
}

.inv-nearly-full {
  color: #a83219 !important;
  opacity: 1 !important;
  font-weight: 600;
}

/* ── Rarity Colors ───────────────────────────────── */
.rarity-common    { border-color: var(--clr-rarity-common) !important; }
.rarity-uncommon  { border-color: var(--clr-rarity-uncommon) !important; }
.rarity-rare      { border-color: var(--clr-rarity-rare) !important; }
.rarity-epic      { border-color: var(--clr-rarity-epic) !important; }
.rarity-legendary {
  border-color: var(--clr-rarity-legendary) !important;
  box-shadow: 0 0 8px rgba(212,160,23,.3);
}

/* ═══════════════════════════════════════════════════
   TWO-COLUMN LAYOUT (Game View)
   ═══════════════════════════════════════════════════ */
.game-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 1rem;
  align-items: start;
}

.game-main { min-width: 0; }
.game-sidebar { display: flex; flex-direction: column; gap: 0.75rem; }

@media (max-width: 860px) {
  .game-layout { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.toast {
  padding: .75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  animation: toastIn .3s ease, toastOut .3s ease 2.7s forwards;
  max-width: 320px;
}

.toast-success { background: #2e7d32; color: white; }
.toast-error   { background: #c62828; color: white; }
.toast-info    { background: var(--clr-bg-mid); color: var(--clr-surface); border: 1px solid var(--clr-gold-dim); }

@keyframes toastIn  { from { opacity:0; transform:translateX(40px); } to { opacity:1; transform:translateX(0); } }
@keyframes toastOut { from { opacity:1; } to { opacity:0; transform:translateY(-10px); } }

/* ── Room Panel Extras ──────────────────────────── */
.room-panel .panel-title { font-size: 1.15rem; }
.biome-label { margin-left: auto !important; font-size: 0.8rem; color: rgba(62,39,35,.4); }
.room-items { margin-top:.5rem; display:flex; flex-wrap:wrap; align-items:center; gap:.4rem; font-size:.9rem; }
.enemy-box { margin-top:.5rem; padding:.6rem .75rem; background:rgba(198,40,40,.08); border-radius:var(--radius-sm); border:1px solid rgba(198,40,40,.2); }
.enemy-header { display:flex; align-items:center; gap:.4rem; margin-bottom:.4rem; }
.enemy-icon { font-size:1.3rem; }
.enemy-stats { font-size:.8rem; color:rgba(62,39,35,.5); margin-top:.3rem; }
.room-exits { margin-top:.5rem; padding-top:.4rem; border-top:1px solid rgba(160,120,16,.2); display:flex; flex-wrap:wrap; align-items:center; gap:.4rem; font-size:.9rem; }

/* ═══════════════════════════════════════════════════
   BACK LINK
   ═══════════════════════════════════════════════════ */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  color: rgba(245,230,200,.5);
  font-family: var(--font-body);
  font-size: .9rem;
  text-decoration: none;
  transition: color var(--transition-fast);
  margin-bottom: 1rem;
}

.back-link:hover {
  color: var(--clr-gold-light);
}

/* ═══════════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════════ */
.game-footer {
  text-align: center;
  padding: 1.5rem;
  color: rgba(245,230,200,.35);
  font-size: .85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
}

.donate-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1rem .55rem .7rem;
  margin-left: -.6rem;
  background: rgba(255,215,0,.08);
  border: 1px solid rgba(255,215,0,.25);
  border-radius: 999px;
  color: rgba(255,215,0,.85);
  font-size: .85rem;
  text-decoration: none;
  font-weight: 600;
  transition: all .25s ease;
  white-space: nowrap;
  position: relative;
  overflow: visible;
}

.donate-badge:hover {
  background: rgba(255,215,0,.15);
  border-color: rgba(255,215,0,.5);
  color: rgba(255,215,0,1);
  transform: scale(1.05);
}

.donate-icon-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex-shrink: 0;
  margin-top: -12px;
  margin-bottom: -12px;
  margin-left: -6px;
  transform: rotate(-15deg);
  filter: drop-shadow(-2px 2px 4px rgba(0,0,0,.5));
  transition: transform .25s ease;
  z-index: 0;
}

.donate-badge:hover .donate-icon-img {
  transform: rotate(-22deg) scale(1.15);
}

.donate-icon-text {
  position: relative;
  z-index: 1;
  line-height: 1;
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE TWEAKS
   ═══════════════════════════════════════════════════ */
@media (max-width: 600px) {
  .container { padding: 1rem; }
  .game-header { padding: 1.5rem 1rem; }
  .class-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-bar { gap: .4rem .75rem; }
  .action-buttons { gap: .4rem; }
  .skill-buttons { grid-template-columns: repeat(4, 1fr); }
  .shop-split { flex-direction: column; }
  .donate-badge { font-size: .78rem; padding: .45rem .75rem; }
  .donate-icon-img { width: 28px; height: 28px; }
  .seal-outer { width: 50px; height: 50px; }
  .seal-icon-img { width: 26px; height: 26px; }
  .seal-text { font-size: .42rem; }
  .donate-seal { top: 8px; left: 8px; }
}

/* ═══════════════════════════════════════════════════
   ACTION BAR (compact, fixed at bottom of main)
   ═══════════════════════════════════════════════════ */
.action-bar {
  background: linear-gradient(135deg, #f7ecd5 0%, #e8d5a8 100%);
  border: 2px solid var(--clr-gold-dim);
  border-radius: var(--radius-md);
  padding: 0.6rem 1rem;
  box-shadow: var(--shadow-card);
}

.action-bar .action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.action-bar .input-row {
  display: flex;
  gap: 0.4rem;
}

/* ═══════════════════════════════════════════════════
   COMPACT SIDEBAR ELEMENTS
   ═══════════════════════════════════════════════════ */
.stats-panel .panel-title { font-size: 1.1rem; margin-bottom: 0.5rem; padding-bottom: 0.3rem; }
.player-class { font-size: 0.8rem; color: rgba(62,39,35,.6); margin-bottom: 0.5rem; }

.stat-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}

.stat-bar .stat-icon { font-size: 1rem; }

.bar-wrap { flex: 1; }

.bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  margin-bottom: 1px;
}

.bar-container { height: 12px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.3rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(160,120,16,.2);
}

.stats-grid .stat { justify-content: center; font-size: 0.8rem; }
.stats-grid .stat-icon { font-size: 0.9rem; }
.stats-grid .stat-value { font-size: 0.85rem; }

.equipped-gear {
  margin-top: 0.5rem;
  padding-top: 0.4rem;
  border-top: 1px solid rgba(160,120,16,.2);
  font-size: 0.8rem;
}

.inv-panel .panel-title, .saves-panel .panel-title { font-size: 1rem; margin-bottom: 0.4rem; padding-bottom: 0.25rem; }

.save-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0;
  border-bottom: 1px solid rgba(160,120,16,.15);
  font-size: 0.8rem;
}

/* ═══════════════════════════════════════════════════
   UTILITY CLASSES
   ═══════════════════════════════════════════════════ */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.empty-msg { font-size: .85rem; color: rgba(62,39,35,.45); text-align: center; padding: .5rem; }

/* ═══════════════════════════════════════════════════
   COMPACT GAME LAYOUT
   ═══════════════════════════════════════════════════ */
.game-compact {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  max-width: 720px;
  margin: 0 auto;
}

/* ── Top Stats Bar ─────────────────────────────── */
.stats-bar-compact {
  background: linear-gradient(135deg, rgba(45,27,78,.92), rgba(26,14,46,.95));
  border: 2px solid var(--clr-gold-dim);
  border-radius: var(--radius-md);
  padding: .5rem .75rem;
  box-shadow: var(--shadow-card);
}

.player-info {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .3rem;
}

.player-name {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--clr-gold-light);
  text-shadow: 0 0 10px rgba(240,201,75,.3);
}

.player-class-badge {
  font-size: .75rem;
  color: rgba(245,230,200,.6);
  background: rgba(255,255,255,.08);
  padding: .1rem .4rem;
  border-radius: 4px;
}

.bars-row {
  display: flex;
  gap: .5rem;
  margin-bottom: .3rem;
}

.mini-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: .3rem;
  position: relative;
  padding-top: .85rem;
}

.mini-bar .bar-label {
  font-family: var(--font-mono);
  font-size: .6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: rgba(245,230,200,.55);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  text-align: center;
  pointer-events: none;
}

.mini-bar .bar-icon { font-size: .85rem; }

.mini-bar .bar-track {
  flex: 1;
  height: 10px;
  background: rgba(0,0,0,.3);
  border-radius: 5px;
  overflow: hidden;
}

.mini-bar .bar-val {
  font-family: var(--font-mono);
  font-size: .7rem;
  color: rgba(245,230,200,.7);
  white-space: nowrap;
  min-width: 3.5em;
}

.stats-mini {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: .78rem;
  color: rgba(245,230,200,.55);
}

.stats-mini b {
  color: rgba(245,230,200,.85);
  font-family: var(--font-mono);
}

#equipped-gear {
  margin-left: auto;
  font-size: .72rem;
  color: rgba(245,230,200,.45);
}

/* ── Room Header ───────────────────────────────── */
.room-header {
  display: flex;
  align-items: center;
  padding: .35rem .75rem;
  background: rgba(26,14,46,.6);
  border-radius: var(--radius-sm);
}

.room-biome-icon { font-size: 1.1rem; flex-shrink: 0; }

.room-name {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--clr-gold-light);
  flex-shrink: 0;
}

.room-day {
  margin-left: 1rem;
  margin-right: auto;
  font-family: var(--font-heading);
  font-size: .95rem;
  color: rgba(201,168,76,.85);
  white-space: nowrap;
}

.room-biome-name {
  flex-shrink: 0;
  font-size: .75rem;
  color: rgba(245,230,200,.4);
}

/* ── Event Log (main scrollable area) ──────────── */
.event-log-panel {
  background: linear-gradient(135deg, #f7ecd5 0%, #f0dfb8 40%, #e8d5a8 100%);
  border: 2px solid var(--clr-gold-dim);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  position: relative;
}

.event-log-panel::before {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(212,160,23,.15);
  border-radius: calc(var(--radius-md) - 2px);
  pointer-events: none;
}

.event-log-scroll {
  padding: .75rem 1rem;
  max-height: 340px;
  min-height: 200px;
  overflow-y: auto;
  scroll-behavior: smooth;
  position: relative;
  z-index: 1;
}

.event-log-scroll::-webkit-scrollbar { width: 7px; }
.event-log-scroll::-webkit-scrollbar-track { background: rgba(0,0,0,.04); border-radius: 4px; }
.event-log-scroll::-webkit-scrollbar-thumb { background: var(--clr-gold-dim); border-radius: 4px; }

/* Town arrival decoration — floats right, bottom aligned with buttons */
.town-arrival-img {
  float: right;
  margin: -80px 0 0.5rem 1rem;
  width: 160px;
  height: auto;
  opacity: 0.2;
  filter: grayscale(30%);
  pointer-events: none;
}

/* ── Log Entry Enhancements ────────────────────── */
.items-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
}

.items-label, .exits-label {
  font-size: .82rem;
  color: rgba(62,39,35,.5);
  margin-right: .15rem;
}

.exits-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .3rem;
}

.dir-btn {
  padding: .25rem .6rem;
  font-family: var(--font-heading);
  font-size: .82rem;
  background: rgba(212,160,23,.12);
  border: 1px solid var(--clr-gold-dim);
  border-radius: 4px;
  color: var(--clr-text-dark);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dir-btn:hover {
  background: rgba(212,160,23,.25);
  border-color: var(--clr-gold);
}

.enemy-alert {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem .6rem;
  background: rgba(198,40,40,.07);
  border: 1px solid rgba(198,40,40,.2);
  border-radius: var(--radius-sm);
  font-size: .88rem;
}

.enemy-alert .enemy-icon { font-size: 1.2rem; }

.enemy-hp-bar {
  width: 80px;
}

.enemy-hp-bar .bar-track {
  height: 8px;
  background: rgba(0,0,0,.15);
  border-radius: 4px;
  overflow: hidden;
}

.log-entry.combat-status {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .35rem .6rem;
  background: rgba(198,40,40,.07);
  border: 1px solid rgba(198,40,40,.2);
  border-radius: var(--radius-sm);
  font-size: .82rem;
}

.combat-hp-bar {
  width: 100px;
  height: 8px;
  background: rgba(0,0,0,.15);
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
}

.combat-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #c62828, #e53935);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.enemy-stats-text {
  font-size: .72rem;
  color: rgba(62,39,35,.5);
  margin-left: .3rem;
}

.enemy-traits {
  font-size: .68rem;
  color: rgba(198,40,40,.7);
  font-style: italic;
  white-space: nowrap;
}

/* ── Boss Warning ──────────────────────────────── */
.log-entry.boss-warning {
  text-align: center;
  font-size: 1.5rem;
  font-weight: bold;
  color: #c62828;
  padding: .6rem .4rem;
  background: linear-gradient(180deg, rgba(198,40,40,.12) 0%, rgba(198,40,40,.04) 100%);
  border: 2px solid rgba(198,40,40,.3);
  border-radius: var(--radius-sm);
  text-shadow: 0 0 12px rgba(198,40,40,.5);
  animation: boss-flash 0.6s ease-in-out 4;
  letter-spacing: .08em;
}

@keyframes boss-flash {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .7; transform: scale(1.03); }
}

/* ── Boss Special Ability ──────────────────────── */
.log-entry.boss-ability {
  text-align: center;
  font-size: 1.15rem;
  font-weight: bold;
  color: #ff6f00;
  padding: .4rem .6rem;
  background: linear-gradient(90deg, rgba(255,111,0,.08) 0%, rgba(255,111,0,.18) 50%, rgba(255,111,0,.08) 100%);
  border: 1px solid rgba(255,111,0,.3);
  border-radius: var(--radius-sm);
  text-shadow: 0 0 8px rgba(255,111,0,.3);
  animation: ability-glow 0.4s ease-in-out 2;
}

@keyframes ability-glow {
  0%, 100% { box-shadow: 0 0 6px rgba(255,111,0,.2); }
  50% { box-shadow: 0 0 16px rgba(255,111,0,.4); }
}

/* ── Boss Popup Modal ──────────────────────────── */
.boss-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.88);
  animation: boss-overlay-in .3s ease-out;
}

.boss-popup-overlay.open {
  display: flex;
}

@keyframes boss-overlay-in {
  from { background: rgba(198,40,40,.4); }
  to { background: rgba(0,0,0,.88); }
}

.boss-popup {
  text-align: center;
  padding: 2rem 2.5rem;
  max-width: 420px;
  width: 90%;
  background: linear-gradient(180deg, #1a0a0a 0%, #2d1515 40%, #1a0a0a 100%);
  border: 3px solid #c62828;
  border-radius: 12px;
  box-shadow: 0 0 60px rgba(198,40,40,.5), inset 0 0 30px rgba(198,40,40,.1);
  color: #f5e6c8;
  animation: boss-pop-in .4s cubic-bezier(.17,.67,.35,1.3);
}

@keyframes boss-pop-in {
  from { transform: scale(.5) rotate(-3deg); opacity: 0; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}

.boss-popup-skull {
  font-size: 4rem;
  animation: boss-skull-pulse 1s ease-in-out infinite;
}

@keyframes boss-skull-pulse {
  0%, 100% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.15) rotate(-5deg); }
  75% { transform: scale(1.15) rotate(5deg); }
}

.boss-popup-title {
  font-family: var(--font-heading);
  font-size: 2rem;
  color: #ff1744;
  text-shadow: 0 0 20px rgba(255,23,68,.6), 0 0 40px rgba(198,40,40,.3);
  margin: .5rem 0 .25rem;
  letter-spacing: .1em;
  animation: boss-title-glow 1.5s ease-in-out infinite;
}

@keyframes boss-title-glow {
  0%, 100% { text-shadow: 0 0 20px rgba(255,23,68,.6), 0 0 40px rgba(198,40,40,.3); }
  50% { text-shadow: 0 0 30px rgba(255,23,68,.9), 0 0 60px rgba(198,40,40,.5), 0 0 80px rgba(198,40,40,.2); }
}

.boss-popup-subtitle {
  font-size: 1rem;
  color: #e53935;
  margin-bottom: .5rem;
}

.boss-popup-flavor {
  font-size: .85rem;
  color: rgba(245,230,200,.6);
  font-style: italic;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.boss-popup-btn {
  display: inline-block;
  padding: .6rem 2rem;
  background: linear-gradient(180deg, #c62828, #b71c1c);
  color: #fff;
  font-size: 1rem;
  font-weight: bold;
  border: 2px solid #ff5252;
  border-radius: 8px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: .08em;
  transition: transform .15s, box-shadow .15s;
  text-decoration: none;
}

.boss-popup-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(255,23,68,.5);
}

/* ── Controls Panel (dir pad + actions) ────────── */
.controls-panel {
  display: flex;
  gap: .75rem;
  align-items: stretch;
}

.dir-pad {
  display: grid;
  grid-template-columns: 1fr 1.5fr 1fr;
  grid-template-rows: repeat(3, 1fr);
  gap: 3px;
  width: 90px;
  min-height: 80px;
  flex-shrink: 0;
  justify-items: center;
  align-items: center;
}

.dir-pad .dir-row { grid-column: 1 / -1; display: flex; justify-content: center; gap: 3px; }
.dir-pad .dir-center {
  font-size: .6rem;
  color: rgba(212,160,23,.4);
}

.dir-pad .dir-btn {
  width: 44px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  font-weight: bold;
  background: linear-gradient(180deg, rgba(255,255,255,.5), rgba(230,210,170,.6));
  border: 2px solid var(--clr-gold-dim);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dir-pad .dir-btn:hover {
  background: linear-gradient(180deg, rgba(255,255,255,.8), rgba(245,230,200,.85));
  border-color: var(--clr-gold);
  transform: scale(1.05);
}

.controls-panel .action-buttons {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  gap: .35rem;
  padding: .25rem 0;
}

.controls-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  min-width: 0;
}

.controls-panel .action-btn {
  padding: .4rem .8rem;
  font-size: .85rem;
}

/* ── Input Row ─────────────────────────────────── */
.game-compact .input-row {
  display: flex;
  gap: .4rem;
}

.game-compact .input-row input[type="text"] {
  flex: 1;
  padding: .55rem .85rem;
  font-family: var(--font-body);
  font-size: .95rem;
  background: rgba(245,230,200,.9);
  border: 2px solid var(--clr-gold-dim);
  border-radius: var(--radius-sm);
  color: var(--clr-text-dark);
}

.game-compact .input-row input:focus {
  outline: none;
  border-color: var(--clr-gold);
  box-shadow: 0 0 0 3px rgba(212,160,23,.2);
}

.game-compact .input-row .btn {
  padding: .55rem 1.2rem;
  font-size: .9rem;
}

/* ── Collapsible Panels ────────────────────────── */
.collapsibles-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
}

.collapse-panel {
  background: linear-gradient(135deg, #f7ecd5 0%, #e8d5a8 100%);
  border: 2px solid var(--clr-gold-dim);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.collapse-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .45rem .75rem;
  font-family: var(--font-heading);
  font-size: .88rem;
  background: transparent;
  border: none;
  color: var(--clr-text-dark);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.collapse-toggle:hover { background: rgba(255,255,255,.2); }

.toggle-arrow {
  font-size: .6rem;
  transition: transform var(--transition-fast);
  color: rgba(62,39,35,.4);
  display: inline-block;
}

.collapse-toggle.open .toggle-arrow { transform: rotate(90deg); }

.collapse-content {
  display: none;
  padding: .5rem .75rem .75rem;
  border-top: 1px solid rgba(160,120,16,.15);
}

.collapse-content:not(.closed) { display: block; }

/* ── Compact Inventory ─────────────────────────── */
.game-compact .inventory-grid {
  display: flex;
  flex-direction: column;
  gap: .3rem;
}

.game-compact .inv-item {
  display: flex;
  align-items: center;
  gap: .35rem;
  background: rgba(255,255,255,.4);
  border: 1px solid var(--clr-gold-dim);
  border-radius: var(--radius-sm);
  padding: .35rem .5rem;
  font-size: .8rem;
}

.game-compact .inv-item .item-icon { font-size: 1.1rem; }
.game-compact .inv-item .item-name { font-family: var(--font-heading); font-weight: 600; }
.game-compact .inv-item .item-desc {
  margin-left: auto;
  font-size: .72rem;
  color: rgba(62,39,35,.7);
}

/* ── Abandon Button ────────────────────────────── */
.abandon-row {
  text-align: center;
  padding-top: .25rem;
}

.abandon-row .btn {
  font-size: .8rem;
  padding: .35rem 1rem;
  opacity: .7;
}

.abandon-row .btn:hover { opacity: 1; }

/* ═══════════════════════════════════════════════════
   SAVE/LOAD UI
   ═══════════════════════════════════════════════════ */
.save-group {
  border: 1px solid rgba(160,120,16,.2);
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
  margin-bottom: .5rem;
}

.save-group legend {
  font-family: var(--font-heading);
  font-size: .85rem;
  color: var(--clr-text-dark);
  padding: 0 .3rem;
}

.save-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .4rem .5rem;
  background: rgba(255,255,255,.3);
  border-radius: var(--radius-sm);
  margin-top: .3rem;
}

.save-info {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .82rem;
  color: var(--clr-text-dark);
}

.save-class-icon { font-size: 1.1rem; }
.save-room { color: rgba(62,39,35,.5); font-style: italic; }
.save-date { margin-left: auto; font-size: .72rem; color: rgba(62,39,35,.4); }

/* In-game save rows */
.save-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .35rem .5rem;
  background: rgba(255,255,255,.4);
  border-radius: var(--radius-sm);
  margin-bottom: .3rem;
  font-size: .8rem;
}

.save-actions {
  display: flex;
  gap: .25rem;
}

.action-btn.tiny {
  padding: .2rem .5rem;
  font-size: .72rem;
}

.action-btn.danger {
  background: rgba(198,40,40,.1);
  border-color: rgba(198,40,40,.3);
  color: #c62828;
}

.action-btn.danger:hover {
  background: rgba(198,40,40,.2);
}

/* ═══════════════════════════════════════════════════
   MODAL OVERLAY
   ═══════════════════════════════════════════════════ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.open { display: flex; }

.modal-content {
  background: linear-gradient(135deg, #f7ecd5 0%, #e8d5a8 100%);
  border: 2px solid var(--clr-gold-dim);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
  max-width: 680px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  position: relative;
}

.modal-close {
  position: absolute;
  top: .75rem;
  left: auto;
  right: .75rem;
  z-index: 10;
  background: rgba(198,40,40,.1);
  border: 1px solid rgba(198,40,40,.3);
  border-radius: 4px;
  width: 28px;
  height: 28px;
  font-size: .85rem;
  cursor: pointer;
  color: #c62828;
  display: flex;
  align-items: center;
  justify-content: center;
}

.shop-modal-content .modal-close,
.tavern-modal-content .modal-close {
  position: absolute !important;
  left: auto !important;
  right: .75rem !important;
  z-index: 20 !important;
}

.modal-close:hover { background: rgba(198,40,40,.2); }

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  color: var(--clr-text-dark);
  margin-bottom: .25rem;
}

.modal-subtitle {
  font-size: .85rem;
  color: rgba(62,39,35,.5);
  margin-bottom: 1rem;
}

/* Mechanics Box */
.mechanics-box {
  background: rgba(45,27,78,.08);
  border: 1px solid rgba(45,27,78,.2);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  margin-bottom: 1rem;
}

.mechanics-box h3 {
  font-family: var(--font-heading);
  font-size: .95rem;
  color: var(--clr-text-dark);
  margin-bottom: .5rem;
}

.mechanics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}

.mechanics-table th {
  text-align: left;
  padding: .3rem .5rem;
  color: rgba(62,39,35,.7);
  font-weight: 600;
  white-space: nowrap;
}

.mechanics-table td {
  padding: .3rem .5rem;
  color: var(--clr-text-dark);
  font-family: var(--font-mono);
  font-size: .78rem;
}

/* Class Mech Cards */
.class-mech-card {
  background: rgba(255,255,255,.4);
  border: 1px solid var(--clr-gold-dim);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  margin-bottom: .5rem;
}

.class-mech-card h3 {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--clr-text-dark);
  margin-bottom: .5rem;
}

.class-stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}

.class-stats-table td {
  padding: .2rem .5rem;
  color: var(--clr-text-dark);
}

.class-stats-table td:first-child {
  color: rgba(62,39,35,.6);
  font-size: .78rem;
}

.class-stats-table td:nth-child(2) {
  font-family: var(--font-mono);
  text-align: center;
}

.class-stats-table td:last-child {
  text-align: right;
  font-size: .72rem;
  color: rgba(62,39,35,.45);
}

.class-playstyle {
  margin-top: .4rem;
  font-size: .8rem;
  color: rgba(62,39,35,.55);
  font-style: italic;
}

/* Power Rankings */
.power-rankings {
  background: rgba(212,160,23,.1);
  border: 1px solid var(--clr-gold-dim);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  margin-top: 1rem;
}

.power-rankings h3 {
  font-family: var(--font-heading);
  font-size: .95rem;
  color: var(--clr-text-dark);
  margin-bottom: .5rem;
}

.power-rankings ol {
  padding-left: 1.2rem;
  font-size: .82rem;
  color: var(--clr-text-dark);
}

.power-rankings li {
  padding: .2rem 0;
}

.modal-note {
  margin-top: 1rem;
  font-size: .78rem;
  color: rgba(62,39,35,.45);
  text-align: center;
}

/* ── Death Modal ─────────────────────────────────── */
.modal-overlay.death-modal-bg {
  background: rgba(0,0,0,.85);
}

.death-modal {
  max-width: 480px;
  text-align: center;
  background: linear-gradient(180deg, #1a0a0a 0%, #2d1515 40%, #1a0a0a 100%);
  border: 2px solid #c62828;
  color: #f5e6c8;
}

.death-skull {
  font-size: 4rem;
  margin-bottom: .5rem;
  animation: death-pulse 2s ease-in-out infinite;
}

@keyframes death-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: .8; }
}

.death-title {
  font-family: var(--font-heading);
  font-size: 2rem;
  color: #c62828;
  text-shadow: 0 0 20px rgba(198,40,40,.5);
  margin-bottom: .25rem;
}

.death-subtitle {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: rgba(245,230,200,.6);
  margin-bottom: .25rem;
}

.death-cause {
  font-family: var(--font-heading);
  font-size: .95rem;
  color: #c62828;
  margin-bottom: .75rem;
  font-weight: bold;
}

.death-message {
  font-size: .9rem;
  color: rgba(245,230,200,.7);
  font-style: italic;
  margin-bottom: 1rem;
  line-height: 1.4;
}

.death-stats {
  display: flex;
  justify-content: center;
  gap: 1rem;
  font-size: .82rem;
  color: rgba(245,230,200,.4);
  margin-bottom: 1.25rem;
}

.death-actions { margin-bottom: 1rem; }

.death-btn {
  min-width: 200px;
}

.death-saves {
  border-top: 1px solid rgba(198,40,40,.3);
  padding-top: .75rem;
  margin-bottom: .75rem;
}

.death-saves h3 {
  font-family: var(--font-heading);
  font-size: .85rem;
  color: rgba(245,230,200,.5);
  margin-bottom: .5rem;
}

.death-save-row {
  margin-bottom: .3rem;
}

.death-save-row .btn {
  width: 100%;
  font-size: .78rem;
  padding: .4rem .6rem;
  background: rgba(255,255,255,.05);
  border-color: rgba(198,40,40,.3);
  color: rgba(245,230,200,.7);
}

.death-save-row .btn:hover {
  background: rgba(198,40,40,.2);
  color: #f5e6c8;
}

.death-new {
  border-top: 1px solid rgba(198,40,40,.2);
  padding-top: .75rem;
}

/* ═══════════════════════════════════════════════════
   SPELL PANEL
   ═══════════════════════════════════════════════════ */
.spell-item {
  background: rgba(0,0,0,.15);
  border: 1px solid rgba(255,215,0,.15);
  border-radius: var(--radius-sm);
  padding: .5rem .6rem;
  margin-bottom: .4rem;
}

.spell-header {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin-bottom: .25rem;
}

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

.spell-name {
  font-weight: 600;
  font-size: .85rem;
  flex: 1;
  color: #8d6e2c;
}

.spell-mp {
  font-size: .75rem;
  font-family: 'JetBrains Mono', monospace;
  color: rgba(44,24,16,.7);
  white-space: nowrap;
}

.spell-desc {
  font-size: .75rem;
  color: rgba(44,24,16,.82);
  margin-bottom: .3rem;
  line-height: 1.3;
}

.spell-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.spell-type-label {
  font-size: .65rem;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  padding: .15rem .4rem;
  border-radius: 3px;
  background: rgba(141,110,44,.12);
  color: rgba(141,110,44,.9);
  letter-spacing: .5px;
}

.spell-item .action-btn.tiny {
  font-size: .7rem;
  padding: .2rem .5rem;
}

/* ═══ Skill Buttons Block ══════════════════════════════ */
.skill-buttons-wrapper {
  background: linear-gradient(135deg, rgba(247,236,213,.85), rgba(232,213,168,.9));
  border: 2px solid var(--clr-gold-dim);
  border-radius: var(--radius-md);
  padding: .2rem .4rem .25rem;
}

.skill-buttons-label {
  display: block;
  font-family: var(--font-heading);
  font-size: .6rem;
  color: rgba(62,39,35,.5);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .15rem;
  padding-left: .1rem;
}

.skill-buttons {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: .3rem;
}

.skill-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .1rem;
  padding: .2rem .15rem;
  background: linear-gradient(180deg, rgba(255,255,255,.95) 0%, rgba(230,210,170,.95) 100%);
  border: 2px solid var(--clr-gold-dim);
  border-radius: var(--radius-sm);
  color: var(--clr-text-dark);
  cursor: pointer;
  transition: all var(--transition-fast);
  line-height: 1.1;
}

.skill-btn:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(255,255,255,.98) 0%, rgba(245,230,200,.98) 100%);
  border-color: var(--clr-gold);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
}

.skill-btn:active:not(:disabled) {
  transform: translateY(0);
}

.skill-btn.proficient {
  position: relative;
  border-color: var(--clr-gold);
  box-shadow: 0 0 6px rgba(212,160,23,.25);
}

.skill-btn.proficient::after {
  content: '★';
  position: absolute;
  top: 2px;
  right: 3px;
  font-size: .55rem;
  color: var(--clr-gold);
  line-height: 1;
}
}

.skill-btn.proficient:hover:not(:disabled) {
  box-shadow: 0 0 10px rgba(212,160,23,.4), 0 2px 6px rgba(0,0,0,.12);
}

.skill-btn-icon {
  font-size: .95rem;
}

.skill-btn-name {
  font-family: var(--font-heading);
  font-size: .52rem;
  color: rgba(62,39,35,.6);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.skill-btn:disabled {
  opacity: .35 !important;
  pointer-events: none !important;
  cursor: not-allowed;
}

/* Active Buffs Display */
.active-buffs-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  align-items: center;
  padding: 0;
  min-height: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease, margin 0.3s ease;
  margin: 0;
}

.active-buffs-bar.has-buffs {
  padding: .4rem .5rem;
  max-height: 200px;
  margin-bottom: .25rem;
  background: rgba(0,0,0,.08);
  border-radius: 6px;
}

.buff-badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-size: .72rem;
  font-family: 'JetBrains Mono', monospace;
  padding: .2rem .5rem;
  border-radius: 4px;
  white-space: nowrap;
}

.buff-badge .buff-name {
  font-weight: 600;
}

.buff-badge .buff-effect {
  opacity: .85;
}

.buff-badge .buff-duration {
  font-size: .62rem;
  opacity: .7;
  margin-left: .15rem;
}

/* Positive buff — green */
.buff-badge.buff-badge {
  background: rgba(46,125,50,.13);
  color: #2e7d32;
  border: 1px solid rgba(46,125,50,.3);
}

/* Negative debuff — red */
.buff-badge.debuff-badge {
  background: rgba(198,40,40,.12);
  color: #c62828;
  border: 1px solid rgba(198,40,40,.28);
}

/* Old selectors for compat */
#active-buffs {
  margin-bottom: 0;
}

.buffs-label {
  font-size: .7rem;
  color: rgba(44,24,16,.55);
  font-family: 'JetBrains Mono', monospace;
}

.buff-tag {
  font-size: .68rem;
  font-family: 'JetBrains Mono', monospace;
  padding: .15rem .4rem;
  border-radius: 3px;
  background: rgba(46,125,50,.12);
  color: #2e7d32;
  border: 1px solid rgba(46,125,50,.25);
}

/* Spell log entries */
.log-entry.spell {
  color: #ce93d8;
  font-style: italic;
  border-left: 2px solid rgba(206,147,216,.4);
  padding-left: .5rem;
}

/* ═══════════════════════════════════════════════════
   D20 DIE ROLL DISPLAY
   ═══════════════════════════════════════════════════ */
.d20-die {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 4px;
  font-family: var(--font-heading);
  font-size: .9rem;
  font-weight: bold;
  background: linear-gradient(135deg, #37474f, #263238);
  color: #b0bec5;
  border: 2px solid #546e7a;
  margin-right: .4rem;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,.4);
}

.d20-die.crit {
  background: linear-gradient(135deg, #d4a017, #b8860b);
  color: #fff;
  border-color: #ffd54f;
  box-shadow: 0 0 8px rgba(212,160,23,.6);
  animation: die-crit .4s ease;
}

.d20-die.fumble {
  background: linear-gradient(135deg, #c62828, #b71c1c);
  color: #ffcdd2;
  border-color: #ef5350;
  box-shadow: 0 0 6px rgba(198,40,40,.4);
}

@keyframes die-crit {
  0% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.3) rotate(10deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* ═══════════════════════════════════════════════════
   PAPERDOLL — Equipped Gear Slots
   ═══════════════════════════════════════════════════ */
.paperdoll {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .25rem;
  margin-top: .4rem;
  padding: .3rem 0;
}

.gear-slot {
  display: flex;
  align-items: center;
  gap: .25rem;
  background: rgba(0,0,0,.2);
  border: 1px solid rgba(212,160,23,.15);
  border-radius: var(--radius-sm);
  padding: .2rem .4rem;
  min-height: 1.6rem;
}

.slot-label {
  font-size: .85rem;
  opacity: .6;
  flex-shrink: 0;
}

.slot-item {
  font-family: var(--font-mono);
  font-size: .68rem;
  color: var(--clr-gold-light);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot-unequip {
  background: none;
  border: none;
  color: rgba(245,230,200,.3);
  cursor: pointer;
  font-size: .65rem;
  padding: 0 .1rem;
  line-height: 1;
  flex-shrink: 0;
}

.slot-unequip:hover {
  color: var(--clr-accent-red);
}

/* ═══════════════════════════════════════════════════
   INVENTORY ACTIONS
   ═══════════════════════════════════════════════════ */
.inv-actions {
  display: flex;
  gap: .2rem;
  margin-top: .25rem;
}

.inv-item .action-btn.tiny {
  font-size: .68rem;
  padding: .15rem .4rem;
}

/* ═══════════════════════════════════════════════════
   ITEMS ROW (dynamic Take buttons)
   ═══════════════════════════════════════════════════ */
.items-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .3rem;
  padding: .4rem .5rem;
  background: rgba(212,160,23,.08);
  border-radius: var(--radius-sm);
  margin: .3rem 0;
}

.items-label {
  font-size: .82rem;
  color: rgba(245,230,200,.6);
  margin-right: .3rem;
}

.item-btn {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .82rem;
  padding: .25rem .3rem .25rem .6rem;
  background: rgba(0,0,0,.25);
  border: 1px solid rgba(212,160,23,.2);
  color: var(--clr-text);
  border-radius: var(--radius-sm);
}

.item-btn:hover {
  background: rgba(0,0,0,.35);
  border-color: rgba(212,160,23,.4);
}

.item-display {
  color: var(--clr-gold-light);
  font-weight: 500;
}

.item-take {
  padding: .15rem .5rem;
  background: rgba(76,175,80,.2);
  border: 1px solid rgba(76,175,80,.45);
  border-radius: 3px;
  color: #a5d6a7;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}

.item-btn:hover .item-take {
  background: rgba(76,175,80,.35);
  color: #c8e6c9;
}

/* ═══════════════════════════════════════════════════
   HELP MODAL
   ═══════════════════════════════════════════════════ */
.help-modal-content {
  max-width: 640px;
  max-height: 85vh;
  overflow-y: auto;
}

.help-section {
  margin-bottom: 1.2rem;
}

.help-section h3 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--clr-gold-light);
  margin-bottom: .4rem;
  padding-bottom: .2rem;
  border-bottom: 1px solid rgba(212,160,23,.2);
}

.help-section ul {
  list-style: none;
  padding-left: 0;
}

.help-section li {
  font-size: .85rem;
  line-height: 1.5;
  padding: .2rem 0;
  color: var(--clr-text-dark);
}

.help-section li::before {
  content: '›';
  color: var(--clr-gold);
  margin-right: .4rem;
  font-weight: bold;
}

.help-section p {
  font-size: .85rem;
  color: var(--clr-text-body);
  margin-bottom: .4rem;
}

.help-section code {
  background: rgba(0,0,0,.2);
  padding: .1rem .3rem;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: .78rem;
  color: var(--clr-gold-light);
}

/* Help button in action bar */
.help-btn {
  background: rgba(21,101,192,.15);
  border-color: rgba(21,101,192,.3);
  color: #64b5f6;
}

.help-btn:hover {
  background: rgba(21,101,192,.25);
  color: #90caf9;
}

.feedback-btn {
  background: rgba(76,175,80,.12);
  border-color: rgba(76,175,80,.3);
  color: #81c784;
}

.feedback-btn:hover {
  background: rgba(76,175,80,.22);
  color: #a5d6a7;
}

.audio-toggle-btn {
  background: rgba(139,90,43,.15);
  border-color: rgba(139,90,43,.35);
  color: #bcaaa4;
  font-weight: 600;
}

.audio-toggle-btn:hover {
  background: rgba(139,90,43,.25);
  color: #d7ccc8;
}

.audio-toggle-btn.enabled {
  background: rgba(76,175,80,.15);
  border-color: rgba(76,175,80,.35);
  color: #81c784;
}

/* ═══════════════════════════════════════════════════
   VOLUME CONTROLS (click/hover speaker)
   ═══════════════════════════════════════════════════ */
.volume-wrapper {
  position: relative;
  display: inline-block;
  vertical-align: bottom;
}

.volume-popup {
  position: fixed;
  z-index: 9999;
  background: linear-gradient(135deg, #2a2520 0%, #1e1b17 100%);
  border: 1px solid rgba(180,140,80,.4);
  border-radius: var(--radius-md);
  box-shadow: 0 6px 24px rgba(0,0,0,.6);
  padding: .75rem 1rem;
  width: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .45rem;
  pointer-events: auto;
  touch-action: manipulation;
}

.volume-popup-header {
  font-size: .75rem;
  font-weight: 600;
  color: #d4a864;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.volume-row {
  display: flex;
  align-items: center;
  gap: .4rem;
  width: 100%;
}

.volume-label {
  font-size: .7rem;
  color: #b89a6a;
  flex-shrink: 0;
  width: 4.5em;
}

.volume-popup .volume-popup-value {
  font-size: .72rem;
  min-width: 2.5em;
  flex-shrink: 0;
}

.volume-popup input[type="range"] {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(180,140,80,.2);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.volume-popup input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #d4a864;
  border: 2px solid #1e1b17;
  box-shadow: 0 0 6px rgba(212,168,100,.5);
  cursor: pointer;
}

.volume-popup input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #d4a864;
  border: 2px solid #1e1b17;
  box-shadow: 0 0 6px rgba(212,168,100,.5);
  cursor: pointer;
}

.volume-popup-value {
  font-size: .85rem;
  font-weight: 700;
  color: #e8d5a8;
  min-width: 3em;
  text-align: center;
}

.volume-mute-btn {
  margin-top: .25rem;
  padding: .25rem .6rem;
  font-size: .72rem;
  background: rgba(180,140,80,.15);
  border: 1px solid rgba(180,140,80,.3);
  border-radius: var(--radius-sm);
  color: #d4a864;
  cursor: pointer;
  transition: background .15s;
}

.volume-mute-btn:hover {
  background: rgba(180,140,80,.3);
}

/* Mobile: volume popup centered above speaker, shifted right */
@media (max-width: 600px) {
  .volume-popup {
    left: calc(50% + 50px) !important;
    transform: translate(-50%, -50%) !important;
    top: 50% !important;
  }
}

/* ═══════════════════════════════════════════════════
   FEEDBACK BUTTON (action bar)
   ═══════════════════════════════════════════════════ */
.feedback-btn {
  background: rgba(139,90,43,.15);
  border-color: rgba(139,90,43,.3);
  color: #bcaaa4;
}

.feedback-btn:hover {
  background: rgba(139,90,43,.25);
  color: #d7ccc8;
}

/* ═══════════════════════════════════════════════════
   FEEDBACK MODAL
   ═══════════════════════════════════════════════════ */
.feedback-modal-content .feedback-section {
  margin-bottom: .85rem;
}

.feedback-section label {
  display: block;
  font-family: var(--font-heading);
  font-size: .85rem;
  color: var(--clr-text-dark);
  margin-bottom: .3rem;
  font-weight: 600;
}

.feedback-section select,
.feedback-section textarea,
.feedback-section input[type="text"] {
  width: 100%;
  padding: .55rem .75rem;
  background: rgba(255,255,255,.85);
  border: 1px solid var(--clr-gold-dim);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: .9rem;
  color: var(--clr-text-body);
  box-sizing: border-box;
  resize: vertical;
  transition: border-color .2s;
}

.feedback-section select:focus,
.feedback-section textarea:focus,
.feedback-section input[type="text"]:focus {
  outline: none;
  border-color: var(--clr-accent-blue);
  box-shadow: 0 0 0 2px rgba(21,101,192,.15);
}

.feedback-section textarea::placeholder,
.feedback-section input[type="text"]::placeholder {
  color: rgba(62,39,35,.45);
  font-style: italic;
}

.feedback-modal-content .btn-primary {
  width: 100%;
  margin-top: .5rem;
  padding: .7rem;
  font-size: 1rem;
  font-weight: 600;
}

.feedback-result {
  margin-top: .85rem;
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  line-height: 1.5;
  display: none;
}

.feedback-result:has(+ .feedback-result),
.feedback-result.success {
  display: block;
  background: rgba(76,175,80,.1);
  border: 1px solid rgba(76,175,80,.3);
  color: #2e7d32;
}

.feedback-result.error {
  display: block;
  background: rgba(198,40,40,.1);
  border: 1px solid rgba(198,40,40,.3);
  color: #c62828;
}

.feedback-sub {
  display: block;
  font-size: .8rem;
  margin-top: .25rem;
  opacity: .75;
}

.feedback-help-links {
  margin-top: 1.25rem;
  padding-top: .75rem;
  border-top: 1px solid rgba(160,120,16,.2);
}

.feedback-help-links h3 {
  font-family: var(--font-heading);
  font-size: .95rem;
  color: var(--clr-text-dark);
  margin-bottom: .4rem;
}

.feedback-help-links ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.feedback-help-links li {
  margin-bottom: .3rem;
}

.feedback-help-links a {
  color: var(--clr-accent-blue);
  text-decoration: none;
  font-size: .88rem;
}

.feedback-help-links a:hover {
  text-decoration: underline;
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE TWEAKS (compact layout)
   ═══════════════════════════════════════════════════ */
@media (max-width: 600px) {
  .game-compact { max-width: 100%; }
  .bars-row { gap: .3rem; }
  .mini-bar .bar-val { font-size: .65rem; min-width: 2.8em; }
  .stats-mini { gap: .4rem; font-size: .72rem; }
  .paperdoll { grid-template-columns: repeat(3, 1fr); gap: .2rem; }
  .gear-slot { padding: .15rem .3rem; min-height: 1.4rem; }
  .slot-item { font-size: .6rem; }
  .slot-label { font-size: .75rem; }
  .event-log-scroll { max-height: 260px; }
  .controls-panel { flex-direction: column; align-items: center; gap: .35rem; }
  .dir-pad { width: 90px; min-height: 72px; margin: 0 auto; }
  .controls-right { flex-direction: column; width: 100%; gap: .3rem; }
  .controls-panel .action-buttons { flex-wrap: wrap; justify-content: center; }
  .skill-buttons-wrapper { padding: .15rem .25rem .2rem; max-width: 100%; box-sizing: border-box; overflow: hidden; }
  .skill-buttons { grid-template-columns: repeat(4, 1fr) !important; gap: .2rem; }
  .skill-btn { padding: .15rem .1rem; }
  .skill-btn-icon { font-size: .85rem; }
  .skill-btn-name { font-size: .46rem; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .collapsibles-row { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════
   TOWN ROW (Shop/Tavern buttons)
   ═══════════════════════════════════════════════════ */
.town-row {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  padding: .4rem .5rem;
  background: rgba(212,160,23,.1);
  border-radius: var(--radius-sm);
  margin: .3rem 0;
}

.town-btn {
  font-size: .85rem;
  padding: .4rem .8rem;
  background: linear-gradient(180deg, rgba(212,160,23,.15), rgba(212,160,23,.08));
  border-color: var(--clr-gold-dim);
}

.town-btn:hover {
  background: linear-gradient(180deg, rgba(212,160,23,.3), rgba(212,160,23,.15));
  border-color: var(--clr-gold);
}

/* Shop items — flex row with Buy button pushed right */
.log-entry.shop-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  padding: .35rem .5rem;
  background: rgba(212,160,23,.06);
  border-radius: var(--radius-sm);
  margin: .2rem 0;
}

.shop-item-label {
  flex: 1;
  min-width: 0;
}

/* ── Quest Offer ── */
.log-entry.quest-offer {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem .7rem;
  background: rgba(255,152,0,.1);
  border: 1px solid rgba(255,152,0,.3);
  border-radius: var(--radius-sm);
  margin: .4rem 0;
  flex-wrap: wrap;
}

.tavern-chat-entry.quest-offer {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem .7rem;
  background: rgba(255,152,0,.1);
  border: 1px solid rgba(255,152,0,.3);
  border-radius: var(--radius-sm);
  margin: .3rem 0;
  flex-wrap: wrap;
}

.quest-accept-btn {
  flex-shrink: 0;
  padding: .3rem .6rem;
  font-size: 12px;
}

/* ── Quests Panel ── */
#quests-list {
  font-size: 13px;
  line-height: 1.5;
}
.quest-entry {
  padding: .4rem .5rem;
  margin: .3rem 0;
  background: rgba(212,160,23,.08);
  border-radius: 4px;
  border-left: 3px solid var(--clr-accent);
}
.quest-progress-bar {
  display: inline-block;
  margin: 0 .3rem;
}

/* ── Compendium Panel ── */
.compendium-tabs { display: flex; gap: .5rem; margin-bottom: .75rem; }
.tab-btn {
  flex: 1;
  padding: .5rem .8rem;
  border: 2px solid rgba(255,255,255,.15);
  border-radius: 6px;
  background: rgba(0,0,0,.3);
  color: #e0e0e0;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  transition: all .15s;
}
.tab-btn.active {
  background: rgba(21,101,192,.35);
  color: #ffffff;
  border-color: #42a5f5;
  box-shadow: 0 0 8px rgba(66,165,245,.25);
}
.tab-btn:hover:not(.active) {
  background: rgba(255,255,255,.08);
  color: #ffffff;
  border-color: rgba(255,255,255,.3);
}

.compendium-search { margin-bottom: .75rem; }
.compendium-search input { width: 100%; padding: .4rem .6rem; border: 1px solid var(--clr-border); border-radius: 4px; background: var(--clr-bg-dark); color: var(--clr-text-body); font-size: 13px; box-sizing: border-box; }

.comp-group { font-size: 13px; color: var(--clr-accent); margin: .75rem 0 .25rem; border-bottom: 1px solid var(--clr-border); padding-bottom: .2rem; }
.comp-list { display: flex; flex-direction: column; gap: .3rem; }

.comp-item { padding: .4rem .5rem; border: 1px solid var(--clr-border); border-radius: 4px; background: var(--clr-bg-dark); font-size: 12px; }
.comp-icon { margin-right: .3rem; }
.comp-rarity { float: right; font-size: 10px; text-transform: uppercase; letter-spacing: .5px; }
.comp-stat { display: inline-block; margin-left: .4rem; color: var(--clr-text-muted); }
.comp-value { display: inline-block; margin-left: .4rem; }
.comp-stats { color: var(--clr-text-muted); font-size: 11px; margin-top: .15rem; }
.comp-traits { font-size: 11px; margin-top: .15rem; }
.comp-desc { color: var(--clr-text-body); font-style: italic; margin-top: .2rem; font-size: 11px; }

.comp-pagination-info {
  font-size: 11px;
  color: var(--clr-text-muted);
  text-align: center;
  padding: .3rem 0;
  margin-bottom: .5rem;
}

.comp-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .5rem 0;
  margin-top: .5rem;
  border-top: 1px solid var(--clr-border);
}

/* ── Version Badge ── */
.game-header .title-text {
  display: inline;
}
.version-badge {
  font-size: 0.42em;
  font-family: var(--font-body);
  font-weight: 700;
  color: #c8e6ff;
  letter-spacing: 0.08em;
  transform: rotate(-12deg);
  opacity: 0.95;
  pointer-events: none;
  user-select: none;
  text-shadow: 0 0 6px rgba(200,230,255,0.4), 0 1px 3px rgba(0,0,0,0.8);
  margin-left: -0.6em;
  vertical-align: 0.5em;
}

/* ── Shop Modal ─────────────────────────────────── */
.shop-modal-content {
  max-width: 720px;
  position: relative;
  overflow: hidden;
}

.shop-modal-content::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url('images/rpg-shop-01.png') center center / cover no-repeat;
  opacity: 0.12;
  pointer-events: none;
  z-index: 0;
}

.shop-modal-content > * {
  position: relative;
  z-index: 1;
}

.shop-split {
  display: flex;
  gap: 1rem;
}

.shop-panel {
  flex: 1;
  min-width: 0;
}

.shop-panel-title {
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--clr-text-dark);
  border-bottom: 1px solid rgba(0,0,0,.12);
  padding-bottom: 0.35rem;
  margin: 0 0 0.5rem 0;
}

.shop-gold {
  text-align: right;
  font-family: var(--font-mono);
  font-size: .9rem;
  color: var(--clr-gold);
  margin: -0.5rem 0 0.75rem 0;
}

.shop-items-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.shop-sell-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

/* ── Shop List Scrollbars ─────────────────────── */
.shop-items-list::-webkit-scrollbar,
.shop-sell-list::-webkit-scrollbar {
  width: 6px;
}
.shop-items-list::-webkit-scrollbar-track,
.shop-sell-list::-webkit-scrollbar-track {
  background: rgba(0,0,0,.05);
  border-radius: 3px;
}
.shop-items-list::-webkit-scrollbar-thumb,
.shop-sell-list::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,.2);
  border-radius: 3px;
}
.shop-items-list::-webkit-scrollbar-thumb:hover,
.shop-sell-list::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,.35);
}

.shop-modal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0,0,0,.05);
  border: 1px solid rgba(0,0,0,.1);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  gap: 0.5rem;
}

.shop-modal-item .item-label {
  flex: 1;
  font-size: .9rem;
}

.shop-modal-item .item-desc {
  font-size: .75rem;
  color: rgba(62,39,35,.6);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}

.shop-modal-item .item-price {
  font-family: var(--font-mono);
  font-size: .85rem;
  color: var(--clr-gold);
  white-space: nowrap;
}

.shop-sell-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0,0,0,.05);
  border: 1px solid rgba(0,0,0,.1);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  gap: 0.5rem;
}

.shop-sell-item .item-label {
  flex: 1;
  font-size: .9rem;
}

.shop-sell-item .item-desc {
  font-size: .75rem;
  color: rgba(62,39,35,.6);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.shop-sell-item .item-sell-price {
  font-family: var(--font-mono);
  font-size: .85rem;
  color: var(--clr-gold);
  white-space: nowrap;
}

/* ── Tavern Modal ───────────────────────────────── */
.tavern-modal-content {
  max-width: 540px;
  position: relative;
  overflow: hidden;
}

.tavern-modal-content::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url('images/rpg-tavern-01.png') center center / cover no-repeat;
  opacity: 0.12;
  pointer-events: none;
  z-index: 0;
}

.tavern-modal-content > * {
  position: relative;
  z-index: 1;
}

.tavern-patrons {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.tavern-patron {
  background: rgba(0,0,0,.04);
  border: 1px solid rgba(0,0,0,.08);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.65rem;
  font-size: .88rem;
}

.tavern-patron strong {
  color: var(--clr-text-dark);
}

.tavern-chat-log {
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 0.75rem;
  padding: 0.5rem;
  background: rgba(0,0,0,.03);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.tavern-chat-entry {
  font-size: .85rem;
  color: var(--clr-text-body);
  line-height: 1.4;
}

.tavern-chat-entry.player-said {
  color: var(--clr-gold);
  font-style: italic;
}

.tavern-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.tavern-input-row {
  display: flex;
  gap: 0.4rem;
}

.tavern-input-row input {
  flex: 1;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.6);
  font-family: var(--font-body);
  font-size: .85rem;
  color: var(--clr-text-dark);
}

.tavern-input-row input::placeholder {
  color: var(--clr-text-muted);
}



/* ── Map Modal & Grid ── */
.map-modal-content {
  max-width: 95vw;
  width: 1100px;
  background: linear-gradient(145deg, #f5e6c8 0%, #e8d5a8 30%, #f0dbb8 60%, #e2cc9a 100%);
  border: 3px solid #8d6e63;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0,0,0,.5), inset 0 0 60px rgba(139,90,43,.15);
  padding: .75rem 1rem;
  position: relative;
  overflow: hidden;
}

.map-modal-content::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='.8' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100' height='100' filter='url(%23n)' opacity='.04'/%3E%3C/svg%3E");
  pointer-events: none;
  border-radius: 8px;
}

.map-modal-content .modal-title {
  font-family: 'Georgia', serif;
  color: #4e342e;
  text-shadow: 1px 1px 0 rgba(255,255,255,.5);
  margin-bottom: .25rem;
  font-size: 1.1rem;
}

.map-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .4rem;
}

.map-legend {
  margin: 0;
  padding: .25rem .5rem;
  background: rgba(139,90,43,.08);
  border-radius: 6px;
  border: 1px dashed #a1887f;
}

.map-legend-items {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  font-size: .7rem;
}

.legend-item {
  padding: 1px 5px;
  background: rgba(255,255,255,.4);
  border-radius: 4px;
  white-space: nowrap;
}

.map-container {
  position: relative;
  max-height: 75vh;
  overflow: hidden;
  padding: 0;
  background: rgba(0,0,0,.05);
  border-radius: 6px;
  border: 2px solid #a1887f;
}

.map-zoom-wrapper {
  width: 100%;
  height: 100%;
  min-height: 65vh;
  overflow: hidden;
  cursor: grab;
  position: relative;
}

.map-zoom-wrapper:active {
  cursor: grabbing;
}

.map-zoom-inner {
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
  transition: transform 0.1s ease-out;
}

/* ── Fantasy SVG Map ─────────────────────────────── */
.fantasy-map {
  width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

.map-bg {
  filter: url(#parchment-texture);
}

.map-path {
  stroke: #8d6e63;
  stroke-width: 1.5;
  fill: none;
  opacity: 0.6;
  stroke-dasharray: 4 2;
}

.marker-bg {
  transition: r .2s, stroke-width .2s;
  cursor: default;
}

.map-marker:hover .marker-bg {
  r: 20;
  stroke-width: 3;
  filter: drop-shadow(0 0 6px rgba(0,0,0,.3));
}

.map-marker.current .marker-bg {
  fill: #ff8f00 !important;
  stroke: #e65100 !important;
  stroke-width: 3;
  animation: fantasy-pulse 2s ease-in-out infinite;
}

.marker-icon {
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.2));
}

.map-label {
  font-family: 'Georgia', serif;
  pointer-events: none;
  user-select: none;
  text-shadow: 0 0 4px rgba(245,230,200,.9), 0 0 4px rgba(245,230,200,.9);
}

.compass-rose {
  opacity: 0.8;
}

@keyframes fantasy-pulse {
  0%, 100% { filter: drop-shadow(0 0 4px rgba(255,143,0,.4)); }
  50%      { filter: drop-shadow(0 0 12px rgba(255,143,0,.8)); }
}

.map-note {
  margin-top: .35rem;
  font-size: .7rem;
  color: #5d4037;
  font-style: italic;
  padding: .25rem .5rem;
  background: rgba(139,90,43,.06);
  border-radius: 4px;
  border-left: 3px solid #a1887f;
}

.map-zoom-controls {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  z-index: 10;
}

.map-zoom-btn {
  width: 28px;
  height: 28px;
  border: 1.5px solid #8d6e63;
  border-radius: 4px;
  background: rgba(245,230,200,0.9);
  color: #4e342e;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.map-zoom-btn:hover {
  background: rgba(255,255,255,0.9);
}
