/* ═══════════════════════════════════════════════════════
   InfiniteRPG — 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;
}

@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);
  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;
  position: relative;
}

.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 ─────────────────────────────────── */
.game-logo {
  width: clamp(80px, 18vw, 140px);
  height: auto;
  display: block;
  margin: 0 auto .75rem;
  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;
}

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

/* ═══════════════════════════════════════════════════
   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;
}

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

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

/* ═══════════════════════════════════════════════════
   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,.55);
}

/* ── 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; }
.item-btn { font-size:.85rem; padding:.3rem .7rem; }
.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;
}

/* ═══════════════════════════════════════════════════
   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; }
}

/* ═══════════════════════════════════════════════════
   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;
}

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

.action-btn.tiny {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
}

/* ═══════════════════════════════════════════════════
   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;
}

.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;
  gap: .4rem;
  padding: .35rem .75rem;
  background: rgba(26,14,46,.6);
  border-radius: var(--radius-sm);
}

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

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

.room-biome-name {
  margin-left: auto;
  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; }

/* ── 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;
}

/* ── 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-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,.45);
}

/* ── 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;
  right: .75rem;
  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;
}

.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: .75rem;
}

.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;
}

/* ═══════════════════════════════════════════════════
   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; }
  .event-log-scroll { max-height: 260px; }
  .controls-panel { flex-direction: column; align-items: stretch; }
  .dir-pad { width: 100%; min-height: auto; justify-content: center; }
  .collapsibles-row { grid-template-columns: 1fr; }
}
