/* ============================================
   HERO VS SCROLL — Modern Feed Design Tokens
   ============================================ */
:root {
  /* Backdrops — true near-black, OLED-friendly */
  --bg-app: #0a0a0c;
  --bg-card: #16171c;
  --bg-card-elevated: #1d1f26;
  --bg-pill: #25272f;

  /* Primary accents — modern social-app energy */
  --accent-primary: #ec4899;       /* electric magenta */
  --accent-primary-glow: #f472b6;
  --accent-primary-grad: linear-gradient(135deg, #ec4899 0%, #a21caf 100%);

  --accent-secondary: #a3e635;     /* acid lime — for "good" notifications */
  --accent-secondary-glow: #bef264;

  --accent-tertiary: #3b82f6;      /* electric blue — hero frame */
  --accent-warning: #f97316;       /* algorithmic orange — enemy frame */

  /* Status colors */
  --color-win: #a3e635;            /* lime success */
  --color-loss: #f43f5e;           /* hot red */
  --color-floor: #3b82f6;          /* blue scroll-marker */
  --color-ability: #ec4899;        /* magenta */
  --color-loot: #a3e635;           /* lime drops */
  --color-heal: #22d3ee;           /* cyan heal — distinct from loot */
  --color-damage: #f43f5e;
  --color-crit: #f97316;           /* orange burst */

  /* Rarity (kept perceptually similar to original for player intuition) */
  --rarity-common: #71717a;        /* zinc grey */
  --rarity-magic: #22d3ee;         /* "Liked" cyan */
  --rarity-rare: #3b82f6;          /* "Shared" blue */
  --rarity-epic: #a855f7;          /* "Viral" purple */
  --rarity-legendary: #f97316;     /* "Trending" orange */
  --rarity-mythic: #ec4899;        /* "Canonical" magenta */
  --rarity-aether: #fde047;        /* electric gold — only via 3-mythic forge */

  /* HP states */
  --hp-healthy: #a3e635;
  --hp-low: #f97316;
  --hp-critical: #f43f5e;

  /* Stat section accents */
  --stat-core: #ec4899;
  --stat-crit: #f97316;
  --stat-defense: #a3e635;

  /* Text */
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-card: rgba(236, 72, 153, 0.2);

  /* Spacing & sizing */
  --gap-xs: 4px;
  --gap-sm: 8px;
  --gap-md: 12px;
  --gap-lg: 16px;
  --gap-xl: 24px;
  --tab-bar-h: 64px;
  --header-h: 48px;
  --log-h: 140px;

  /* Mobile-frame width — desktop centers the app inside this. */
  --app-max-w: 440px;
}

/* ============================================
   RESET + GLOBAL
   ============================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  width: 100%;
  overflow-x: hidden;
  /* Outside-the-phone backdrop: subtle radial vignette so the centered app reads as a frame. */
  background:
    radial-gradient(ellipse at top, rgba(236, 72, 153, 0.05), transparent 60%),
    linear-gradient(180deg, #050507 0%, #0d0d12 100%);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body { display: flex; justify-content: center; }

button {
  font-family: inherit;
  font-size: inherit;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button { transition: transform 0.08s ease-out, opacity 0.15s, box-shadow 0.2s, background 0.15s; }
button:active { transform: scale(0.97); }
button:focus { outline: none; }   /* Use :focus-visible (below) for keyboard rings, not click-focus. */

img { user-select: none; -webkit-user-drag: none; }

/* ============================================
   APP SHELL
   ============================================ */
#app {
  position: relative;
  width: 100%;
  max-width: var(--app-max-w);
  /* Lock the frame to the viewport. dvh handles iOS Safari's URL-bar resize. */
  height: 100vh;
  height: 100dvh;
  padding-bottom: var(--tab-bar-h);
  overflow: hidden;
  background: var(--bg-app);
  /* Subtle phone-frame edges visible only when viewport > app width. */
  box-shadow: 0 0 0 1px var(--border-subtle), 0 0 80px rgba(0, 0, 0, 0.6);
}

.app-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border-bottom: 1px solid var(--border-subtle);
}

.app-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: linear-gradient(135deg, #fafafa 0%, var(--accent-primary-glow) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  cursor: pointer;             /* clickable — fires the same home/back-to-menu flow */
  user-select: none;
  transition: filter 0.15s;
}
.app-title:hover { filter: brightness(1.15); }

.header-icon-btn {
  position: absolute;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-pill);
  font-size: 18px;
  line-height: 1;
  top: 50%;
  transform: translateY(-50%);
}
.header-icon-btn--left  { left: 12px; }
.header-icon-btn--right { right: 12px; }
.header-icon-btn:active { transform: translateY(-50%) scale(0.92); }

/* Home-button confirm bubble — appears after the second press so a third press
   exits to Main Menu. Times out after 3s. */
.home-popup {
  position: fixed;
  top: 56px;
  left: 12px;
  max-width: calc(100% - 24px);
  background: var(--bg-card-elevated);
  border: 1px solid var(--accent-primary);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  z-index: 240;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6), 0 0 14px rgba(236, 72, 153, 0.25);
  animation: home-popup-in 0.2s ease-out;
}
@keyframes home-popup-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================
   SCREENS
   ============================================ */
.screen {
  display: none;
  width: 100%;
  padding: var(--gap-lg);
}

/* Active screens fill the area between header and tab bar, scrolling *within* the frame
   if their content overflows. The page itself never scrolls. Combat and Gear override
   below to manage their own internal scroll regions. */
.screen[data-active="true"] {
  display: block;
  height: calc(100vh - var(--header-h) - var(--tab-bar-h));
  height: calc(100dvh - var(--header-h) - var(--tab-bar-h));
  overflow-y: auto;
}

/* Combat: flex column with overflow hidden. Activity log is the only scrolling region
   (PRD §4.2 — fixed-height log, autoscroll on append). `position: relative` so the
   narrative-event overlay can absolute-position itself across the whole combat area. */
#screen-combat[data-active="true"] {
  display: flex;
  flex-direction: column;
  padding-bottom: 0;
  overflow: hidden;
  position: relative;
}

/* Collection: sub-tabs pin at the top; the active sub-screen takes the rest and scrolls. */
#screen-gear[data-active="true"] {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

/* ============================================
   MAIN MENU — Cursed Codex / Neon Sigil
   Each mode is a "rite" — the primary one is presented as an altar with
   ornamental corner marks. Other modes live behind a sealed drawer.
   ============================================ */
.main-menu {
  --mode-color: var(--accent-primary);
  --mode-color-soft: rgba(236, 72, 153, 0.22);
  --mode-color-faint: rgba(236, 72, 153, 0.08);
  flex-direction: column;
  gap: 18px;
  padding: 28px 18px 24px;
  /* Layered atmosphere: warm vignette below, cold above, faint grain everywhere. */
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(236, 72, 153, 0.10), transparent 55%),
    radial-gradient(140% 80% at 50% 110%, rgba(59, 130, 246, 0.06), transparent 60%),
    linear-gradient(180deg, #08070b 0%, #0a0a10 100%);
}
.main-menu[data-active="true"] {
  display: flex !important;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
}
.main-menu[data-active="false"] { display: none !important; }

/* ---------- Cover: brand mark + sigil halo ---------- */
.main-menu-cover {
  position: relative;
  text-align: center;
  padding: 8px 0 4px;
  isolation: isolate;
}
.main-menu-cover-halo {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 360px;
  height: 360px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: -1;
  background:
    conic-gradient(
      from 0deg,
      transparent 0deg,
      rgba(236, 72, 153, 0.18) 60deg,
      transparent 120deg,
      rgba(163, 230, 53, 0.10) 200deg,
      transparent 240deg,
      rgba(59, 130, 246, 0.12) 320deg,
      transparent 360deg
    );
  -webkit-mask: radial-gradient(closest-side, #000 30%, transparent 72%);
          mask: radial-gradient(closest-side, #000 30%, transparent 72%);
  filter: blur(8px);
  animation: sigil-spin 32s linear infinite;
  opacity: 0.85;
}
@keyframes sigil-spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
.main-menu-cover-img {
  position: relative;
  display: block;
  margin: 0 auto 10px;
  width: min(64vw, 240px);
  height: auto;
  image-rendering: -webkit-optimize-contrast;
  filter: drop-shadow(0 6px 22px rgba(236, 72, 153, 0.30));
}
.main-menu-tagline {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.main-menu-tagline i {
  font-style: normal;
  color: var(--accent-primary);
  opacity: 0.7;
  font-size: 9px;
  text-shadow: 0 0 6px rgba(236, 72, 153, 0.7);
}

.main-menu-modes {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---------- Mode card base ---------- */
.main-menu-mode-row {
  display: flex;
  gap: 0;
  position: relative;
}
.main-menu-mode-btn {
  flex: 1;
  position: relative;
  text-align: left;
  padding: 18px 18px 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent), var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 14px 0 0 14px;
  color: var(--text-primary);
  overflow: hidden;
  isolation: isolate;
  transition: transform 0.12s ease-out, border-color 0.18s, box-shadow 0.2s;
}
.main-menu-mode-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(120% 80% at 0% 0%, var(--mode-color-faint), transparent 55%),
    radial-gradient(120% 60% at 100% 100%, var(--mode-color-faint), transparent 60%);
  pointer-events: none;
}
.main-menu-mode-btn:active { transform: scale(0.985); }
.main-menu-mode-btn:hover  { border-color: var(--mode-color); box-shadow: 0 8px 28px var(--mode-color-faint); }

/* In-progress mode card — overrides the mode color with the win-green so
   "continue your run" reads at a glance, regardless of which mode it is.
   Compound selector (.btn.btn--in-progress) wins specificity against the
   per-mode variant rules (.btn--doom, .btn--hero, etc.) declared elsewhere. */
.main-menu-mode-btn.main-menu-mode-btn--in-progress {
  --mode-color: var(--color-win);
  --mode-color-soft: rgba(163, 230, 53, 0.32);
  --mode-color-faint: rgba(163, 230, 53, 0.12);
  border-color: rgba(163, 230, 53, 0.65);
  box-shadow: 0 0 0 1px rgba(163, 230, 53, 0.25), 0 10px 30px rgba(163, 230, 53, 0.18);
  animation: in-progress-breath 3.2s ease-in-out infinite;
}
.main-menu-mode-btn.main-menu-mode-btn--in-progress:hover {
  box-shadow: 0 0 0 1px rgba(163, 230, 53, 0.45), 0 12px 36px rgba(163, 230, 53, 0.28);
}
.main-menu-mode-btn.main-menu-mode-btn--in-progress .mode-eyebrow { color: var(--color-win); }
.main-menu-mode-btn.main-menu-mode-btn--in-progress .mode-corner { border-color: var(--color-win); }
/* Hide the bottom-right "Begin ›" CTA when in-progress — the chip already
   reads "▶ Continue Run", so the CTA would just be a duplicate signal. */
.main-menu-mode-btn.main-menu-mode-btn--in-progress .mode-cta { display: none; }
@keyframes in-progress-breath {
  0%, 100% { box-shadow: 0 0 0 1px rgba(163, 230, 53, 0.22), 0 10px 28px rgba(163, 230, 53, 0.14); }
  50%      { box-shadow: 0 0 0 1px rgba(163, 230, 53, 0.40), 0 12px 36px rgba(163, 230, 53, 0.28); }
}

/* Continue chip — flips the "best" pill to the win-green palette and pulses
   subtly so the player's eye lands on it. */
.main-menu-mode-best--continue {
  color: var(--color-win);
  background: rgba(163, 230, 53, 0.14);
  border-color: rgba(163, 230, 53, 0.45);
  animation: continue-chip-pulse 2.4s ease-in-out infinite;
}
@keyframes continue-chip-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(163, 230, 53, 0); }
  50%      { box-shadow: 0 0 14px 2px rgba(163, 230, 53, 0.35); }
}

@media (prefers-reduced-motion: reduce) {
  .main-menu-mode-btn--in-progress,
  .main-menu-mode-best--continue { animation: none; }
}

/* Mode color theming via custom properties — each variant just swaps colors. */
.main-menu-mode-btn--doom {
  --mode-color: #ec4899;
  --mode-color-soft: rgba(236, 72, 153, 0.30);
  --mode-color-faint: rgba(236, 72, 153, 0.10);
  border-color: rgba(236, 72, 153, 0.55);
}
.main-menu-mode-btn--timed {
  --mode-color: #f59e0b;
  --mode-color-soft: rgba(245, 158, 11, 0.28);
  --mode-color-faint: rgba(245, 158, 11, 0.10);
  border-color: rgba(245, 158, 11, 0.55);
}
.main-menu-mode-btn--endless {
  --mode-color: #3b82f6;
  --mode-color-soft: rgba(59, 130, 246, 0.28);
  --mode-color-faint: rgba(59, 130, 246, 0.10);
  border-color: rgba(59, 130, 246, 0.55);
}
.main-menu-mode-btn--seasonal {
  --mode-color: #a3e635;
  --mode-color-soft: rgba(163, 230, 53, 0.28);
  --mode-color-faint: rgba(163, 230, 53, 0.10);
  border-color: rgba(163, 230, 53, 0.55);
}

/* Eyebrow label — small caps "rite" tag above each mode title. */
.mode-eyebrow {
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--mode-color);
  opacity: 0.85;
  margin-bottom: 10px;
  font-weight: 700;
}

.main-menu-mode-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.005em;
  margin-bottom: 5px;
  color: var(--text-primary);
}
.main-menu-mode-sub {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}
.main-menu-mode-best {
  display: inline-block;
  margin-top: 10px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--mode-color);
  background: var(--mode-color-faint);
  border: 1px solid var(--mode-color-soft);
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Hero (Defeat the Doom) altar ---------- */
.main-menu-mode-row--hero { position: relative; }
/* Slow ambient pulse around the altar — sits behind the buttons. */
.main-menu-mode-row--hero::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 20px;
  background: radial-gradient(60% 100% at 50% 50%, rgba(236, 72, 153, 0.22), transparent 70%);
  filter: blur(14px);
  opacity: 0.85;
  pointer-events: none;
  z-index: -1;
  animation: altar-pulse 4.5s ease-in-out infinite;
}
@keyframes altar-pulse {
  0%, 100% { opacity: 0.55; transform: scale(0.97); }
  50%      { opacity: 0.95; transform: scale(1.02); }
}
.main-menu-mode-btn--hero {
  padding: 24px 22px 22px;
  border-width: 2px;
  border-radius: 18px 0 0 18px;
  background:
    linear-gradient(180deg, rgba(236, 72, 153, 0.05), transparent 60%),
    linear-gradient(180deg, rgba(255,255,255,0.02), transparent),
    var(--bg-card);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 0 0 1px rgba(236, 72, 153, 0.18),
    0 12px 30px rgba(236, 72, 153, 0.18);
}
.main-menu-mode-btn--hero .mode-eyebrow { font-size: 11px; margin-bottom: 14px; }
.main-menu-mode-btn--hero .main-menu-mode-title {
  font-size: 28px;
  letter-spacing: -0.005em;
  background: linear-gradient(180deg, #fafafa 0%, #fbcfe8 100%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
}
.main-menu-mode-btn--hero .main-menu-mode-sub  { font-size: 13px; margin-top: 4px; max-width: 28ch; }
.main-menu-mode-btn--hero .main-menu-mode-best { margin-top: 14px; }

/* Ornamental corner marks on the hero card (sigil-style). */
.mode-corner {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--mode-color);
  opacity: 0.85;
  pointer-events: none;
}
.mode-corner--tl { top: 8px;    left: 8px;    border-right: none; border-bottom: none; }
.mode-corner--tr { top: 8px;    right: 8px;   border-left: none;  border-bottom: none; }
.mode-corner--bl { bottom: 8px; left: 8px;    border-right: none; border-top: none; }
.mode-corner--br { bottom: 8px; right: 8px;   border-left: none;  border-top: none; }

/* "Begin ›" CTA — bottom-right of the altar */
.mode-cta {
  position: absolute;
  right: 16px;
  bottom: 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--mode-color);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.mode-cta-arrow {
  display: inline-block;
  transition: transform 0.18s ease;
  font-size: 14px;
  line-height: 1;
}
.main-menu-mode-btn--hero:hover .mode-cta-arrow { transform: translateX(3px); }

/* ---------- Leaderboard side button ---------- */
.main-menu-leaderboard-btn {
  width: 52px;
  flex-shrink: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-left: none;
  border-radius: 0 14px 14px 0;
  font-size: 20px;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.main-menu-leaderboard-btn::after {
  content: '';
  position: absolute;
  left: 0;
  top: 18%;
  bottom: 18%;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,0.06), transparent);
}
.main-menu-leaderboard-btn:hover { color: var(--text-primary); background: var(--bg-card-elevated); }
.main-menu-leaderboard-btn:active { transform: scale(0.96); }
.main-menu-leaderboard-btn--hero {
  width: 60px;
  border-width: 2px;
  border-left: none;
  border-radius: 0 18px 18px 0;
  font-size: 24px;
  border-color: rgba(236, 72, 153, 0.55);
}

/* ---------- Other Modes sealed drawer ---------- */
.other-games-toggle {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 12px 4px;
  margin-top: 6px;
  background: transparent;
  border: none;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.30em;
  color: var(--text-secondary);
  transition: color 0.15s;
}
.other-games-toggle:hover { color: var(--text-primary); }
.other-games-toggle:active { transform: none; }
.other-games-rule {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.18), transparent);
}
.other-games-chevron {
  display: inline-block;
  transition: transform 0.3s cubic-bezier(.5,0,.2,1), color 0.2s;
  color: var(--accent-primary);
  text-shadow: 0 0 8px rgba(236, 72, 153, 0.45);
  font-size: 10px;
}
.other-games-toggle.is-open .other-games-chevron {
  transform: rotate(180deg);
  color: var(--accent-primary-glow);
}

.other-games-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px 0 0;
  animation: panel-fade-in 0.25s ease;
}
.other-games-panel[hidden] { display: none !important; }
@keyframes panel-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Timed card: mode + slider bonded together ---------- */
.timed-card {
  position: relative;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.04), transparent 70%);
  border: 1px solid rgba(245, 158, 11, 0.18);
  overflow: hidden;
}
.timed-card .main-menu-mode-row { gap: 0; }
.timed-card .main-menu-mode-btn,
.timed-card .main-menu-leaderboard-btn {
  border-radius: 0;
  border-top: none;
  border-left: none;
  border-right: none;
}
.timed-card .main-menu-mode-btn { border-bottom: 1px solid rgba(245, 158, 11, 0.18); }
.timed-card .main-menu-leaderboard-btn { border-bottom: 1px solid rgba(245, 158, 11, 0.18); }

/* Difficulty slider — fully custom track + thumb */
.timed-difficulty {
  padding: 14px 16px 14px;
  background: transparent;
}
.timed-difficulty-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.timed-difficulty-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-weight: 700;
}
.timed-difficulty-value {
  font-size: 13px;
  font-weight: 800;
  color: #fbbf24;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.timed-difficulty-divider { color: rgba(251, 191, 36, 0.45); margin: 0 4px; }

#timed-difficulty-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  background: transparent;
  cursor: pointer;
  margin: 0;
}
#timed-difficulty-slider::-webkit-slider-runnable-track {
  height: 4px;
  background: linear-gradient(90deg,
    rgba(245, 158, 11, 0.55) 0%,
    rgba(245, 158, 11, 0.35) 50%,
    rgba(244, 63, 94, 0.55) 100%);
  border-radius: 2px;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.25);
}
#timed-difficulty-slider::-moz-range-track {
  height: 4px;
  background: linear-gradient(90deg,
    rgba(245, 158, 11, 0.55) 0%,
    rgba(245, 158, 11, 0.35) 50%,
    rgba(244, 63, 94, 0.55) 100%);
  border-radius: 2px;
}
#timed-difficulty-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -7px;
  background: #fbbf24;
  border: 2px solid #fef3c7;
  border-radius: 3px;
  transform: rotate(45deg);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.20), 0 0 16px rgba(245, 158, 11, 0.55);
  transition: transform 0.12s, box-shadow 0.18s;
}
#timed-difficulty-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: #fbbf24;
  border: 2px solid #fef3c7;
  border-radius: 3px;
  transform: rotate(45deg);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.20), 0 0 16px rgba(245, 158, 11, 0.55);
}
#timed-difficulty-slider:hover::-webkit-slider-thumb,
#timed-difficulty-slider:focus-visible::-webkit-slider-thumb {
  transform: rotate(45deg) scale(1.1);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.25), 0 0 22px rgba(245, 158, 11, 0.75);
}

.timed-difficulty-marks {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 10px;
  font-size: 10px;
  letter-spacing: 0.06em;
}
.timed-difficulty-marks > span {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  position: relative;
  padding-top: 8px;
  color: var(--text-muted);
}
.timed-difficulty-marks > span::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 1px;
  height: 5px;
  background: rgba(255, 255, 255, 0.18);
}
.timed-difficulty-marks > span:nth-child(1) { align-items: flex-start; }
.timed-difficulty-marks > span:nth-child(1)::before { left: 9px; }
.timed-difficulty-marks > span:nth-child(3) { align-items: flex-end; }
.timed-difficulty-marks > span:nth-child(3)::before { left: auto; right: 9px; transform: none; }
.timed-difficulty-marks b {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-secondary);
}
.timed-difficulty-marks em {
  font-style: normal;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: 10px;
}

/* Combat HUD: countdown turns red as it nears zero. */
.controls-timer--low,
#controls-timer.controls-timer--low { color: var(--color-loss, #f43f5e); font-weight: 700; }

.main-menu-settings-btn {
  margin-top: auto;
  padding: 12px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-muted);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.main-menu-settings-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-card);
  background: rgba(255, 255, 255, 0.02);
}

.settings-action {
  display: block;
  width: 100%;
  margin-top: var(--gap-sm);
  padding: 10px;
  background: var(--bg-pill);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-primary);
  text-align: center;
}
.settings-action--danger { color: var(--color-loss); border: 1px solid rgba(244, 63, 94, 0.3); }
/* Abandon Scroll — destructive but expected mid-run action; warmer than danger. */
.settings-action--abandon {
  color: var(--accent-warning);
  border: 1px solid rgba(249, 115, 22, 0.40);
  background: rgba(249, 115, 22, 0.08);
  font-weight: 700;
}
/* Quit Hero's Journey — ends the archive cleanly; magenta to read as
   "ceremonial close" between abandon-orange and wipe-red. */
.settings-action--quit {
  color: var(--accent-primary-glow);
  border: 1px solid rgba(236, 72, 153, 0.40);
  background: rgba(236, 72, 153, 0.06);
  font-weight: 700;
}

/* Leaderboard modal — small list inside .drawer */
.leaderboard-list { display: flex; flex-direction: column; gap: 4px; max-height: 60vh; overflow-y: auto; }
.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-card);
  border-radius: 8px;
  font-size: 13px;
}
.leaderboard-rank { width: 28px; color: var(--text-muted); font-weight: 800; }
.leaderboard-score { flex: 1; font-weight: 700; }
.leaderboard-date { font-size: 11px; color: var(--text-muted); }

/* ============================================
   IDLE SCREEN
   ============================================ */
.channel-banner {
  text-align: center;
  padding: var(--gap-md) 0;
  border-radius: 12px;
  background: var(--bg-card);
  margin-bottom: var(--gap-md);
  position: relative;
  overflow: hidden;
}
.channel-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(236, 72, 153, 0.08), transparent);
  animation: shimmer 4s ease-in-out infinite;
}
@keyframes shimmer { 0%, 100% { transform: translateX(-100%); } 50% { transform: translateX(100%); } }
.channel-name { font-size: 11px; letter-spacing: 0.15em; color: var(--text-muted); position: relative; }
.channel-title { font-size: 18px; color: var(--accent-primary-glow); font-weight: 700; margin-top: 2px; position: relative; }

.archive-card {
  display: flex;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--accent-primary);
  border-radius: 12px;
  padding: var(--gap-md) var(--gap-lg);
  margin-bottom: var(--gap-sm);
  box-shadow: 0 0 0 1px rgba(236, 72, 153, 0.1), 0 4px 16px rgba(236, 72, 153, 0.08);
}
.archive-stat { display: flex; gap: var(--gap-md); align-items: center; }
.archive-stat--right { text-align: right; }
.archive-icon { font-size: 32px; }
.archive-label { font-size: 10px; letter-spacing: 0.15em; color: var(--text-muted); }
.archive-value { font-size: 24px; font-weight: 800; color: var(--accent-primary); }
.archive-value--lime { color: var(--accent-secondary); }

.session-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--gap-sm);
  font-size: 13px;
  color: var(--text-secondary);
  margin: var(--gap-md) 0 var(--gap-xl);
}
.session-pill .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--color-win);
  box-shadow: 0 0 8px var(--color-win);
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.hero-portrait-wrap {
  position: relative;
  width: 140px;
  margin: 0 auto var(--gap-md);
}
.hero-portrait {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 14px;
  border: 2px solid var(--accent-primary);
  box-shadow: 0 0 24px rgba(236, 72, 153, 0.4), 0 0 0 1px rgba(236, 72, 153, 0.1);
  cursor: pointer;        /* tap → Profile */
}
/* Lime-gradient PWR badge anchored to the bottom of the portrait (slight overhang). */
.hero-pwr-badge {
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, var(--accent-secondary) 0%, var(--accent-secondary-glow) 100%);
  color: #0a0a0c;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.05em;
  padding: 4px 14px;
  border-radius: 14px;
  box-shadow: 0 0 14px rgba(163, 230, 53, 0.45), 0 2px 6px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  white-space: nowrap;
}

.ready-headline {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  margin: var(--gap-lg) 0;
}

.inventory-chips {
  display: flex;
  justify-content: center;
  gap: var(--gap-sm);
  margin-bottom: var(--gap-lg);
}
.inv-chip {
  background: var(--bg-pill);
  padding: 6px 14px;
  border-radius: 14px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s;
}
.inv-chip:hover { background: var(--bg-card-elevated); }
.inv-icon { margin-right: 4px; }

.primary-cta {
  display: block;
  width: 100%;
  padding: 16px;
  background: var(--accent-primary-grad);
  color: white;
  font-size: 17px;
  font-weight: 800;
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(236, 72, 153, 0.5);
  letter-spacing: 0.02em;
}

/* Post-run hint sits as a quiet text link beneath the primary CTA, not a button. */
.post-run-buttons {
  display: flex;
  justify-content: center;
  margin-top: var(--gap-sm);
}
.post-run-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  letter-spacing: 0.05em;
  padding: 6px 12px;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: var(--text-muted);
  cursor: pointer;
}
.post-run-btn:hover { color: var(--text-secondary); }

/* "How it goes" tutorial loop — shown beneath the primary CTA on a fresh archive,
   replacing the Last Run hint slot until the player has completed a scroll. */
.how-to-play {
  margin-top: var(--gap-md);
  padding: 14px 16px 12px;
  background: rgba(163, 230, 53, 0.04);
  border: 1px solid rgba(163, 230, 53, 0.18);
  border-radius: 12px;
  text-align: center;
}
.how-to-play-title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.10em;
  color: var(--accent-secondary);
  text-transform: uppercase;
  margin-bottom: 12px;
  opacity: 0.9;
}
.how-to-play-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.how-to-step {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 72px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
}
.how-to-icon {
  font-size: 22px; line-height: 1;
}
.how-to-label {
  font-size: 11px; font-weight: 800;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.15;
}
.how-to-arrow {
  font-size: 18px;
  color: var(--accent-secondary);
  font-weight: 700;
  opacity: 0.7;
  user-select: none;
}
.how-to-arrow--loop {
  color: var(--accent-primary-glow);
  font-size: 22px;
  margin-left: 2px;
  animation: how-to-loop-pulse 2.4s ease-in-out infinite;
}
@keyframes how-to-loop-pulse {
  0%, 100% { opacity: 0.55; transform: rotate(0deg); }
  50%      { opacity: 1.0;  transform: rotate(-15deg); }
}
.how-to-hint {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.4;
}

/* ============================================
   COMBAT SCREEN
   ============================================ */
.boss-toast {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  background: var(--bg-card-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: var(--gap-md);
  font-size: 14px;
  animation: slide-down 0.4s ease-out;
}
/* `display: flex` above outranks the user-agent [hidden] rule, so override. */
.boss-toast[hidden] { display: none !important; }
.boss-toast-icon { font-size: 18px; color: var(--text-secondary); }
.boss-toast-badge {
  margin-left: auto;
  background: var(--text-secondary);
  color: #0a0a0c;
  font-size: 12px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 10px;
}
/* Active boss fight — loud orange warning styling */
.boss-toast--active {
  border-color: var(--accent-warning);
  box-shadow: 0 0 16px rgba(249, 115, 22, 0.2);
}
.boss-toast--active .boss-toast-icon { color: var(--accent-warning); }
.boss-toast--active .boss-toast-badge { background: var(--accent-warning); }
/* Upcoming boss preview — quieter, just a heads-up */
.boss-toast--upcoming {
  background: var(--bg-card);
  font-size: 13px;
  opacity: 0.85;
}
.boss-toast--upcoming .boss-toast-icon { color: var(--text-secondary); font-size: 16px; }
.boss-toast--upcoming .boss-toast-badge {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  font-weight: 700;
}
@keyframes slide-down { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }

.combat-zone {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: var(--gap-md);
  align-items: center;
  background:
    radial-gradient(ellipse at center, rgba(236, 72, 153, 0.08), transparent 70%),
    var(--bg-card);
  padding: var(--gap-lg);
  border-radius: 12px;
  margin-bottom: var(--gap-md);
  overflow: hidden;
}
/* Subtle scrolling background of post fragments — represents the feed scrolling past */
.combat-zone::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(180deg, transparent 0%, transparent 49%, rgba(255, 255, 255, 0.02) 50%, transparent 51%);
  background-size: 100% 8px;
  animation: feed-scroll 12s linear infinite;
  pointer-events: none;
  opacity: 0.5;
}
@keyframes feed-scroll { from { background-position-y: 0; } to { background-position-y: 100px; } }

.combat-zone.boss-fight {
  box-shadow: inset 0 0 80px rgba(244, 63, 94, 0.3);
  animation: boss-pulse 2s ease-in-out infinite;
}
@keyframes boss-pulse {
  0%, 100% { box-shadow: inset 0 0 80px rgba(244, 63, 94, 0.3); }
  50% { box-shadow: inset 0 0 120px rgba(244, 63, 94, 0.5); }
}

.combatant { text-align: center; position: relative; z-index: 1; }
.combat-vs { font-size: 14px; color: var(--text-muted); font-weight: 800; letter-spacing: 0.1em; }
.combat-portrait {
  width: 72px; height: 72px;
  border-radius: 12px;
  border: 2px solid var(--accent-tertiary);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.4);
  transition: width 0.3s, height 0.3s;
}
.combat-zone.boss-fight .combat-portrait { width: 84px; height: 84px; }

/* Brief shake + brightness flash when a combatant takes damage. */
.combat-portrait.hit-flash { animation: hit-shake 0.18s ease-out; }
@keyframes hit-shake {
  0%   { transform: translateX(0);    filter: brightness(1); }
  25%  { transform: translateX(-3px); filter: brightness(1.5); }
  60%  { transform: translateX(3px);  filter: brightness(1.2); }
  100% { transform: translateX(0);    filter: brightness(1); }
}

/* VS text pulses warning-orange during boss fights for extra menace. */
.combat-zone.boss-fight .combat-vs {
  color: var(--accent-warning);
  text-shadow: 0 0 10px var(--accent-warning);
  animation: vs-pulse 1.2s ease-in-out infinite;
}
@keyframes vs-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
.combatant--enemy .combat-portrait { border-color: var(--accent-warning); box-shadow: 0 0 12px rgba(249, 115, 22, 0.4); }
.combatant-name { font-size: 14px; font-weight: 700; margin-top: 6px; }
.combatant-mini-stats { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.enemy-biome-floor { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; letter-spacing: 0.03em; }

/* Engagement bar (HP) — segmented like an Instagram story progress bar */
.hp-bar {
  width: 100%; height: 8px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 6px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}
.hp-fill {
  height: 100%;
  width: 100%;
  transition: width 0.3s ease-out, background 0.3s;
  border-radius: 4px;
}
.hp-fill--healthy { background: linear-gradient(90deg, #a3e635, #bef264); }
.hp-fill--low { background: linear-gradient(90deg, #f97316, #fb923c); }
.hp-fill--critical { background: linear-gradient(90deg, #f43f5e, #fb7185); }
.hp-text { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

.status-strip {
  display: flex;
  justify-content: center;
  gap: 4px;
  min-height: 24px;
  margin-top: 6px;
}
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 13px;
  padding: 2px 7px;
  border-radius: 8px;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-color);
  font-weight: 700;
}
.status-badge-stacks { font-size: 10px; opacity: 0.85; }
.status-badge--mark   { color: #fbbf24; box-shadow: 0 0 10px rgba(251, 191, 36, 0.45); border-color: rgba(251, 191, 36, 0.5); }
.status-badge--burn   { color: var(--accent-warning); box-shadow: 0 0 10px rgba(249, 115, 22, 0.45); border-color: rgba(249, 115, 22, 0.5); }
.status-badge--bleed  { color: var(--color-loss);     box-shadow: 0 0 10px rgba(244, 63, 94, 0.45);  border-color: rgba(244, 63, 94, 0.5); }
.status-badge--poison { color: #84cc16;               box-shadow: 0 0 10px rgba(132, 204, 22, 0.45); border-color: rgba(132, 204, 22, 0.5); }

/* Damage numbers — react-emoji float */
.damage-number-layer { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.damage-number {
  position: absolute;
  font-weight: 800;
  font-size: 13px;
  opacity: 0.85;
  animation: damage-float 1s ease-out forwards;
  text-shadow: 0 0 6px currentColor, 0 1px 2px rgba(0,0,0,0.7);
  pointer-events: none;
  white-space: nowrap;
}
.damage-number--crit    { color: var(--color-crit);    font-size: 24px; opacity: 1; text-shadow: 0 0 14px currentColor, 0 0 24px var(--color-crit); }
.damage-number--special { color: var(--color-ability); font-size: 18px; opacity: 1; }
.damage-number--taken   { color: var(--color-damage);  }
.damage-number--heal    { color: var(--color-heal);    font-size: 16px; opacity: 1; }
.damage-number--dot     { color: #84cc16;              font-size: 12px; opacity: 0.9; }
@keyframes damage-float {
  0% { opacity: 0; transform: translate(-50%, 0) scale(0.6); }
  20% { opacity: 1; transform: translate(-50%, -8px) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -40px) scale(1); }
}

/* Treasure chest (PRD §22). Gold pill with a wiggle, anchored within the combat zone.
   Layer is pass-through so non-chest clicks land on the underlying UI. */
.treasure-layer { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.treasure-chest {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px 0 12px;
  background: linear-gradient(135deg, #fbbf24 0%, #fde047 50%, #f59e0b 100%);
  color: #1a1300;
  border: 2px solid #fffbe6;
  border-radius: 22px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  pointer-events: auto;
  cursor: pointer;
  transform: translate(-50%, -50%) rotate(0);
  box-shadow: 0 0 28px rgba(251, 191, 36, 0.7), 0 6px 14px rgba(0, 0, 0, 0.5);
  animation: treasure-wiggle 0.7s ease-in-out infinite, treasure-pop-in 0.25s ease-out;
  z-index: 6;
  white-space: nowrap;
}
.treasure-icon  { font-size: 20px; line-height: 1; filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.6)); }
.treasure-label { font-size: 12px; }
@keyframes treasure-wiggle {
  0%, 100% { transform: translate(-50%, -50%) rotate(-5deg) scale(1); }
  25%      { transform: translate(-50%, -50%) rotate(5deg)  scale(1.05); }
  50%      { transform: translate(-50%, -50%) rotate(-5deg) scale(1); }
  75%      { transform: translate(-50%, -50%) rotate(5deg)  scale(1.05); }
}
@keyframes treasure-pop-in {
  0%   { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  60%  { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
.treasure-chest:active { animation: none; transform: translate(-50%, -50%) scale(0.92); }

/* Hearts HUD — doom + seasonal show one heart per remaining life.
   Lives on the idle screen between scrolls so the player can read run progress at a glance. */
.heart-hud {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  margin: 0 auto var(--gap-sm);
}
.heart-hud-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.heart-hud-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
}
.heart {
  display: inline-block;
  width: 16px;
  height: 16px;
  background-image: url('assets/icons/hearts.png');
  background-repeat: no-repeat;
  background-size: 300% 300%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  flex-shrink: 0;
}
.heart--alive { background-position: 0%   0%; }   /* top-left: red w/ black outline */
.heart--lost  { background-position: 50%  0%; }   /* top-middle: gray w/ outline */
.heart--just-lost {
  animation: heart-wiggle 0.45s ease-out, heart-pop 0.55s ease-out;
  transform-origin: center;
}

@keyframes heart-wiggle {
  0%, 100% { transform: rotate(0deg) scale(1); }
  20%      { transform: rotate(-12deg) scale(1.4); }
  40%      { transform: rotate(10deg)  scale(1.3); }
  60%      { transform: rotate(-8deg)  scale(1.2); }
  80%      { transform: rotate(6deg)   scale(1.1); }
}
@keyframes heart-pop {
  0%   { filter: brightness(2.2) drop-shadow(0 0 4px #f43f5e); }
  60%  { filter: brightness(1.5) drop-shadow(0 0 2px #f43f5e); }
  100% { filter: brightness(1) drop-shadow(0 0 0 transparent); }
}

/* Hearts strip on the run-summary modal — slightly bigger than the HUD. */
.run-summary-hearts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  margin: 8px 0 12px;
}
.run-summary-hearts .heart {
  width: 22px;
  height: 22px;
}

/* Controls bar */
.controls-bar {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  background: var(--bg-card);
  padding: var(--gap-sm) var(--gap-md);
  border-radius: 10px;
  margin-bottom: var(--gap-sm);
  font-size: 13px;
}
.floor-badge {
  background: rgba(236, 72, 153, 0.18);
  color: var(--accent-primary-glow);
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 8px;
  letter-spacing: 0.05em;
  font-size: 11px;
}
.run-info { color: var(--text-secondary); flex: 1; }
.speed-toggle, .abandon-btn {
  background: var(--bg-pill);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
}
.abandon-btn { color: var(--text-secondary); }

/* Recent Drops sidebar — only rendered in landscape mode. Hidden in portrait. */
.recent-drops { display: none; }
.recent-drops-header {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: 0 0 var(--gap-sm);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--gap-sm);
}
.recent-drops-list {
  display: flex;
  flex-direction: column;
  gap: var(--gap-xs);
  overflow-y: auto;
  flex: 1 1 0;
  min-height: 0;
}
.recent-drop {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  background: var(--bg-card);
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  border-left: 3px solid var(--accent-secondary);
  animation: drop-slide-in 0.3s ease-out;
  cursor: pointer;
  transition: background 0.15s;
}
.recent-drop:hover { background: var(--bg-card-elevated); }
@keyframes drop-slide-in { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: translateX(0); } }
.recent-drop-name { flex: 1; font-weight: 700; }
.recent-drop-pwr { font-size: 11px; color: var(--text-muted); }

/* ============================================================
   LANDSCAPE MODE
   Wide canvas with side-by-side panels. Toggled by a Profile setting.
   ============================================================ */
body.landscape {
  background: var(--bg-app);
  display: block;
}
body.landscape #app {
  max-width: none;
  width: 100%;
  box-shadow: none;
  padding-bottom: var(--tab-bar-h);
}
body.landscape .tab-bar,
body.landscape .drawer {
  max-width: none;
  width: 100%;
  left: 0;
  right: 0;
  transform: none;
}
body.landscape .toast { /* keep centered to viewport */ }

/* ----- Combat: 3-column grid (combat | log | recent drops) ----- */
body.landscape #screen-combat[data-active="true"] {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr) 260px;
  /* boss → combat → controls → stats fill the left column from top to bottom. */
  grid-template-rows: auto auto auto 1fr;
  grid-template-areas:
    "boss     log    drops"
    "combat   log    drops"
    "controls log    drops"
    "stats    log    drops";
  gap: var(--gap-md);
  padding: var(--gap-md);
  padding-bottom: 0;
  height: calc(100vh - var(--header-h) - var(--tab-bar-h));
  overflow: hidden;
}
body.landscape #boss-toast    { grid-area: boss;    margin-bottom: 0; }
body.landscape #combat-zone   { grid-area: combat;  margin-bottom: 0; }
body.landscape .controls-bar  { grid-area: controls; margin-bottom: 0; }
body.landscape #activity-log,
body.landscape #narrative-event { grid-area: log; height: 100%; border-radius: 10px; border-bottom: 1px solid var(--border-subtle); }
/* Landscape uses the grid layout, not the portrait absolute overlay. */
body.landscape #narrative-event { position: static; inset: auto; }
body.landscape #recent-drops {
  grid-area: drops;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border-radius: 10px;
  padding: var(--gap-md);
  border: 1px solid var(--border-subtle);
}
/* Combat stats panel — only renders in landscape, fills the empty bottom-left tile. */
body.landscape #combat-stats {
  grid-area: stats;
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: var(--gap-md);
  overflow-y: auto;
  min-height: 0;
}
.combat-stats { display: none; }   /* hidden in portrait */
.combat-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
  font-size: 12px;
}
.combat-stats-cell {
  background: var(--bg-card-elevated);
  border-radius: 8px;
  padding: 6px 8px;
  text-align: center;
}
.combat-stats-cell-label { font-size: 9px; color: var(--text-muted); letter-spacing: 0.1em; font-weight: 700; }
.combat-stats-cell-value { font-size: 14px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
.combat-stats-buffs-header {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  margin-top: var(--gap-xs);
}
.combat-stats-buff {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(163, 230, 53, 0.10);
  border-left: 2px solid var(--accent-secondary);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--accent-secondary-glow);
}
.combat-stats-buff-value { font-weight: 800; }

/* ----- Collection: 3-column grid showing Equipped + Stash + Forge at once ----- */
body.landscape #screen-gear[data-active="true"] {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr;          /* single row stretched to screen height */
  gap: var(--gap-md);
  padding: var(--gap-md);
}
body.landscape #screen-gear .sub-tabs { display: none; }
body.landscape #screen-gear .sub-screen {
  display: block;
  background: var(--bg-card);
  border-radius: 12px;
  padding: var(--gap-md);
  border: 1px solid var(--border-subtle);
  overflow-y: auto;
  min-height: 0;                    /* required so grid lets the column shrink to row height */
}
body.landscape #screen-gear .sub-screen::before {
  content: attr(data-landscape-label);
  display: block;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: var(--gap-md);
  padding-bottom: var(--gap-sm);
  border-bottom: 1px solid var(--border-subtle);
}

/* ----- Profile: cap width and center so the column doesn't stretch full screen ----- */
body.landscape #screen-stats[data-active="true"] {
  max-width: 720px;
  margin: 0 auto;
}

/* Plot Twist overlay (PRD §23). Lives in the activity-log's flex slot so the
   character portraits stay visible above. While shown, body.narrative-active
   hides the controls bar so the overlay also takes that vertical space —
   prompt sits centered, choices pin to the bottom of the screen. */
.narrative-event {
  flex: 1 1 0;
  min-height: 0;
  background: var(--bg-card-elevated);
  border: 2px solid var(--accent-primary);
  border-radius: 12px 12px 0 0;
  border-bottom: none;
  padding: var(--gap-md);
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
  animation: narrative-slide-in 0.3s ease-out;
  box-shadow: 0 -4px 20px rgba(236, 72, 153, 0.25);
  overflow-y: auto;
}
/* Hide the pause/speed/abandon row while a narrative event is up so the overlay
   has more room. Combat is paused during the event anyway. */
body.narrative-active .controls-bar { display: none !important; }
/* Push icon + prompt block toward vertical center; choices already sit at the
   bottom via .narrative-event-choices `margin-top: auto`. */
.narrative-event-icon { margin-top: auto; }
.narrative-event[hidden] { display: none; }
@keyframes narrative-slide-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.narrative-event-icon { font-size: 32px; text-align: center; }
.narrative-event-prompt { font-size: 16px; font-weight: 700; text-align: center; line-height: 1.3; }
.narrative-event-choices { display: flex; flex-direction: column; gap: var(--gap-sm); margin-top: auto; }
.narrative-event-choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: left;
}
.narrative-event-choice:active { transform: scale(0.98); border-color: var(--accent-primary); }

.narrative-event-timer { height: 4px; background: rgba(255, 255, 255, 0.06); border-radius: 2px; overflow: hidden; margin-top: var(--gap-sm); }
.narrative-event-timer-fill {
  height: 100%;
  background: var(--accent-primary);
  width: 100%;
  animation: narrative-timer-shrink 9s linear forwards;
}
@keyframes narrative-timer-shrink { from { width: 100%; } to { width: 0%; } }

.narrative-event-result { background: var(--bg-card); border-radius: 10px; padding: var(--gap-md); text-align: center; }
.narrative-event-result-roll { font-size: 12px; color: var(--text-muted); }
.narrative-event-result-body { font-size: 14px; color: var(--text-secondary); line-height: 1.4; margin-top: var(--gap-sm); }

.narrative-event-result-headline {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-align: center;
  text-transform: uppercase;
}
.narrative-event-result-headline.success { color: var(--color-win); text-shadow: 0 0 16px rgba(163, 230, 53, 0.5); }
.narrative-event-result-headline.fail    { color: var(--color-loss); text-shadow: 0 0 16px rgba(244, 63, 94, 0.5); }
/* Headline pop on reveal. Success scales up smoothly; failure jolts in with a
   shake so the two outcomes feel kinetically different at a glance. */
.narrative-event-result-headline.success { animation: result-headline-success 0.7s cubic-bezier(0.34, 1.56, 0.64, 1); }
.narrative-event-result-headline.fail    { animation: result-headline-fail 0.55s cubic-bezier(0.36, 0.07, 0.19, 0.97); }
@keyframes result-headline-success {
  0%   { transform: scale(0.6); opacity: 0; filter: blur(4px); }
  60%  { transform: scale(1.12); opacity: 1; filter: blur(0); }
  100% { transform: scale(1); }
}
@keyframes result-headline-fail {
  0%   { transform: translate(0, -8px) scale(0.9); opacity: 0; }
  20%  { transform: translate(-6px, 0)  scale(1.05); opacity: 1; }
  40%  { transform: translate(6px, 0)   scale(1.05); }
  60%  { transform: translate(-4px, 0)  scale(1.02); }
  80%  { transform: translate(3px, 0)   scale(1); }
  100% { transform: translate(0, 0)     scale(1); }
}
/* Natural 1 / 20 get a tighter font + extra glow so the moment reads bigger. */
.narrative-event-result-headline.epic    {
  font-size: 18px;
  letter-spacing: 0.14em;
}
.narrative-event-result-headline.epic.success {
  text-shadow: 0 0 24px rgba(163, 230, 53, 0.8), 0 0 48px rgba(163, 230, 53, 0.35);
  animation: result-headline-success 0.7s cubic-bezier(0.34, 1.56, 0.64, 1),
             epic-pulse 1.4s 0.7s ease-in-out infinite;
}
.narrative-event-result-headline.epic.fail    {
  text-shadow: 0 0 24px rgba(244, 63, 94, 0.8),  0 0 48px rgba(244, 63, 94, 0.35);
  animation: result-headline-fail 0.55s cubic-bezier(0.36, 0.07, 0.19, 0.97),
             epic-pulse 1.4s 0.55s ease-in-out infinite;
}
@keyframes epic-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }

/* Result panel border + glow flip color with the outcome. Reading the panel
   itself should signal win/loss before you read the headline. */
.narrative-event--success .narrative-event-result {
  border: 1px solid color-mix(in srgb, var(--color-win) 60%, transparent);
  box-shadow: 0 0 24px rgba(163, 230, 53, 0.25), inset 0 0 16px rgba(163, 230, 53, 0.08);
}
.narrative-event--fail .narrative-event-result {
  border: 1px solid color-mix(in srgb, var(--color-loss) 60%, transparent);
  box-shadow: 0 0 24px rgba(244, 63, 94, 0.25), inset 0 0 16px rgba(244, 63, 94, 0.08);
}

/* Continue button tone follows the outcome — green for success, red for fail. */
.narrative-event-continue--success {
  background: linear-gradient(135deg, var(--color-win) 0%, var(--accent-secondary-glow) 100%);
  color: #0a0a0c;
}
.narrative-event-continue--fail {
  background: linear-gradient(135deg, var(--color-loss) 0%, #b91c3c 100%);
}

/* Result sparkle burst — a fan of 7 glyphs that radiate from the headline.
   Mounted inside .narrative-event-result, positioned over its top-center. */
.result-burst {
  position: absolute;
  top: 16px;
  left: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 4;
  --burst-tone: var(--color-win);
  --burst-scale: 1;
}
.result-burst--loss { --burst-tone: var(--color-loss); }
.result-burst--epic { --burst-scale: 1.5; }
.result-burst > span {
  position: absolute;
  top: 0;
  left: 0;
  font-size: calc(16px * var(--burst-scale));
  color: var(--burst-tone);
  text-shadow:
    0 0 10px color-mix(in srgb, var(--burst-tone) 80%, transparent),
    0 0 20px color-mix(in srgb, var(--burst-tone) 40%, transparent);
  opacity: 0;
  animation: result-burst-fly 1.2s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}
.result-burst--epic > span { animation-duration: 1.55s; }
/* 7 spans → angles span -135° to +135°. */
.result-burst > span:nth-child(1) { --burst-angle: -135deg; animation-delay: 0ms;   }
.result-burst > span:nth-child(2) { --burst-angle:  -90deg; animation-delay: 40ms;  }
.result-burst > span:nth-child(3) { --burst-angle:  -45deg; animation-delay: 80ms;  }
.result-burst > span:nth-child(4) { --burst-angle:    0deg; animation-delay: 60ms;  }
.result-burst > span:nth-child(5) { --burst-angle:   45deg; animation-delay: 100ms; }
.result-burst > span:nth-child(6) { --burst-angle:   90deg; animation-delay: 30ms;  }
.result-burst > span:nth-child(7) { --burst-angle:  135deg; animation-delay: 70ms;  }
@keyframes result-burst-fly {
  0%   { opacity: 0; transform: rotate(var(--burst-angle)) translateY(0)    scale(0.4); }
  20%  { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--burst-angle)) translateY(calc(-90px * var(--burst-scale))) scale(1); }
}

/* Epic vignette: longer dwell + a touch more reach on the radial. Layered on
   top of .vignette-flash--{damage|heal} so the base color is preserved. */
.vignette-flash--epic { animation-duration: 1.1s; }
.vignette-flash--epic.vignette-flash--heal   { background: radial-gradient(ellipse at center, transparent 18%, rgba(163, 230, 53, 0.75) 100%); }
.vignette-flash--epic.vignette-flash--damage { background: radial-gradient(ellipse at center, transparent 18%, rgba(244, 63, 94, 0.80) 100%); }

@media (prefers-reduced-motion: reduce) {
  .narrative-event-result-headline.success,
  .narrative-event-result-headline.fail,
  .narrative-event-result-headline.epic.success,
  .narrative-event-result-headline.epic.fail { animation: none; }
  .result-burst > span { animation-duration: 0.3s; }
}

.narrative-event-item-card {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  background: var(--bg-card-elevated);
  border: 1px solid var(--accent-secondary);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: var(--gap-md);
  box-shadow: 0 0 14px rgba(163, 230, 53, 0.18);
}

/* Pause button shares look with speed-toggle but indicates state via aria + content. */
.speed-toggle[aria-label="Pause"][data-paused="true"] {
  background: var(--accent-secondary);
  color: #0a0a0c;
}

/* Choice "dice rolling" highlight — alternates in the last 2s of the timer. */
.narrative-event-choice.rolling {
  background: linear-gradient(135deg, rgba(236, 72, 153, 0.45), rgba(236, 72, 153, 0.20));
  border-color: var(--accent-primary-glow);
  transform: scale(1.02);
  box-shadow: 0 0 14px rgba(236, 72, 153, 0.5);
}
.narrative-event-choice.rolling-final {
  background: linear-gradient(135deg, var(--accent-secondary) 0%, var(--accent-secondary-glow) 100%);
  border-color: var(--accent-secondary-glow);
  color: #0a0a0c;
  transform: scale(1.04);
  box-shadow: 0 0 20px rgba(163, 230, 53, 0.7);
  animation: settle-pulse 0.5s ease-out;
}
@keyframes settle-pulse {
  0%, 100% { transform: scale(1.04); }
  50%      { transform: scale(1.10); }
}

/* d20 roll animation — spinning emoji + ticking number that settles on the final value. */
.d20-roll {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px 12px;
}
.d20-emoji {
  font-size: 64px;
  animation: d20-spin 0.5s linear infinite;
  filter: drop-shadow(0 0 10px var(--accent-primary));
}
@keyframes d20-spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
.d20-value {
  font-size: 36px;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}
.d20-value.d20-settled {
  font-size: 48px;
  color: var(--accent-secondary);
  text-shadow: 0 0 18px var(--accent-secondary);
  animation: d20-pop 0.45s ease-out;
}
@keyframes d20-pop {
  0%   { transform: scale(0.5); opacity: 0; }
  60%  { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(1); }
}
.d20-label { font-size: 12px; color: var(--text-muted); letter-spacing: 0.15em; text-transform: uppercase; }
/* Continue button stays pinned at the bottom of the panel even when content scrolls. */
.narrative-event-continue {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  padding: 12px;
  background: var(--accent-primary-grad);
  color: white;
  font-size: 14px;
  font-weight: 800;
  border-radius: 10px;
  letter-spacing: 0.03em;
  flex-shrink: 0;
  z-index: 1;
}
.narrative-event-continue-bar {
  position: relative;
  height: 3px;
  background: rgba(255, 255, 255, 0.12);
  margin-top: 6px;
  border-radius: 2px;
  overflow: hidden;
}
.narrative-event-continue-bar-fill {
  position: absolute;
  inset: 0;
  background: var(--accent-secondary);
  transform-origin: left center;
  animation: result-auto-shrink 5s linear forwards;
}
@keyframes result-auto-shrink {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}
.narrative-event-paused-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 10px;
  letter-spacing: 0.12em;
  font-weight: 800;
  color: var(--accent-secondary);
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 6px;
  pointer-events: none;
}

/* Activity log fills the remaining vertical space between the controls bar and the
   tab bar. min-height:0 is required so flex can actually shrink it below content size
   — without it, the log expands to fit all entries and pushes the rest of the page
   out of the viewport. Internal overflow-y handles the scrolling. */
.activity-log {
  flex: 1 1 0;
  min-height: 0;
  background: var(--bg-card);
  border-radius: 10px 10px 0 0;
  padding: var(--gap-sm);
  overflow-y: auto;
  scroll-behavior: smooth;
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid var(--border-subtle);
  border-bottom: none;
}
.log-entry { padding: 2px 6px; border-radius: 4px; }
.log-entry--win { border-left: 3px solid var(--color-win); background: rgba(163, 230, 53, 0.08); padding-left: 8px; }
.log-entry--loss { border-left: 3px solid var(--color-loss); background: rgba(244, 63, 94, 0.08); padding-left: 8px; }
.log-entry--floor { border-left: 3px solid var(--color-floor); background: rgba(59, 130, 246, 0.08); padding-left: 8px; }

/* Loot row reads as a card: rarity-tinted gradient, thicker border, more breathing room.
   Tier-specific overrides recolor the gradient + border so the rarity is legible at a glance. */
.log-entry--loot {
  --loot-tone: var(--accent-secondary);
  border-left: 4px solid var(--loot-tone);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0));
  background-color: color-mix(in srgb, var(--loot-tone) 18%, transparent);
  padding: 6px 10px 6px 12px;
  margin: 3px 0;
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--loot-tone) 24%, transparent);
}
.log-entry--loot .log-entry-time { color: color-mix(in srgb, var(--loot-tone) 70%, var(--text-muted)); }
.log-entry--tier-common    { --loot-tone: var(--rarity-common); }
.log-entry--tier-magic     { --loot-tone: var(--rarity-magic); }
.log-entry--tier-rare      { --loot-tone: var(--rarity-rare); }
.log-entry--tier-epic      { --loot-tone: var(--rarity-epic); }
.log-entry--tier-legendary { --loot-tone: var(--rarity-legendary); }
.log-entry--tier-mythic    { --loot-tone: var(--rarity-mythic); }
.log-entry--tier-aether    { --loot-tone: var(--rarity-aether); }
/* Unique drops glow a touch stronger so they're spotted in a busy feed. */
.log-entry--unique {
  background-color: color-mix(in srgb, var(--loot-tone) 28%, transparent);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--loot-tone) 50%, transparent),
    0 0 14px color-mix(in srgb, var(--loot-tone) 32%, transparent);
}

.log-entry-time { color: var(--text-muted); margin-right: 6px; font-variant-numeric: tabular-nums; }

/* ============================================
   GEAR (INBOX) SCREEN
   ============================================ */
.sub-tabs {
  display: flex;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-app);
  padding: 0 var(--gap-lg);
}
.sub-tab {
  flex: 1;
  padding: 12px 0;
  font-size: 14px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  font-weight: 600;
}
.sub-tab[data-active="true"] {
  color: var(--text-primary);
  border-bottom-color: var(--accent-primary);
}

/* The active sub-screen claims the rest of the gear-tab space and scrolls inside. */
.sub-screen { display: none; }
.sub-screen[data-active="true"] {
  display: block;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: var(--gap-lg);
}

.hero-power-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: var(--gap-md);
  margin-bottom: var(--gap-md);
  border: 1px solid var(--border-subtle);
}
.hp-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--gap-md);
}
.hp-card-label { font-size: 14px; color: var(--text-secondary); }
.hp-card-value { color: var(--accent-primary-glow); font-weight: 800; font-size: 20px; margin-left: 4px; }
.auto-upgrade-btn {
  background: rgba(163, 230, 53, 0.12);
  color: var(--accent-secondary);
  border: 1px solid var(--accent-secondary);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  transition: transform 0.1s, background 0.2s;
}
.badge {
  background: var(--accent-secondary);
  color: #0a0a0c;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 800;
}
.hp-card-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap-sm);
}
.hp-card-grid > div { background: var(--bg-card-elevated); border-radius: 8px; padding: 8px; text-align: center; }
.mini-stat-label { font-size: 10px; color: var(--text-muted); letter-spacing: 0.1em; font-weight: 600; }
.mini-stat-value { font-size: 16px; font-weight: 800; margin-top: 2px; }

.equipped-list { display: flex; flex-direction: column; gap: var(--gap-xs); }
.slot-row {
  display: flex;
  align-items: center;
  gap: var(--gap-md);
  background: var(--bg-card);
  padding: var(--gap-md);
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  transition: background 0.15s, border-color 0.15s;
}
.slot-row:hover { background: var(--bg-card-elevated); border-color: var(--border-card); }
.slot-row.empty { opacity: 0.6; }
.slot-icon { width: 24px; }
.slot-info { flex: 1; }
.slot-name { font-size: 14px; font-weight: 700; }
.slot-pwr { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.slot-affix-chips { display: flex; gap: 6px; font-size: 12px; }
.affix-chip { color: var(--text-secondary); }
.upgrade-arrow {
  background: var(--accent-secondary);
  color: #0a0a0c;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

/* Collection (stash) */
.stash-list { display: flex; flex-direction: column; gap: var(--gap-xs); }
.stash-item-row {
  display: flex;
  align-items: center;
  gap: var(--gap-md);
  background: var(--bg-card);
  padding: var(--gap-md);
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  transition: background 0.15s, border-color 0.15s;
}
.stash-item-row:hover { background: var(--bg-card-elevated); border-color: var(--border-card); }
.rarity-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.rarity-dot.rarity-common { background: var(--rarity-common); }
.rarity-dot.rarity-magic { background: var(--rarity-magic); box-shadow: 0 0 6px var(--rarity-magic); }
.rarity-dot.rarity-rare { background: var(--rarity-rare); box-shadow: 0 0 6px var(--rarity-rare); }
.rarity-dot.rarity-epic { background: var(--rarity-epic); box-shadow: 0 0 6px var(--rarity-epic); }
.rarity-dot.rarity-legendary { background: var(--rarity-legendary); box-shadow: 0 0 8px var(--rarity-legendary); }
.rarity-dot.rarity-mythic { background: var(--rarity-mythic); box-shadow: 0 0 10px var(--rarity-mythic); }
.rarity-dot.rarity-aether { background: var(--rarity-aether); box-shadow: 0 0 14px var(--rarity-aether); }
.stash-item-name { flex: 1; font-size: 14px; }
.power-pill {
  background: var(--accent-secondary);
  color: #0a0a0c;
  font-weight: 800;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 10px;
}

/* Forge (fusion) */
.fusion-rules {
  background: var(--bg-card);
  border-radius: 10px;
  padding: var(--gap-md);
  margin-bottom: var(--gap-md);
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.8;
  border: 1px solid var(--border-subtle);
}

.fusion-bulk-row { display: flex; gap: var(--gap-sm); margin-bottom: var(--gap-md); }
.fusion-bulk-btn {
  flex: 1;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
}
.fusion-bulk-btn--primary {
  background: var(--accent-primary-grad);
  border-color: transparent;
  color: white;
}

.fusion-slots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap-sm);
  margin-bottom: var(--gap-md);
  margin-top: 22px;       /* room for the "OUTPUT SLOT" label above slot 0 */
  position: relative;
}
.fusion-slots::before {
  content: 'OUTPUT SLOT ↓';
  position: absolute;
  top: -18px;
  left: 0;
  width: calc((100% - 16px) / 3);
  text-align: center;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.15em;
  color: var(--accent-secondary);
}
.fusion-slot {
  aspect-ratio: 1;
  background: var(--bg-card);
  border: 2px dashed var(--border-card);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 12px;
  padding: 4px;
}
/* Leftmost slot is highlighted as the Output reference. */
.fusion-slot[data-slot="0"] {
  border-color: var(--accent-secondary);
  background: rgba(163, 230, 53, 0.06);
  box-shadow: 0 0 12px rgba(163, 230, 53, 0.2);
}
.fusion-slot-empty { font-size: 28px; color: var(--text-muted); }
.fusion-slot--filled {
  border-style: solid;
  border-color: var(--accent-primary);
  cursor: pointer;
  animation: slot-pop-in 0.22s ease-out;
}
@keyframes slot-pop-in {
  0%   { transform: scale(0.85); }
  60%  { transform: scale(1.05); }
  100% { transform: scale(1); }
}
.fusion-slot-name { font-size: 11px; font-weight: 700; line-height: 1.2; }
.fusion-slot-pwr  { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

/* Forge confirm CTA — visible only when 3 slots are filled. */
.fusion-forge-btn {
  display: block;
  width: 100%;
  padding: 14px;
  background: var(--accent-primary-grad);
  color: white;
  font-size: 16px;
  font-weight: 800;
  border-radius: 12px;
  letter-spacing: 0.03em;
  margin-bottom: var(--gap-md);
  box-shadow: 0 4px 16px rgba(236, 72, 153, 0.4);
}
.fusion-forge-btn[hidden] { display: none; }

.fusion-result {
  background: var(--bg-card);
  border: 1px solid var(--accent-primary);
  border-radius: 10px;
  padding: var(--gap-md);
  margin-bottom: var(--gap-md);
  box-shadow: 0 0 16px rgba(236, 72, 153, 0.15);
}
.fusion-result-headline { font-size: 14px; font-weight: 700; margin-bottom: var(--gap-sm); }

/* Quick Equip — only renders on the forge result panel when the new item beats
   what's currently equipped in that slot. Lime glow + up arrow. */
.fusion-result-quick-equip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: var(--gap-md);
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(163, 230, 53, 0.22), rgba(163, 230, 53, 0.08));
  border: 1px solid var(--accent-secondary);
  border-radius: 10px;
  color: var(--accent-secondary);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.05em;
  animation: quick-equip-glow 1.8s ease-in-out infinite;
}
.fusion-result-quick-equip:active { transform: scale(0.97); animation: none; }
.fusion-result-quick-equip-delta { font-weight: 700; opacity: 0.9; font-size: 12px; }
@keyframes quick-equip-glow {
  0%, 100% { box-shadow: 0 0 10px rgba(163, 230, 53, 0.30); }
  50%      { box-shadow: 0 0 20px rgba(163, 230, 53, 0.65); }
}

.fusion-available-header { font-size: 12px; color: var(--text-muted); margin-bottom: var(--gap-sm); }
.fusion-available-list { display: flex; flex-direction: column; gap: var(--gap-xs); }

/* ============================================
   PROFILE (STATS) SCREEN
   ============================================ */
.hero-stats-header {
  display: flex;
  align-items: center;
  gap: var(--gap-md);
  background: var(--bg-card);
  border: 1px solid var(--accent-primary);
  border-radius: 12px;
  padding: var(--gap-md);
  margin-bottom: var(--gap-md);
}
.hero-stats-portrait { width: 48px; height: 48px; border-radius: 8px; }
.hero-stats-info { flex: 1; }
.hero-stats-name { font-size: 16px; font-weight: 800; }
.hero-stats-sub { font-size: 12px; color: var(--text-muted); }
.hero-stats-pwr { color: var(--accent-secondary); font-weight: 800; font-size: 18px; }

.stat-section {
  background: var(--bg-card);
  border-radius: 10px;
  padding: var(--gap-md);
  margin-bottom: var(--gap-sm);
  border-left: 3px solid var(--text-muted);
  border-top: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}
.stat-section--core { border-left-color: var(--stat-core); }
.stat-section--crit { border-left-color: var(--stat-crit); }
.stat-section--defense { border-left-color: var(--stat-defense); }
.stat-section--powerups { border-left-color: var(--accent-secondary); }
.stat-section[hidden] { display: none !important; }

.stat-section-header {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
  margin-bottom: var(--gap-sm);
}
.stat-section-sub {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-left: 4px;
}

.powerup-stack-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.powerup-stack-row {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  padding: 7px 10px;
  background: var(--bg-card-elevated);
  border-radius: 8px;
  font-size: 13px;
}
.powerup-stack-icon { font-size: 16px; width: 22px; text-align: center; }
.powerup-stack-label { flex: 1; color: var(--text-primary); font-weight: 700; }
.powerup-stack-count {
  font-weight: 800;
  color: var(--accent-secondary);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}

.stat-row {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  padding: 6px 0;
  font-size: 14px;
}
.stat-icon { width: 20px; }
.stat-label { flex: 1; color: var(--text-secondary); }
.stat-badge {
  background: var(--accent-secondary);
  color: #0a0a0c;
  font-size: 11px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 8px;
}
.stat-value { font-weight: 800; }

.settings-section { border-left-color: var(--text-muted); }
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
  cursor: pointer;
}
.settings-label { color: var(--text-secondary); }
.settings-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}
.settings-row--column { flex-direction: column; align-items: stretch; gap: 6px; }
.settings-input {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text-primary);
  font-size: 12px;
  font-family: inherit;
}
.settings-input:focus { outline: none; border-color: var(--accent-primary); }
.settings-hint { font-size: 11px; color: var(--text-muted); }
.settings-hint--warn { color: var(--accent-warning); }
.settings-value { font-size: 11px; color: var(--text-muted); font-weight: 600; float: right; }
.settings-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  outline: none;
}
.settings-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  border: 2px solid var(--bg-card);
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.settings-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-primary);
  cursor: pointer;
  border: 2px solid var(--bg-card);
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* Phase 2 placeholder — taste-profile uploads */
.media-prefs {
  margin-top: var(--gap-lg);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: var(--gap-md);
}
.media-prefs-header {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
  margin-bottom: var(--gap-md);
}
.media-prefs-sub {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 11px;
  margin-left: 6px;
}
.media-row {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  padding: 8px 0;
  font-size: 13px;
  border-top: 1px solid var(--border-subtle);
  cursor: pointer;
}
.media-row:first-of-type { border-top: none; }
.media-label { flex: 1; color: var(--text-primary); }
.media-status {
  font-size: 11px;
  color: var(--text-muted);
  margin-right: var(--gap-sm);
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.media-upload-btn {
  background: var(--accent-primary-grad);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 8px;
  letter-spacing: 0.03em;
}

.admin-details {
  margin-top: var(--gap-xl);
  font-size: 12px;
  color: var(--text-muted);
}
.admin-details summary { cursor: pointer; padding: var(--gap-sm) 0; }
.admin-panel { background: var(--bg-card); padding: var(--gap-md); border-radius: 10px; border: 1px solid var(--border-subtle); }
.admin-panel button { display: block; width: 100%; margin: 6px 0; padding: 8px; background: var(--bg-pill); border-radius: 8px; }

.reset-game-btn {
  display: block;
  width: 100%;
  margin-top: var(--gap-xl);
  padding: 10px;
  background: rgba(244, 63, 94, 0.1);
  color: var(--color-loss);
  border: 1px solid var(--color-loss);
  border-radius: 8px;
  font-size: 13px;
}

/* ============================================
   TAB BAR
   ============================================ */
.tab-bar {
  /* Fixed to viewport bottom but constrained to the phone-frame width and centered. */
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max-w);
  height: var(--tab-bar-h);
  background: var(--bg-card);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  z-index: 100;
}
/* Main menu has no in-game tabs. */
body.on-main-menu .tab-bar { display: none; }
body.on-main-menu .app-header { display: none; }
body.on-main-menu #app { padding-bottom: 0; }
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  position: relative;
  color: var(--text-muted);
}
.tab[data-active="true"] {
  color: var(--accent-primary-glow);
}
.tab[data-active="true"]::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 30%;
  right: 30%;
  height: 2px;
  background: var(--accent-primary);
  box-shadow: 0 0 8px var(--accent-primary);
}
.tab-icon { font-size: 22px; transition: transform 0.2s; }
.tab[data-active="true"] .tab-icon { transform: scale(1.1); }
.tab-label { font-size: 11px; letter-spacing: 0.03em; font-weight: 600; }

.fuse-nudge {
  position: absolute;
  top: 4px;
  right: 24px;
  background: var(--accent-secondary);
  color: #0a0a0c;
  font-size: 9px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 8px;
  animation: fuse-pulse 1.5s ease-in-out infinite;
  letter-spacing: 0.05em;
  box-shadow: 0 0 8px var(--accent-secondary);
}
@keyframes fuse-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* ============================================
   PORTAL: drawers / toasts
   ============================================ */
#portal-root { position: relative; z-index: 200; }

.drawer {
  /* Drawers and toasts ride at the bottom of the phone frame, not the full viewport. */
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max-w);
  background: var(--bg-card-elevated);
  border-top: 1px solid var(--border-card);
  border-radius: 16px 16px 0 0;
  padding: var(--gap-lg);
  max-height: 80vh;
  overflow-y: auto;
  z-index: 210;
  animation: drawer-slide-up 0.3s ease-out;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 205;
  animation: backdrop-fade-in 0.2s ease-out;
}
@keyframes backdrop-fade-in { from { opacity: 0; } to { opacity: 1; } }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--gap-md);
}
.drawer-title { font-size: 16px; font-weight: 700; }
.drawer-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-pill);
  font-size: 22px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.last-run-log {
  font-size: 13px;
  line-height: 1.5;
}

/* Item-details drawer (PRD §16) — tier dot + name + slot + affix rows + action buttons */
.item-drawer-head {
  display: flex;
  align-items: center;
  gap: var(--gap-md);
  margin-bottom: var(--gap-md);
}
.item-drawer-name { font-size: 17px; font-weight: 800; }
.item-drawer-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; text-transform: capitalize; }

.item-drawer-affixes {
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
  margin-bottom: var(--gap-lg);
}
.item-drawer-affix {
  display: flex;
  align-items: center;
  gap: var(--gap-sm);
  background: var(--bg-card);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
}
.item-drawer-affix-icon { font-size: 16px; }

.item-drawer-actions { display: flex; gap: var(--gap-sm); }
.item-drawer-btn {
  flex: 1;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
}
.item-drawer-btn--primary {
  background: var(--accent-primary-grad);
  border-color: transparent;
  color: white;
}

/* Powerup picker — full-screen overlay with 3 cards, 1-of-3 selection.
   Used after a 10% boss-kill proc (and from narrative 'powerup' outcomes). */
.powerup-picker {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(163, 230, 53, 0.18), rgba(0, 0, 0, 0.92));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--gap-md);
  z-index: 220;
  padding: var(--gap-lg);
  animation: powerup-fade-in 0.3s ease-out;
}
.powerup-picker[hidden] { display: none; }
@keyframes powerup-fade-in { from { opacity: 0; } to { opacity: 1; } }

.powerup-headline {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: var(--accent-secondary);
  text-shadow: 0 0 18px rgba(163, 230, 53, 0.55);
}
.powerup-subhead {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.powerup-cards {
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
  width: 100%;
  max-width: 380px;
}
.powerup-card {
  background: var(--bg-card-elevated);
  border: 2px solid var(--accent-secondary);
  border-radius: 12px;
  padding: var(--gap-md) var(--gap-md);
  display: flex;
  align-items: center;
  gap: var(--gap-md);
  cursor: pointer;
  text-align: left;
  transition: transform 0.1s, box-shadow 0.2s, border-color 0.2s;
  animation: powerup-card-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.powerup-card:nth-child(2) { animation-delay: 0.06s; }
.powerup-card:nth-child(3) { animation-delay: 0.12s; }
@keyframes powerup-card-in {
  from { transform: translateY(8px) scale(0.92); opacity: 0; }
  to   { transform: translateY(0)   scale(1);    opacity: 1; }
}
.powerup-card:hover, .powerup-card:focus-visible {
  transform: scale(1.02);
  box-shadow: 0 0 22px rgba(163, 230, 53, 0.5);
  border-color: var(--accent-secondary-glow);
  outline: none;
}
.powerup-card:active { transform: scale(0.98); }
.powerup-card-icon { font-size: 30px; line-height: 1; flex-shrink: 0; }
.powerup-card-info { flex: 1; min-width: 0; }
.powerup-card-name { font-weight: 800; font-size: 15px; color: var(--accent-secondary); }
.powerup-card-desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.powerup-card-stack {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  margin-top: 4px;
  font-weight: 700;
}
.powerup-timer {
  height: 4px;
  width: 100%;
  max-width: 380px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
  margin-top: var(--gap-xs);
}
.powerup-timer-fill {
  height: 100%;
  width: 100%;
  background: var(--accent-secondary);
  transform-origin: left center;
  animation: powerup-timer-shrink 9s linear forwards;
}
@keyframes powerup-timer-shrink { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* Doom victory modal — celebrates an archive completion before sending the player home. */
.victory-backdrop {
  background: radial-gradient(ellipse at center, rgba(163, 230, 53, 0.25), rgba(0, 0, 0, 0.92));
  z-index: 250 !important;
  animation: victory-backdrop-in 0.6s ease-out;
}
@keyframes victory-backdrop-in { from { opacity: 0; } to { opacity: 1; } }

.victory-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: var(--app-max-w);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-card-elevated);
  border: 2px solid var(--accent-secondary);
  border-radius: 16px;
  padding: var(--gap-xl);
  text-align: center;
  z-index: 251;
  box-shadow: 0 0 60px rgba(163, 230, 53, 0.45), 0 12px 40px rgba(0, 0, 0, 0.6);
  animation: victory-modal-in 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes victory-modal-in {
  from { transform: translate(-50%, -50%) scale(0.6); opacity: 0; }
  to   { transform: translate(-50%, -50%) scale(1);   opacity: 1; }
}

.victory-headline {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0.18em;
  background: linear-gradient(135deg, var(--accent-secondary) 0%, #fde047 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}
.victory-archive { font-size: 11px; color: var(--text-muted); letter-spacing: 0.22em; }
.victory-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: var(--gap-lg) 0;
}
.victory-stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  background: var(--bg-card);
  padding: 10px 14px;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
}
.victory-stat-row span:last-child { font-weight: 800; color: var(--accent-secondary); }

.victory-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin: var(--gap-md) 0 var(--gap-lg);
}
.victory-tag {
  background: rgba(163, 230, 53, 0.14);
  border: 1px solid var(--accent-secondary);
  color: var(--accent-secondary);
  padding: 5px 12px;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.victory-actions {
  display: flex;
  gap: var(--gap-sm);
}
.victory-btn {
  flex: 1;
  padding: 14px 12px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  border: 1px solid var(--border-subtle);
}
.victory-btn--primary {
  flex: 1.4;
  background: var(--accent-primary-grad);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 18px rgba(236, 72, 153, 0.5);
}
.victory-btn--secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
}
.victory-btn--secondary:hover { color: var(--text-primary); }

/* Run summary modal — defeat / abandon. Doom victory uses .victory-modal above. */
.run-summary-backdrop {
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.92));
  z-index: 250 !important;
  animation: victory-backdrop-in 0.3s ease-out;
}
.run-summary-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 92%;
  max-width: var(--app-max-w);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-card-elevated);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: var(--gap-lg);
  text-align: center;
  z-index: 251;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  animation: victory-modal-in 0.35s cubic-bezier(0.34, 1.4, 0.64, 1);
}
.run-summary-headline {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.16em;
  margin-bottom: 2px;
}
.run-summary-headline--defeat {
  color: var(--color-loss);
  text-shadow: 0 0 18px rgba(244, 63, 94, 0.45);
}
.run-summary-headline--abandon {
  color: var(--text-secondary);
  letter-spacing: 0.18em;
}
.run-summary-slainby {
  font-size: 14px;
  color: var(--color-loss);
  margin: 2px 0 6px;
}
.run-summary-slainby strong {
  font-weight: 700;
  color: var(--text-primary);
}
.run-summary-subhead {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: var(--gap-md);
}
.run-summary-stats {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: var(--gap-md);
}
.run-summary-stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  background: var(--bg-card);
  padding: 9px 14px;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
}
.run-summary-stat-row span:last-child {
  font-weight: 800;
  color: var(--text-primary);
}
.run-summary-highlights {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: var(--gap-md);
}
.run-summary-highlight {
  font-size: 12px;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 10px;
}
.run-summary-highlight strong { color: var(--text-primary); font-weight: 800; }
.run-summary-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap-sm);
  margin-bottom: var(--gap-md);
}
.run-summary-btn {
  padding: 13px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.run-summary-btn:hover { background: var(--bg-card-elevated); }
.run-summary-btn--primary {
  background: var(--accent-primary-grad);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(236, 72, 153, 0.4);
}
/* Continue is a between-run "next scroll" action — neutral acid-lime to keep the
   pink/magenta primary reserved for momentous "fresh archive" CTAs (Doom victory). */
.run-summary-btn--continue {
  background: linear-gradient(135deg, #a3e635 0%, #65a30d 100%);
  color: #0a1006;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(163, 230, 53, 0.35);
}
.run-summary-btn--continue:hover { filter: brightness(1.08); background: linear-gradient(135deg, #bef264 0%, #84cc16 100%); }
.run-summary-timer {
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
}
.run-summary-timer-fill {
  height: 100%;
  width: 100%;
  background: var(--text-secondary);
  transform-origin: left center;
  animation: run-summary-tick 10s linear forwards;
}
@keyframes run-summary-tick {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* Slot picker — pops when the player taps an equipment slot. */
.slot-picker-section {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  margin: var(--gap-md) 0 var(--gap-sm);
}
.slot-picker-section:first-of-type { margin-top: 0; }
.slot-picker-row {
  display: flex;
  align-items: center;
  gap: var(--gap-md);
  background: var(--bg-card);
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: var(--gap-xs);
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  transition: background 0.15s, border-color 0.15s;
}
.slot-picker-row:hover { background: var(--bg-card-elevated); border-color: var(--border-card); }
.slot-picker-row--current { border-color: var(--accent-primary); background: rgba(236, 72, 153, 0.08); }
.slot-picker-info { flex: 1; min-width: 0; font-size: 13px; }
.slot-picker-affix { font-size: 11px; color: var(--text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-picker-action {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}
.slot-picker-delta {
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  min-width: 40px;
  text-align: right;
}
.slot-picker-delta.positive { color: var(--accent-secondary); }
.slot-picker-delta.negative { color: var(--color-loss); }
@keyframes drawer-slide-up {
  from { transform: translate(-50%, 100%); }
  to   { transform: translate(-50%, 0); }
}

.toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card-elevated);
  border: 1px solid var(--accent-primary);
  padding: 10px 16px;
  border-radius: 24px;
  font-size: 13px;
  white-space: nowrap;
  animation: toast-in 0.3s ease-out;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6), 0 0 16px rgba(236, 72, 153, 0.2);
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ============================================================
   POLISH PASS
   Accessibility, micro-interactions, finishing touches.
   ============================================================ */

/* Keyboard focus rings — visible only on keyboard nav, never on tap/click. */
button:focus-visible,
input:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--accent-primary-glow);
  outline-offset: 2px;
}

/* Smooth screen-enter — gentle fade + lift on activation. */
.screen[data-active="true"] { animation: screen-in 0.18s ease-out; }
@keyframes screen-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Idle hero portrait — subtle breath animation while the player hesitates. */
.hero-portrait { animation: hero-breath 3.6s ease-in-out infinite; }
@keyframes hero-breath {
  0%, 100% { transform: scale(1);     box-shadow: 0 0 24px rgba(236, 72, 153, 0.40), 0 0 0 1px rgba(236, 72, 153, 0.10); }
  50%      { transform: scale(1.012); box-shadow: 0 0 34px rgba(236, 72, 153, 0.55), 0 0 0 1px rgba(236, 72, 153, 0.22); }
}

/* Primary CTA gets a slow shimmer + lift on hover. */
.primary-cta { position: relative; overflow: hidden; }
.primary-cta:hover { box-shadow: 0 6px 24px rgba(236, 72, 153, 0.65); }
.primary-cta::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 35%, rgba(255, 255, 255, 0.18) 50%, transparent 65%);
  transform: translateX(-100%);
  animation: cta-shimmer 4.5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes cta-shimmer {
  0%, 70%   { transform: translateX(-100%); }
  85%, 100% { transform: translateX(100%); }
}

/* Tab-bar icon scale + glow on active state. */
.tab-icon { transition: transform 0.2s ease-out; }
.tab[data-active="true"] .tab-icon { transform: scale(1.15); }

/* Mode-card hover lift handled in the MAIN MENU block above; leave this empty hook
   in case future themes want to layer additional hover treatment. */

/* Empty-state utility — used by render.js for consistent "nothing here yet" states. */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}
.empty-state-icon { font-size: 28px; margin-bottom: 8px; opacity: 0.6; }

/* HP bar fill — smooth color/width tween (already partially set; consolidating). */
.hp-fill { transition: width 0.3s ease-out, background 0.3s; }

/* ============================================================
   ONBOARDING — first-launch gate + contextual shortcut bar
   ============================================================ */

/* On the very first launch (no run completed yet) the bottom-nav tabs are
   visually disabled so the only inviting interaction is the primary CTA. */
body.first-run .tab           { pointer-events: none; opacity: 0.35; }
body.first-run .tab-icon      { transform: scale(1); }

/* Slim shortcut bar above the tab bar. Frame-locked, scoped to the phone width. */
/* Chevron-shaped shortcut bar — buttons slot into each other like arrows. */
.shortcut-bar {
  position: fixed;
  bottom: var(--tab-bar-h);
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max-w);
  height: 44px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 4px 4px;
  z-index: 99;
}
/* `display: flex` above outranks the user-agent [hidden] rule, so we override
   explicitly. Without this the bar stays visible even when hidden=true is set. */
.shortcut-bar[hidden] { display: none !important; }
body.landscape .shortcut-bar { max-width: none; }

.shortcut-btn {
  flex: 1;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  padding: 0 18px 0 22px;
  background: var(--bg-card-elevated);
  color: var(--text-secondary);
  /* Right-pointing arrow with notched left, so the previous chevron slots in. */
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%, 12px 50%);
  margin-right: -10px;
}
.shortcut-btn:first-child {
  /* Flat left edge for the first chip — nothing slots in from before. */
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%);
  padding-left: 16px;
}
.shortcut-btn:last-child {
  /* Flat right edge for the final chip — nothing slots in after. */
  clip-path: polygon(12px 0, 100% 0, 100% 100%, 12px 100%, 0 50%);
  padding-right: 16px;
  margin-right: 0;
}

/* Visual de-emphasis when the button isn't the next suggested step. We use a class
   instead of the [disabled] attribute because [disabled] would block click events
   at the browser level, breaking back-navigation. */
.shortcut-btn--muted { opacity: 0.35; }
.shortcut-btn:disabled { opacity: 0.35; }     /* legacy — Forge still uses disabled */

/* Profile powerup rows are buttons now — keep them looking like rows but tappable. */
button.powerup-stack-row {
  width: 100%;
  background: transparent;
  border: 0;
  padding: 8px 10px;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s;
}
button.powerup-stack-row:hover,
button.powerup-stack-row:focus-visible {
  background: rgba(255, 255, 255, 0.05);
  outline: none;
}

/* Victory tags become buttons too. Keep the chip look. */
button.victory-tag {
  border: 0;
  cursor: pointer;
  font: inherit;
  transition: transform 0.1s, filter 0.1s;
}
button.victory-tag:hover,
button.victory-tag:focus-visible { filter: brightness(1.2); transform: translateY(-1px); outline: none; }

/* Generic info popup — used for powerup details and tag explanations. */
.info-popup-backdrop { background: rgba(0, 0, 0, 0.65); z-index: 220; }
.info-popup {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(340px, calc(100vw - 32px));
  background: linear-gradient(160deg, #1c1430 0%, #0d0820 100%);
  border: 1px solid rgba(236, 72, 153, 0.30);
  border-radius: 14px;
  padding: 22px 20px 18px;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
  z-index: 221;
  text-align: center;
  animation: info-popup-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.info-popup--tag      { border-color: rgba(163, 230, 53, 0.35); }
.info-popup--powerup  { border-color: rgba(236, 72, 153, 0.45); }
@keyframes info-popup-pop {
  0%   { transform: translate(-50%, -50%) scale(0.85); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1);    opacity: 1; }
}
.info-popup-icon  { font-size: 36px; margin-bottom: 6px; }
.info-popup-title { font-size: 18px; font-weight: 800; margin-bottom: 10px; color: var(--text-primary); }
.info-popup-tagline {
  font-size: 13px; line-height: 1.5; color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
  text-align: left;
}
.info-popup-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 14px;
  margin-bottom: 12px;
  text-align: left;
}
.info-popup-stat-grid > div { display: flex; justify-content: space-between; font-size: 13px; }
.info-popup-stat-grid > div span  { color: var(--text-muted); }
.info-popup-stat-grid > div strong { color: var(--accent-secondary); font-variant-numeric: tabular-nums; }
.info-popup-penalty { color: var(--color-loss) !important; }
.info-popup-foot { font-size: 11px; color: var(--text-muted); margin-bottom: 12px; }
.info-popup-btn {
  width: 100%;
  background: var(--accent-primary-grad);
  color: white;
  font-weight: 700;
  padding: 10px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
}
.info-popup-btn:hover { filter: brightness(1.1); }

/* Item drawer — DPS / TTL impact summary beneath the Power pill. */
.item-drawer-impact {
  background: rgba(163, 230, 53, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 8px 12px 10px;
  margin: 0 0 10px;
}
.item-drawer-impact-head {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.item-drawer-impact-chips {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.item-drawer-impact-chip {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.item-drawer-impact-chip.positive { background: rgba(163, 230, 53, 0.18); color: var(--accent-secondary); }
.item-drawer-impact-chip.negative { background: rgba(244, 63, 94, 0.18);  color: #fda4af; }
.item-drawer-impact-chip.neutral  { color: var(--text-secondary); }

/* Slot-picker forecast chips — show DPS / TTL delta for each candidate item. */
.slot-picker-forecast {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-top: 4px;
}
.slot-picker-forecast-chip {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.slot-picker-forecast-chip.positive { background: rgba(163, 230, 53, 0.18); color: var(--accent-secondary); }
.slot-picker-forecast-chip.negative { background: rgba(244, 63, 94, 0.18);  color: #fda4af; }

/* ============================================================
   COMBAT FORECAST — Profile panel showing analytical DPS / EHP
   ============================================================ */
.stat-section--forecast { background: rgba(163, 230, 53, 0.04); }
.forecast-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 14px;
  padding: 6px 0 10px;
}
.forecast-row {
  display: flex; justify-content: space-between;
  font-size: 13px; padding: 3px 0;
  font-variant-numeric: tabular-nums;
}
.forecast-row--margin { grid-column: 1 / -1; border-top: 1px solid var(--border-subtle); padding-top: 6px; margin-top: 4px; }
.forecast-label { color: var(--text-muted); }
.forecast-value { color: var(--text-secondary); font-weight: 700; }
.forecast-row--margin .forecast-value { color: var(--accent-secondary); }
.forecast-bar {
  height: 6px; background: rgba(255, 255, 255, 0.06); border-radius: 3px;
  overflow: hidden; margin-top: 4px;
}
.forecast-bar-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #f43f5e, #f97316, #a3e635);
  transition: width 0.3s ease-out;
}
.forecast-bar-fill[data-tone="losing"] { background: #f43f5e; }
.forecast-bar-fill[data-tone="tight"]  { background: linear-gradient(90deg, #f97316, #facc15); }
.forecast-bar-fill[data-tone="good"]   { background: linear-gradient(90deg, #facc15, #a3e635); }
.forecast-bar-fill[data-tone="great"]  { background: linear-gradient(90deg, #a3e635, #22c55e); }

/* ============================================================
   PORTRAIT PICKER — new-archive Seeker selection
   ============================================================ */
.portrait-picker-backdrop { background: rgba(0, 0, 0, 0.78); z-index: 240; }
.portrait-picker {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(380px, calc(100vw - 24px));
  background: linear-gradient(160deg, #1c1430 0%, #0a0518 100%);
  border: 1px solid rgba(236, 72, 153, 0.40);
  border-radius: 16px;
  padding: 22px 18px 18px;
  box-shadow: 0 0 60px rgba(236, 72, 153, 0.30);
  z-index: 241;
  animation: info-popup-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.portrait-picker-headline {
  text-align: center;
  font-size: 18px; font-weight: 800; letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.portrait-picker-sub {
  text-align: center;
  font-size: 12px; color: var(--text-muted);
  margin-bottom: 14px;
}
.portrait-picker-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.portrait-picker-card {
  position: relative;
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid var(--border-subtle);
  border-radius: 10px;
  padding: 8px 4px 6px;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s, background 0.15s;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font: inherit; color: inherit;
}
.portrait-picker-card img {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: 8px;
  background: #110820;
}
.portrait-picker-card span {
  font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
  color: var(--text-secondary);
}
.portrait-picker-card:hover,
.portrait-picker-card:focus-visible {
  border-color: var(--accent-secondary);
  background: rgba(163, 230, 53, 0.06);
  outline: none;
}
.portrait-picker-card--highlight {
  border-color: var(--accent-secondary);
  box-shadow: 0 0 18px rgba(163, 230, 53, 0.5);
  transform: scale(1.04);
  background: rgba(163, 230, 53, 0.10);
}
.portrait-picker-card--chosen {
  border-color: #ec4899;
  box-shadow: 0 0 24px rgba(236, 72, 153, 0.7);
  transform: scale(1.06);
  background: rgba(236, 72, 153, 0.14);
}
/* Subhead pieces: "for your Scroll (Dungeon Run)" — second half is dimmer */
.portrait-picker-sub-dim { color: var(--text-muted); }

/* 10-second timer bar that drains across the full picker window. */
.portrait-picker-timer {
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}
.portrait-picker-timer-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--accent-secondary), #ec4899);
}

/* "Auto-picks in Ns" caption — gets an urgent pulse for the last 3 seconds. */
.portrait-picker-countdown {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin: 6px 0 8px;
  font-variant-numeric: tabular-nums;
}
.portrait-picker-countdown--urgent {
  color: #fda4af;
  animation: portrait-countdown-pulse 0.5s ease-in-out infinite alternate;
}
@keyframes portrait-countdown-pulse {
  from { opacity: 0.7; }
  to   { opacity: 1; }
}

/* Start Scrolling — primary CTA, only enabled once a portrait is chosen. */
.portrait-picker-start {
  width: 100%;
  margin-top: 4px;
  padding: 12px;
  border: 0;
  border-radius: 10px;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, #a3e635 0%, #65a30d 100%);
  color: #0a1006;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}
.portrait-picker-start:hover:not(:disabled) { filter: brightness(1.08); }
.portrait-picker-start:disabled {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.6;
}

/* Ephemeral countdown — pulses softly so the player notices the timer. */
.ephemeral-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  margin-left: 6px;
  border-radius: 6px;
  background: rgba(244, 63, 94, 0.18);
  color: #fda4af;
  vertical-align: middle;
  animation: ephemeral-pulse 2.4s ease-in-out infinite;
}
@keyframes ephemeral-pulse {
  0%, 100% { opacity: 0.85; }
  50%      { opacity: 1; box-shadow: 0 0 6px rgba(244, 63, 94, 0.45); }
}
.shortcut-btn--primary { background: var(--accent-primary-grad); color: white; }
.shortcut-btn--highlighted {
  background: linear-gradient(135deg, rgba(163, 230, 53, 0.30), rgba(163, 230, 53, 0.10));
  color: var(--accent-secondary);
  /* drop-shadow respects clip-path so the glow follows the chevron shape */
  animation: shortcut-pulse 1.4s ease-in-out infinite;
}
.shortcut-btn--primary.shortcut-btn--highlighted { color: #fff; }
@keyframes shortcut-pulse {
  0%, 100% { filter: drop-shadow(0 0 0 transparent); }
  50%      { filter: drop-shadow(0 0 6px var(--accent-secondary)); }
}

/* When the shortcut bar is visible, the idle screen needs room above the tab bar. */
body.shortcuts-on #screen-idle[data-active="true"]    { padding-bottom: 60px; }
body.shortcuts-on .drawer                             { bottom: var(--tab-bar-h); }

/* ============================================================
   NARRATIVE EVENT — DC chip + Luck banner for clearer risk read
   ============================================================ */
.narrative-event-luck {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--accent-secondary);
  text-transform: uppercase;
}
.dc-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 8px;
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}
.dc-chip--low  { background: rgba(163, 230, 53, 0.18); color: var(--color-win); }
.dc-chip--mid  { background: rgba(249, 115, 22, 0.18); color: var(--accent-warning); }
.dc-chip--high { background: rgba(244, 63, 94, 0.18);  color: var(--color-loss); }
.dc-chip--auto { background: rgba(163, 230, 53, 0.30); color: var(--color-win); }

/* ============================================================
   ITEM DRAWER — POWER takes the spotlight, Compare slides out
   ============================================================ */
.item-drawer-power {
  text-align: center;
  margin: 0 0 var(--gap-md);
  padding: var(--gap-md) 0;
  background: var(--bg-card);
  border-radius: 12px;
}
.item-drawer-power-value {
  font-size: 44px;
  font-weight: 900;
  color: var(--accent-secondary);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 18px rgba(163, 230, 53, 0.3);
  line-height: 1;
}
.item-drawer-power-label {
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 4px;
}
.item-drawer-compare {
  margin-top: var(--gap-md);
  padding: var(--gap-md);
  background: var(--bg-card);
  border-radius: 10px;
  font-size: 13px;
}
.item-drawer-compare-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.item-drawer-compare-row:last-child { border-bottom: none; }
.item-drawer-compare-label { color: var(--text-muted); }
.item-drawer-compare-delta { font-weight: 800; font-variant-numeric: tabular-nums; }
.item-drawer-compare-delta.positive { color: var(--accent-secondary); }
.item-drawer-compare-delta.negative { color: var(--color-loss); }

/* ============================================================
   COLLECTION — sort toggle row
   ============================================================ */
.stash-sort {
  display: flex;
  gap: 4px;
  margin-bottom: var(--gap-md);
  padding: 4px;
  background: var(--bg-card);
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
}
.stash-sort-btn {
  flex: 1;
  padding: 6px 8px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}
.stash-sort-btn[data-active="true"] {
  background: var(--bg-card-elevated);
  color: var(--text-primary);
}

/* Reduce motion — respect OS preference and quiet the heavy animations. */
@media (prefers-reduced-motion: reduce) {
  .hero-portrait, .primary-cta::after, .channel-banner::before,
  .combat-zone::before, .session-pill .dot, .fuse-nudge,
  .treasure-chest, .shortcut-btn--highlighted,
  .fusion-result-quick-equip { animation: none; }
  .screen[data-active="true"] { animation: none; }
}

/* ============================================================
   DISCOVERY MODAL — LLM-minted recipe celebration
   ============================================================ */
.discovery-backdrop { background: rgba(0, 0, 0, 0.7); z-index: 200; }
.discovery-modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(360px, calc(100vw - 32px));
  background: linear-gradient(160deg, #1a0f2e 0%, #0d0820 100%);
  border: 1px solid rgba(236, 72, 153, 0.45);
  border-radius: 16px;
  padding: 24px 20px 20px;
  box-shadow: 0 0 60px rgba(236, 72, 153, 0.35), 0 0 120px rgba(163, 230, 53, 0.15);
  z-index: 201;
  text-align: center;
  animation: discovery-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes discovery-pop {
  0%   { transform: translate(-50%, -50%) scale(0.6); opacity: 0; }
  100% { transform: translate(-50%, -50%) scale(1);   opacity: 1; }
}
.discovery-eyebrow {
  font-size: 11px; font-weight: 800; letter-spacing: 0.18em;
  color: var(--accent-secondary);
  margin-bottom: 8px;
}
.discovery-name {
  font-size: 22px; font-weight: 800; line-height: 1.2;
  background: linear-gradient(90deg, #f9a8d4, #ec4899, #f9a8d4);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  margin-bottom: 8px;
}
.discovery-desc {
  font-size: 13px; color: var(--text-muted); font-style: italic;
  line-height: 1.4; margin-bottom: 14px;
}
.discovery-affixes {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 12px;
}
.discovery-affix-row {
  display: flex; justify-content: space-between;
  font-size: 13px; padding: 3px 0;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.discovery-affix-row span:first-child { text-transform: capitalize; }
.discovery-affix-row span:last-child { color: var(--accent-secondary); font-weight: 700; }
.discovery-hint {
  font-size: 11px; color: var(--text-muted);
  margin-bottom: 16px;
}
.discovery-btn {
  width: 100%;
  background: var(--accent-primary-grad);
  color: white;
  font-weight: 700;
  padding: 12px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
}
.discovery-btn:hover { filter: brightness(1.1); }

/* ============================================================
   FANFARE OVERLAY — rarity discovery + unique drop takeover
   ============================================================ */
.fanfare-overlay {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gap-lg);
  background: radial-gradient(
    ellipse at center,
    color-mix(in srgb, var(--fanfare-tone, #ec4899) 22%, transparent) 0%,
    rgba(0, 0, 0, 0.85) 70%
  );
  animation: fanfare-fade-in 0.25s ease-out;
}
.fanfare-overlay.tier-magic     { --fanfare-tone: var(--rarity-magic); }
.fanfare-overlay.tier-rare      { --fanfare-tone: var(--rarity-rare); }
.fanfare-overlay.tier-epic      { --fanfare-tone: var(--rarity-epic); }
.fanfare-overlay.tier-legendary { --fanfare-tone: var(--rarity-legendary); }
.fanfare-overlay.tier-mythic    { --fanfare-tone: var(--rarity-mythic); }
.fanfare-overlay.tier-aether    { --fanfare-tone: var(--rarity-aether); }

@keyframes fanfare-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.fanfare-card {
  position: relative;
  width: min(380px, 100%);
  background: linear-gradient(160deg, rgba(20, 14, 32, 0.96), rgba(8, 6, 16, 0.96));
  border: 2px solid var(--fanfare-tone);
  border-radius: 18px;
  padding: 28px 24px 22px;
  text-align: center;
  box-shadow:
    0 0 80px color-mix(in srgb, var(--fanfare-tone) 45%, transparent),
    0 0 160px color-mix(in srgb, var(--fanfare-tone) 22%, transparent),
    inset 0 0 30px color-mix(in srgb, var(--fanfare-tone) 12%, transparent);
  animation: fanfare-pop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes fanfare-pop {
  0%   { transform: scale(0.6); opacity: 0; }
  60%  { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); }
}

.fanfare-card::before {
  /* Slow rotating sheen behind the card content. Pointer events off so it doesn't eat clicks. */
  content: '';
  position: absolute;
  inset: -40%;
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    color-mix(in srgb, var(--fanfare-tone) 40%, transparent) 60deg,
    transparent 120deg,
    transparent 240deg,
    color-mix(in srgb, var(--fanfare-tone) 40%, transparent) 300deg,
    transparent 360deg
  );
  opacity: 0.35;
  pointer-events: none;
  animation: fanfare-spin 6s linear infinite;
  border-radius: 50%;
  z-index: -1;
}
@keyframes fanfare-spin { to { transform: rotate(360deg); } }

.fanfare-eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--fanfare-tone) 80%, white);
  margin-bottom: 12px;
}

.fanfare-rarity-name {
  font-size: 38px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--fanfare-tone);
  text-shadow:
    0 0 20px color-mix(in srgb, var(--fanfare-tone) 70%, transparent),
    0 0 40px color-mix(in srgb, var(--fanfare-tone) 35%, transparent);
  margin-bottom: 8px;
}
.fanfare-rarity-blurb {
  font-size: 13px;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.4;
  margin-bottom: 22px;
}

.fanfare-unique-name {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--fanfare-tone);
  text-shadow: 0 0 18px color-mix(in srgb, var(--fanfare-tone) 60%, transparent);
  margin-bottom: 4px;
}
.fanfare-unique-tier {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--fanfare-tone) 80%, var(--text-muted));
  margin-bottom: 10px;
}
.fanfare-unique-flavor {
  font-size: 13px;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.45;
  margin-bottom: 14px;
}

.fanfare-affix-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-bottom: 18px;
}
.fanfare-affix-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid color-mix(in srgb, var(--fanfare-tone) 30%, transparent);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}
.fanfare-affix-chip em { font-style: normal; color: var(--text-muted); font-weight: 500; margin-left: 4px; }

.fanfare-continue {
  position: relative;
  width: 100%;
  background: var(--fanfare-tone);
  color: #0a0a0c;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 12px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-size: 13px;
}
.fanfare-continue:hover { filter: brightness(1.15); }
.fanfare-continue:active { transform: scale(0.98); }
.fanfare-continue-bar {
  position: relative;
  height: 3px;
  background: rgba(0, 0, 0, 0.25);
  margin-top: 8px;
  border-radius: 2px;
  overflow: hidden;
}
.fanfare-continue-bar-fill {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 12, 0.85);
  transform-origin: left center;
  animation: result-auto-shrink 5s linear forwards;
}

.fanfare-paused-badge {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 10px;
  letter-spacing: 0.12em;
  font-weight: 800;
  color: var(--fanfare-tone);
  background: rgba(10, 10, 12, 0.85);
  padding: 3px 8px;
  border-radius: 6px;
  pointer-events: none;
  border: 1px solid color-mix(in srgb, var(--fanfare-tone) 40%, transparent);
}

@media (prefers-reduced-motion: reduce) {
  .fanfare-overlay,
  .fanfare-card { animation: none; }
  .fanfare-card::before { animation: none; opacity: 0.18; }
}

/* ============================================================
   LOOT BURST — sparkle fan that fires above the combat zone on every drop.
   Tier sets the color via --loot-tone; intensity sets size + count of visible
   particles (commons read as a wisp, aether as a starburst).
   ============================================================ */
.loot-burst {
  position: absolute;
  top: 50%;
  left: 50%;
  pointer-events: none;
  z-index: 6;
  --loot-tone: var(--rarity-common);
  --loot-scale: 1;
  width: 0;
  height: 0;
  animation: loot-burst-glow 1.4s ease-out forwards;
}
.loot-burst.loot-burst--tier-common    { --loot-tone: var(--rarity-common);    --loot-scale: 0.7; }
.loot-burst.loot-burst--tier-magic     { --loot-tone: var(--rarity-magic);     --loot-scale: 0.85; }
.loot-burst.loot-burst--tier-rare      { --loot-tone: var(--rarity-rare);      --loot-scale: 1; }
.loot-burst.loot-burst--tier-epic      { --loot-tone: var(--rarity-epic);      --loot-scale: 1.2; }
.loot-burst.loot-burst--tier-legendary { --loot-tone: var(--rarity-legendary); --loot-scale: 1.45; }
.loot-burst.loot-burst--tier-mythic    { --loot-tone: var(--rarity-mythic);    --loot-scale: 1.7; }
.loot-burst.loot-burst--tier-aether    { --loot-tone: var(--rarity-aether);    --loot-scale: 1.9; }

.loot-burst > span {
  position: absolute;
  top: 0;
  left: 0;
  font-size: calc(20px * var(--loot-scale));
  color: var(--loot-tone);
  text-shadow:
    0 0 12px color-mix(in srgb, var(--loot-tone) 80%, transparent),
    0 0 24px color-mix(in srgb, var(--loot-tone) 40%, transparent);
  opacity: 0;
  animation: loot-sparkle 1.2s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}
/* Each of the five spans gets a different angle + delay so the burst fans out. */
.loot-burst > span:nth-child(1) { --burst-angle:  -90deg; animation-delay: 0ms;   }
.loot-burst > span:nth-child(2) { --burst-angle:  -30deg; animation-delay: 60ms;  }
.loot-burst > span:nth-child(3) { --burst-angle:   30deg; animation-delay: 30ms;  }
.loot-burst > span:nth-child(4) { --burst-angle:  150deg; animation-delay: 90ms;  }
.loot-burst > span:nth-child(5) { --burst-angle: -150deg; animation-delay: 120ms; }

@keyframes loot-sparkle {
  0%   { opacity: 0; transform: rotate(var(--burst-angle)) translateY(0) scale(0.3); }
  20%  { opacity: 1; }
  100% { opacity: 0; transform: rotate(var(--burst-angle)) translateY(calc(-70px * var(--loot-scale))) scale(1); }
}
@keyframes loot-burst-glow {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--loot-tone) 50%, transparent); }
  30%  { box-shadow: 0 0 calc(40px * var(--loot-scale)) calc(8px * var(--loot-scale)) color-mix(in srgb, var(--loot-tone) 35%, transparent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* Forge pop — a brief radiant pulse on the result panel when a fresh forge lands. */
.fusion-result.fusion-result--just-forged {
  animation: forge-pop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes forge-pop {
  0%   { transform: scale(0.92); box-shadow: 0 0 0 0 rgba(163, 230, 53, 0); }
  35%  { transform: scale(1.04); box-shadow: 0 0 32px 8px rgba(163, 230, 53, 0.5); }
  100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(163, 230, 53, 0); }
}

/* Full-screen vignette flash. Sits inside #app so it inherits the phone-frame
   width. pointer-events: none means it can't block input even during the flash. */
.vignette-flash {
  position: absolute;
  inset: 0;
  z-index: 230;
  pointer-events: none;
  background: radial-gradient(
    ellipse at center,
    transparent 30%,
    rgba(244, 63, 94, 0.65) 100%
  );
  animation: vignette-pulse 0.7s ease-out forwards;
}
.vignette-flash--heal {
  background: radial-gradient(
    ellipse at center,
    transparent 30%,
    rgba(163, 230, 53, 0.55) 100%
  );
}
@keyframes vignette-pulse {
  0%   { opacity: 0; }
  20%  { opacity: 1; }
  100% { opacity: 0; }
}

/* Sustained low-HP vignette while the hero is below 25% in combat. Slow breath
   so the panic reads without being seizure-inducing. */
body.combat-low-hp #screen-combat[data-active="true"]::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 9;
  box-shadow: inset 0 0 80px 14px rgba(244, 63, 94, 0.45);
  animation: low-hp-pulse 1.6s ease-in-out infinite;
}
@keyframes low-hp-pulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .loot-burst,
  .loot-burst > span,
  .fusion-result--just-forged,
  .vignette-flash { animation-duration: 0.15s; }
  body.combat-low-hp #screen-combat[data-active="true"]::before { animation: none; opacity: 0.6; }
}

