/* DELVE — Daily 5-Room Dungeon Party Builder & Expedition Sim
   Visual system v2: "Torchlit Cartographer" — layered depth, gold-foil accents, role-tinted UI. */

:root {
  --bg-abyss: #0a0806;
  --bg-deep: #0f0c09;
  --bg-stone: #15110d;
  --bg-slate: #1c1612;
  --bg-card: #211a14;
  --bg-card-hover: #2a2119;
  --border-subtle: rgba(212, 168, 83, 0.20);
  --border-brass: rgba(212, 168, 83, 0.50);
  --border-bright: #f0c36d;
  --text-vellum: #f3ead8;
  --text-muted: #b9ab93;
  --text-dim: #847763;
  --gold-deep: #a97a2c;
  --brass: #d4a853;
  --gold-bright: #f0c36d;
  --gold-pale: #f7dfa6;
  --ember: #d96b38;
  --amber: #e09f3e;
  --emerald: #4e9a6f;
  --emerald-bright: #8ce0b0;
  --crimson: #c94a4a;
  --azure: #5fa8d3;
  --violet: #a27ce0;
  --role-vanguard: #d96b38;
  --role-striker: #e09f3e;
  --role-arcanist: #5fa8d3;
  --role-warden: #4e9a6f;
  --font-display: 'Cinzel', Georgia, serif;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-float: 0 18px 50px rgba(0, 0, 0, 0.6);
  --glow-gold: 0 0 26px rgba(240, 195, 109, 0.22);
  --radius-lg: 16px;
  --radius-md: 11px;
  --radius-sm: 7px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

[hidden] {
  display: none !important;
}

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

html, body {
  min-height: 100%;
  background-color: var(--bg-abyss);
  color: var(--text-vellum);
  font-family: var(--font-sans);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  scrollbar-color: rgba(212, 168, 83, 0.45) #0f0c09;
}

body {
  position: relative;
  background-image:
    radial-gradient(ellipse 70% 50% at 50% -8%, rgba(217, 107, 56, 0.17), transparent 60%),
    radial-gradient(ellipse 50% 40% at 90% 100%, rgba(212, 168, 83, 0.08), transparent 55%),
    radial-gradient(ellipse 40% 35% at 5% 85%, rgba(95, 168, 211, 0.05), transparent 60%),
    linear-gradient(180deg, #0d0a07 0%, #0a0806 48%, #0b0806 100%);
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
}

/* Grain + vignette layers (fixed, non-interactive) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.09;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 85% 75% at 50% 45%, transparent 50%, rgba(0, 0, 0, 0.55) 100%);
}

#ambient-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.9;
}

.topbar, .challenge-banner, main, .site-footer, .toast-container {
  position: relative;
  z-index: 1;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #0f0c09;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(212, 168, 83, 0.55), rgba(169, 122, 44, 0.55));
  border-radius: 8px;
  border: 2px solid #0f0c09;
}

::selection {
  background: rgba(240, 195, 109, 0.35);
  color: #fff8e8;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid rgba(240, 195, 109, 0.8);
  outline-offset: 2px;
}

/* ==================== TOP NAVIGATION BAR ==================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 22px;
  background: linear-gradient(180deg, rgba(22, 17, 12, 0.94), rgba(14, 11, 8, 0.90));
  border-bottom: 1px solid rgba(212, 168, 83, 0.22);
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.topbar::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(240, 195, 109, 0.75) 50%, transparent 100%);
  pointer-events: none;
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  text-align: left;
  padding: 2px 4px;
  border-radius: 10px;
  transition: transform 0.2s var(--ease-out);
}

.brand-cluster:hover {
  transform: translateY(-1px);
}

.brand-emblem {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 0 10px rgba(240, 195, 109, 0.35));
}

.brand-emblem svg {
  width: 40px;
  height: 40px;
  display: block;
}

.brand-emblem .sigil-flame {
  transform-origin: 20px 23px;
  animation: flameFlicker 1.6s ease-in-out infinite alternate;
}

@keyframes flameFlicker {
  0% { transform: scale(1) translateY(0); opacity: 0.92; }
  40% { transform: scale(1.06, 1.12) translateY(-0.4px); opacity: 1; }
  100% { transform: scale(0.96, 1.04) translateY(0.3px); opacity: 0.88; }
}

.brand-titles {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 800;
  letter-spacing: 0.18em;
  line-height: 1.1;
  background: linear-gradient(180deg, #fbe9bd 0%, #f0c36d 55%, #c9983f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--brass);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.85;
}

.mode-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  padding: 3px;
  border-radius: 10px;
  background: rgba(10, 8, 6, 0.55);
  border: 1px solid rgba(212, 168, 83, 0.12);
}

.nav-btn {
  padding: 7px 13px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  border: 1px solid transparent;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.nav-btn:hover {
  color: var(--text-vellum);
  background: rgba(243, 234, 216, 0.05);
}

.nav-btn.active {
  color: #1a130b;
  background: linear-gradient(180deg, #f3cd7b, #d9a040);
  border-color: rgba(255, 235, 180, 0.55);
  box-shadow: 0 2px 12px rgba(224, 159, 62, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.streak-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px 6px 9px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(217, 107, 56, 0.16), rgba(217, 107, 56, 0.08));
  border: 1px solid rgba(217, 107, 56, 0.42);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--gold-bright);
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.streak-badge svg {
  width: 14px;
  height: 16px;
  display: block;
  opacity: 0.55;
  transition: opacity 0.3s ease;
}

.streak-badge.lit {
  border-color: rgba(240, 195, 109, 0.7);
  box-shadow: 0 0 18px rgba(217, 107, 56, 0.35);
}

.streak-badge.lit svg {
  opacity: 1;
  filter: drop-shadow(0 0 6px rgba(240, 160, 60, 0.9));
  animation: flameFlicker 1.3s ease-in-out infinite alternate;
  transform-origin: 50% 85%;
}

.icon-btn {
  padding: 6px 11px;
  border-radius: 7px;
  background: linear-gradient(180deg, rgba(36, 29, 22, 0.9), rgba(24, 19, 14, 0.9));
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  transition: border-color 0.15s ease, color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.icon-btn:hover:not(:disabled) {
  border-color: var(--brass);
  color: var(--text-vellum);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

/* ==================== CHALLENGE BANNER ==================== */
.challenge-banner {
  background: linear-gradient(90deg, rgba(217, 107, 56, 0.26), rgba(212, 168, 83, 0.18) 60%, rgba(217, 107, 56, 0.12));
  border-bottom: 1px solid var(--brass);
  padding: 9px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  animation: bannerIn 0.5s var(--ease-out);
}

@keyframes bannerIn {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.challenge-banner-text {
  font-weight: 600;
  color: var(--gold-bright);
}

/* ==================== HOME LANDING SCREEN ==================== */
.home-screen {
  max-width: 1100px;
  width: 100%;
  margin: 30px auto;
  padding: 0 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.home-hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse 60% 70% at 0% 0%, rgba(217, 107, 56, 0.20), transparent 60%),
    radial-gradient(ellipse 45% 60% at 100% 100%, rgba(212, 168, 83, 0.12), transparent 60%),
    linear-gradient(165deg, rgba(36, 28, 21, 0.97), rgba(19, 15, 11, 0.99));
  border: 1px solid var(--border-brass);
  border-radius: var(--radius-lg);
  padding: 34px 36px;
  box-shadow: var(--shadow-float), inset 0 1px 0 rgba(255, 235, 180, 0.08);
  display: grid;
  grid-template-columns: 1.42fr 1fr;
  gap: 32px;
  align-items: center;
  animation: riseIn 0.7s var(--ease-out) both;
}

.home-hero::before {
  content: '';
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(212, 168, 83, 0.14);
  border-radius: calc(var(--radius-lg) - 6px);
  pointer-events: none;
}

.home-hero::after {
  content: '';
  position: absolute;
  top: -120px;
  left: -60px;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(240, 195, 109, 0.16), transparent 62%);
  filter: blur(12px);
  pointer-events: none;
  animation: torchBreathe 4.2s ease-in-out infinite alternate;
}

@keyframes torchBreathe {
  from { opacity: 0.75; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1.06); }
}

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

.home-hero > div {
  position: relative;
  z-index: 1;
}

.home-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--brass);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.home-eyebrow::before {
  content: '';
  width: 26px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--brass));
}

.home-title {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 800;
  line-height: 1.12;
  margin-bottom: 14px;
  letter-spacing: 0.01em;
  background: linear-gradient(100deg, #e9c87d 0%, #f0c36d 28%, #fff4d4 46%, #f0c36d 56%, #c99a46 82%, #e2b964 100%);
  background-size: 230% 100%;
  background-position: 110% 0;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 14px rgba(240, 195, 109, 0.16));
  animation: titleShine 2.6s var(--ease-out) 0.35s 1 both;
}

@keyframes titleShine {
  from { background-position: 110% 0; }
  to { background-position: -30% 0; }
}

.home-lead {
  font-size: 15.5px;
  color: var(--text-muted);
  margin-bottom: 22px;
  max-width: 56ch;
  line-height: 1.55;
}

.home-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.home-step-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(14, 11, 8, 0.75), rgba(10, 8, 6, 0.6));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 13px 13px;
  transition: border-color 0.2s ease, transform 0.2s var(--ease-out), box-shadow 0.2s ease;
}

.home-step-card::before {
  content: attr(data-num);
  position: absolute;
  right: 8px;
  top: -6px;
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 800;
  color: rgba(240, 195, 109, 0.09);
  line-height: 1;
  pointer-events: none;
}

.home-step-card:hover {
  border-color: var(--border-brass);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.home-step-num {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--ember);
  margin-bottom: 5px;
}

.home-step-title {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--text-vellum);
  margin-bottom: 4px;
}

.home-step-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

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

.home-hero .home-cta-row .btn-secondary {
  padding: 12px 15px;
  font-size: 13px;
}

/* ---- Buttons ---- */
.btn-primary {
  position: relative;
  overflow: hidden;
  padding: 13px 24px;
  border-radius: 10px;
  background: linear-gradient(180deg, #f6d58a 0%, #e0a444 48%, #c3822c 100%);
  color: #17100a;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.02em;
  border: 1px solid rgba(255, 236, 190, 0.7);
  box-shadow: 0 6px 20px rgba(224, 159, 62, 0.30), inset 0 1px 0 rgba(255, 255, 255, 0.45), inset 0 -1px 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.15s var(--ease-out), filter 0.15s ease, box-shadow 0.15s ease;
  text-shadow: 0 1px 0 rgba(255, 245, 220, 0.35);
}

.btn-primary::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -60%;
  width: 40%;
  background: linear-gradient(100deg, transparent 0%, rgba(255, 255, 255, 0.45) 50%, transparent 100%);
  transform: skewX(-18deg);
  transition: left 0.6s var(--ease-out);
  pointer-events: none;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.05);
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(224, 159, 62, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.btn-primary:hover:not(:disabled)::after {
  left: 120%;
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0) scale(0.99);
}

.btn-primary.pulse {
  animation: ctaPulse 2.4s ease-in-out infinite;
}

@keyframes ctaPulse {
  0%, 100% { box-shadow: 0 6px 20px rgba(224, 159, 62, 0.30), 0 0 0 0 rgba(240, 195, 109, 0.0), inset 0 1px 0 rgba(255, 255, 255, 0.45); }
  50% { box-shadow: 0 8px 26px rgba(224, 159, 62, 0.45), 0 0 0 6px rgba(240, 195, 109, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.45); }
}

.btn-secondary {
  padding: 12px 18px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(40, 32, 24, 0.95), rgba(26, 20, 15, 0.95));
  color: var(--text-vellum);
  font-weight: 600;
  font-size: 13.5px;
  border: 1px solid var(--border-brass);
  box-shadow: inset 0 1px 0 rgba(255, 235, 180, 0.06), 0 4px 14px rgba(0, 0, 0, 0.3);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s var(--ease-out), box-shadow 0.15s ease;
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--gold-bright);
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255, 235, 180, 0.1), 0 8px 20px rgba(0, 0, 0, 0.4), 0 0 18px rgba(240, 195, 109, 0.12);
}

/* ---- Today's Contract Preview Box on Home ---- */
.home-contract-box {
  position: relative;
  z-index: 1;
  background:
    linear-gradient(180deg, rgba(12, 10, 8, 0.86), rgba(10, 8, 6, 0.92));
  border: 1px solid var(--border-brass);
  border-radius: 14px;
  padding: 20px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-card), inset 0 0 0 1px rgba(240, 195, 109, 0.05), inset 0 1px 0 rgba(255, 235, 180, 0.06);
  animation: riseIn 0.7s var(--ease-out) 0.12s both;
}

.home-contract-box::before {
  content: '';
  position: absolute;
  top: -40px;
  right: -40px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(240, 195, 109, 0.14), transparent 65%);
  pointer-events: none;
}

.contract-box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 10px;
}

.contract-box-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--gold-bright);
  letter-spacing: 0.04em;
}

.contract-box-timer {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.contract-title-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.contract-seal {
  flex-shrink: 0;
  width: 54px;
  height: 54px;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
}

.contract-seal svg {
  width: 54px;
  height: 54px;
  display: block;
}

.contract-seal .seal-ring {
  transform-origin: 27px 27px;
  animation: sealSpin 28s linear infinite;
}

@keyframes sealSpin {
  to { transform: rotate(360deg); }
}

.contract-box-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-vellum);
  line-height: 1.2;
}

.contract-box-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 3px;
}

.contract-rooms-mini {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 2px;
}

.contract-room-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  padding: 7px 10px 7px 12px;
  border-radius: 7px;
  background: linear-gradient(90deg, rgba(31, 25, 19, 0.85), rgba(24, 19, 14, 0.75));
  border: 1px solid rgba(212, 168, 83, 0.14);
  border-left: 3px solid var(--room-color, var(--brass));
  animation: rowIn 0.45s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 70ms + 200ms);
  transition: border-color 0.2s ease, transform 0.2s var(--ease-out);
}

.contract-room-row:hover {
  transform: translateX(2px);
  border-color: rgba(212, 168, 83, 0.35);
  border-left-color: var(--room-color, var(--brass));
}

@keyframes rowIn {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

.contract-room-type {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--room-color, var(--brass));
  padding: 2px 7px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--room-color, var(--brass)) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--room-color, var(--brass)) 40%, transparent);
}

[data-type="TRAP"] { --room-color: #e09f3e; }
[data-type="SWARM"] { --room-color: #d96b38; }
[data-type="HAZARD"] { --room-color: #5fa8d3; }
[data-type="ELITE"] { --room-color: #c94a4a; }
[data-type="BOSS"] { --room-color: #f0c36d; }

.home-modes-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.mode-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(25, 20, 15, 0.96), rgba(17, 13, 10, 0.96));
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 22px 20px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  text-align: left;
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s ease, transform 0.25s var(--ease-out), box-shadow 0.25s ease;
  animation: riseIn 0.7s var(--ease-out) both;
}

.mode-card:nth-child(1) { animation-delay: 0.18s; }
.mode-card:nth-child(2) { animation-delay: 0.26s; }
.mode-card:nth-child(3) { animation-delay: 0.34s; }

.mode-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 50% at 50% 0%, rgba(240, 195, 109, 0.12), transparent 70%);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.mode-card:hover {
  border-color: var(--brass);
  transform: translateY(-4px);
  box-shadow: var(--shadow-float), var(--glow-gold);
}

.mode-card:hover::before {
  opacity: 1;
}

.mode-card-icon {
  width: 34px;
  height: 34px;
  margin-bottom: 12px;
  color: var(--gold-bright);
  filter: drop-shadow(0 0 8px rgba(240, 195, 109, 0.35));
}

.mode-card-icon svg {
  width: 34px;
  height: 34px;
  display: block;
}

.mode-card-tag {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--ember);
  text-transform: uppercase;
}

.mode-card-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-vellum);
  margin-top: 5px;
}

.mode-card-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 6px;
}

.mode-card .sidebar-sub {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: gap 0.2s var(--ease-out), color 0.2s ease;
}

.mode-card:hover .sidebar-sub {
  gap: 10px;
  color: var(--gold-bright);
}

/* ==================== MAIN GAME WORKSPACE ==================== */
.game-workspace {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 20px 36px;
  display: grid;
  grid-template-columns: minmax(0, 768px) minmax(350px, 1fr);
  gap: 18px;
  align-items: start;
  animation: riseIn 0.5s var(--ease-out) both;
}

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

/* Expedition HUD Bar */
.expedition-hud {
  position: relative;
  background: linear-gradient(180deg, rgba(26, 21, 16, 0.96), rgba(18, 14, 11, 0.96));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-card), inset 0 1px 0 rgba(255, 235, 180, 0.05);
}

.hud-metrics {
  display: flex;
  align-items: stretch;
  gap: 0;
  flex-wrap: wrap;
}

.hud-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 16px;
  border-right: 1px solid rgba(212, 168, 83, 0.14);
}

.hud-metric:first-child {
  padding-left: 2px;
}

.hud-metric:last-child {
  border-right: none;
}

.hud-metric-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.hud-metric-val {
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-vellum);
  font-variant-numeric: tabular-nums;
}

.hud-metric-val.gold {
  color: var(--gold-bright);
}

.purse-meter {
  display: grid;
  grid-template-columns: repeat(20, 7px);
  gap: 2px;
  margin-top: 4px;
}

.purse-meter i {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(212, 168, 83, 0.16);
  border: 1px solid rgba(212, 168, 83, 0.22);
  transition: background 0.25s ease, box-shadow 0.25s ease, transform 0.25s var(--ease-out);
}

.purse-meter i.spent {
  background: radial-gradient(circle at 35% 30%, #fbe7b3, #e0a444 55%, #a97a2c);
  border-color: rgba(255, 236, 190, 0.6);
  box-shadow: 0 0 6px rgba(240, 195, 109, 0.5);
}

.purse-meter i.bid {
  border-color: rgba(240, 195, 109, 0.7);
  background: rgba(240, 195, 109, 0.12);
  animation: bidBlink 1.6s ease-in-out infinite;
}

@keyframes bidBlink {
  0%, 100% { box-shadow: 0 0 0 rgba(240, 195, 109, 0); }
  50% { box-shadow: 0 0 6px rgba(240, 195, 109, 0.55); }
}

.hud-rating {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.hud-rating.hidden-rating {
  color: var(--text-muted);
  letter-spacing: 0.08em;
  animation: ratingShimmer 2.2s ease-in-out infinite;
}

@keyframes ratingShimmer {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.grade-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 7px;
  border-radius: 6px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 800;
  color: #17100a;
  background: linear-gradient(180deg, #f6d58a, #d9a040);
  box-shadow: 0 0 12px rgba(240, 195, 109, 0.35);
  animation: gradePop 0.5s var(--ease-out);
}

.grade-badge[data-grade="A"] { background: linear-gradient(180deg, #9fe9c0, #4e9a6f); box-shadow: 0 0 12px rgba(78, 154, 111, 0.45); }
.grade-badge[data-grade="B"] { background: linear-gradient(180deg, #a9d7f2, #5fa8d3); box-shadow: 0 0 12px rgba(95, 168, 211, 0.45); }
.grade-badge[data-grade="C"] { background: linear-gradient(180deg, #f3c784, #e09f3e); }
.grade-badge[data-grade="D"], .grade-badge[data-grade="F"] { background: linear-gradient(180deg, #ef8f8f, #c94a4a); color: #fff3f3; box-shadow: 0 0 12px rgba(201, 74, 74, 0.45); }

@keyframes gradePop {
  0% { transform: scale(0.4) rotate(-12deg); opacity: 0; }
  60% { transform: scale(1.15) rotate(3deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); }
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Canvas Frame */
.canvas-frame {
  position: relative;
  width: 100%;
  background: var(--bg-abyss);
  border: 1px solid var(--border-brass);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-float), inset 0 0 0 1px rgba(240, 195, 109, 0.06);
}

.canvas-frame::before,
.canvas-frame::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid rgba(240, 195, 109, 0.75);
  pointer-events: none;
  z-index: 2;
  filter: drop-shadow(0 0 6px rgba(240, 195, 109, 0.4));
}

.canvas-frame::before {
  top: 8px;
  left: 8px;
  border-right: none;
  border-bottom: none;
  border-top-left-radius: 6px;
}

.canvas-frame::after {
  right: 8px;
  bottom: 8px;
  border-left: none;
  border-top: none;
  border-bottom-right-radius: 6px;
}

.canvas-frame.revealing::after {
  bottom: 44px;
}

#dungeon-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 768 / 532;
}

.reveal-bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px 9px 30px;
  background: linear-gradient(90deg, rgba(217, 107, 56, 0.22), rgba(212, 168, 83, 0.14));
  border-top: 1px solid var(--border-brass);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--gold-bright);
}

.reveal-bar::before {
  content: '';
  position: absolute;
  left: 13px;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--gold-bright);
  box-shadow: 0 0 0 0 rgba(240, 195, 109, 0.6);
  animation: livePing 1.1s ease-out infinite;
}

@keyframes livePing {
  0% { box-shadow: 0 0 0 0 rgba(240, 195, 109, 0.6); }
  100% { box-shadow: 0 0 0 9px rgba(240, 195, 109, 0); }
}

#reveal-status-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* 5-Room Scout's Parchment Inspector */
.room-inspector {
  background: linear-gradient(180deg, rgba(23, 18, 14, 0.96), rgba(16, 13, 10, 0.96));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-card);
}

.room-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.room-tab-btn {
  position: relative;
  min-width: 0;
  overflow: hidden;
  padding: 9px 8px 8px 12px;
  border-radius: 8px;
  background: rgba(28, 22, 18, 0.9);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--room-color, var(--brass));
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s var(--ease-out);
}

.room-tab-btn:hover {
  border-color: var(--brass);
  border-left-color: var(--room-color, var(--brass));
  transform: translateY(-1px);
}

.room-tab-btn.active {
  background: linear-gradient(180deg, rgba(212, 168, 83, 0.18), rgba(212, 168, 83, 0.08));
  border-color: var(--gold-bright);
  border-left-color: var(--room-color, var(--gold-bright));
  box-shadow: 0 0 16px rgba(240, 195, 109, 0.12);
}

.room-tab-btn[data-status="FLAWLESS"] { border-left-color: #f0c36d; }
.room-tab-btn[data-status="CLEARED"] { border-left-color: #4e9a6f; }
.room-tab-btn[data-status="BATTERED"] { border-left-color: #e09f3e; }
.room-tab-btn[data-status="WIPED"] { border-left-color: #c94a4a; }
.room-tab-btn[data-status="UNREACHED"] { opacity: 0.55; }

.room-tab-num {
  display: block;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--room-color, var(--brass));
}

.room-tab-name {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-vellum);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-detail-body {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 14px;
  background: rgba(10, 8, 6, 0.6);
  border: 1px solid rgba(212, 168, 83, 0.16);
  border-radius: 10px;
  padding: 14px 16px;
}

.room-detail-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--gold-bright);
  margin-bottom: 3px;
}

.room-detail-foes {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ember);
  margin-bottom: 6px;
}

.room-detail-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.55;
}

.room-detail-log {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(240, 195, 109, 0.05);
  border: 1px dashed rgba(212, 168, 83, 0.3);
  font-size: 12.5px;
  color: var(--text-vellum);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.room-detail-log div {
  animation: rowIn 0.4s var(--ease-out) both;
}

.room-tags-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
}

.tag-group-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tag-group-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  min-width: 78px;
}

.trait-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  background: rgba(33, 26, 20, 0.9);
  border: 1px solid var(--border-subtle);
  color: var(--text-vellum);
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.trait-pill.covered {
  background: rgba(78, 154, 111, 0.2);
  border-color: var(--emerald);
  color: var(--emerald-bright);
  box-shadow: 0 0 10px rgba(78, 154, 111, 0.25);
  animation: pillPop 0.4s var(--ease-out);
}

@keyframes pillPop {
  0% { transform: scale(0.85); }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.trait-pill.weakness {
  background: rgba(212, 168, 83, 0.16);
  border-color: var(--brass);
  color: var(--gold-bright);
}

.trait-pill.resist {
  background: rgba(201, 74, 74, 0.16);
  border-color: var(--crimson);
  color: #f28b8b;
}

/* ==================== RIGHT COLUMN: TAVERN SIDEBAR ==================== */
.tavern-sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-card {
  background: linear-gradient(180deg, rgba(23, 18, 14, 0.97), rgba(16, 13, 10, 0.97));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-card), inset 0 1px 0 rgba(255, 235, 180, 0.04);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 9px;
}

.sidebar-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-vellum);
}

.sidebar-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--brass);
}

/* Tavern Hand 6-Unit Grid */
.tavern-hand-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.unit-card {
  --role-color: var(--brass);
  position: relative;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--role-color) 13%, transparent) 0%, transparent 42%),
    linear-gradient(180deg, #241c15, #1a140f);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--role-color);
  border-radius: 10px;
  padding: 11px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.16s ease, transform 0.2s var(--ease-out), box-shadow 0.2s ease;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  animation: cardDeal 0.45s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 55ms);
}

@keyframes cardDeal {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.unit-card[data-role="VANGUARD"] { --role-color: var(--role-vanguard); }
.unit-card[data-role="STRIKER"] { --role-color: var(--role-striker); }
.unit-card[data-role="ARCANIST"] { --role-color: var(--role-arcanist); }
.unit-card[data-role="WARDEN"] { --role-color: var(--role-warden); }

.unit-card:hover {
  border-color: var(--brass);
  border-left-color: var(--role-color);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
}

.unit-card.selected {
  border-color: var(--gold-bright);
  border-left-color: var(--gold-bright);
  box-shadow: 0 0 0 1px var(--gold-bright), 0 0 28px rgba(240, 195, 109, 0.22), 0 10px 24px rgba(0, 0, 0, 0.45);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--role-color) 16%, transparent) 0%, transparent 46%),
    linear-gradient(180deg, #2c2319, #1f1812);
}

.unit-card.unaffordable {
  opacity: 0.42;
  filter: saturate(0.6);
}

/* Legendary gold-foil border shimmer */
.unit-card.legendary::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 11px;
  padding: 1.5px;
  background: linear-gradient(115deg, transparent 20%, rgba(255, 238, 190, 0.85) 48%, rgba(240, 195, 109, 0.4) 55%, transparent 78%);
  background-size: 260% 100%;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  animation: foilSweep 3.2s linear infinite;
  pointer-events: none;
}

@keyframes foilSweep {
  from { background-position: 140% 0; }
  to { background-position: -140% 0; }
}

.unit-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.unit-crest-wrap {
  position: relative;
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.unit-crest-wrap::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--role-color) 38%, transparent), transparent 68%);
  opacity: 0.8;
}

.unit-crest-mini {
  position: relative;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.55));
}

.unit-head-info {
  flex: 1;
  min-width: 0;
}

.unit-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.unit-name {
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-vellum);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unit-cost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 22px;
  padding: 0 7px;
  border-radius: 11px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  color: #1a130b;
  background: radial-gradient(circle at 35% 30%, #fbe7b3, #e0a444 60%, #b8862e);
  border: 1px solid rgba(255, 236, 190, 0.6);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  flex-shrink: 0;
  letter-spacing: -0.01em;
}

.unit-cost.legendary {
  background: radial-gradient(circle at 35% 30%, #fff5d6, #f0c36d 55%, #c9983f);
  box-shadow: 0 0 12px rgba(240, 195, 109, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.unit-class {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.unit-badges-row {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.mini-badge {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(10, 8, 6, 0.7);
  color: var(--text-muted);
  border: 1px solid rgba(212, 168, 83, 0.16);
}

.mini-badge.counter-match {
  background: rgba(78, 154, 111, 0.22);
  border-color: var(--emerald);
  color: #93e5b6;
  box-shadow: 0 0 8px rgba(78, 154, 111, 0.25);
}

.mini-badge.dmg-match {
  background: rgba(212, 168, 83, 0.20);
  border-color: var(--brass);
  color: var(--gold-bright);
  box-shadow: 0 0 8px rgba(240, 195, 109, 0.22);
}

.unit-stats-mini {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
  background: rgba(10, 8, 6, 0.6);
  padding: 6px 7px 7px;
  border-radius: 7px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 9.5px;
  border: 1px solid rgba(212, 168, 83, 0.1);
}

.stat-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-cell-lbl {
  color: var(--text-dim);
  display: block;
  font-size: 8.5px;
  letter-spacing: 0.04em;
}

.stat-cell-val {
  color: var(--text-vellum);
  font-weight: 700;
}

.stat-bar {
  height: 3px;
  border-radius: 2px;
  background: rgba(243, 234, 216, 0.08);
  overflow: hidden;
}

.stat-bar i {
  display: block;
  height: 100%;
  width: calc(var(--v, 0) * 1%);
  background: var(--stat-color, var(--brass));
  border-radius: 2px;
  box-shadow: 0 0 6px color-mix(in srgb, var(--stat-color, var(--brass)) 60%, transparent);
  transition: width 0.5s var(--ease-out);
}

.stat-cell[data-stat="HP"] { --stat-color: #4e9a6f; }
.stat-cell[data-stat="AC"] { --stat-color: #5fa8d3; }
.stat-cell[data-stat="ATK"] { --stat-color: #d96b38; }
.stat-cell[data-stat="MAG"] { --stat-color: #a27ce0; }
.stat-cell[data-stat="WIT"] { --stat-color: #e09f3e; }
.stat-cell[data-stat="SPD"] { --stat-color: #e8dcc3; }

/* 4 Role Assign Buttons on each Unit Card */
.unit-assign-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin-top: 1px;
}

.sb-pos-btn {
  --btn-role: var(--brass);
  padding: 6px 2px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: rgba(28, 22, 18, 0.9);
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease, transform 0.12s var(--ease-out), box-shadow 0.12s ease;
}

.sb-pos-btn[data-role="VANGUARD"] { --btn-role: var(--role-vanguard); }
.sb-pos-btn[data-role="STRIKER"] { --btn-role: var(--role-striker); }
.sb-pos-btn[data-role="ARCANIST"] { --btn-role: var(--role-arcanist); }
.sb-pos-btn[data-role="WARDEN"] { --btn-role: var(--role-warden); }

.sb-pos-btn:not(:disabled) {
  color: var(--text-muted);
}

.sb-pos-btn.natural-fit:not(:disabled) {
  border-color: var(--btn-role);
  color: color-mix(in srgb, var(--btn-role) 70%, #ffffff);
  background: color-mix(in srgb, var(--btn-role) 16%, transparent);
  box-shadow: 0 0 10px color-mix(in srgb, var(--btn-role) 28%, transparent);
}

.sb-pos-btn.flex-fit:not(:disabled) {
  border-color: color-mix(in srgb, var(--btn-role) 60%, transparent);
  color: color-mix(in srgb, var(--btn-role) 80%, #ffffff);
}

.sb-pos-btn:hover:not(:disabled) {
  background: var(--btn-role);
  color: #120d08;
  border-color: color-mix(in srgb, var(--btn-role) 60%, #ffffff);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--btn-role) 45%, transparent);
}

/* Party Roster & Checklist Panel */
.roster-slots-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.roster-slot-row {
  --role-color: var(--brass);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px 8px 12px;
  border-radius: 8px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--role-color) 9%, transparent), rgba(10, 8, 6, 0.6) 55%);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--role-color);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.roster-slot-row[data-role="VANGUARD"] { --role-color: var(--role-vanguard); }
.roster-slot-row[data-role="STRIKER"] { --role-color: var(--role-striker); }
.roster-slot-row[data-role="ARCANIST"] { --role-color: var(--role-arcanist); }
.roster-slot-row[data-role="WARDEN"] { --role-color: var(--role-warden); }

.roster-slot-row.empty {
  border-style: dashed;
  border-left-style: solid;
  background: rgba(10, 8, 6, 0.4);
}

.roster-slot-row.filled {
  animation: slotFill 0.45s var(--ease-out);
}

@keyframes slotFill {
  0% { transform: scale(0.97); box-shadow: 0 0 0 0 rgba(240, 195, 109, 0.4); }
  100% { transform: scale(1); box-shadow: 0 0 0 10px rgba(240, 195, 109, 0); }
}

.roster-slot-role {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  min-width: 74px;
}

.roster-crest {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.roster-slot-unit {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-vellum);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.roster-slot-row.empty .roster-slot-unit {
  color: var(--text-dim);
  font-weight: 500;
}

.roster-slot-unit small {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.roster-slot-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gold-bright);
}

.synergy-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.synergy-item {
  position: relative;
  padding: 8px 10px 8px 14px;
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(78, 154, 111, 0.16), rgba(78, 154, 111, 0.06));
  border: 1px solid rgba(78, 154, 111, 0.38);
  border-left: 3px solid var(--emerald);
  font-size: 11.5px;
  animation: rowIn 0.4s var(--ease-out) both;
}

.synergy-item-title {
  font-weight: 700;
  color: #93e5b6;
}

/* ==================== TAVERN DRAW REEL OVERLAY (#roll-pop) ==================== */
.roll-pop-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 40%, rgba(40, 28, 16, 0.6), rgba(8, 6, 5, 0.9) 70%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  cursor: pointer;
  animation: fadeIn 0.18s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.roll-pop-card {
  position: relative;
  background: linear-gradient(165deg, #2a211a, #150f0b);
  border: 1.5px solid var(--gold-bright);
  border-radius: 18px;
  padding: 28px 36px 24px;
  text-align: center;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.8), 0 0 40px rgba(240, 195, 109, 0.18), inset 0 1px 0 rgba(255, 235, 180, 0.12);
  animation: popIn 0.32s var(--ease-out);
}

.roll-pop-card::before {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 13px;
  border: 1px solid rgba(240, 195, 109, 0.18);
  pointer-events: none;
}

@keyframes popIn {
  from { transform: scale(0.9) translateY(10px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.roll-pop-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--brass);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.roll-pop-crest {
  width: 96px;
  height: 96px;
  margin: 0 auto 12px;
  display: block;
  filter: drop-shadow(0 0 18px rgba(240, 195, 109, 0.35));
  animation: crestSpin 0.5s var(--ease-out);
}

@keyframes crestSpin {
  from { transform: rotateY(90deg) scale(0.8); opacity: 0; }
  to { transform: rotateY(0) scale(1); opacity: 1; }
}

.roll-pop-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-vellum);
  margin-bottom: 6px;
  min-height: 1.25em;
}

.roll-pop-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  min-height: 1.2em;
}

.roll-pop-hint {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: rgba(240, 195, 109, 0.75);
}

/* ==================== DIALOG MODALS ==================== */
dialog.delve-modal {
  margin: auto;
  background: linear-gradient(180deg, #1a1510, #110d0a);
  color: var(--text-vellum);
  border: 1.5px solid var(--brass);
  border-radius: 18px;
  padding: 0;
  max-width: 800px;
  width: calc(100% - 28px);
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.85), 0 0 60px rgba(240, 195, 109, 0.1);
}

dialog.delve-modal[open] {
  animation: modalIn 0.36s var(--ease-out);
}

@keyframes modalIn {
  from { transform: translateY(16px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

dialog.delve-modal::backdrop {
  background: radial-gradient(ellipse at 50% 30%, rgba(40, 26, 12, 0.55), rgba(6, 4, 3, 0.9) 70%);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.modal-inner {
  padding: 24px 28px 26px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 14px;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  line-height: 1.15;
  background: linear-gradient(180deg, #fbe9bd 0%, #f0c36d 55%, #c9983f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.modal-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.recap-card-preview {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--border-brass);
  box-shadow: var(--shadow-card), 0 0 30px rgba(240, 195, 109, 0.1);
  animation: riseIn 0.5s var(--ease-out) 0.1s both;
}

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

.recap-kpi-box {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(14, 11, 8, 0.85), rgba(10, 8, 6, 0.8));
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 13px 12px 12px;
  text-align: center;
  animation: riseIn 0.5s var(--ease-out) both;
}

.recap-kpi-box:nth-child(1) { animation-delay: 0.15s; }
.recap-kpi-box:nth-child(2) { animation-delay: 0.22s; }
.recap-kpi-box:nth-child(3) { animation-delay: 0.29s; }
.recap-kpi-box:nth-child(4) { animation-delay: 0.36s; }

.recap-kpi-box::before {
  content: '';
  position: absolute;
  left: 20%;
  right: 20%;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(240, 195, 109, 0.6), transparent);
}

.recap-kpi-lbl {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.recap-kpi-val {
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 800;
  color: var(--gold-bright);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}

.recap-rooms-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recap-room-card {
  position: relative;
  background: rgba(10, 8, 6, 0.6);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--status-color, var(--brass));
  border-radius: 9px;
  padding: 11px 14px 11px 16px;
}

.recap-room-card[data-status="FLAWLESS"] { --status-color: #f0c36d; }
.recap-room-card[data-status="CLEARED"] { --status-color: #4e9a6f; }
.recap-room-card[data-status="BATTERED"] { --status-color: #e09f3e; }
.recap-room-card[data-status="WIPED"] { --status-color: #c94a4a; }
.recap-room-card[data-status="UNREACHED"] { --status-color: #554c40; opacity: 0.7; }

.recap-room-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.recap-room-title {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--text-vellum);
}

.recap-room-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}

/* Compendium Grid */
.compendium-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.compendium-input, .compendium-select {
  background: var(--bg-abyss);
  color: var(--text-vellum);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 13px;
  transition: border-color 0.15s ease;
}

.compendium-input {
  flex: 1;
  min-width: 200px;
}

.compendium-input:focus, .compendium-select:focus {
  border-color: var(--brass);
}

.compendium-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  max-height: 52vh;
  overflow-y: auto;
  padding-right: 4px;
}

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast-msg {
  background: linear-gradient(180deg, #2a211a, #1b1510);
  color: var(--gold-bright);
  border: 1px solid var(--brass);
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-float), 0 0 20px rgba(240, 195, 109, 0.12);
  animation: toastIn 0.35s var(--ease-out);
}

@keyframes toastIn {
  from { transform: translateY(12px) scale(0.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

/* Footer SRD Attribution */
.site-footer {
  margin-top: auto;
  padding: 16px 22px;
  border-top: 1px solid var(--border-subtle);
  background: linear-gradient(180deg, rgba(10, 8, 6, 0.6), rgba(8, 6, 5, 0.95));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--text-dim);
}

.site-footer a {
  color: var(--brass);
  text-decoration: none;
  border-bottom: 1px solid rgba(212, 168, 83, 0.3);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.site-footer a:hover {
  color: var(--gold-bright);
  border-color: var(--gold-bright);
}

/* Motion preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  #ambient-canvas {
    display: none;
  }
}

/* Responsive Breakpoints */
@media (max-width: 1080px) {
  .game-workspace {
    grid-template-columns: 1fr;
  }
  .home-hero {
    grid-template-columns: 1fr;
    padding: 26px 22px;
  }
  .home-title {
    font-size: 34px;
  }
  .mode-tabs {
    order: 3;
    width: 100%;
    justify-content: center;
  }
  .topbar {
    flex-wrap: wrap;
  }
}

@media (max-width: 680px) {
  .home-steps, .home-modes-grid {
    grid-template-columns: 1fr;
  }
  .tavern-hand-grid, .compendium-grid {
    grid-template-columns: 1fr;
  }
  .recap-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .room-detail-body {
    grid-template-columns: 1fr;
  }
  .home-title {
    font-size: 28px;
  }
  .room-tabs {
    grid-template-columns: repeat(2, 1fr);
  }
  .hud-metric {
    padding: 0 10px;
  }
  .purse-meter {
    grid-template-columns: repeat(10, 7px);
  }
  .modal-inner {
    padding: 18px 16px 20px;
  }
  .topbar {
    padding: 10px 14px;
  }
  .brand-tag {
    display: none;
  }
}
