/* =====================================================================
   Embervale theme
   Applying UI UX Pro Max priorities:
     §1 Accessibility    — visible focus rings, 4.5:1 contrast, aria-live
     §2 Touch            — 44px minimum interactive area, 8px spacing
     §3 Performance      — CSS-only motion, reserved layout, no heavy shadows
     §4 Style selection  — one consistent aesthetic: parchment-on-obsidian
     §5 Layout           — mobile-first with three-pane desktop grid
     §6 Typography       — Cinzel display / Crimson Pro body / JetBrains Mono mechanics
     §7 Animation        — 150-300ms durations, ease-out enter, transform/opacity only
     §8 Forms            — visible labels, inline error, disabled states
   ===================================================================== */

:root {
  /* Semantic color tokens (never use raw hex in components) */
  --ink-obsidian: #0a0908;
  --ink-char:     #14100c;
  --ink-soot:     #1d1812;
  --ink-smoke:    #2a2219;
  --ink-ash:      #3d3328;

  --parch:        #e8d9b8;
  --parch-dim:    #b8a688;
  --parch-muted:  #8a7859;

  --ember:        #d98a3a;       /* primary accent */
  --ember-bright: #f0a353;
  --ember-deep:   #9e5a1c;

  --leaf:         #6a8e52;       /* success / HP */
  --wound:        #c44a3c;       /* damage / danger */
  --arcane:       #8d6eb8;       /* magic / cast */
  --gold-coin:    #d4af47;

  --border-soft:  rgba(232, 217, 184, 0.12);
  --border-mid:   rgba(232, 217, 184, 0.22);
  --border-hot:   rgba(217, 138, 58, 0.55);

  /* Elevation scale (consistent, not random) */
  --shadow-1: 0 1px 2px rgba(0,0,0,0.35);
  --shadow-2: 0 4px 12px rgba(0,0,0,0.45);
  --shadow-3: 0 12px 40px rgba(0,0,0,0.55);
  --glow-ember: 0 0 14px rgba(217,138,58,0.35);

  /* Radii & spacing (4/8 rhythm) */
  --r-sm: 4px;
  --r:    8px;
  --r-md: 12px;
  --r-lg: 20px;

  /* Motion tokens */
  --dur-fast: 150ms;
  --dur:      220ms;
  --dur-slow: 320ms;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  /* Type */
  --font-display: "Cinzel", "Trajan Pro", Georgia, serif;
  --font-body:    "Crimson Pro", Georgia, "Times New Roman", serif;
  --font-mono:    "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

/* ---- Base ---- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { color-scheme: dark; }
body {
  background: var(--ink-obsidian);
  color: var(--parch);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(217,138,58,0.08), transparent 60%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(141,110,184,0.06), transparent 60%);
}

h1, h2, h3, h4 { font-family: var(--font-display); letter-spacing: 0.04em; margin: 0; }
h1 { font-weight: 700; }
h2, h3, h4 { font-weight: 500; }
p  { margin: 0 0 0.7em; }

/* Any number-heavy text uses tabular figures so HP doesn't jitter when it changes */
.num, [data-bind="player-gold"], .hp, .stat-value { font-variant-numeric: tabular-nums; }

/* ---- A11y: focus ring is always visible ---- */
:focus-visible {
  outline: 2px solid var(--ember-bright);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
.sr {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* ---- Buttons (≥44px per UI UX Pro Max rule §2) ---- */
.btn, .icon-btn, .btn-ghost {
  font-family: var(--font-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 13px;
  border: 1px solid var(--border-mid);
  background: var(--ink-soot);
  color: var(--parch);
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--r);
  cursor: pointer;
  transition:
    background var(--dur) var(--ease-out),
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur) var(--ease-out),
    border-color var(--dur) var(--ease-out);
}
.btn:hover:not(:disabled), .icon-btn:hover:not(:disabled) {
  background: var(--ink-smoke);
  border-color: var(--border-hot);
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled, .icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(180deg, var(--ember), var(--ember-deep));
  border-color: var(--ember);
  color: var(--ink-obsidian);
  font-weight: 700;
  box-shadow: var(--shadow-2), var(--glow-ember);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--ember-bright), var(--ember));
}

.icon-btn {
  min-width: 44px;
  padding: 0 12px;
  font-size: 16px;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border-soft);
  color: var(--parch-dim);
  font-size: 12px;
  min-height: 36px;    /* visually secondary; still large enough with hit-slop */
  padding: 0 12px;
}

/* ---- Fields ---- */
.field { display: block; margin-bottom: 16px; }
.field-label {
  display: block;
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--parch-dim);
  margin-bottom: 6px;
}
.field input, .field select, .field textarea, textarea#action-input, input#battle-action-input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  background: var(--ink-char);
  border: 1px solid var(--border-mid);
  color: var(--parch);
  font-family: var(--font-body);
  font-size: 16px;        /* 16 min to prevent iOS auto-zoom */
  border-radius: var(--r);
  transition: border-color var(--dur) var(--ease-out);
}
.field input:focus, .field select:focus, textarea:focus {
  border-color: var(--ember);
  outline-offset: 0;
}
.form-error { color: var(--wound); font-size: 14px; margin-top: 8px; }
.hint-muted { color: var(--parch-muted); font-size: 13px; }

/* ---- Flash notifications ---- */
.flash-stack {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 1000; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.flash {
  pointer-events: auto;
  padding: 10px 16px;
  border-radius: var(--r);
  background: var(--ink-smoke);
  border: 1px solid var(--border-mid);
  box-shadow: var(--shadow-2);
  animation: slide-in var(--dur-slow) var(--ease-out);
}
.flash-error   { border-color: var(--wound); }
.flash-warning { border-color: var(--ember); }
@keyframes slide-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* =====================================================================
   Auth pages
   ===================================================================== */
.page-auth {
  display: grid; place-items: center; min-height: 100dvh;
}
.auth-shell {
  display: grid; grid-template-columns: minmax(320px, 460px);
  gap: 40px; padding: 24px;
}
@media (min-width: 900px) {
  .auth-shell { grid-template-columns: 460px 360px; align-items: center; }
}

.auth-card {
  background: linear-gradient(160deg, var(--ink-soot), var(--ink-char));
  border: 1px solid var(--border-soft);
  padding: 40px 32px;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
}
.display-title {
  font-size: clamp(40px, 6vw, 56px);
  line-height: 1;
  text-align: center;
  margin: 0 0 8px;
  background: linear-gradient(180deg, var(--parch), var(--ember));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 10px rgba(217,138,58,0.15));
}
.subtitle {
  text-align: center;
  font-style: italic;
  color: var(--parch-dim);
  margin-bottom: 32px;
}
.auth-form .btn-primary { width: 100%; margin-top: 8px; }
.auth-aside {
  text-align: center;
  margin-top: 24px;
  color: var(--parch-dim);
  font-size: 14px;
}
.auth-aside a { color: var(--ember-bright); text-decoration: none; border-bottom: 1px dotted var(--ember); }
.auth-aside a:hover { color: var(--parch); }

.auth-lore {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 18px;
  color: var(--parch-muted);
  line-height: 1.8;
}
.lore-line   { animation: fade-up 800ms var(--ease-out); }
.lore-line-2 { animation: fade-up 800ms var(--ease-out) 200ms backwards; opacity: 0.7; }
@keyframes fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* =====================================================================
   Home
   ===================================================================== */
.page-home { overflow: hidden; }
.home-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 1fr auto auto;
  align-items: center;
  justify-items: center;
  padding: 24px;
  position: relative;
}
.home-title-block { text-align: center; margin-top: 4vh; }
.home-title { font-size: clamp(56px, 10vw, 96px); }
.home-subtitle {
  font-style: italic;
  color: var(--parch-dim);
  margin-top: 6px;
}

/* Home screen menu items */
.home-menu-item {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 480px;
  max-width: 90vw;
  height: 72px;
  padding: 0 28px;
  background: transparent;
  border: 1px solid var(--border-soft);
  border-left: 3px solid transparent;
  color: var(--parch);
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    border-color var(--dur) var(--ease-out),
    transform var(--dur-fast) var(--ease-out),
    background var(--dur) var(--ease-out);
}
.home-menu-item:hover {
  border-left-color: var(--ember);
  background: rgba(217,138,58,0.05);
  transform: translateX(4px);
}
.home-menu-item:active { transform: translateX(4px) scale(0.97); }
.home-menu-item .menu-icon {
  color: var(--ember);
  font-size: 20px;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}
.home-menu {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}
.home-credits {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--parch-muted);
  margin-bottom: 10px;
}
.home-logout {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10;
}
.home-logout .btn-ghost { min-height: 44px; }

/* Ember particles */
.ember-particle {
  position: fixed;
  border-radius: 50%;
  background: var(--ember);
  pointer-events: none;
  animation: float-up linear infinite;
}
.home-embers .ember-particle:nth-child(odd) { width: 2px; height: 2px; }
.home-embers .ember-particle:nth-child(even) { width: 3px; height: 3px; opacity: 0.5; }
.home-embers .ember-particle:nth-child(1) { left: 4%; bottom: 0; animation-duration: 11s; }
.home-embers .ember-particle:nth-child(2) { left: 12%; bottom: -10vh; animation-duration: 14s; }
.home-embers .ember-particle:nth-child(3) { left: 18%; bottom: -8vh; animation-duration: 12s; }
.home-embers .ember-particle:nth-child(4) { left: 27%; bottom: -14vh; animation-duration: 17s; }
.home-embers .ember-particle:nth-child(5) { left: 35%; bottom: -6vh; animation-duration: 13s; }
.home-embers .ember-particle:nth-child(6) { left: 42%; bottom: -12vh; animation-duration: 15s; }
.home-embers .ember-particle:nth-child(7) { left: 51%; bottom: -5vh; animation-duration: 18s; }
.home-embers .ember-particle:nth-child(8) { left: 59%; bottom: -9vh; animation-duration: 16s; }
.home-embers .ember-particle:nth-child(9) { left: 66%; bottom: -7vh; animation-duration: 12s; }
.home-embers .ember-particle:nth-child(10) { left: 74%; bottom: -11vh; animation-duration: 14s; }
.home-embers .ember-particle:nth-child(11) { left: 82%; bottom: -4vh; animation-duration: 19s; }
.home-embers .ember-particle:nth-child(12) { left: 89%; bottom: -12vh; animation-duration: 13s; }
.home-embers .ember-particle:nth-child(13) { left: 94%; bottom: -8vh; animation-duration: 16s; }
.home-embers .ember-particle:nth-child(14) { left: 23%; bottom: -10vh; animation-duration: 15s; }
.home-embers .ember-particle:nth-child(15) { left: 71%; bottom: -9vh; animation-duration: 11s; }
@keyframes float-up {
  0%   { opacity: 0; transform: translateY(0) scale(1); }
  10%  { opacity: 0.7; }
  90%  { opacity: 0.2; }
  100% { opacity: 0; transform: translateY(-100vh) scale(0.3); }
}

/* Decorative divider */
.title-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 320px;
  margin: 16px auto;
  color: var(--ember);
}
.title-divider::before,
.title-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--ember-deep), transparent);
}

.home-panel {
  width: min(980px, 94vw);
  max-height: 62vh;
  overflow: auto;
  background: linear-gradient(160deg, var(--ink-soot), var(--ink-char));
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  padding: 20px;
  animation: fade-up var(--dur) var(--ease-out);
}
.home-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.home-panel-head .btn-ghost { min-height: 44px; }
.home-campaign-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.home-campaign-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) 90px minmax(140px, 1fr) 90px auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border-soft);
  border-radius: var(--r);
  padding: 10px 12px;
}
.home-campaign-name { font-family: var(--font-display); }
.home-campaign-code {
  font-family: var(--font-mono);
  letter-spacing: 0.2em;
  color: var(--ember-bright);
}
.home-campaign-meta { color: var(--parch-dim); font-size: 13px; }
.home-join-form { margin-top: 14px; border-top: 1px solid var(--border-soft); padding-top: 14px; }
.home-help h3 {
  margin-top: 14px;
  margin-bottom: 6px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}
.home-help { padding-right: 4px; }
#new-game-modal[open] > .modal-head,
#new-game-modal[open] > .modal-body {
  animation: modal-pop 220ms var(--ease-out);
}
@keyframes modal-pop {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.char-rolls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.roll-counter {
  font-family: var(--font-mono);
  color: var(--parch-muted);
  font-size: 12px;
}
.char-rolls .btn-ghost { min-height: 44px; }

@media (max-width: 760px) {
  .home-campaign-row {
    grid-template-columns: 1fr;
    align-items: start;
  }
}

/* Follow-up #7 scroll-home overrides */
.page-home {
  background: #0a0806;
  background-image: none;
}
.home-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.scroll-container {
  position: relative;
  width: 600px;
  max-width: 92vw;
  margin: 0 auto;
  z-index: 2;
}
.scroll-top {
  height: 60px;
  background: linear-gradient(180deg, #8b6030 0%, #c4a060 20%, #e8d098 45%, #c4a060 70%, #8b6030 100%);
  border-radius: 50% / 30px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.6), inset 0 2px 4px rgba(255,255,255,0.15), inset 0 -2px 4px rgba(0,0,0,0.3);
  position: relative;
  z-index: 2;
}
.scroll-body {
  background: linear-gradient(180deg, #d4a84b 0%, #e8c878 8%, #f0d890 20%, #ecdda0 50%, #f0d890 80%, #e8c878 92%, #d4a84b 100%);
  padding: 40px 60px 50px;
  position: relative;
  z-index: 1;
  box-shadow: inset 4px 0 8px rgba(0,0,0,0.15), inset -4px 0 8px rgba(0,0,0,0.15), 0 8px 32px rgba(0,0,0,0.5);
}
.scroll-body::before,
.scroll-body::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 30px;
  pointer-events: none;
}
.scroll-body::before {
  left: 0;
  background: linear-gradient(to right, rgba(0,0,0,0.2), transparent);
}
.scroll-body::after {
  right: 0;
  background: linear-gradient(to left, rgba(0,0,0,0.2), transparent);
}
.scroll-bottom {
  height: 60px;
  background: linear-gradient(180deg, #8b6030 0%, #c4a060 20%, #e8d098 45%, #c4a060 70%, #8b6030 100%);
  border-radius: 50% / 30px;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.6), inset 0 2px 4px rgba(255,255,255,0.15), inset 0 -2px 4px rgba(0,0,0,0.3);
  position: relative;
  z-index: 2;
}
.scroll-title {
  font-family: var(--font-display);
  font-size: clamp(52px, 8vw, 88px);
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.12em;
  color: #3d1a06;
  text-shadow: 0 1px 0 rgba(255,255,255,0.2), 0 2px 6px rgba(0,0,0,0.4);
  margin: 0 0 32px;
  position: relative;
  z-index: 10;
}
.dragon-svg {
  position: absolute;
  top: -30px;
  left: 0;
  width: 100%;
  height: 160px;
  z-index: 5;
  pointer-events: none;
  overflow: visible;
}
.dragon-body,
.dragon-body-highlight {
  transform-origin: 300px 60px;
  animation: dragon-breathe 3.5s ease-in-out infinite;
}
.dragon-head {
  transform-origin: 570px 25px;
  animation: dragon-sway 4s ease-in-out infinite;
}
.dragon-flame {
  transform-origin: 35px 8px;
  animation: flame-flicker 0.4s ease-in-out infinite alternate;
}
.dragon-wing-left {
  transform-origin: 180px 52px;
  animation: wing-idle-left 5s ease-in-out infinite;
}
.dragon-wing-right {
  transform-origin: 400px 50px;
  animation: wing-idle-right 5s ease-in-out infinite;
}
@keyframes dragon-breathe {
  0%, 100% { transform: scaleY(1); opacity: 1; }
  50% { transform: scaleY(1.04); opacity: 0.95; }
}
@keyframes dragon-sway {
  0%, 100% { transform: rotate(-3deg) translateY(0); }
  25% { transform: rotate(2deg) translateY(-2px); }
  75% { transform: rotate(-1deg) translateY(1px); }
}
@keyframes flame-flicker {
  0% { transform: scale(1) skewX(0deg); opacity: 0.8; }
  100% { transform: scale(1.15) skewX(5deg); opacity: 1; }
}
@keyframes wing-idle-left {
  0%, 100% { transform: rotate(0deg); }
  40% { transform: rotate(-8deg) translateY(-3px); }
  60% { transform: rotate(-6deg) translateY(-2px); }
}
@keyframes wing-idle-right {
  0%, 100% { transform: rotate(0deg); }
  40% { transform: rotate(8deg) translateY(-3px); }
  60% { transform: rotate(6deg) translateY(-2px); }
}
.scroll-menu-item {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  height: 64px;
  padding: 0 24px;
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(61, 26, 6, 0.25);
  color: #3d1a06;
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background var(--dur) var(--ease-out), letter-spacing var(--dur) var(--ease-out), transform var(--dur-fast) var(--ease-out);
  text-align: left;
}
.scroll-menu-item:first-of-type { border-top: 1px solid rgba(61,26,6,0.25); }
.scroll-menu-item:hover {
  background: rgba(61, 26, 6, 0.08);
  letter-spacing: 0.26em;
  transform: translateX(6px);
}
.scroll-menu-item:active { transform: translateX(6px) scale(0.98); }
.scroll-menu-item .menu-icon {
  color: #8b3010;
  font-size: 18px;
  width: 24px;
  text-align: center;
}
.scroll-menu-item:focus-visible {
  outline: 2px solid #8b3010;
  outline-offset: -2px;
}

/* Home screen overlay panels (Resume list, How To Play, New Game modal) */
.home-panel,
.home-overlay,
.resume-panel,
.howtoplay-panel,
.new-game-modal,
dialog {
  z-index: 200;
  position: fixed;
}
/* Dialogs specifically need this */
dialog {
  z-index: 300;
}
dialog::backdrop {
  z-index: 299;
}
.resume-panel,
.howtoplay-panel {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(980px, 94vw);
  max-height: 70vh;
  overflow: auto;
}
.home-logout {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 210;
}

/* =====================================================================
   Lobby
   ===================================================================== */
.lobby-shell {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}
.lobby-header { text-align: center; margin-bottom: 36px; }
.lobby-header .display-title { font-size: clamp(36px, 5vw, 52px); }
.lobby-brief {
  max-width: 680px; margin: 0 auto;
  font-style: italic; color: var(--parch-dim);
}

.lobby-card {
  background: linear-gradient(160deg, var(--ink-soot), var(--ink-char));
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-2);
}
.lobby-card h2 {
  font-size: 22px; margin-bottom: 16px; color: var(--parch);
}

.char-summary {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 0; margin-bottom: 16px;
}
.char-pin {
  --pin: var(--ember);
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--pin);
  box-shadow: 0 0 10px var(--pin), inset 0 0 0 2px var(--ink-obsidian);
  flex-shrink: 0;
}
.char-name { font-family: var(--font-display); font-size: 22px; }
.char-meta { color: var(--parch-dim); font-size: 14px; }

/* Class picker */
.class-picker { border: 0; padding: 0; margin: 0 0 16px; }
.class-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.class-option input { position: absolute; opacity: 0; pointer-events: none; }
.class-option .class-card {
  display: block; padding: 14px 12px;
  background: var(--ink-char);
  border: 1px solid var(--border-mid);
  border-radius: var(--r);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease-out), transform var(--dur-fast) var(--ease-out);
  min-height: 72px;
}
.class-option .class-card:hover { border-color: var(--border-hot); }
.class-option input:checked + .class-card {
  border-color: var(--ember);
  background: linear-gradient(160deg, var(--ink-smoke), var(--ink-soot));
  box-shadow: var(--glow-ember);
}
.class-option input:focus-visible + .class-card { outline: 2px solid var(--ember-bright); outline-offset: 2px; }
.class-name { display: block; font-family: var(--font-display); font-size: 16px; margin-bottom: 4px; }
.class-stats { color: var(--parch-dim); font-size: 13px; font-family: var(--font-mono); }

/* Party list */
.lobby-party { margin-top: 32px; }
.lobby-party h3 {
  font-size: 14px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--parch-muted); margin-bottom: 12px;
}
.party-list { list-style: none; padding: 0; margin: 0; }
.party-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center; gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--r);
  margin-bottom: 6px;
  background: rgba(20,16,12,0.5);
}
.party-name { font-family: var(--font-display); }
.join-code-inline {
  font-family: var(--font-mono);
  letter-spacing: 0.2em;
  margin-left: 8px;
  color: var(--ember-bright);
}
.copy-code-icon {
  min-height: 44px;
  min-width: 44px;
  border: 1px solid var(--border-soft);
  border-radius: var(--r);
  background: transparent;
  color: var(--parch-dim);
  margin-left: 6px;
  position: relative;
}
.copy-code-icon[data-copied="true"]::after {
  content: "Copied!";
  position: absolute;
  top: -22px;
  right: 0;
  font-size: 11px;
  color: var(--ember-bright);
}
.party-meta { color: var(--parch-dim); font-size: 13px; }
.party-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--parch-muted);
}
.party-dot.online { background: var(--leaf); box-shadow: 0 0 8px var(--leaf); }
.party-empty { color: var(--parch-muted); font-style: italic; padding: 10px; }

.logout-bar { margin-top: 32px; text-align: center; }

/* =====================================================================
   Play screen — three-pane layout
   ===================================================================== */
.page-play { overflow: hidden; }

.play-shell {
  display: grid;
  grid-template-rows: 56px 1fr;
  height: 100dvh;
}

.play-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: var(--ink-char);
  border-bottom: 1px solid var(--border-soft);
  z-index: 20;
}
.top-back-btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.campaign-id {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display);
}
.id-mark { color: var(--ember); font-size: 20px; }
.id-name { font-size: 15px; letter-spacing: 0.08em; text-transform: uppercase; }
.id-mode {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.2em;
  padding: 4px 8px; border-radius: 4px;
  background: var(--ink-soot); color: var(--parch-dim);
  font-family: var(--font-mono);
}
.top-actions { display: flex; gap: 8px; align-items: center; }
.inline-form { display: inline; margin: 0; }

.play-grid {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 1fr auto auto;
  gap: 0;
  overflow: hidden;
  min-height: 0;
}
@media (min-width: 1024px) {
  .play-grid {
    grid-template-columns: minmax(520px, 640px) minmax(360px, 1fr);
    grid-template-rows: 1fr;
  }
}
@media (min-width: 1200px) {
  .play-grid {
    grid-template-columns: minmax(520px, 640px) minmax(360px, 1fr) 280px;
  }
}

/* Panels (all three share this) */
.panel {
  display: flex; flex-direction: column;
  background: var(--ink-char);
  border-right: 1px solid var(--border-soft);
  min-height: 0;  /* so flex children can shrink */
  overflow: hidden;
}
.panel:last-child { border-right: 0; }
.panel-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.panel-title { font-size: 14px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--parch); }
.panel-sub   { font-size: 12px; color: var(--parch-muted); font-family: var(--font-mono); }

/* ---- Map panel ---- */
.panel-map { background: linear-gradient(180deg, #0d0906 0%, var(--ink-char) 100%); }
.panel-map.map-expanded {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 500;
}
.map-wrap { flex: 1; min-height: 0; padding: 12px; }
#world-map { width: 100%; height: 100%; display: block; }

.map-pin {
  cursor: pointer;
  transition: transform var(--dur) var(--ease-out);
  transform-origin: center;
}
.map-pin:hover { transform: scale(1.15); }
.map-pin-lg { transform: scale(1.25); }
.map-pin-label {
  font-family: var(--font-display);
  font-size: 13px;
  fill: var(--parch);
  paint-order: stroke;
  stroke: var(--ink-obsidian);
  stroke-width: 3px;
  stroke-linejoin: round;
}
.map-location {
  cursor: pointer;
  transition: opacity var(--dur) var(--ease-out);
}
.map-location-label {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  fill: var(--parch-dim);
  paint-order: stroke;
  stroke: var(--ink-obsidian);
  stroke-width: 2.5px;
}
.map-location-sublabel {
  font-family: var(--font-body);
  font-size: 9px;
  fill: var(--parch-muted);
  paint-order: stroke;
  stroke: var(--ink-obsidian);
  stroke-width: 2px;
}
.map-location-glow { filter: url(#glow); }

.map-legend {
  padding: 8px 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--parch-muted);
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.map-controls {
  display: inline-flex;
  gap: 8px;
}

/* ---- Log panel ---- */
.panel-log { border-right: 1px solid var(--border-soft); }
.log-stream {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  scroll-behavior: smooth;
}
.log-entry {
  margin-bottom: 18px;
  animation: fade-up var(--dur-slow) var(--ease-out);
}
.log-entry p { font-size: 17px; line-height: 1.65; color: var(--parch); margin: 0; }
.entry-player {
  padding: 10px 14px;
  border-left: 3px solid var(--ember);
  background: rgba(217,138,58,0.06);
  border-radius: 0 var(--r) var(--r) 0;
}
.entry-player .log-author {
  display: block;
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ember-bright);
  margin-bottom: 4px;
}
.entry-dm p::first-letter {
  font-family: var(--font-display);
  font-size: 1.6em;
  color: var(--ember-bright);
  margin-right: 2px;
}
.entry-mutation {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--parch-muted);
  background: var(--ink-soot);
  padding: 8px 12px;
  border-radius: var(--r-sm);
  border-left: 2px solid var(--border-hot);
}
.entry-mutation strong { color: var(--ember-bright); }
.dice-roll-wrap {
  display: inline-flex;
}
.dice-roll-icon {
  width: 24px;
  height: 24px;
  fill: rgba(217, 138, 58, 0.15);
  stroke: var(--ember-bright);
  stroke-width: 4;
  animation: d20-spin 600ms ease-out;
}
.dice-roll-icon text {
  fill: var(--ember-bright);
  font-size: 38px;
  font-family: var(--font-mono);
  font-weight: 600;
}
@keyframes d20-spin {
  from { transform: rotate(0deg) scale(0.85); opacity: 0.6; }
  to { transform: rotate(360deg) scale(1); opacity: 1; }
}
.log-entry.is-fading {
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out);
}
.entry-scene {
  font-style: italic;
  color: var(--parch-dim);
  text-align: center;
  padding: 8px 0;
  border-top: 1px dashed var(--border-soft);
  border-bottom: 1px dashed var(--border-soft);
}
.entry-error {
  color: var(--wound);
  font-style: italic;
  font-size: 14px;
}

/* Composer */
.composer {
  border-top: 1px solid var(--border-soft);
  padding: 12px 16px 16px;
  background: var(--ink-soot);
  flex-shrink: 0;
}
.composer-row {
  display: flex; gap: 10px; align-items: stretch;
}
.mic-btn {
  flex-shrink: 0;
  transition: background var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}
.mic-btn[aria-pressed="true"] {
  background: var(--wound);
  border-color: var(--wound);
  box-shadow: 0 0 16px rgba(196,74,60,0.5);
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { transform: scale(1);} 50% { transform: scale(1.05);} }
#action-input {
  flex: 1; resize: none; min-height: 44px;
  font-family: var(--font-body); font-size: 16px;
}
.btn-send { min-width: 80px; flex-shrink: 0; }
.composer-hints {
  display: flex; justify-content: space-between; gap: 12px;
  margin-top: 6px; min-height: 18px;
}

/* ---- Party rail ---- */
.panel-party { padding: 0; }
#party-toggle { display: none; }
@media (min-width: 1024px) and (max-width: 1199px) {
  #party-toggle { display: inline-flex; }
  .panel-party {
    position: fixed;
    top: 56px;
    right: 0;
    bottom: 0;
    width: 280px;
    z-index: 30;
    transform: translateX(100%);
    transition: transform var(--dur) var(--ease-out);
    border-left: 1px solid var(--border-soft);
    box-shadow: var(--shadow-3);
  }
  body.party-open .panel-party { transform: translateX(0); }
}
@media (min-width: 1200px) {
  #party-toggle { display: none !important; }
  .panel-party {
    position: static;
    transform: none;
    box-shadow: none;
    border-left: 0;
  }
}
.party-rail {
  list-style: none; padding: 12px; margin: 0;
  overflow-y: auto;
}
.party-card {
  background: var(--ink-soot);
  border: 1px solid var(--border-soft);
  border-radius: var(--r);
  padding: 12px;
  margin-bottom: 10px;
  transition: border-color var(--dur) var(--ease-out);
}
.party-card.is-self { border-color: var(--border-hot); }
.party-card.is-downed { opacity: 0.55; }
.party-card-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
}
.party-card-name { font-family: var(--font-display); font-size: 15px; }
.party-card-meta { color: var(--parch-muted); font-size: 11px; font-family: var(--font-mono); letter-spacing: 0.04em; }
.profile-open-btn { margin-top: 10px; min-height: 44px; width: 100%; }
.hp-bar {
  height: 6px; border-radius: 3px; background: var(--ink-obsidian);
  overflow: hidden; margin-top: 6px;
}
.hp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--leaf), #9ab66d);
  transition: width var(--dur-slow) var(--ease-out);
}
.hp-bar-fill.low    { background: linear-gradient(90deg, var(--ember), var(--ember-bright)); }
.hp-bar-fill.critical { background: linear-gradient(90deg, var(--wound), #e06a5d); }
.hp-text {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--parch-dim); margin-top: 4px;
  display: flex; justify-content: space-between;
}

.metrics-panel {
  margin: 14px 12px;
  padding: 12px;
  background: var(--ink-obsidian);
  border: 1px dashed var(--border-soft);
  border-radius: var(--r);
  font-family: var(--font-mono); font-size: 12px;
}
.metrics-panel h3 {
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--parch-muted); margin-bottom: 10px;
}
.metric-grid {
  display: grid; grid-template-columns: 1fr auto;
  gap: 6px 12px; margin: 0;
}
.metric-grid dt { color: var(--parch-muted); }
.metric-grid dd { color: var(--parch); margin: 0; text-align: right; }

/* =====================================================================
   Modals (shop + battle)
   ===================================================================== */
.modal {
  background: transparent;
  border: 0;
  padding: 0;
  max-width: min(640px, 92vw);
  width: 100%;
  color: var(--parch);
  margin: auto;
}
.modal::backdrop {
  background: rgba(10, 9, 8, 0.75);
  backdrop-filter: blur(6px);
}

.modal > .modal-head,
.modal > .modal-body {
  background: linear-gradient(180deg, var(--ink-soot), var(--ink-char));
  border: 1px solid var(--border-soft);
  padding: 20px 24px;
}
.modal > .modal-head {
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  border-bottom: 0;
  position: relative;
}
.modal > .modal-body {
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  border-top: 0;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-title { font-size: 24px; }
.modal-sub { color: var(--parch-dim); font-style: italic; margin: 4px 0 0; }
.modal-close {
  position: absolute; top: 14px; right: 14px;
  background: transparent; border: 0; color: var(--parch-dim);
  width: 44px; height: 44px; cursor: pointer;
  font-size: 18px; border-radius: var(--r-sm);
  transition: color var(--dur) var(--ease-out);
}
.modal-close:hover { color: var(--parch); }
.modal-profile { max-width: min(720px, 95vw); }
.modal-tabs {
  display: flex;
  gap: 8px;
  padding: 0 24px 12px;
}
.modal-tabs [role="tab"] {
  min-height: 44px;
  border: 1px solid var(--border-mid);
  background: var(--ink-soot);
  color: var(--parch);
  border-radius: var(--r);
  padding: 0 12px;
}
.modal-tabs [aria-selected="true"] { border-color: var(--ember); }
.profile-stat-row {
  display: grid;
  grid-template-columns: 70px 40px 40px 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.profile-stat-row span:first-child { font-family: var(--font-display); }
.profile-stat-row strong { font-family: var(--font-mono); font-size: 18px; }
.profile-meta { margin-top: 10px; color: var(--parch-dim); }
.profile-item-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border-soft);
}

/* Shop */
.shop-gold-line {
  display: flex; align-items: baseline; gap: 8px;
  padding: 10px 14px; margin-bottom: 16px;
  background: rgba(212,175,71,0.08);
  border: 1px solid rgba(212,175,71,0.3);
  border-radius: var(--r);
  font-family: var(--font-mono);
}
.shop-gold-line strong { color: var(--gold-coin); font-size: 18px; }

.shop-items { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.shop-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 16px;
  padding: 14px;
  background: var(--ink-obsidian);
  border: 1px solid var(--border-soft);
  border-radius: var(--r);
}
.shop-item-name { font-family: var(--font-display); font-size: 16px; }
.shop-item-desc { color: var(--parch-dim); font-size: 14px; font-style: italic; margin-top: 2px; }
.shop-item-meta {
  font-family: var(--font-mono); font-size: 12px;
  color: var(--parch-muted); margin-top: 4px;
}
.shop-item-price { font-family: var(--font-mono); color: var(--gold-coin); }
.shop-buy-btn { min-width: 90px; grid-row: span 2; align-self: center; }
.shop-buy-btn:disabled { opacity: 0.4; }

/* Battle */
.battle-sides {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  margin-bottom: 18px;
}
@media (max-width: 560px) {
  .battle-sides { grid-template-columns: 1fr; }
}
.battle-side h4 {
  font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--parch-muted); margin-bottom: 8px;
  font-family: var(--font-display);
}
.battle-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.battle-participant {
  padding: 10px 12px;
  background: var(--ink-obsidian);
  border: 1px solid var(--border-soft);
  border-radius: var(--r);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease-out), transform var(--dur-fast) var(--ease-out);
  min-height: 56px;
}
.battle-participant:hover { border-color: var(--border-hot); transform: translateX(2px); }
.battle-participant.active {
  border-color: var(--ember);
  box-shadow: var(--glow-ember);
}
.battle-participant.targeted {
  border-color: var(--wound);
  box-shadow: 0 0 12px rgba(196,74,60,0.4);
}
.battle-participant.downed { opacity: 0.4; text-decoration: line-through; cursor: not-allowed; }
.bp-head {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-display); font-size: 14px;
}
.bp-init {
  font-family: var(--font-mono); font-size: 11px; color: var(--parch-muted);
  background: var(--ink-soot); padding: 1px 6px; border-radius: 3px;
}

.battle-actions { padding-top: 10px; }
.battle-btns {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 8px; margin-top: 10px;
}
.btn-attack { border-color: var(--wound); }
.btn-cast   { border-color: var(--arcane); }
.btn-use    { border-color: var(--leaf); }
.btn-flee   { border-color: var(--parch-muted); }

/* =====================================================================
   Accessibility: honour prefers-reduced-motion
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .dice-roll-icon { animation: none !important; }
  .ember-particle { animation: none !important; }
  .dragon-body, .dragon-body-highlight, .dragon-head,
  .dragon-flame, .dragon-wing-left, .dragon-wing-right {
    animation: none !important;
  }
}

/* =====================================================================
   Cozy fantasy refresh: home + play living tabletop
   ===================================================================== */
.page-home {
  background:
    radial-gradient(1200px 500px at 70% 110%, rgba(244, 176, 84, 0.2), transparent 70%),
    radial-gradient(1000px 380px at 20% -20%, rgba(138, 98, 42, 0.45), transparent 70%),
    linear-gradient(180deg, #2f2014 0%, #1f140d 46%, #140d08 100%);
}
.home-shell {
  min-height: 100dvh;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 24px;
}
.tavern-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 18%, rgba(255, 198, 110, 0.22), transparent 36%);
  animation: tavern-flicker 4.5s ease-in-out infinite;
}
@keyframes tavern-flicker {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; }
}
.home-hero {
  position: relative;
  z-index: 2;
  width: min(740px, 96vw);
  background: linear-gradient(160deg, rgba(50, 31, 19, 0.78), rgba(26, 16, 11, 0.84));
  border: 1px solid rgba(232, 217, 184, 0.2);
  border-radius: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 34px rgba(240, 163, 83, 0.16);
  text-align: center;
  padding: 52px 34px 34px;
  backdrop-filter: blur(2px);
}
.home-kicker {
  color: #e7bf7f;
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 12px;
  margin-bottom: 10px;
}
.home-title {
  font-size: clamp(54px, 11vw, 96px);
  color: #f4e3c2;
  text-shadow: 0 5px 20px rgba(240, 163, 83, 0.28);
}
.home-subtitle {
  max-width: 560px;
  margin: 8px auto 24px;
  color: #d6bf99;
}
.home-menu-item {
  width: min(480px, 92vw);
  height: 62px;
  border-radius: 14px;
  border: 1px solid rgba(232, 217, 184, 0.25);
  background: linear-gradient(180deg, rgba(94, 63, 38, 0.5), rgba(51, 33, 22, 0.72));
  color: #f3e0be;
  font-size: 17px;
  letter-spacing: 0.12em;
  justify-content: center;
  transition: transform 200ms ease, box-shadow 200ms ease, border-color 200ms ease;
}
.home-menu-item:hover {
  transform: translateY(-2px);
  border-color: rgba(244, 176, 84, 0.58);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.4), 0 0 20px rgba(244, 176, 84, 0.22);
}
.home-menu-item:active { transform: scale(0.98); }
.home-overlay {
  background: linear-gradient(150deg, rgba(242, 227, 191, 0.95), rgba(225, 202, 154, 0.95));
  border: 1px solid rgba(105, 69, 34, 0.35);
  color: #3f2614;
}
.home-overlay .btn-ghost {
  background: rgba(63, 38, 20, 0.08);
  border-color: rgba(63, 38, 20, 0.24);
  color: #3f2614;
}

.play-grid {
  grid-template-columns: 1fr;
  grid-template-rows: minmax(280px, 38vh) 1fr auto;
  gap: 10px;
  padding: 10px;
  background:
    radial-gradient(circle at 50% -20%, rgba(255, 188, 98, 0.2), transparent 44%),
    linear-gradient(180deg, #23160f 0%, #17100c 100%);
}
@media (min-width: 1200px) {
  .play-grid {
    grid-template-columns: 30% 50% 20%;
    grid-template-rows: 1fr;
    gap: 12px;
    padding: 12px;
  }
}
.panel {
  background: linear-gradient(160deg, #f1e0b7 0%, #e8d2a8 100%);
  color: #3f2614;
  border: 1px solid rgba(93, 65, 38, 0.25);
  border-radius: 18px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.25);
}
.panel-title, .panel-sub { color: #5a3a22; }
.panel-head {
  border-bottom: 1px solid rgba(93, 65, 38, 0.18);
  padding: 12px 14px;
}
.panel-map {
  overflow: hidden;
  position: relative;
}
.map-wrap {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  margin: 10px;
}
.map-ambient-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(circle at 30% 30%, rgba(255, 231, 179, 0.08), transparent 46%);
  animation: drift-light 18s linear infinite alternate;
}
@keyframes drift-light {
  from { transform: translateX(-6px) translateY(0); }
  to { transform: translateX(6px) translateY(-6px); }
}
#world-map {
  filter: saturate(0.95) contrast(1.02);
}
.map-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 80px rgba(34, 20, 10, 0.5);
}
.map-controls-floating {
  position: absolute;
  right: 18px;
  bottom: 22px;
  display: grid;
  gap: 8px;
  z-index: 5;
}
.map-fab {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(97, 61, 31, 0.24);
  background: rgba(244, 233, 207, 0.9);
  color: #5a351b;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}
.map-fab:hover {
  background: #fff4dc;
  box-shadow: 0 0 0 1px rgba(240, 163, 83, 0.4), 0 6px 16px rgba(0, 0, 0, 0.2);
}
.map-legend {
  min-height: 42px;
  position: relative;
  border-top: 1px solid rgba(93, 65, 38, 0.18);
}
.map-legend-copy {
  color: #8a643f;
}
.map-tooltip {
  position: fixed;
  z-index: 900;
  max-width: 280px;
  background: rgba(53, 32, 19, 0.94);
  color: #f3dfb8;
  border: 1px solid rgba(243, 223, 184, 0.24);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  pointer-events: none;
}
.panel-map.map-expanded {
  animation: map-cinematic-open 240ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes map-cinematic-open {
  from { transform: scale(0.96); opacity: 0.6; }
  to { transform: scale(1); opacity: 1; }
}

.map-pin { cursor: pointer; }
.map-pin-glow {
  fill: rgba(255, 176, 82, 0.34);
  animation: pin-pulse 2.2s ease-in-out infinite;
}
@keyframes pin-pulse {
  0%, 100% { r: 6; opacity: 0.5; }
  50% { r: 10; opacity: 0.15; }
}
.story-stream {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.story-card {
  margin: 0;
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(250, 241, 219, 0.68);
  border: 1px solid rgba(101, 65, 35, 0.22);
  color: #412716;
  animation: fade-up 230ms ease;
}
.entry-dm {
  background: linear-gradient(160deg, rgba(245, 232, 196, 0.9), rgba(234, 216, 176, 0.88));
  box-shadow: 0 5px 15px rgba(109, 75, 43, 0.12);
}
.entry-player {
  align-self: flex-end;
  max-width: 82%;
  background: rgba(226, 248, 220, 0.9);
  border-left: 0;
}
.entry-mutation {
  background: rgba(255, 248, 225, 0.9);
  border-left: 3px solid rgba(231, 158, 74, 0.9);
  color: #6b4a2d;
}
.action-composer {
  border-top: 1px solid rgba(93, 65, 38, 0.18);
  padding: 12px;
  background: rgba(245, 231, 196, 0.85);
}
#action-input {
  background: rgba(255, 249, 235, 0.95);
  border: 1px solid rgba(98, 66, 41, 0.3);
  color: #3f2614;
  border-radius: 14px;
  min-height: 56px;
}
.btn-send {
  border-radius: 12px;
  width: 52px;
  min-width: 52px;
  font-size: 20px;
  background: linear-gradient(180deg, #f0a353, #cf7d2f);
  color: #2c170a;
  border: 1px solid #bb6d28;
}
.quick-actions {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.quick-action-btn {
  min-height: 34px;
  border-radius: 999px;
  background: rgba(78, 115, 61, 0.11);
  border: 1px solid rgba(78, 115, 61, 0.26);
  color: #445e36;
  text-transform: none;
  letter-spacing: 0.03em;
}
.quick-action-btn:hover {
  background: rgba(78, 115, 61, 0.2);
}
.panel-party {
  transition: width 220ms ease, opacity 220ms ease;
}
body.party-collapsed .panel-party {
  width: 64px;
  min-width: 64px;
}
body.party-collapsed .panel-party .party-rail,
body.party-collapsed .panel-party .metrics-panel,
body.party-collapsed .panel-party .panel-title,
body.party-collapsed .panel-party .quest-panel,
body.party-collapsed .panel-party .rail-actions {
  display: none;
}
.party-card {
  background: rgba(255, 249, 232, 0.9);
  border: 1px solid rgba(96, 63, 36, 0.24);
}
.party-card:hover {
  border-color: rgba(217, 138, 58, 0.56);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}
.party-card-meta {
  color: #6d4d31;
}
.party-dot.online,
.char-pin {
  box-shadow: 0 0 12px currentColor;
}

/* =====================================================================
   Cozy fantasy visual pass (warm tabletop by candlelight)
   ===================================================================== */
:root {
  --ink-obsidian: #2a1f1a;
  --ink-char: #332720;
  --ink-soot: #3a2d25;
  --ink-smoke: #4a3a30;
  --ink-ash: #5a483b;

  --parch: #f2e6c9;
  --parch-dim: #d9c7a7;
  --parch-muted: #8a7665;
  --ember: #d9a441;
  --ember-bright: #d7ac5f;
  --ember-deep: #b8833d;
  --leaf: #6f8f5b;
  --wound: #a65a4d;
  --gold-coin: #cfac66;

  --border-soft: rgba(88, 66, 49, 0.18);
  --border-mid: rgba(88, 66, 49, 0.26);
  --border-hot: rgba(170, 124, 64, 0.44);
}

body {
  color: #3a2e25;
  background:
    radial-gradient(900px 440px at 52% 36%, rgba(244, 202, 131, 0.18), transparent 64%),
    radial-gradient(1300px 600px at 50% 120%, rgba(112, 83, 53, 0.26), transparent 72%),
    linear-gradient(180deg, #2f231d 0%, #2a1f1a 100%);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(circle at 50% 30%, rgba(244, 220, 170, 0.16), transparent 45%),
    radial-gradient(circle at 50% 50%, transparent 58%, rgba(52, 38, 29, 0.08) 100%);
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.06;
  mix-blend-mode: multiply;
  background-image: radial-gradient(circle at 1px 1px, rgba(82, 56, 39, 0.9) 1px, transparent 0);
  background-size: 3px 3px;
}

.play-shell,
.home-shell {
  position: relative;
  z-index: 1;
}

.play-grid {
  background:
    radial-gradient(circle at 52% 46%, rgba(243, 210, 153, 0.2), transparent 58%),
    linear-gradient(180deg, #3a2c24 0%, #2a1f1a 100%);
}
.panel {
  background:
    linear-gradient(160deg, #f2e6c9 0%, #e8d8b5 100%);
  border-color: rgba(113, 86, 61, 0.24);
  box-shadow:
    inset 0 1px 0 rgba(255, 247, 228, 0.65),
    inset 0 -8px 18px rgba(125, 92, 65, 0.08),
    0 6px 18px rgba(64, 46, 33, 0.16);
}
.panel-title,
.panel-sub,
.log-entry p,
.story-card,
.party-card-name,
.party-card-meta,
.hp-text,
.hint-muted {
  color: #3a2e25;
}

.story-stream {
  background: radial-gradient(circle at 50% 0%, rgba(248, 230, 192, 0.22), transparent 60%);
}
.story-card {
  background:
    linear-gradient(165deg, rgba(242, 231, 201, 0.95), rgba(232, 216, 181, 0.94));
  border: 1px solid rgba(111, 83, 57, 0.24);
  box-shadow:
    inset 0 1px 0 rgba(255, 247, 230, 0.65),
    0 5px 12px rgba(110, 80, 54, 0.1);
}
.entry-player {
  background:
    linear-gradient(165deg, rgba(226, 237, 214, 0.95), rgba(214, 227, 199, 0.95));
}
.entry-dm {
  background:
    linear-gradient(165deg, rgba(243, 229, 198, 0.98), rgba(229, 210, 172, 0.96));
}

.btn,
.icon-btn,
.btn-ghost {
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(244, 233, 206, 0.95), rgba(224, 205, 169, 0.95));
  border: 1px solid rgba(121, 91, 60, 0.28);
  color: #4a3729;
  box-shadow: inset 0 1px 0 rgba(255, 249, 232, 0.7);
}
.btn-primary {
  background: linear-gradient(180deg, #ddb461, #c7954b);
  color: #3a2e25;
  border-color: rgba(133, 95, 46, 0.38);
  box-shadow:
    inset 0 1px 0 rgba(255, 242, 209, 0.7),
    0 4px 10px rgba(116, 81, 46, 0.18);
}
.btn:hover:not(:disabled),
.icon-btn:hover:not(:disabled),
.btn-ghost:hover:not(:disabled) {
  box-shadow:
    inset 0 1px 0 rgba(255, 249, 232, 0.76),
    0 0 0 4px rgba(217, 164, 65, 0.12);
}

.map-wrap {
  background:
    linear-gradient(165deg, rgba(236, 218, 184, 0.9), rgba(220, 199, 161, 0.88));
  border: 1px solid rgba(113, 83, 55, 0.25);
}
#world-map {
  filter: saturate(0.9) contrast(0.94) brightness(1.03);
}
.map-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  opacity: 0.07;
  mix-blend-mode: multiply;
  background-image: radial-gradient(circle at 1px 1px, #7d5f45 1px, transparent 0);
  background-size: 4px 4px;
}
.map-ambient-layer {
  background:
    radial-gradient(circle at 30% 30%, rgba(244, 221, 181, 0.16), transparent 44%),
    radial-gradient(circle at 75% 70%, rgba(146, 168, 121, 0.08), transparent 48%);
}
.map-location-label {
  fill: #503a2b;
  stroke: #efe1c2;
}
.map-location-banner {
  fill: rgba(239, 225, 192, 0.88);
  stroke: rgba(106, 76, 48, 0.45);
  stroke-width: 1;
}
.map-waypoint-path {
  fill: none;
  stroke: rgba(120, 89, 61, 0.55);
  stroke-width: 1.3;
  stroke-dasharray: 3 5;
  animation: path-shimmer 6s linear infinite;
}
@keyframes path-shimmer {
  from { stroke-dashoffset: 0; opacity: 0.65; }
  to { stroke-dashoffset: -32; opacity: 0.5; }
}
.panel-map.is-explore-mode #world-map,
.panel-map.is-explore-mode .map-wrap {
  cursor: crosshair;
}
#explore-mode-btn[aria-pressed="true"] {
  box-shadow:
    inset 0 1px 0 rgba(255, 249, 232, 0.76),
    0 0 0 4px rgba(111, 143, 91, 0.14);
  border-color: rgba(111, 143, 91, 0.46);
}
.map-pin-glow {
  fill: rgba(217, 164, 65, 0.28);
}
.map-pin-shape {
  stroke: #5b4331;
}
.map-tooltip {
  background: rgba(244, 234, 213, 0.94);
  color: #483628;
  border: 1px solid rgba(110, 82, 56, 0.28);
}

.party-card {
  background: linear-gradient(170deg, rgba(238, 221, 187, 0.95), rgba(220, 199, 161, 0.95));
  border-color: rgba(116, 86, 59, 0.24);
}
.hp-bar {
  background: rgba(104, 82, 64, 0.2);
  border-radius: 999px;
}
.hp-bar-fill {
  border-radius: 999px;
  background: linear-gradient(90deg, #6f8f5b, #8fa97b);
}
.hp-bar-fill.low {
  background: linear-gradient(90deg, #c9a258, #d7b36f);
}
.hp-bar-fill.critical {
  background: linear-gradient(90deg, #a65a4d, #bb776a);
}

.page-home {
  background:
    radial-gradient(circle at 50% 24%, rgba(248, 210, 140, 0.3), transparent 46%),
    linear-gradient(180deg, #3b2c23 0%, #2a1f1a 100%);
}
.home-hero {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding-top: 20px;
}
.home-title {
  position: relative;
  color: #f2e6c9;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
  text-shadow: 0 7px 22px rgba(217, 164, 65, 0.24);
}
.dragon-hero {
  width: min(760px, 92vw);
  margin: 0 auto -10px;
}
.dragon-orbit-svg {
  width: 100%;
  height: auto;
  overflow: visible;
}
.dragon-body-wrap {
  filter: url(#dragonGlow);
  transform-origin: 340px 140px;
  animation: dragon-coil 9s ease-in-out infinite;
}
.dragon-body-line {
  fill: none;
  stroke: rgba(223, 177, 98, 0.9);
  stroke-width: 4.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.dragon-wing {
  fill: rgba(217, 164, 65, 0.24);
  stroke: rgba(186, 136, 67, 0.8);
  stroke-width: 1.4;
  transform-origin: center;
}
.wing-left { animation: wing-left 4.2s ease-in-out infinite; }
.wing-right { animation: wing-right 4.2s ease-in-out infinite; }
.dragon-head {
  fill: rgba(223, 177, 98, 0.9);
  stroke: rgba(143, 101, 48, 0.72);
  stroke-width: 1.2;
}
.dragon-eye { fill: rgba(88, 57, 30, 0.9); }
.dragon-tail {
  fill: rgba(223, 177, 98, 0.75);
  stroke: rgba(143, 101, 48, 0.72);
  stroke-width: 1.2;
}
@keyframes dragon-coil {
  0%, 100% { transform: scale(1) translateY(0); opacity: 0.92; }
  50% { transform: scale(1.01) translateY(-2px); opacity: 1; }
}
@keyframes wing-left {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-5deg); }
}
@keyframes wing-right {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(5deg); }
}
.home-menu {
  margin-top: 18px;
  animation: buttons-fade 700ms ease-out 180ms both;
}
@keyframes buttons-fade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.home-menu-item {
  background: linear-gradient(180deg, rgba(242, 229, 196, 0.95), rgba(224, 204, 166, 0.95));
  border-color: rgba(118, 86, 58, 0.28);
  color: #4b3727;
}
.home-menu-item:hover {
  box-shadow: 0 0 0 4px rgba(217, 164, 65, 0.12);
}

.panel,
.story-card,
.party-card,
.btn,
.icon-btn {
  animation: cozy-breathe 7s ease-in-out infinite;
}
@keyframes cozy-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.002); }
}
.btn:hover:not(:disabled),
.icon-btn:hover:not(:disabled) {
  position: relative;
  overflow: hidden;
}
.btn:hover:not(:disabled)::after,
.icon-btn:hover:not(:disabled)::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(217, 164, 65, 0.35);
  animation: hover-ripple 420ms ease-out;
}
@keyframes hover-ripple {
  from { opacity: 0.65; transform: scale(0.92); }
  to { opacity: 0; transform: scale(1.08); }
}

.panel-party {
  display: grid;
  grid-template-rows: auto minmax(140px, 1fr) auto auto auto;
}
.quest-panel {
  padding: 10px 12px 0;
}
.quest-title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 12px;
  color: #6b5a4a;
}
.quest-card {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  background: linear-gradient(160deg, rgba(242, 230, 201, 0.95), rgba(232, 216, 181, 0.95));
  border: 1px solid rgba(113, 86, 61, 0.22);
  border-radius: 14px;
  padding: 10px;
}
.quest-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(217, 164, 65, 0.2);
}
.quest-card h4 {
  margin: 0 0 4px;
  font-size: 14px;
  color: #3a2e25;
}
.quest-card p {
  margin: 0;
  font-size: 12px;
  color: #6b5a4a;
  line-height: 1.45;
}
.rail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 12px 12px;
}
.rail-action-btn {
  min-height: 34px;
  font-size: 11px;
  letter-spacing: 0.08em;
}

.map-location {
  cursor: pointer;
  transition: transform 200ms ease, filter 200ms ease;
}
.map-location:hover {
  transform: scale(1.03);
  filter: drop-shadow(0 0 6px rgba(217, 164, 65, 0.3));
}
.map-location-temp .map-temp-ring {
  fill: none;
  stroke: rgba(111, 143, 91, 0.65);
  stroke-width: 1.6;
  stroke-dasharray: 3 3;
  animation: temp-ring-pulse 2.4s ease-in-out infinite;
}
.map-location-temp .map-temp-core {
  fill: rgba(111, 143, 91, 0.55);
}
@keyframes temp-ring-pulse {
  0%, 100% { opacity: 0.8; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.12); }
}
.map-travel-trail {
  fill: none;
  stroke: rgba(111, 143, 91, 0.65);
  stroke-width: 2;
  stroke-dasharray: 4 6;
  animation: trail-fade 1.6s ease-out forwards;
}
@keyframes trail-fade {
  from { opacity: 0.9; }
  to { opacity: 0; }
}
.map-explorer-token {
  pointer-events: none;
}
.map-explorer-glow {
  fill: rgba(217, 164, 65, 0.25);
  animation: explorer-pulse 2s ease-in-out infinite;
}
.map-explorer-disc {
  fill: rgba(243, 228, 194, 0.94);
  stroke: rgba(91, 67, 49, 0.62);
  stroke-width: 1.6;
}
@keyframes explorer-pulse {
  0%, 100% { r: 10; opacity: 0.4; }
  50% { r: 13; opacity: 0.18; }
}
.entry-dm .dm-text {
  position: relative;
}
.entry-dm .dm-text::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 1em;
  margin-left: 3px;
  vertical-align: -0.15em;
  background: rgba(150, 111, 71, 0.45);
  animation: text-caret 1.1s steps(1) infinite;
}
@keyframes text-caret {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}

/* =====================================================================
   Dark cinematic illustrated map rebuild
   ===================================================================== */
.panel-map {
  background: linear-gradient(180deg, #121917 0%, #0d1210 100%);
  border-color: rgba(93, 109, 95, 0.28);
  box-shadow:
    inset 0 1px 0 rgba(170, 186, 170, 0.09),
    inset 0 -12px 28px rgba(5, 9, 8, 0.36),
    0 12px 24px rgba(0, 0, 0, 0.35);
}
.panel-map .panel-title,
.panel-map .panel-sub {
  color: #aeb8ac;
}
.map-wrap {
  position: relative;
  background: #0d1311;
  border: 1px solid rgba(108, 122, 110, 0.32);
}
.map-base-texture {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 55% 44%, rgba(106, 121, 102, 0.18), transparent 52%),
    radial-gradient(circle at 20% 70%, rgba(58, 78, 62, 0.22), transparent 46%),
    linear-gradient(170deg, rgba(20, 29, 25, 0.8), rgba(10, 16, 14, 0.92));
}
#world-map {
  position: relative;
  z-index: 1;
}
.map-ambient-layer {
  z-index: 2;
  background:
    radial-gradient(circle at 32% 30%, rgba(169, 185, 146, 0.08), transparent 48%),
    radial-gradient(circle at 70% 64%, rgba(109, 133, 154, 0.08), transparent 44%);
}
.map-major-route {
  fill: none;
  stroke: url(#map-path-dash);
  stroke-width: 4;
  opacity: 0.92;
  filter: drop-shadow(0 0 3px rgba(191, 175, 130, 0.32));
  animation: route-flow 11s linear infinite;
}
@keyframes route-flow {
  from { stroke-dashoffset: 0; }
  to { stroke-dashoffset: -140; }
}
.map-location {
  transition: transform 200ms ease, filter 200ms ease;
}
.map-location-icon {
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
}
.map-location:hover {
  transform: scale(1.06);
  filter: drop-shadow(0 0 7px rgba(212, 191, 127, 0.35));
}
.map-location-banner {
  fill: rgba(12, 19, 16, 0.84);
  stroke: rgba(146, 160, 136, 0.45);
}
.map-location-label {
  fill: #c8cfbf;
  stroke: #121714;
  stroke-width: 2.4;
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.map-waypoint-path {
  stroke: rgba(151, 162, 137, 0.55);
  stroke-dasharray: 2.4 6.2;
}
.map-legend {
  border-top: 1px solid rgba(112, 126, 113, 0.22);
}
.map-legend-copy {
  color: #889183;
}
.map-fab {
  background: linear-gradient(180deg, rgba(30, 40, 35, 0.92), rgba(18, 26, 22, 0.94));
  border-color: rgba(114, 128, 114, 0.35);
  color: #c5cfbf;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.32);
}
.map-fab:hover {
  background: linear-gradient(180deg, rgba(42, 53, 47, 0.96), rgba(24, 34, 29, 0.96));
  box-shadow: 0 0 0 1px rgba(164, 177, 157, 0.28), 0 6px 14px rgba(0, 0, 0, 0.35);
}
.map-tooltip {
  background: rgba(10, 15, 13, 0.95);
  color: #c2cabd;
  border: 1px solid rgba(116, 129, 116, 0.28);
}
.map-pin-label {
  fill: #d0d7c8;
  stroke: #0f1512;
}
.map-explorer-disc {
  fill: rgba(185, 194, 178, 0.95);
  stroke: rgba(46, 57, 50, 0.85);
}
.map-explorer-glow {
  fill: rgba(199, 180, 117, 0.28);
}

@keyframes spin-slow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.animate-spin-slow {
  animation: spin-slow 60s linear infinite;
}

@keyframes float {
  0% { transform: translateY(0); opacity: 0.2; }
  50% { opacity: 0.8; }
  100% { transform: translateY(-100px); opacity: 0; }
}

.animate-float {
  animation: float 6s infinite;
}

.dragon-hero-image {
  position: absolute;
  width: min(560px, 82vw);
  opacity: 0.72;
  pointer-events: none;
  filter: drop-shadow(0 0 18px rgba(217, 164, 65, 0.18));
}
