/**
 * K-Pop Demon Hunters — Main Styles
 * Mobile-first, responsive from iPhone SE (320px) to iPad (1024px)
 */

/* ============================================
   CSS Custom Properties
   ============================================ */

:root {
  /* Typography */
  --font-family: "Nunito", system-ui, -apple-system, sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-md: clamp(1rem, 0.957rem + 0.22vw, 1.125rem);
  --text-lg: clamp(1.3rem, 1.213rem + 0.43vw, 1.5rem);
  --text-xl: clamp(1.75rem, 1.533rem + 1.08vw, 2.25rem);
  --text-2xl: clamp(2.5rem, 2.174rem + 1.63vw, 3.25rem);
  --text-3xl: clamp(4rem, 3.348rem + 3.26vw, 5.5rem);

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: clamp(24px, 22.7px + 0.57vw, 28px);
  --space-xl: clamp(32px, 29.7px + 1.14vw, 40px);
  --space-2xl: clamp(48px, 45.7px + 1.14vw, 56px);

  /* Backgrounds */
  --bg-primary: #1a1a2e;
  --bg-secondary: #2d1b69;
  --aurora-1: #1a1a2e;
  --aurora-2: #2d1b69;
  --bg-gradient: linear-gradient(180deg, var(--aurora-1) 0%, var(--aurora-2) 100%);
  --bg-panel: rgba(200, 180, 255, 0.12);
  --bg-panel-warm: rgba(255, 215, 0, 0.1);
  --bg-panel-vivid: rgba(200, 180, 255, 0.16);
  --bg-overlay: rgba(0, 0, 0, 0.65);
  --bg-primary-80: rgba(26, 26, 46, 0.8);
  --bg-primary-88: rgba(26, 26, 46, 0.88);
  --bg-primary-92: rgba(26, 26, 46, 0.92);

  /* Text colors */
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-gold: #ffd700;

  /* Character colors */
  --color-mira: #ff69b4;
  --color-zoey: #1e90ff;
  --color-rumi: #9370db;
  --color-jinu: #008080;
  --color-avery: #ffd700;
  --color-double-jump: #c084fc;

  /* Accent / UI colors */
  --color-danger: #e53935;
  --color-success: #4caf50;
  --color-coral: #ff7f50;
  --color-orange: #ffa500;
  --color-silver: #b8b0cc;
  --color-cyan: #5ce0d6;
  --color-cyan-dark: #3cc8be;
  --color-mint: #a8e6cf;
  --color-muted: #4a4460;
  --color-card-back: #9b306b;

  /* Text on light backgrounds (speech bubbles, dialogue) */
  --text-dark: #332b44;
  --text-dim: #504868;

  /* Gradients */
  --gradient-gold: linear-gradient(135deg, var(--text-gold), var(--color-orange));
  --gradient-warm: linear-gradient(135deg, var(--text-gold), var(--color-coral));

  /* Border radii */
  --border-radius-xs: 4px;
  --border-radius-sm: 8px;
  --border-radius-md: 16px;
  --border-radius-lg: 24px;
  --border-radius-pill: 999px;
  --border-radius-circle: 50%;

  /* Shadows */
  --shadow-soft: 0 4px 16px var(--black-35);
  --shadow-glow: 0 0 20px var(--gold-50), 0 0 48px var(--gold-20);

  /* Alpha scales — reusable transparency tiers */
  --white-05: rgba(255, 255, 255, 0.05);
  --white-10: rgba(255, 255, 255, 0.1);
  --white-15: rgba(255, 255, 255, 0.15);
  --white-20: rgba(255, 255, 255, 0.2);
  --white-25: rgba(255, 255, 255, 0.25);
  --white-30: rgba(255, 255, 255, 0.3);
  --white-40: rgba(255, 255, 255, 0.4);
  --white-50: rgba(255, 255, 255, 0.5);
  --white-60: rgba(255, 255, 255, 0.6);
  --white-80: rgba(255, 255, 255, 0.8);
  --white-85: rgba(255, 255, 255, 0.85);
  --white-90: rgba(255, 255, 255, 0.9);
  --white-92: rgba(255, 255, 255, 0.92);
  --white-95: rgba(255, 255, 255, 0.95);
  --black-15: rgba(0, 0, 0, 0.15);
  --black-20: rgba(0, 0, 0, 0.2);
  --black-25: rgba(0, 0, 0, 0.25);
  --black-30: rgba(0, 0, 0, 0.3);
  --black-35: rgba(0, 0, 0, 0.35);
  --black-40: rgba(0, 0, 0, 0.4);
  --black-45: rgba(0, 0, 0, 0.45);
  --black-50: rgba(0, 0, 0, 0.5);
  --black-60: rgba(0, 0, 0, 0.6);
  --black-70: rgba(0, 0, 0, 0.7);
  --black-75: rgba(0, 0, 0, 0.75);
  --black-80: rgba(0, 0, 0, 0.8);
  --gold-10: rgba(255, 215, 0, 0.1);
  --gold-15: rgba(255, 215, 0, 0.15);
  --gold-20: rgba(255, 215, 0, 0.2);
  --gold-25: rgba(255, 215, 0, 0.25);
  --gold-30: rgba(255, 215, 0, 0.3);
  --gold-35: rgba(255, 215, 0, 0.35);
  --gold-40: rgba(255, 215, 0, 0.4);
  --gold-45: rgba(255, 215, 0, 0.45);
  --gold-50: rgba(255, 215, 0, 0.5);
  --gold-60: rgba(255, 215, 0, 0.6);
  --gold-70: rgba(255, 215, 0, 0.7);
  --gold-80: rgba(255, 215, 0, 0.8);
  --coral-20: rgba(255, 127, 80, 0.2);
  --coral-25: rgba(255, 127, 80, 0.25);

  /* Shadow presets — common glow patterns */

  /* Easing curves — intentional, not CSS defaults */
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);

  /* Transition durations */
  --duration-instant: 100ms;
  --duration-fast: 200ms;
  --duration-normal: 300ms;
  --duration-slow: 500ms;
  --duration-slower: 800ms;

  /* Z-index scale */
  --z-content: 1;
  --z-raised: 2;
  --z-nav: 10;
  --z-sticky: 15;
  --z-header: 20;
  --z-chrome: 50;
  --z-overlay: 100;
  --z-toast: 200;
  --z-max: 9998;

  /* Letter spacing */
  --tracking-tight: 0.5px;
  --tracking-normal: 1px;
  --tracking-wide: 2px;
  --tracking-wider: 3px;
  --tracking-hero: 5px;

  /* Font weights */
  --weight-body: 700;
  --weight-heading: 800;

  /* Line heights */
  --leading-none: 1;
  --leading-tight: 1.05;
  --leading-snug: 1.2;
  --leading-normal: 1.4;
  --leading-relaxed: 1.5;
}

/* ============================================
   Reset & Base
   ============================================ */

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

button,
input,
select,
textarea {
  font-family: inherit;
}

/* Keyboard focus indicator — only visible for keyboard users */
:focus-visible {
  outline: 3px solid var(--color-avery);
  outline-offset: 2px;
  border-radius: var(--border-radius-sm);
}

/* Hide outline for touch/mouse users */
:focus:not(:focus-visible) {
  outline: none;
}

/* Scenes should not show focus ring when programmatically focused */
.scene:focus {
  outline: none;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-family);
  font-weight: var(--weight-body);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background: var(--bg-primary);
}

body {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  overscroll-behavior: contain;
  position: relative;
}

/* ============================================
   Scene System
   ============================================ */

.scene {
  display: none;
  position: absolute;
  inset: 0;
  flex-direction: column;
  background: var(--bg-gradient);
  animation: aurora-shift 20s ease-in-out infinite;
  overflow: hidden;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.scene.active {
  display: flex;
  contain: layout style paint;
}

/* ============================================
   Overlay System
   ============================================ */

.overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.overlay.active {
  display: flex;
  align-items: center;
  justify-content: center;
  contain: paint;
}

/* ============================================
   Splash Screen
   ============================================ */

#scene-splash {
  align-items: center;
  justify-content: center;
  animation-duration: 15s;
  background:
    radial-gradient(ellipse at 50% 45%, rgba(255, 215, 0, 0.08) 0%, transparent 45%),
    radial-gradient(ellipse at 30% 70%, rgba(255, 105, 180, 0.05) 0%, transparent 40%),
    radial-gradient(ellipse at 75% 25%, rgba(147, 112, 219, 0.05) 0%, transparent 35%), var(--bg-gradient);
}

.splash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
}

.splash-logo {
  max-width: 460px;
  width: 90%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 0 32px var(--gold-60)) drop-shadow(0 0 64px var(--gold-25));
}

.splash-logo + .splash-title {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.splash-logo ~ .splash-subtitle {
  display: none;
}

.splash-title {
  font-size: var(--text-3xl);
  font-weight: 800;
  line-height: 1.05;
  color: var(--text-primary);
  text-align: center;
  letter-spacing: var(--tracking-hero);
  text-shadow:
    0 0 24px var(--gold-60),
    0 0 48px var(--gold-30),
    0 0 80px rgba(255, 105, 180, 0.15),
    0 3px 0 var(--black-40);
}

@media (min-width: 600px) {
  .splash-title {
    font-size: var(--text-3xl);
  }
}

.splash-subtitle {
  font-size: var(--text-md);
  color: var(--text-secondary);
  text-align: center;
}

.splash-tap {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--text-gold);
  text-align: center;
  margin-top: var(--space-2xl);
  text-shadow:
    0 0 16px var(--gold-50),
    0 0 32px var(--gold-20);
  letter-spacing: var(--tracking-wide);
  animation: sparkle-pulse 1.5s ease-in-out infinite;
}

/* ============================================
   Header Bar
   ============================================ */

.game-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(48px + env(safe-area-inset-top));
  z-index: var(--z-chrome);
  background: var(--bg-primary);
  align-items: center;
  justify-content: space-between;
  padding: env(safe-area-inset-top) var(--space-sm) 0;
}

.game-header.visible {
  display: flex;
}

@media (min-width: 600px) {
  .game-header {
    height: calc(56px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) var(--space-md) 0;
  }
}

.header-back,
.header-settings {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 24px;
  border-radius: var(--border-radius-sm);
  flex-shrink: 0;
  transition: transform var(--duration-instant) var(--ease-out-quart);
}

@media (min-width: 600px) {
  .header-back,
  .header-settings {
    width: 48px;
    height: 48px;
    font-size: 28px;
  }
}

.header-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-settings-icon {
  opacity: 0.7;
}

/* ============================================
   Bottom Nav Bar
   ============================================ */

.game-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(64px + env(safe-area-inset-bottom));
  z-index: var(--z-chrome);
  background: var(--bg-primary);
  border-top: 1px solid var(--white-10);
  align-items: center;
  justify-content: space-around;
  padding: 0 0 env(safe-area-inset-bottom);
}

.game-nav.visible {
  display: flex;
}

@media (min-width: 600px) {
  .game-nav {
    height: calc(72px + env(safe-area-inset-bottom));
  }
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 48px;
  height: 48px;
  flex: 1;
  background: none;
  border: none;
  color: var(--text-secondary);
  border-radius: var(--border-radius-sm);
  padding: var(--space-xs);
  position: relative;
  transition:
    transform var(--duration-instant) var(--ease-out-quart),
    color var(--duration-fast) var(--ease-out-quart);
}

@media (min-width: 600px) {
  .nav-btn {
    min-width: 56px;
    height: 56px;
    flex-direction: row;
    gap: var(--space-xs);
  }
}

.nav-btn.active {
  color: var(--text-gold);
  transform: scale(1.1);
}

.nav-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.nav-btn.active .nav-icon {
  filter: drop-shadow(0 0 6px var(--gold-70)) drop-shadow(0 0 12px var(--gold-25));
}

.nav-label {
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  min-width: 0;
}

/* Badge dot on nav items — hidden by default, shown via .visible */
.nav-btn .badge-dot {
  display: none;
  position: absolute;
  top: var(--space-xs);
  right: var(--space-xs);
  width: 8px;
  height: 8px;
  border-radius: var(--border-radius-circle);
  background: var(--color-danger);
}

.nav-btn .badge-dot.visible {
  display: block;
  animation: badge-pulse 2s ease-in-out infinite;
}

/* ============================================
   Toast Notifications
   ============================================ */

#overlay-toast {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: var(--text-md);
  font-weight: 800;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--border-radius-pill);
  border: 1px solid var(--gold-25);
  box-shadow:
    var(--shadow-soft),
    0 0 20px var(--gold-20);
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

#overlay-toast:not(.active):not(.exiting) {
  display: none;
}

#overlay-toast.active {
  display: block;
  animation: popup-bounce-in 250ms var(--ease-out-expo) forwards;
}

#overlay-toast.exiting {
  display: block;
  animation: fade-out 200ms var(--ease-out-quart) forwards;
}

/* ============================================
   Scene Layout Helpers (with header/nav offsets)
   ============================================ */

/* Scenes that have header + nav should offset their content */
.scene-with-chrome {
  padding-top: calc(48px + env(safe-area-inset-top));
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}

@media (min-width: 600px) {
  .scene-with-chrome {
    padding-top: calc(56px + env(safe-area-inset-top));
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }
}

/* ============================================
   Scrollable containers
   ============================================ */

.scrollable {
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  overflow-y: auto;
  contain: content;
}

.scroll-horizontal {
  touch-action: pan-x;
  scroll-snap-type: x mandatory;
  overflow-x: auto;
}

/* ============================================
   Intro Slides
   ============================================ */

#scene-intro {
  position: absolute;
  inset: 0;
}

.intro-slides-container {
  display: flex;
  width: 100%;
  height: 100%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.intro-slides-container::-webkit-scrollbar {
  display: none;
}

.intro-slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
}

.intro-illustration {
  flex: 0 0 62%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
  position: relative;
  overflow: hidden;
}

/* Per-slide gradient backgrounds */
.intro-slide[data-slide="0"] .intro-illustration {
  background: linear-gradient(135deg, var(--color-mira), var(--color-zoey), var(--color-avery));
}
.intro-slide[data-slide="1"] .intro-illustration {
  background: linear-gradient(135deg, var(--bg-secondary), var(--color-rumi), var(--bg-primary));
}
.intro-slide[data-slide="2"] .intro-illustration {
  background: linear-gradient(135deg, var(--color-mira), var(--color-rumi), var(--color-jinu), var(--color-avery));
}
.intro-slide[data-slide="3"] .intro-illustration {
  background: linear-gradient(135deg, var(--color-avery), var(--color-coral), var(--color-mira));
}

.intro-illustration-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.intro-illustration-label {
  position: relative;
  z-index: var(--z-content);
  font-size: var(--text-2xl);
  font-weight: 800;
  line-height: 1.05;
  color: var(--text-primary);
  text-shadow:
    0 2px 12px var(--black-70),
    0 0 24px var(--white-30),
    0 0 48px var(--gold-15);
  text-align: center;
  letter-spacing: var(--tracking-wide);
}

.intro-text-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md) var(--space-lg);
}

.intro-text {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--text-primary);
  text-align: center;
  line-height: 1.3;
  max-width: 320px;
  overflow-wrap: break-word;
  word-break: break-word;
}

.intro-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 0px));
  z-index: var(--z-nav);
}

.intro-skip,
.intro-next {
  background: none;
  border: none;
  font-weight: 700;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm) var(--space-md);
}

.intro-skip {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.intro-next {
  font-size: var(--text-lg);
  color: var(--bg-primary);
  background: var(--gradient-gold);
  border-radius: var(--border-radius-pill);
  padding: var(--space-sm) var(--space-lg);
  box-shadow: 0 0 14px var(--gold-45);
}

.intro-dots {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

.dot-indicator {
  width: 10px;
  height: 10px;
  border-radius: var(--border-radius-circle);
  border: 2px solid var(--white-40);
  background: transparent;
  transition:
    background var(--duration-fast) var(--ease-out-quart),
    border-color var(--duration-fast) var(--ease-out-quart),
    width var(--duration-fast) var(--ease-out-quart);
}

.dot-indicator.active {
  width: 24px;
  background: var(--text-gold);
  border-color: var(--text-gold);
}

/* ============================================
   Character Pick
   ============================================ */

#scene-character-pick {
  align-items: center;
  padding: var(--space-xl) var(--space-md);
  gap: var(--space-lg);
  background:
    radial-gradient(ellipse at 50% 30%, rgba(255, 215, 0, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 20% 70%, rgba(255, 105, 180, 0.05) 0%, transparent 40%),
    radial-gradient(ellipse at 80% 60%, rgba(30, 144, 255, 0.04) 0%, transparent 35%), var(--bg-gradient);
}

.pick-title {
  font-size: var(--text-2xl);
  font-weight: 800;
  line-height: 1.05;
  color: var(--text-primary);
  text-align: center;
  flex-shrink: 0;
  letter-spacing: var(--tracking-normal);
  text-shadow:
    0 0 20px var(--gold-40),
    0 0 40px rgba(255, 105, 180, 0.15);
}

.pick-cards-container {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  max-width: 100%;
  flex-shrink: 0;
}

.pick-card {
  flex: 0 0 200px;
  width: 200px;
  height: 280px;
  background: var(--bg-panel);
  border-radius: var(--border-radius-md);
  border: 2px solid var(--card-color, var(--white-20));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  scroll-snap-align: center;
  transition:
    transform var(--duration-fast) var(--ease-out-quart),
    opacity var(--duration-fast) var(--ease-out-quart),
    border-width var(--duration-fast) var(--ease-out-quart),
    box-shadow var(--duration-fast) var(--ease-out-quart);
  position: relative;
}

.pick-card.dimmed {
  opacity: 0.5;
  transform: scale(0.92);
  filter: grayscale(0.3);
}

.pick-card.selected {
  transform: scale(1.15);
  border-width: 3px;
  box-shadow:
    0 0 28px var(--card-color),
    0 0 56px var(--card-color),
    0 8px 24px var(--black-40);
  z-index: var(--z-raised);
}

.pick-card.pick-celebrating {
  animation: pick-celebrate 500ms var(--ease-out-expo);
}

.pick-card-portrait {
  flex: 0 0 60%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-color);
}

.pick-card-portrait-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.pick-card-initials {
  font-size: var(--text-3xl);
  font-weight: 800;
  color: var(--white-90);
  text-shadow: 0 2px 8px var(--black-20);
}

.pick-card-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm);
  gap: var(--space-xs);
}

.pick-card-name {
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--card-color);
}

.pick-card-weapon {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-align: center;
}

.pick-card-check {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  width: 32px;
  height: 32px;
  border-radius: var(--border-radius-circle);
  background: var(--text-gold);
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--bg-primary);
  font-weight: 800;
}

.pick-card.selected .pick-card-check {
  display: flex;
  animation: bounce-in 300ms var(--ease-out-expo);
}

.pick-quote {
  font-size: var(--text-md);
  color: var(--text-secondary);
  text-align: center;
  min-height: 1.5em;
  padding: 0 var(--space-md);
  overflow-wrap: break-word;
  word-break: break-word;
}

.pick-go-btn {
  font-size: var(--text-lg);
  padding: var(--space-md) var(--space-2xl);
  box-shadow:
    var(--shadow-glow),
    0 6px 20px var(--black-30);
  min-height: 60px;
  max-width: 260px;
  animation: glow-pulse 2s ease-in-out infinite;
}

@media (min-width: 600px) {
  .pick-card {
    flex: 0 0 140px;
    width: 140px;
    height: 210px;
  }

  .pick-cards-container {
    justify-content: center;
    overflow-x: visible;
    scroll-snap-type: none;
    gap: var(--space-sm);
  }
}

@media (min-width: 900px) {
  .pick-card {
    flex: 0 0 170px;
    width: 170px;
    height: 250px;
  }

  .pick-cards-container {
    gap: var(--space-md);
  }
}

/* ============================================
   Sparkle HQ Hub
   ============================================ */

.hq-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg) var(--space-md);
  overflow-y: auto;
}

/* Daily Sparkle Banner */
.hq-daily-banner {
  width: 100%;
  max-width: 480px;
  background: linear-gradient(135deg, var(--bg-panel-warm), var(--bg-panel));
  border-radius: var(--border-radius-md);
  border: 1px solid var(--gold-25);
  box-shadow: 0 0 20px var(--gold-10);
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.hq-daily-info {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.hq-daily-icon {
  font-size: var(--text-2xl);
  color: var(--text-gold);
  filter: drop-shadow(0 0 8px var(--gold-60)) drop-shadow(0 0 16px var(--gold-25));
  animation: sparkle-pulse 2s ease-in-out infinite;
}

.hq-daily-text {
  display: flex;
  flex-direction: column;
}

.hq-daily-title {
  font-size: var(--text-md);
  font-weight: 800;
  color: var(--text-gold);
}

.hq-daily-streak {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.hq-streak-dots {
  display: flex;
  gap: var(--space-xs);
  justify-content: center;
}

.hq-streak-dot {
  width: 20px;
  height: 20px;
  border-radius: var(--border-radius-circle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
}

.hq-streak-dot.filled {
  background: var(--text-gold);
  color: var(--bg-primary);
  box-shadow: 0 0 8px var(--gold-40);
}

.hq-streak-dot.empty {
  background: var(--white-15);
  border: 1px solid var(--white-20);
  color: var(--text-secondary);
}

.hq-collect-btn {
  min-height: 48px;
  align-self: center;
  box-shadow:
    var(--shadow-glow),
    0 4px 12px var(--black-25);
  animation: glow-pulse 2s ease-in-out infinite;
}

/* Favorite Character Display */
.hq-character-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  width: 100%;
  max-width: 480px;
  margin-bottom: var(--space-sm);
}

.hq-portrait {
  width: 160px;
  height: 160px;
  aspect-ratio: 1;
  border-radius: var(--border-radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--portrait-color, var(--color-avery));
  border: 4px solid var(--white-30);
  box-shadow:
    0 0 40px var(--portrait-color, var(--color-avery)),
    0 0 80px color-mix(in srgb, var(--portrait-color, var(--color-avery)) 25%, transparent),
    0 6px 24px var(--black-40);
}

@media (min-width: 600px) {
  .hq-portrait {
    width: 180px;
    height: 180px;
  }
}

.hq-portrait-initials {
  font-size: 56px;
  font-weight: 800;
  color: var(--white-90);
  text-shadow:
    0 2px 12px var(--black-25),
    0 0 24px var(--white-10);
}

.hq-char-name {
  font-size: var(--text-xl);
  font-weight: 800;
  letter-spacing: var(--tracking-normal);
  text-shadow:
    0 0 16px currentColor,
    0 0 32px var(--gold-15);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.hq-weapon-name {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* Star rating */
.star-rating {
  display: inline-flex;
  gap: var(--space-xs);
}

.star-filled,
.star-empty {
  display: inline-block;
  width: 24px;
  height: 24px;
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

.star-filled {
  background: var(--text-gold);
  filter: drop-shadow(0 0 5px var(--gold-60)) drop-shadow(0 0 10px var(--gold-20));
}

.star-empty {
  background: var(--white-20);
}

#hq-star-rating .star-filled,
#hq-star-rating .star-empty {
  width: 32px;
  height: 32px;
  opacity: 0;
  animation: bounce-in 300ms var(--ease-out-expo) forwards;
}

/* XP Bar */
.hq-xp-bar-container {
  width: 100%;
  max-width: 240px;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.hq-xp-bar {
  height: 8px;
}

.hq-upgrade-notice {
  font-size: var(--text-sm);
  font-weight: 800;
  color: var(--text-gold);
}

/* HQ entrance — portrait pops in, map teaser slides up */
.hq-entering .hq-portrait {
  animation: bounce-in 420ms 50ms var(--ease-out-expo) both;
}

.hq-entering .hq-map-teaser {
  animation: slide-up-in 380ms 150ms var(--ease-out-expo) both;
}

/* Map Teaser Card */
.hq-map-teaser {
  position: relative;
  width: 100%;
  max-width: 480px;
  min-height: 80px;
  margin-top: auto;
  background: linear-gradient(135deg, var(--bg-panel-warm), var(--bg-panel-vivid));
  border: 2px solid var(--gold-35);
  border-radius: var(--border-radius-md);
  padding: var(--space-lg) var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  color: inherit;
  font: inherit;
  text-align: left;
  box-shadow:
    0 0 32px var(--gold-20),
    0 4px 16px var(--black-25);
}

.hq-map-teaser.onboard-pulse {
  animation: onboard-glow 1.2s ease-in-out infinite;
  border-color: var(--text-gold);
  border-width: 3px;
  transform: scale(1.02);
}

.hq-map-teaser.onboard-pulse::after {
  content: "👆";
  position: absolute;
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.75rem;
  animation: advance-pulse 1s ease-in-out infinite;
  pointer-events: none;
  z-index: var(--z-raised);
}

.hq-map-icon {
  font-size: var(--text-3xl);
  color: var(--text-gold);
  filter: drop-shadow(0 0 10px var(--gold-60)) drop-shadow(0 0 20px var(--gold-25));
}

.hq-map-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.hq-map-title {
  font-size: var(--text-lg);
  font-weight: 800;
}

.hq-map-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.hq-map-arrow {
  font-size: var(--text-xl);
  color: var(--text-gold);
}

/* ============================================
   Overlay Shared
   ============================================ */

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: var(--bg-overlay);
}

.overlay-content {
  position: relative;
  z-index: var(--z-content);
}

/* ============================================
   Settings Overlay
   ============================================ */

.settings-panel {
  background: var(--bg-secondary);
  border-radius: var(--border-radius-lg);
  width: calc(100% - 48px);
  max-width: 360px;
  max-height: 80vh;
  overflow-y: auto;
  border: 2px solid var(--gold-35);
  box-shadow:
    0 8px 32px var(--black-40),
    0 0 20px var(--gold-10);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--white-10);
}

.settings-title {
  font-size: var(--text-lg);
  font-weight: 800;
}

.settings-close {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 28px;
}

.settings-body {
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}

.settings-label {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text-primary);
}

.settings-toggle-btn {
  font-size: var(--text-sm);
  font-weight: 800;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--border-radius-pill);
  border: 2px solid var(--text-gold);
  background: var(--gold-15);
  color: var(--text-gold);
  min-width: 60px;
  min-height: 44px;
  transition:
    color var(--duration-fast) var(--ease-out-quart),
    border-color var(--duration-fast) var(--ease-out-quart),
    background var(--duration-fast) var(--ease-out-quart);
}

.settings-toggle-btn.off {
  border-color: var(--white-30);
  background: none;
  color: var(--text-secondary);
}

.settings-divider {
  height: 1px;
  background: var(--white-10);
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.settings-char-picker {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
}

.settings-char-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--border-radius-circle);
  border: 2px solid var(--btn-color);
  background: var(--white-05);
  color: var(--text-primary);
  font-size: var(--text-md);
  font-weight: 800;
  transition:
    background var(--duration-fast) var(--ease-out-quart),
    box-shadow var(--duration-fast) var(--ease-out-quart);
}

.settings-char-btn.active {
  background: var(--btn-color);
  box-shadow: 0 0 12px var(--btn-color);
}

.settings-reset-btn {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--color-danger);
  background: none;
  border: none;
  padding: var(--space-sm);
  min-height: 44px;
  text-align: center;
}

/* ============================================
   Confirm Dialog
   ============================================ */

.confirm-panel {
  background: var(--bg-secondary);
  border-radius: var(--border-radius-lg);
  padding: var(--space-xl);
  width: calc(100% - 48px);
  max-width: 300px;
  border: 2px solid var(--gold-35);
  box-shadow:
    0 8px 32px var(--black-40),
    0 0 20px var(--gold-10);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
}

.confirm-text {
  font-size: var(--text-md);
  font-weight: 700;
  text-align: center;
  line-height: 1.4;
}

.confirm-buttons {
  display: flex;
  gap: var(--space-md);
  width: 100%;
}

.confirm-cancel-btn,
.confirm-action-btn {
  flex: 1;
  font-size: var(--text-md);
  font-weight: 700;
  border: none;
  border-radius: var(--border-radius-pill);
  padding: var(--space-sm) var(--space-md);
  min-height: 48px;
}

.confirm-cancel-btn {
  background: var(--white-15);
  color: var(--text-primary);
}

.confirm-action-btn {
  background: var(--color-danger);
  color: var(--text-primary);
}

/* ============================================
   Shared Button Styles
   ============================================ */

.btn-pill {
  font-weight: 800;
  border: none;
  border-radius: var(--border-radius-pill);
  min-height: 44px;
  padding: var(--space-sm) var(--space-xl);
  font-size: var(--text-md);
  color: var(--text-primary);
  transition: transform var(--duration-instant) var(--ease-out-quart);
}

.btn-gold {
  background: var(--gradient-gold);
  color: var(--bg-primary);
  box-shadow:
    var(--shadow-glow),
    0 4px 16px var(--black-25);
  letter-spacing: var(--tracking-normal);
}

.btn-warm {
  background: var(--gradient-warm);
  color: var(--text-primary);
  box-shadow:
    0 6px 24px var(--gold-45),
    0 0 40px var(--coral-25),
    0 8px 24px var(--black-25);
  letter-spacing: var(--tracking-normal);
}

/* Universal tap feedback — every tappable element gets a satisfying press */
.btn-pill:active,
.btn-gold:active,
.header-back:active,
.header-settings:active,
.nav-btn:active,
.coll-tab:active,
.wardrobe-cat-tab:active,
.map-marker:active,
.sticker-cell:active,
.card-cell:active {
  transform: scale(0.95);
}

/* Map demons have translate(-50%,-50%) positioning — must preserve it */
.map-demon:active {
  transform: translate(-50%, -50%) scale(0.95);
}

.btn-lg {
  min-height: 64px;
  font-size: var(--text-lg);
  padding: var(--space-md) var(--space-2xl);
  max-width: 260px;
}

/* ============================================
   Shared XP Bar — HQ + Weapon Gallery
   ============================================ */

.hq-xp-bar,
.wg-detail-xp-bar {
  width: 100%;
  background: var(--white-15);
  border-radius: var(--border-radius-xs);
  overflow: hidden;
}

.hq-xp-fill,
.wg-detail-xp-fill {
  height: 100%;
  width: 100%;
  background: var(--text-gold);
  border-radius: var(--border-radius-xs);
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform var(--duration-slow) ease;
}

.hq-xp-text,
.wg-detail-xp-text {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-align: right;
}

/* ============================================
   Sparkle Map
   ============================================ */

.map-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--space-md);
  gap: var(--space-md);
  overflow-y: auto;
}

.map-count {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-align: center;
}

.map-grid {
  flex: 1;
  position: relative;
  min-height: 420px;
  border-radius: var(--border-radius-lg);
  background:
    url("../assets/backgrounds/sparkle-map.webp") center / cover no-repeat,
    linear-gradient(170deg, var(--bg-primary) 0%, var(--bg-secondary) 40%, var(--bg-primary) 100%);
  border: 2px solid var(--gold-20);
  overflow: hidden;
  contain: content;
  box-shadow:
    inset 0 0 40px rgba(147, 112, 219, 0.08),
    0 4px 20px var(--black-30);
}

.map-location {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  transform: translate(-50%, -50%);
  z-index: var(--z-content);
}

.map-marker {
  width: 48px;
  height: 48px;
  border-radius: var(--border-radius-circle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: var(--gradient-gold);
  box-shadow:
    0 0 16px var(--gold-50),
    0 4px 12px var(--black-30);
  transition: transform var(--duration-instant) var(--ease-out-quart);
}

.map-marker.locked {
  background: var(--color-muted);
  box-shadow: none;
}

.map-location-name {
  font-size: var(--text-xs);
  color: var(--text-primary);
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  text-shadow: 0 1px 4px var(--black-80);
}

.map-demon {
  position: absolute;
  width: 68px;
  height: 68px;
  border-radius: var(--border-radius-circle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--text-primary);
  border: 3px solid var(--demon-color, var(--text-gold));
  box-shadow:
    0 0 18px var(--demon-color, var(--text-gold)),
    0 0 36px var(--black-35),
    inset 0 0 12px var(--black-20);
  transform: translate(-50%, -50%);
  animation: bounce-subtle 600ms ease-in-out infinite;
  z-index: var(--z-raised);
  overflow: hidden;
}

.map-demon-img {
  width: 100%;
  height: 100%;
  border-radius: var(--border-radius-circle);
  object-fit: cover;
  pointer-events: none;
}

.map-demon-initials {
  text-shadow: 0 1px 3px var(--black-50);
}

.map-demon-badge {
  position: absolute;
  top: -6px;
  right: -8px;
  font-size: var(--text-xs);
  font-weight: 800;
  background: var(--gradient-gold);
  color: var(--bg-primary);
  padding: 2px 6px;
  border-radius: var(--border-radius-pill);
  white-space: nowrap;
}

.map-lock-icon {
  font-size: 16px;
  color: var(--white-50);
}

/* Sparkle path decorations */
.map-grid::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 45% 30%, rgba(255, 215, 0, 0.08) 0%, transparent 35%),
    radial-gradient(circle at 70% 60%, rgba(147, 112, 219, 0.07) 0%, transparent 30%),
    radial-gradient(circle at 20% 80%, rgba(30, 144, 255, 0.06) 0%, transparent 28%),
    radial-gradient(circle at 85% 15%, rgba(255, 105, 180, 0.04) 0%, transparent 25%);
  pointer-events: none;
}

/* ============================================
   Weapon Gallery
   ============================================ */

.wg-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--space-lg) var(--space-md);
  gap: var(--space-md);
  overflow-y: auto;
}

.wg-cards {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  flex-shrink: 0;
}

.wg-card {
  flex: 0 0 100px;
  width: 100px;
  height: 140px;
  background: var(--bg-panel);
  border-radius: var(--border-radius-sm);
  border: 2px solid var(--weapon-color, var(--white-20));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  transition:
    transform var(--duration-fast) var(--ease-out-quart),
    border-width var(--duration-fast) var(--ease-out-quart),
    box-shadow var(--duration-fast) var(--ease-out-quart);
  scroll-snap-align: center;
}

.wg-card.selected {
  transform: scale(1.05);
  border-width: 3px;
  box-shadow: 0 0 16px var(--weapon-color);
}

.wg-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--border-radius-circle);
  background: var(--weapon-color, var(--color-muted));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.wg-card-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.wg-card-name {
  font-size: var(--text-xs);
  color: var(--weapon-color, var(--text-primary));
  font-weight: 700;
  text-align: center;
}

.wg-card-stars {
  display: flex;
  gap: var(--space-xs);
}

.wg-card-stars .star-filled,
.wg-card-stars .star-empty {
  width: 12px;
  height: 12px;
}

.wg-divider {
  height: 1px;
  background: var(--white-10);
}

.wg-detail {
  flex: 1;
  background: var(--bg-panel-vivid);
  border-radius: var(--border-radius-md);
  border: 1px solid var(--white-10);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  min-height: 200px;
}

.wg-detail-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  color: var(--text-secondary);
  font-size: var(--text-md);
  text-align: center;
  margin: auto;
}

.wg-detail-empty-icon {
  font-size: 2rem;
  color: var(--text-gold);
  animation: sparkle-pulse 2s ease-in-out infinite;
}

.wg-detail-sprite {
  width: 96px;
  height: 96px;
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.wg-detail-sprite img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.wg-detail-name {
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--text-primary);
}

.wg-detail-level {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text-gold);
}

.wg-detail-xp-container {
  width: 100%;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.wg-detail-xp-bar {
  height: 10px;
}

.wg-detail-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-align: center;
}

.wg-detail-stats {
  display: flex;
  gap: var(--space-lg);
}

.wg-detail-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
}

.wg-detail-stat-label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.wg-detail-stat-value {
  font-size: var(--text-md);
  font-weight: 800;
  color: var(--text-primary);
}

.wg-upgrade-banner {
  font-size: var(--text-sm);
  font-weight: 800;
  color: var(--text-gold);
  animation: sparkle-pulse 1.5s ease-in-out infinite;
}

.wg-upgrade-btn {
  font-size: var(--text-lg);
  padding: var(--space-md) var(--space-2xl);
  box-shadow:
    var(--shadow-glow),
    0 6px 20px var(--black-25);
  min-height: 60px;
  animation: glow-pulse 2s ease-in-out infinite;
}

.wg-legendary-text {
  font-size: var(--text-md);
  font-weight: 800;
  background: linear-gradient(
    90deg,
    var(--color-mira),
    var(--color-zoey),
    var(--text-gold),
    var(--color-rumi),
    var(--color-coral)
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer-slide 3s linear infinite;
}

@media (min-width: 600px) {
  .wg-cards {
    justify-content: center;
    overflow-x: visible;
    scroll-snap-type: none;
  }
}

/* ============================================
   Demon Intro
   ============================================ */

#scene-demon-intro {
  background:
    radial-gradient(ellipse at 50% 25%, rgba(147, 112, 219, 0.18) 0%, transparent 55%),
    radial-gradient(ellipse at 20% 80%, rgba(255, 105, 180, 0.06) 0%, transparent 40%),
    radial-gradient(ellipse at 80% 70%, rgba(30, 144, 255, 0.05) 0%, transparent 35%), var(--bg-gradient);
}

.di-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2xl) var(--space-md) var(--space-xl);
  gap: var(--space-lg);
}

.di-demon-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
}

.di-demon-sprite {
  width: 200px;
  height: 200px;
  aspect-ratio: 1;
  border-radius: var(--border-radius-circle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  font-weight: 800;
  color: var(--text-primary);
  text-shadow: 0 2px 10px var(--black-35);
  overflow: hidden;
  position: relative;
  border: 4px solid color-mix(in srgb, var(--demon-color, var(--color-rumi)) 60%, transparent);
  box-shadow:
    0 0 40px var(--black-50),
    0 0 80px color-mix(in srgb, var(--demon-color, var(--color-rumi)) 50%, transparent),
    inset 0 0 20px var(--black-15);
}

/* Dramatic entrance animation — overrides the idle bounce-loop briefly */
.di-entering {
  animation: bounce-in 400ms var(--ease-out-expo) forwards !important;
}

.di-demon-sprite-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--border-radius-circle);
  object-fit: contain;
  pointer-events: none;
}

.di-demon-name {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--text-primary);
  text-shadow:
    0 0 24px var(--white-50),
    0 0 48px rgba(147, 112, 219, 0.3);
  letter-spacing: var(--tracking-wide);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

@media (min-width: 600px) {
  .di-demon-sprite {
    width: 240px;
    height: 240px;
    font-size: 80px;
  }
}

.di-dialogue-area {
  width: 100%;
  max-width: 480px;
}

.di-bubble {
  background: var(--white-95);
  border-radius: var(--border-radius-md);
  padding: var(--space-lg);
  position: relative;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.di-bubble-text {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.5;
  overflow-wrap: break-word;
  word-break: break-word;
}

.di-advance {
  font-size: var(--text-xs);
  color: var(--black-30);
  text-align: center;
}

.di-actions {
  display: flex;
  gap: var(--space-lg);
  width: 100%;
  max-width: 400px;
}

.btn-fight {
  flex: 1;
  min-height: 64px;
  font-size: var(--text-xl);
  background: var(--fight-color, var(--color-avery));
  color: var(--bg-primary);
  box-shadow:
    0 0 24px var(--fight-color, var(--color-avery)),
    0 0 48px var(--gold-25),
    0 6px 20px var(--black-30);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  text-shadow: 0 1px 2px var(--black-15);
}

.btn-run {
  flex: 0 0 auto;
  min-height: 44px;
  font-size: var(--text-md);
  background: none;
  border: 2px solid var(--white-30);
  color: var(--text-primary);
}

/* ============================================
   Weapon Select
   ============================================ */

#scene-weapon-select {
  background:
    radial-gradient(ellipse at 50% 55%, rgba(30, 144, 255, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 75% 20%, rgba(147, 112, 219, 0.06) 0%, transparent 40%),
    radial-gradient(ellipse at 25% 80%, rgba(255, 215, 0, 0.04) 0%, transparent 35%), var(--bg-gradient);
}

.ws-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-md);
  gap: var(--space-lg);
  overflow-y: auto;
}

.ws-cards {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  flex-shrink: 0;
  width: 100%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.ws-card {
  flex: 0 0 140px;
  width: 140px;
  height: 200px;
  background: var(--bg-panel);
  border-radius: var(--border-radius-sm);
  border: 2px solid var(--card-color, var(--white-20));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  scroll-snap-align: center;
  transition:
    transform var(--duration-fast) var(--ease-out-quart),
    border-width var(--duration-fast) var(--ease-out-quart),
    box-shadow var(--duration-fast) var(--ease-out-quart),
    translate var(--duration-fast) var(--ease-out-quart);
}

.ws-card.selected {
  transform: scale(1.12);
  translate: 0 -10px;
  border-width: 3px;
  box-shadow:
    0 0 24px var(--card-color),
    0 8px 24px var(--black-35);
}

.ws-card.dimmed {
  opacity: 0.6;
}

.ws-card-portrait {
  flex: 0 0 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-color);
  position: relative;
}

.ws-card-initials {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--white-85);
}

.ws-card-weapon-icon {
  position: absolute;
  bottom: var(--space-xs);
  left: var(--space-xs);
  width: 24px;
  height: 24px;
  border-radius: var(--border-radius-circle);
  background: var(--black-30);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.ws-card-weapon-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ws-card-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xs);
  gap: var(--space-xs);
}

.ws-card-name {
  font-size: var(--text-sm);
  font-weight: 800;
  color: var(--card-color);
}

.ws-card-stars {
  display: flex;
  gap: var(--space-xs);
}

.ws-card-stars .star-filled,
.ws-card-stars .star-empty {
  width: 12px;
  height: 12px;
}

.ws-card-xp {
  width: 80%;
  height: 4px;
  background: var(--white-15);
  border-radius: var(--border-radius-xs);
  overflow: hidden;
}

.ws-card-xp-fill {
  height: 100%;
  background: var(--text-gold);
  border-radius: var(--border-radius-xs);
}

.ws-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  min-height: 50px;
}

.ws-quote {
  font-size: var(--text-md);
  color: var(--text-secondary);
  text-align: center;
}

.ws-weakness {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-gold);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

@media (min-width: 600px) {
  .ws-cards {
    justify-content: center;
    overflow-x: visible;
    scroll-snap-type: none;
  }

  .ws-card {
    flex: 0 0 130px;
    width: 130px;
    height: 190px;
  }
}

/* ============================================
   Weapon Charge
   ============================================ */

#scene-weapon-charge {
  background:
    radial-gradient(ellipse at 50% 45%, var(--gold-10) 0%, transparent 45%),
    radial-gradient(ellipse at 30% 70%, rgba(255, 105, 180, 0.05) 0%, transparent 35%),
    radial-gradient(ellipse at 70% 30%, rgba(147, 112, 219, 0.05) 0%, transparent 35%), var(--bg-gradient);
}

.wc-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-xl);
  user-select: none;
}

.wc-weapon {
  width: 160px;
  height: 160px;
  border-radius: var(--border-radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    filter var(--duration-fast) var(--ease-out-quart),
    transform var(--duration-fast) var(--ease-out-quart);
  filter: brightness(0.3) grayscale(0.5);
}
.wc-weapon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@media (min-width: 600px) {
  .wc-weapon {
    width: 200px;
    height: 200px;
  }
}

.wc-prompt {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  padding: 0 var(--space-md);
}

.wc-dots {
  display: flex;
  gap: var(--space-sm);
}

.wc-dot {
  width: 14px;
  height: 14px;
  border-radius: var(--border-radius-circle);
  border: 2px solid var(--white-40);
  background: transparent;
  transition:
    background var(--duration-fast) ease,
    border-color var(--duration-fast) ease;
}

.wc-dot.filled {
  background: var(--text-gold);
  border-color: var(--text-gold);
}

/* ============================================
   Puzzle System
   ============================================ */

.puzzle-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* --- Demon Area (top ~18%) --- */

.puzzle-demon-area {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  min-height: 88px;
  flex-shrink: 0;
}

.puzzle-demon-circle {
  width: 68px;
  height: 68px;
  border-radius: var(--border-radius-circle);
  background: var(--bg-panel);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 2px solid var(--demon-color, var(--white-30));
  box-shadow:
    0 0 16px var(--demon-color, transparent),
    0 4px 12px var(--black-25);
  animation: bounce-subtle 1.5s ease-in-out infinite;
  position: relative;
  overflow: hidden;
}

.puzzle-demon-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--border-radius-circle);
  object-fit: contain;
  pointer-events: none;
}

.puzzle-demon-initial {
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--text-primary);
}

.puzzle-speech-bubble {
  background: var(--white-92);
  border-radius: var(--border-radius-md);
  padding: var(--space-sm) var(--space-md);
  flex: 1;
  min-height: 40px;
  display: flex;
  align-items: center;
  position: relative;
}

.puzzle-speech-bubble::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 8px solid var(--white-92);
}

.puzzle-speech-text {
  font-size: var(--text-md);
  color: var(--text-dark);
  line-height: 1.4;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* --- Puzzle Play Area --- */

.puzzle-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  gap: var(--space-lg);
}

/* --- Sparkle Boost Button --- */

.puzzle-boost-btn {
  position: absolute;
  bottom: var(--space-md);
  right: var(--space-md);
  width: 48px;
  height: 48px;
  border-radius: var(--border-radius-circle);
  background: linear-gradient(135deg, var(--color-mira), var(--text-gold), var(--color-zoey), var(--color-rumi));
  background-size: 300% 300%;
  border: 2px solid var(--white-60);
  color: var(--text-primary);
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation:
    glow-pulse 2s ease-in-out infinite,
    boost-bg-shift 4s ease-in-out infinite;
  box-shadow: 0 0 12px var(--gold-40);
  z-index: var(--z-nav);
}

@keyframes boost-bg-shift {
  0%,
  100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

/* --- Pattern Match Puzzle --- */

.pm-prompt {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
}

.pm-display {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  align-items: center;
}

.pm-star {
  width: 80px;
  height: 80px;
  border-radius: var(--border-radius-circle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  transition:
    transform var(--duration-fast) ease,
    filter var(--duration-fast) ease,
    box-shadow var(--duration-normal) ease;
  position: relative;
}

.pm-star.dim {
  filter: brightness(0.3) grayscale(0.6);
  transform: scale(0.9);
}

.pm-star.lit {
  filter: brightness(1.1);
  transform: scale(1);
}

.pm-star.flashing {
  filter: brightness(1.2);
  transform: scale(1.2);
  animation: none; /* override any idle animation */
}

.pm-star.correct-glow {
  animation: correct-pulse 300ms ease-out;
}

.pm-star.hint-shimmer {
  animation: hint-shimmer 500ms ease-in-out infinite;
}

.pm-buttons {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  flex-wrap: wrap;
}

.pm-btn {
  height: 80px;
  min-width: 90px;
  padding: 0 var(--space-lg);
  border-radius: var(--border-radius-pill);
  border: 3px solid var(--white-40);
  color: var(--text-primary);
  font-size: var(--text-md);
  font-weight: 800;
  text-transform: uppercase;
  transition:
    transform var(--duration-instant) ease,
    filter var(--duration-instant) ease,
    box-shadow var(--duration-normal) ease;
  letter-spacing: var(--tracking-normal);
  opacity: 0.4;
  pointer-events: none;
}

.pm-btn.active {
  opacity: 1;
  pointer-events: auto;
  animation: btn-activate 300ms ease-out;
}

.pm-btn.active:active {
  transform: scale(0.95);
}

.pm-btn.wrong-flash {
  animation: shake-wrong 200ms ease-in-out;
}

.pm-btn.hint-glow {
  animation: hint-glow-btn 1s ease-in-out infinite;
}

/* --- Encourage message overlay --- */

.puzzle-encourage-msg {
  position: absolute;
  top: clamp(60px, 15vw, 120px);
  left: 0;
  right: 0;
  width: fit-content;
  margin-inline: auto;
  background: rgba(147, 112, 219, 0.92);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: 700;
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--border-radius-pill);
  white-space: nowrap;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  animation: slide-up-in 300ms var(--ease-out-expo) forwards;
  z-index: 5;
  pointer-events: none;
}

/* --- Responsive: Tablet --- */

@media (min-width: 600px) {
  .puzzle-demon-area {
    padding: var(--space-md) var(--space-lg);
    min-height: 104px;
  }

  .puzzle-demon-circle {
    width: 72px;
    height: 72px;
  }

  .puzzle-demon-initial {
    font-size: var(--text-xl);
  }

  .puzzle-speech-text {
    font-size: var(--text-md);
  }

  .pm-star {
    width: 96px;
    height: 96px;
    font-size: 40px;
  }

  .pm-btn {
    min-width: 110px;
    height: 88px;
    font-size: var(--text-lg);
  }
}

/* ═══════════════════════════════════════════════ */
/* Hidden Items Puzzle (Snorina)                  */
/* ═══════════════════════════════════════════════ */

.hi-prompt {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
}

.hi-scene {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 200px;
  max-height: 400px;
  border-radius: var(--border-radius-md);
  background: linear-gradient(145deg, var(--bg-primary) 0%, var(--bg-secondary) 40%, var(--bg-primary) 100%);
  overflow: hidden;
  touch-action: manipulation;
}

/* Lighter rectangular "hiding spots" for visual interest */
.hi-scene::before {
  content: "";
  position: absolute;
  left: 10%;
  top: 30%;
  width: 25%;
  height: 35%;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--border-radius-sm);
}

.hi-scene::after {
  content: "";
  position: absolute;
  right: 8%;
  top: 20%;
  width: 20%;
  height: 40%;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--border-radius-sm);
}

.hi-item {
  position: absolute;
  width: 48px;
  height: 48px;
  border-radius: var(--border-radius-circle);
  transform: translate(-50%, -50%);
  animation: hi-shimmer 2s ease-in-out infinite;
  transition:
    transform var(--duration-normal) ease,
    opacity var(--duration-normal) ease;
  z-index: var(--z-raised);
  /* 64px radius tap target via padding */
  padding: 22px;
  margin: -22px;
  background-clip: content-box;
  box-sizing: content-box;
}

@keyframes hi-shimmer {
  0%,
  100% {
    opacity: 0.4;
    transform: translate(-50%, -50%) scale(0.9);
  }
  50% {
    opacity: 0.75;
    transform: translate(-50%, -50%) scale(1.05);
  }
}

.hi-item-hint {
  animation: hi-shimmer-fast 500ms ease-in-out infinite !important;
}

@keyframes hi-shimmer-fast {
  0%,
  100% {
    opacity: 0.5;
    transform: translate(-50%, -50%) scale(0.95);
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.15);
  }
}

.hi-item-found {
  pointer-events: none;
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.5);
  animation: none;
}

.hi-item-collected {
  opacity: 0;
  transform: translate(-50%, -100%) scale(0.3);
  transition:
    opacity var(--duration-slow) ease-in,
    transform var(--duration-slow) ease-in;
}

.hi-dust-puff {
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: var(--border-radius-circle);
  background: radial-gradient(circle, rgba(221, 160, 221, 0.5), transparent 70%);
  transform: translate(-50%, -50%) scale(0.5);
  pointer-events: none;
  animation: hi-puff 400ms ease-out forwards;
  z-index: 3;
}

@keyframes hi-puff {
  0% {
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0.8;
  }
  100% {
    transform: translate(-50%, -50%) scale(2);
    opacity: 0;
  }
}

.hi-counter {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-sm) 0;
}

.hi-counter-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 700;
}

.hi-star {
  font-size: 24px;
  color: var(--text-dim);
  transition:
    color var(--duration-normal) ease,
    transform var(--duration-normal) ease;
}

.hi-star-found {
  color: var(--text-gold);
  transform: scale(1.2);
}

/* ═══════════════════════════════════════════════ */
/* Tap Sequence Puzzle (Wobbleknees)              */
/* ═══════════════════════════════════════════════ */

.ts-prompt {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
}

.ts-moves {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
  flex-wrap: wrap;
}

.ts-move {
  width: 80px;
  height: 80px;
  border-radius: var(--border-radius-circle);
  border: 3px solid var(--white-40);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition:
    transform var(--duration-fast) ease,
    filter var(--duration-fast) ease,
    box-shadow var(--duration-normal) ease;
  position: relative;
  touch-action: manipulation;
}

.ts-move-label {
  font-size: var(--text-sm);
  font-weight: 800;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: var(--tracking-tight);
  pointer-events: none;
}

.ts-guide {
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: 16px;
  color: var(--text-primary);
  background: var(--black-50);
  width: 22px;
  height: 22px;
  border-radius: var(--border-radius-circle);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.ts-move-dim {
  filter: brightness(0.35) grayscale(0.5);
  transform: scale(0.88);
}

.ts-move-lit {
  filter: brightness(1.2);
  transform: scale(1.15);
  box-shadow: 0 0 20px currentColor;
}

.ts-move-ready {
  filter: brightness(1);
  transform: scale(1);
  animation: btn-activate 300ms ease-out;
}

.ts-move-done {
  filter: brightness(1.1);
  border-color: var(--color-success);
  box-shadow:
    0 0 12px rgba(76, 175, 80, 0.7),
    0 0 24px rgba(76, 175, 80, 0.3);
}

.ts-move-hint {
  animation: ts-hint-bounce 800ms ease-in-out infinite;
}

@keyframes ts-hint-bounce {
  0%,
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
  50% {
    transform: scale(1.12);
    filter: brightness(1.3);
    box-shadow: 0 0 16px var(--white-50);
  }
}

.ts-move:active {
  transform: scale(0.92);
}

/* ═══════════════════════════════════════════════ */
/* Memory Game Puzzle (Tanglefur)                 */
/* ═══════════════════════════════════════════════ */

.mg-prompt {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
}

.mg-grid {
  display: grid;
  gap: var(--space-sm);
  justify-content: center;
  perspective: 800px;
}

.mg-card {
  width: 72px;
  height: 96px;
  position: relative;
  touch-action: manipulation;
}

.mg-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform var(--duration-normal) var(--ease-out-quart);
  transform-style: preserve-3d;
}

.mg-card-flipped .mg-card-inner {
  transform: rotateY(180deg);
}

.mg-card-front,
.mg-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: var(--border-radius-sm);
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Card front = card BACK design (magenta with gold star) */
.mg-card-front {
  background: var(--color-card-back);
  border: 2px solid var(--color-card-back);
}

.mg-card-star {
  font-size: 28px;
  color: var(--text-gold);
}

/* Card back = card FACE (character-colored with initial + name) */
.mg-card-back {
  transform: rotateY(180deg);
  border: 2px solid var(--white-60);
}

.mg-card-initial {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  text-shadow: 0 1px 3px var(--black-40);
  pointer-events: none;
}

.mg-card-name {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-primary);
  text-shadow: 0 1px 2px var(--black-40);
  margin-top: 2px;
  pointer-events: none;
}

.mg-card-matched {
  pointer-events: none;
}

.mg-card-matched .mg-card-inner {
  box-shadow: 0 0 12px var(--gold-50);
  border-radius: var(--border-radius-sm);
}

.mg-card-hint .mg-card-inner {
  animation: mg-hint-glow 1s ease-in-out infinite;
}

@keyframes mg-hint-glow {
  0%,
  100% {
    box-shadow: 0 0 4px var(--hint-color, #ffd700);
  }
  50% {
    box-shadow:
      0 0 16px var(--hint-color, #ffd700),
      0 0 24px var(--hint-color, var(--gold-25));
  }
}

.mg-counter {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-sm) 0;
}

.mg-counter-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 700;
}

.mg-star {
  font-size: 24px;
  color: var(--text-dim);
  transition:
    color var(--duration-normal) ease,
    transform var(--duration-normal) ease;
}

.mg-star-found {
  color: var(--text-gold);
  transform: scale(1.2);
}

/* ═══════════════════════════════════════════════ */
/* Responsive: Tablet — New Puzzle Types          */
/* ═══════════════════════════════════════════════ */

@media (min-width: 600px) {
  .hi-scene {
    max-height: 480px;
  }

  .hi-item {
    width: 48px;
    height: 48px;
  }

  .ts-move {
    width: 96px;
    height: 96px;
  }

  .ts-move-label {
    font-size: var(--text-md);
  }

  .mg-card {
    width: 84px;
    height: 112px;
  }

  .mg-grid {
    gap: var(--space-sm);
  }

  .mg-card-initial {
    font-size: 32px;
  }

  .mg-card-name {
    font-size: var(--text-xs);
  }
}

/* ═══════════════════════════════════════════════ */
/* Sparkle Timer Bar (Pattern Match+ / Medley)    */
/* ═══════════════════════════════════════════════ */

.sparkle-timer-container {
  width: 100%;
  height: 8px;
  background: var(--bg-primary-80);
  border: 1px solid var(--text-gold);
  border-radius: var(--border-radius-xs);
  overflow: hidden;
  position: relative;
  margin: var(--space-xs) 0;
}

.sparkle-timer-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-cyan), var(--color-cyan-dark));
  border-radius: var(--border-radius-xs);
  transition: none;
  position: relative;
}

.sparkle-timer-fill.timer-calm {
  box-shadow: 0 0 4px rgba(92, 224, 214, 0.3);
}

.sparkle-timer-fill.timer-warning {
  animation: timer-pulse 1.5s ease-in-out infinite;
}

.sparkle-timer-fill.timer-urgent {
  background: linear-gradient(90deg, var(--color-cyan), var(--text-gold));
  animation: timer-pulse 800ms ease-in-out infinite;
}

.sparkle-timer-fill.timer-critical {
  background: linear-gradient(90deg, var(--text-gold), var(--color-mira));
  animation: timer-critical-flash 300ms ease-in-out infinite;
}

/* ═══════════════════════════════════════════════ */
/* Medley Round Indicator (Shade King)            */
/* ═══════════════════════════════════════════════ */

.medley-round-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-xs) 0;
}

.medley-round-label {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-secondary);
}

.medley-round-star {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--text-dim);
  transition:
    color var(--duration-normal) ease,
    transform var(--duration-normal) ease;
}

.medley-round-star.completed {
  color: var(--text-gold);
  animation: round-star-fill 400ms ease-out forwards;
}

/* Medley between-round title card */
.medley-round-title {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1);
  font-size: var(--text-xl);
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-gold);
  text-align: center;
  text-shadow: 0 2px 8px var(--black-60);
  z-index: var(--z-sticky);
  pointer-events: none;
  animation: medley-round-title-in 500ms var(--ease-out-expo) forwards;
}

/* Timer reset flash overlay */
.timer-reset-flash {
  position: absolute;
  inset: 0;
  background: white;
  opacity: 0;
  pointer-events: none;
  z-index: var(--z-header);
  animation: wrong-flash 200ms ease-out forwards;
}

/* ============================================
   Victory Screen
   ============================================ */

.victory-container {
  width: 100%;
  height: 100%;
  position: relative;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(255, 215, 0, 0.14) 0%, transparent 50%),
    radial-gradient(ellipse at 30% 70%, rgba(255, 105, 180, 0.06) 0%, transparent 40%),
    radial-gradient(ellipse at 70% 20%, rgba(147, 112, 219, 0.06) 0%, transparent 40%), var(--bg-gradient);
  overflow: hidden;
}

.victory-phase {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  padding: var(--space-lg);
}

/* --- Phase 1: Weapon Victory --- */

.victory-phase-1 {
  flex-direction: row;
  justify-content: space-evenly;
  align-items: center;
  padding: var(--space-xl) var(--space-md);
}

.victory-circle {
  width: 120px;
  height: 120px;
  aspect-ratio: 1;
  border-radius: var(--border-radius-circle);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--circle-color, var(--white-50));
  box-shadow:
    0 0 28px var(--circle-color, var(--white-30)),
    0 6px 20px var(--black-40);
  position: relative;
  overflow: hidden;
}

.victory-demon-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--border-radius-circle);
  object-fit: contain;
  pointer-events: none;
}

@media (min-width: 600px) {
  .victory-circle {
    width: 140px;
    height: 140px;
  }
}

.victory-circle-initial {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--text-primary);
  text-shadow: 0 2px 4px var(--black-30);
}

.victory-char-circle {
  animation: bounce-subtle 600ms ease-in-out infinite;
}

.victory-char-name {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  margin-top: var(--space-xs);
}

.victory-character,
.victory-demon {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Weapon effect particles traveling across */
.victory-weapon-effect {
  position: relative;
  width: 100px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.victory-particle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: var(--border-radius-circle);
  opacity: 0;
}

.victory-effect-active .victory-particle {
  animation: victory-particle-travel 1s ease-out forwards;
  animation-delay: var(--delay, 0ms);
}

@keyframes victory-particle-travel {
  0% {
    transform: translateX(-60px) translateY(var(--y-offset, 0));
    opacity: 0;
    scale: 0.5;
  }
  20% {
    opacity: 1;
    scale: 1;
  }
  80% {
    opacity: 1;
  }
  100% {
    transform: translateX(60px) translateY(var(--y-offset, 0));
    opacity: 0;
    scale: 0.3;
  }
}

/* --- Legendary Victory (Star 5) --- */

.legendary-particle {
  width: 12px;
  height: 12px;
  box-shadow: 0 0 6px currentColor;
}

.legendary-victory-banner {
  position: absolute;
  top: 12%;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  z-index: var(--z-nav);
  pointer-events: none;
}

.legendary-label {
  font-size: var(--text-xl);
  font-weight: var(--weight-heading);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-hero);
  color: var(--text-gold);
  text-shadow:
    0 0 14px var(--text-gold),
    0 0 28px var(--color-mira),
    0 0 48px var(--gold-20),
    0 2px 6px var(--black-50);
}

.legendary-name {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-primary);
  text-shadow: 0 0 8px var(--gold-60);
}

/* --- Phase 2: Demon Defeat --- */

.victory-phase-2 {
  gap: var(--space-xl);
}

.victory-demon-defeat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
}

.victory-demon-name {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text-secondary);
}

.victory-defeat-dialogue {
  width: 100%;
  max-width: min(100%, 380px);
  padding: 0 var(--space-md);
  opacity: 0;
  animation: slide-up-in 300ms var(--ease-out-expo) forwards;
  animation-delay: 200ms;
}

.victory-dialogue-bubble {
  background: var(--white-92);
  border-radius: var(--border-radius-md);
  padding: var(--space-md);
  position: relative;
}

.victory-dialogue-name {
  display: block;
  font-size: var(--text-sm);
  font-weight: 800;
  color: var(--color-rumi);
  margin-bottom: var(--space-xs);
  text-transform: capitalize;
}

.victory-dialogue-text {
  display: block;
  font-size: var(--text-md);
  color: var(--text-dark);
  line-height: 1.4;
}

/* --- Defeat Animations (CSS keyframes per demon type) --- */

.defeat-anim-spin-dizzy .victory-circle {
  animation: defeat-spin-dizzy 2s ease-in-out forwards;
}

.defeat-anim-yawn-deflate .victory-circle {
  animation: defeat-yawn-deflate 2s ease-in-out forwards;
}

.defeat-anim-somersault-glitter .victory-circle {
  animation: defeat-somersault-glitter 2s ease-in-out forwards;
}

.defeat-anim-comb-reveal .victory-circle {
  animation: defeat-comb-reveal 2s ease-in-out forwards;
}

.defeat-anim-pixel-scatter .victory-circle {
  animation: defeat-pixel-scatter 2s ease-in-out forwards;
}

.defeat-anim-projector-break .victory-circle {
  animation: defeat-projector-break 3s ease-in-out forwards;
}

@keyframes defeat-spin-dizzy {
  0% {
    transform: rotate(0deg) scale(1);
  }
  60% {
    transform: rotate(1080deg) scale(0.6);
    opacity: 1;
  }
  100% {
    transform: rotate(1440deg) scale(0);
    opacity: 0;
  }
}

@keyframes defeat-yawn-deflate {
  0% {
    transform: scaleY(1) scaleX(1);
    opacity: 1;
  }
  30% {
    transform: scaleY(1.3) scaleX(0.8);
  }
  100% {
    transform: scaleY(0) scaleX(1.5);
    opacity: 0;
  }
}

@keyframes defeat-somersault-glitter {
  0% {
    transform: rotate(0deg) translateY(0);
  }
  50% {
    transform: rotate(360deg) translateY(-80px);
  }
  100% {
    transform: rotate(720deg) translateY(40px);
    opacity: 0;
  }
}

@keyframes defeat-comb-reveal {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(0.2);
    opacity: 0;
  }
}

@keyframes defeat-pixel-scatter {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  25% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
  75% {
    opacity: 0.3;
  }
  100% {
    opacity: 0;
    transform: scale(0.8);
  }
}

@keyframes defeat-projector-break {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  20% {
    opacity: 0.4;
    transform: scale(1.05);
  }
  30% {
    opacity: 1;
    transform: scale(0.95);
  }
  50% {
    opacity: 0.2;
    transform: scale(1.1);
  }
  60% {
    opacity: 1;
    transform: scale(0.9);
  }
  80% {
    opacity: 0.1;
    transform: scale(1.15);
  }
  100% {
    opacity: 0;
    transform: scale(0);
  }
}

/* --- Phase 3: Celebration --- */

.victory-phase-3 {
  gap: var(--space-xl);
  z-index: var(--z-raised);
}

.victory-sparkle-burst {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.victory-celebration-particle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  border-radius: var(--border-radius-circle);
  animation: victory-celebrate-burst 1s ease-out forwards;
  animation-delay: var(--delay, 0ms);
}

@keyframes victory-celebrate-burst {
  0% {
    transform: translate(-50%, -50%) translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%)
      translate(calc(cos(var(--angle, 0)) * var(--dist, 60px)), calc(sin(var(--angle, 0)) * var(--dist, 60px))) scale(0);
    opacity: 0;
  }
}

.victory-title {
  font-size: var(--text-3xl);
  font-weight: 800;
  line-height: 1;
  color: var(--text-gold);
  text-shadow:
    0 2px 16px var(--gold-70),
    0 0 48px var(--gold-35),
    0 0 80px var(--coral-20);
  z-index: var(--z-content);
  opacity: 0;
  letter-spacing: var(--tracking-hero);
}

.victory-title.bounce-in {
  animation: bounce-in 500ms var(--ease-out-expo) forwards;
}

.victory-xp-text {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-primary);
  z-index: var(--z-content);
  animation: fade-in 300ms 200ms ease-out both;
}

.victory-level-up {
  text-align: center;
  z-index: var(--z-content);
  animation: fade-in 300ms 400ms ease-out both;
}

.victory-level-stars {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  margin-bottom: var(--space-xs);
}

.victory-level-stars .star-filled {
  width: 44px;
  height: 44px;
  color: var(--text-gold);
  animation: victory-star-fill 300ms ease-out both;
  animation-delay: var(--delay, 0ms);
}

.victory-level-stars .star-empty {
  width: 44px;
  height: 44px;
  color: var(--text-dim);
}

.victory-star-animate {
  opacity: 0;
  animation: victory-star-fill 400ms ease-out forwards;
}

@keyframes victory-star-fill {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  60% {
    opacity: 1;
    transform: scale(1.3);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.victory-level-text {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text-gold);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.victory-rewards-btn {
  min-width: 240px;
  z-index: var(--z-content);
  animation: fade-in 300ms 600ms ease-out both;
}

/* ============================================
   Reward Popup Overlay
   ============================================ */

.reward-panel {
  background: var(--bg-secondary);
  border-radius: var(--border-radius-lg);
  max-width: 360px;
  width: calc(100% - 48px);
  max-height: 80vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 0 var(--space-lg);
  box-shadow:
    0 8px 32px var(--black-40),
    0 0 24px var(--gold-15);
  border: 2px solid var(--gold-35);
}

@media (min-width: 600px) {
  .reward-panel {
    max-width: 420px;
  }
}

.reward-banner {
  width: 100%;
  text-align: center;
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--text-primary);
  padding: var(--space-lg) var(--space-lg);
  background: var(--gradient-warm);
  border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
  text-shadow:
    0 2px 6px var(--black-35),
    0 0 24px var(--gold-30);
  letter-spacing: var(--tracking-wider);
}

.reward-items {
  width: 100%;
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.reward-item-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-panel);
  border-radius: var(--border-radius-sm);
  opacity: 0;
  animation: slide-up-in 300ms var(--ease-out-expo) forwards;
  animation-delay: var(--delay, 0ms);
}

.reward-item-icon {
  width: 48px;
  height: 48px;
  min-width: 48px;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--text-primary);
  background: var(--gold-10);
}

.reward-item-text {
  flex: 1;
  min-width: 0;
}

.reward-item-name {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text-primary);
}

.reward-item-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: 2px;
}

.reward-awesome-btn {
  min-width: 240px;
  margin-top: var(--space-md);
  box-shadow:
    0 6px 24px var(--gold-45),
    0 0 40px var(--coral-20),
    0 8px 24px var(--black-25);
}

/* ============================================
   Boost Button States
   ============================================ */

/* Boost visual effect classes for puzzle elements */

.boost-glow {
  animation: boost-glow-anim 800ms ease-in-out;
  box-shadow: 0 0 20px var(--gold-80) !important;
  filter: brightness(1.4) !important;
}

@keyframes boost-glow-anim {
  0% {
    box-shadow: 0 0 8px var(--gold-30);
    filter: brightness(1);
  }
  50% {
    box-shadow: 0 0 24px rgba(255, 215, 0, 0.9);
    filter: brightness(1.5);
  }
  100% {
    box-shadow: 0 0 8px var(--gold-30);
    filter: brightness(1);
  }
}

.boost-pulse {
  animation: boost-pulse-anim 800ms ease-in-out;
}

@keyframes boost-pulse-anim {
  0% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.15);
  }
  60% {
    transform: scale(0.95);
  }
  100% {
    transform: scale(1);
  }
}

.boost-bright {
  filter: brightness(1.8) drop-shadow(0 0 12px var(--gold-80)) !important;
  transition: filter var(--duration-normal) ease;
}

.boost-shimmer {
  animation: boost-shimmer-anim 1s ease-in-out infinite;
}

@keyframes boost-shimmer-anim {
  0%,
  100% {
    filter: brightness(1.2);
  }
  50% {
    filter: brightness(1.5);
  }
}

.boost-bounce {
  animation: boost-bounce-anim 1.5s ease-in-out;
}

@keyframes boost-bounce-anim {
  0% {
    transform: scale(1) translateY(0);
  }
  15% {
    transform: scale(1.2) translateY(-8px);
  }
  30% {
    transform: scale(1) translateY(0);
  }
  45% {
    transform: scale(1.15) translateY(-6px);
  }
  60% {
    transform: scale(1) translateY(0);
  }
  75% {
    transform: scale(1.1) translateY(-4px);
  }
  100% {
    transform: scale(1) translateY(0);
  }
}

/* ============================================
   Story Moment Overlay
   ============================================ */

/* Full-screen layout — override the default .overlay.active centering */
#overlay-story-moment.active {
  align-items: stretch;
  justify-content: stretch;
  animation: fade-in 350ms var(--ease-out-expo) forwards;
}

.story-bg {
  position: absolute;
  inset: 0;
  background: var(--bg-gradient);
  background-size: cover;
  background-position: center;
}

.story-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--black-40);
}

.story-content {
  position: absolute;
  bottom: 56px; /* above advance hint */
  left: 0;
  right: 0;
  max-height: 45%;
  overflow-y: auto;
  padding: var(--space-md);
  z-index: var(--z-content);
}

.story-advance-hint {
  position: absolute;
  bottom: var(--space-md);
  left: 50%;
  transform: translateX(-50%);
  color: var(--white-80);
  font-size: var(--text-lg);
  animation: sparkle-pulse 1.5s ease-in-out infinite;
  z-index: var(--z-content);
  pointer-events: none;
}

/* Narration */
.story-narration-bar {
  background: var(--bg-primary-88);
  border-radius: var(--border-radius-sm);
  padding: var(--space-sm) var(--space-lg);
  text-align: center;
}

.story-narration-text {
  color: var(--text-secondary);
  font-size: var(--text-md);
  font-weight: var(--weight-body);
  min-height: 1.5em;
  margin: 0;
  overflow-wrap: break-word;
}

/* Dialogue */
.story-dialogue-wrapper {
  display: flex;
  align-items: flex-end;
  gap: var(--space-sm);
}

.story-portrait {
  width: 84px;
  height: 84px;
  min-width: 84px;
  border-radius: var(--border-radius-circle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xl);
  font-weight: 800;
  border: 3px solid;
  background: var(--black-45);
  flex-shrink: 0;
  box-shadow:
    0 0 16px var(--black-30),
    0 0 24px var(--gold-10);
  opacity: 0;
  animation: bounce-in 300ms var(--ease-out-expo) forwards;
}

.story-bubble-wrap {
  flex: 1;
  min-width: 0;
}

.story-char-name {
  font-size: var(--text-sm);
  font-weight: 800;
  margin-bottom: var(--space-xs);
  padding: 2px 10px;
  border-radius: var(--border-radius-pill);
  display: inline-block;
  background: var(--black-35);
}

.story-bubble {
  background: var(--white-95);
  border-radius: 0 var(--border-radius-md) var(--border-radius-md) var(--border-radius-md);
  padding: var(--space-sm) var(--space-md);
}

.story-bubble-text {
  color: var(--text-dark);
  font-size: var(--text-md);
  font-weight: 700;
  min-height: 1.5em;
  margin: 0;
  overflow-wrap: break-word;
}

/* Choice */
.story-choice-wrap {
  background: var(--bg-primary-92);
  border-radius: var(--border-radius-md);
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.story-choice-prompt {
  color: var(--text-primary);
  font-size: var(--text-md);
  font-weight: 800;
  text-align: center;
  margin: 0 0 var(--space-xs);
}

.story-choice-btn {
  min-height: 52px;
  border: none;
  border-radius: var(--border-radius-pill);
  color: var(--text-primary);
  font-size: var(--text-md);
  font-weight: 800;
  padding: var(--space-sm) var(--space-md);
  background: var(--gradient-warm);
  touch-action: manipulation;
  opacity: 0;
  animation: slide-up-in 300ms var(--ease-out-expo) forwards;
}

.story-choice-btn:nth-child(2) {
  animation-delay: 80ms;
}
.story-choice-btn:nth-child(3) {
  animation-delay: 160ms;
}

/* Tablet scale-up */
@media (min-width: 600px) {
  .story-portrait {
    width: 96px;
    height: 96px;
    min-width: 96px;
  }

  .story-bubble-text,
  .story-narration-text {
    font-size: var(--text-lg);
  }
}

/* ============================================
   Pause Menu Overlay
   ============================================ */

.pause-panel {
  background: var(--bg-secondary);
  border-radius: var(--border-radius-lg);
  max-width: 300px;
  width: calc(100% - 48px);
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  border: 2px solid var(--gold-35);
  box-shadow:
    0 8px 32px var(--black-40),
    0 0 20px var(--gold-10);
}

.pause-title {
  font-size: var(--text-2xl);
  font-weight: 800;
  line-height: 1.05;
  color: var(--text-primary);
  letter-spacing: var(--tracking-wide);
  text-shadow:
    0 0 20px var(--white-30),
    0 2px 4px var(--black-30);
}

.pause-keep-btn {
  width: 100%;
  height: 60px;
  background: var(--color-success);
  border: none;
  border-radius: var(--border-radius-pill);
  color: var(--text-primary);
  font-size: var(--text-lg);
  font-weight: 800;
  touch-action: manipulation;
  box-shadow:
    0 0 16px rgba(76, 175, 80, 0.35),
    0 4px 12px var(--black-25);
  letter-spacing: var(--tracking-normal);
}

.pause-back-btn {
  width: 100%;
  height: 48px;
  background: var(--color-muted);
  border: none;
  border-radius: var(--border-radius-pill);
  color: var(--text-primary);
  font-size: var(--text-md);
  font-weight: 700;
  touch-action: manipulation;
}

/* ============================================
   Puzzle Pause Button
   ============================================ */

.puzzle-pause-btn {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  width: 44px;
  height: 44px;
  background: var(--white-15);
  border: 1px solid var(--white-25);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  font-size: 20px;
  z-index: var(--z-nav);
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  transition: background var(--duration-fast) var(--ease-out-quart);
}

/* ============================================
   WARDROBE SCREEN
   ============================================ */

.wardrobe-layout {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  height: 100%;
  padding: var(--space-sm) var(--space-md);
  box-sizing: border-box;
}

.wardrobe-preview-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.wardrobe-preview-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
}

.wardrobe-cycle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--border-radius-circle);
  background: var(--bg-panel);
  border: 2px solid var(--white-20);
  color: var(--text-primary);
  font-size: 24px;
  font-weight: 800;
  flex-shrink: 0;
  touch-action: manipulation;
  transition:
    transform var(--duration-instant) var(--ease-out-quart),
    background var(--duration-fast) var(--ease-out-quart);
}

.wardrobe-preview-circle {
  width: 120px;
  height: 120px;
  aspect-ratio: 1;
  border-radius: var(--border-radius-circle);
  background: var(--wardrobe-char-color, var(--color-avery));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.8rem;
  box-shadow:
    0 0 24px var(--wardrobe-char-color, var(--gold-45)),
    0 0 48px var(--black-15),
    0 6px 16px var(--black-35);
  font-weight: 800;
  color: var(--text-primary);
  border: 3px solid var(--white-40);
  transition: background var(--duration-normal) var(--ease-out-quart);
}

.wardrobe-preview-name {
  font-size: var(--text-md);
  font-weight: 800;
  color: var(--text-primary);
}

.wardrobe-cat-tabs {
  display: flex;
  gap: var(--space-xs);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}

.wardrobe-cat-tabs::-webkit-scrollbar {
  display: none;
}

.wardrobe-cat-tab {
  flex-shrink: 0;
  padding: var(--space-xs) var(--space-sm);
  border: 2px solid transparent;
  border-radius: var(--border-radius-pill);
  background: var(--bg-panel);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 700;
  touch-action: manipulation;
  transition:
    color var(--duration-fast) var(--ease-out-quart),
    border-color var(--duration-fast) var(--ease-out-quart),
    transform var(--duration-instant) var(--ease-out-quart);
}

.wardrobe-cat-tab.active {
  color: var(--text-gold);
  border-color: var(--text-gold);
  background: var(--gold-10);
}

.wardrobe-item-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  overflow-y: auto;
  flex: 1;
  contain: content;
}

.wardrobe-item-cell {
  aspect-ratio: 1;
  background: var(--bg-panel);
  border-radius: var(--border-radius-sm);
  border: 2px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
  gap: var(--space-xs);
  position: relative;
  padding: var(--space-xs);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  font-weight: 700;
  text-align: center;
  touch-action: manipulation;
}

.wardrobe-item-cell.equipped {
  border-color: var(--text-gold);
  color: var(--text-gold);
}

.wardrobe-item-cell.locked {
  opacity: 0.4;
}

.wardrobe-item-cell .lock-icon {
  font-size: 1.4rem;
  position: relative;
  z-index: var(--z-content);
}

.wardrobe-item-img {
  width: 100%;
  height: 75%;
  object-fit: contain;
  pointer-events: none;
}

.wardrobe-item-img.locked-img {
  position: absolute;
  inset: 4px;
  width: calc(100% - 8px);
  height: calc(100% - 8px);
  opacity: 0.15;
  filter: grayscale(1);
}

.wardrobe-item-name {
  word-break: break-word;
  hyphens: auto;
  line-height: 1.2;
}

.wardrobe-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  text-align: center;
  color: var(--text-secondary);
  font-size: var(--text-lg);
  font-weight: 700;
  padding: var(--space-2xl) var(--space-lg);
}

.wardrobe-empty-icon {
  font-size: 4rem;
  animation:
    bounce-subtle 600ms ease-in-out infinite,
    sparkle-pulse 2s ease-in-out infinite;
  filter: drop-shadow(0 0 12px var(--gold-40));
}

@media (min-width: 600px) {
  .wardrobe-item-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .wardrobe-preview-circle {
    width: 140px;
    height: 140px;
  }
}

/* ==========================================================================
   Collection Screen
   ========================================================================== */

.collection-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: var(--space-sm) var(--space-md);
  box-sizing: border-box;
}

.collection-tabs {
  display: flex;
  gap: var(--space-xs);
  flex-shrink: 0;
}

.coll-tab {
  flex: 1;
  padding: var(--space-sm) var(--space-xs);
  border: 2px solid transparent;
  border-radius: var(--border-radius-pill);
  background: var(--bg-panel);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 800;
  min-height: 44px;
  transition:
    color var(--duration-fast) var(--ease-out-quart),
    border-color var(--duration-fast) var(--ease-out-quart),
    transform var(--duration-instant) var(--ease-out-quart);
}

.coll-tab.active {
  color: var(--text-gold);
  border: 2px solid var(--text-gold);
  background: var(--gold-10);
}

.collection-counter {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-align: right;
  padding: var(--space-xs) 0;
  flex-shrink: 0;
}

.coll-panel {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  contain: content;
  content-visibility: auto;
  contain-intrinsic-size: auto 400px;
}

.coll-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  color: var(--text-secondary);
  font-size: var(--text-lg);
  font-weight: 700;
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  line-height: 1.4;
}

.coll-empty-icon {
  font-size: 4rem;
  animation:
    bounce-subtle 600ms ease-in-out infinite,
    sparkle-pulse 2s ease-in-out infinite;
  filter: drop-shadow(0 0 12px var(--gold-40));
}

/* --------------------------------------------------------------------------
   Sticker grid
   -------------------------------------------------------------------------- */

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  padding: var(--space-xs);
  contain: content;
}

.sticker-cell {
  aspect-ratio: 1;
  background: var(--bg-panel);
  border-radius: var(--border-radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  min-width: 0;
  font-weight: 700;
  color: var(--text-secondary);
  text-align: center;
  padding: var(--space-xs);
  position: relative;
  overflow: hidden;
}

.sticker-cell.earned {
  color: var(--text-primary);
  border: 1px solid var(--gold-30);
  background: linear-gradient(135deg, var(--gold-10), var(--bg-panel));
  animation: glow-pulse 3s ease-in-out infinite;
}

.sticker-cell.locked {
  opacity: 0.35;
}

.sticker-img {
  width: 80%;
  aspect-ratio: 1;
  object-fit: contain;
  pointer-events: none;
}

.sticker-emoji {
  font-size: 1.6rem;
  line-height: 1;
}

.sticker-name {
  font-size: var(--text-xs);
  margin-top: var(--space-xs);
  line-height: 1.2;
  word-break: break-word;
}

.sticker-silhouette {
  position: absolute;
  font-size: 2.4rem;
  opacity: 0.12;
  pointer-events: none;
}

.sticker-q {
  position: relative;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--white-50);
}

/* --------------------------------------------------------------------------
   Card grid
   -------------------------------------------------------------------------- */

.cards-section-label {
  font-size: var(--text-sm);
  font-weight: 800;
  padding: var(--space-sm) var(--space-xs) var(--space-xs);
}

.cards-row {
  display: flex;
  gap: var(--space-sm);
  padding: 0 var(--space-xs) var(--space-sm);
  flex-wrap: wrap;
}

.card-cell {
  width: 72px;
  height: 96px;
  border-radius: var(--border-radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  text-align: center;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  padding: var(--space-xs);
}

.card-cell.rarity-common {
  background: rgba(184, 176, 204, 0.1);
  border: 2px solid var(--color-silver);
  color: var(--color-silver);
}
.card-cell.rarity-rare {
  background: rgba(255, 215, 0, 0.08);
  border: 2px solid var(--text-gold);
  color: var(--text-gold);
}
.card-cell.rarity-special {
  background: rgba(255, 105, 180, 0.1);
  border: 2px solid var(--color-mira);
  color: var(--text-primary);
}
.card-cell.locked {
  opacity: 0.35;
}
.card-cell:not(.locked) {
  animation: glow-pulse 3s ease-in-out infinite;
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--border-radius-xs);
  pointer-events: none;
}

.card-back-bg {
  position: absolute;
  inset: 0;
  background: var(--color-card-back);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

/* --------------------------------------------------------------------------
   Song list (Jukebox)
   -------------------------------------------------------------------------- */

.song-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-xs);
  border-radius: var(--border-radius-sm);
  min-height: 72px;
  background: var(--bg-panel);
  margin-bottom: var(--space-xs);
}

.song-row.locked {
  opacity: 0.5;
}

.song-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}

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

.song-title {
  font-size: var(--text-md);
  font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-sub {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: 2px;
}

.song-row.playing .song-sub {
  color: var(--text-gold);
}

/* --------------------------------------------------------------------------
   Story Album list
   -------------------------------------------------------------------------- */

.story-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-xs);
  border-radius: var(--border-radius-sm);
  min-height: 80px;
  background: var(--bg-panel);
  margin-bottom: var(--space-xs);
}

.story-row.locked {
  opacity: 0.5;
}

.story-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}

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

.story-title {
  font-size: var(--text-md);
  font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.story-sub {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: 2px;
}

.story-row.viewed .story-sub {
  color: var(--color-success);
}

/* --------------------------------------------------------------------------
   Collection modal panel
   -------------------------------------------------------------------------- */

#coll-modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--black-75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-max);
  padding: var(--space-lg);
  box-sizing: border-box;
}

.coll-modal-panel {
  background: var(--bg-secondary);
  border-radius: var(--border-radius-lg);
  padding: var(--space-lg);
  max-width: 320px;
  width: 100%;
  box-shadow: var(--shadow-soft);
}

.coll-modal-panel .card-modal-img {
  width: 200px;
  height: 280px;
  object-fit: contain;
  border-radius: var(--border-radius-md);
}

.coll-modal-panel .card-modal-icon {
  font-size: 2.5rem;
}

.coll-modal-panel .card-modal-name {
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--text-primary);
  margin: var(--space-sm) 0;
}

.coll-modal-panel .card-modal-meta {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-transform: capitalize;
}

.coll-modal-panel .card-modal-hint {
  font-size: var(--text-xs);
  color: var(--text-gold);
  margin-top: var(--space-md);
}

/* Card fallback text (when image fails to load or no image) */
.card-cell .card-fallback-icon {
  font-size: 1.1rem;
}

.card-cell .card-fallback-name {
  font-size: var(--text-xs);
  margin-top: var(--space-xs);
  line-height: 1.2;
  word-break: break-word;
}

.card-cell.locked .card-locked-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--white-60);
}

/* --------------------------------------------------------------------------
   Puzzle sparkle particles
   -------------------------------------------------------------------------- */

.puzzle-sparkle-particle {
  position: absolute;
  border-radius: var(--border-radius-circle);
  pointer-events: none;
  z-index: var(--z-sticky);
}

.puzzle-sparkle-particle.bonus {
  z-index: 16;
}

/* --------------------------------------------------------------------------
   Medley sub-puzzle area
   -------------------------------------------------------------------------- */

.medley-sub-area {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  flex: 1;
  align-items: center;
  justify-content: center;
  width: 100%;
}

/* --------------------------------------------------------------------------
   Tablet adjustments
   -------------------------------------------------------------------------- */

@media (min-width: 600px) {
  .sticker-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .coll-tab {
    font-size: var(--text-md);
  }

  .map-grid {
    min-height: 480px;
  }
}

/* --------------------------------------------------------------------------
   Narrow screen fixes (iPhone SE / 320px)
   -------------------------------------------------------------------------- */

@media (max-width: 374px) {
  /* Collection tabs: shrink text to fit all 4 */
  .coll-tab {
    font-size: var(--text-xs);
    padding: 6px 2px;
  }

  /* Pattern match buttons: smaller to fit 3-4 in a row */
  .pm-btn {
    min-width: 68px;
    padding: 0 var(--space-sm);
    font-size: var(--text-xs);
  }

  .pm-star {
    width: 56px;
    height: 56px;
    font-size: 24px;
  }

  .pm-display {
    gap: var(--space-sm);
  }

  .pm-buttons {
    gap: var(--space-sm);
  }

  /* Wardrobe: reduce preview circle on narrow screens */
  .wardrobe-preview-circle {
    width: 90px;
    height: 90px;
    font-size: 2rem;
  }

  /* Collection modal: tighter padding on tiny screens */
  #coll-modal-backdrop {
    padding: var(--space-sm);
  }

  .coll-modal-panel {
    padding: var(--space-md);
  }

  /* Map grid: reduce min-height */
  .map-grid {
    min-height: 340px;
  }

  /* HQ content: reduce gaps */
  .hq-content {
    gap: var(--space-lg);
    padding: var(--space-lg) var(--space-sm);
  }

  /* Victory title: prevent overflow */
  .victory-title {
    font-size: var(--text-2xl);
    letter-spacing: var(--tracking-wide);
  }

  /* Reward/victory buttons: fit narrow modals */
  .victory-rewards-btn,
  .reward-awesome-btn {
    min-width: 200px;
  }

  /* Collection card modal: smaller image */
  .coll-modal-panel .card-modal-img {
    width: 160px;
    height: 220px;
  }

  /* HQ portrait: reduce for narrow screens */
  .hq-portrait {
    width: 120px;
    height: 120px;
  }

  .hq-portrait-initials {
    font-size: 40px;
  }

  /* Story portrait: slightly smaller */
  .story-portrait {
    width: 72px;
    height: 72px;
    min-width: 72px;
  }
}

/* --------------------------------------------------------------------------
   Tablet landscape / Chromebook (900px+)
   -------------------------------------------------------------------------- */

@media (min-width: 900px) {
  /* Grids: more columns for wider screens */
  .sticker-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  .wardrobe-item-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  /* Container max-widths: use more horizontal space */
  .hq-daily-banner,
  .hq-character-display {
    max-width: 560px;
  }

  .hq-map-teaser {
    max-width: 560px;
  }

  .di-dialogue-area {
    max-width: 560px;
  }

  .di-actions {
    max-width: 480px;
  }

  .victory-defeat-dialogue {
    max-width: 400px;
  }

  /* Weapon gallery: larger cards, side-by-side potential */
  .wg-card {
    flex: 0 0 120px;
    width: 120px;
    height: 160px;
  }

  .wg-detail-sprite {
    width: 120px;
    height: 120px;
  }

  .wg-detail-xp-container {
    max-width: 340px;
  }

  /* Demon intro: bigger demon sprite */
  .di-demon-sprite {
    width: 260px;
    height: 260px;
    font-size: 80px;
  }

  /* HQ portrait: larger */
  .hq-portrait {
    width: 200px;
    height: 200px;
  }

  .hq-portrait-initials {
    font-size: 64px;
  }

  /* Map grid: more room */
  .map-grid {
    min-height: 520px;
  }

  .map-demon {
    width: 76px;
    height: 76px;
    font-size: var(--text-xl);
  }

  /* Victory circles: larger */
  .victory-circle {
    width: 150px;
    height: 150px;
  }

  /* Reward panel: wider */
  .reward-panel {
    max-width: 480px;
  }

  /* Settings panel: wider */
  .settings-panel {
    max-width: 420px;
  }

  /* Puzzle stars: bigger on wide screens */
  .pm-star {
    width: 104px;
    height: 104px;
    font-size: 44px;
  }

  .pm-btn {
    min-width: 120px;
    height: 92px;
  }

  /* Hidden items scene: taller */
  .hi-scene {
    max-height: 560px;
  }

  /* Memory game cards: larger */
  .mg-card {
    width: 96px;
    height: 128px;
  }

  .mg-card-initial {
    font-size: 36px;
  }

  /* Story portraits: larger */
  .story-portrait {
    width: 110px;
    height: 110px;
    min-width: 110px;
  }

  /* Wardrobe preview: larger */
  .wardrobe-preview-circle {
    width: 160px;
    height: 160px;
    font-size: 3rem;
  }

  /* Card cells: slightly bigger */
  .card-cell {
    width: 84px;
    height: 112px;
  }

  /* Collection modal: use more space */
  .coll-modal-panel {
    max-width: 380px;
  }

  .coll-modal-panel .card-modal-img {
    width: 240px;
    height: 320px;
  }
}

/* --------------------------------------------------------------------------
   Landscape orientation — short viewports
   -------------------------------------------------------------------------- */

@media (orientation: landscape) and (max-height: 500px) {
  /* Reduce vertical padding for short landscape viewports */
  .hq-content {
    gap: var(--space-md);
    padding: var(--space-md) var(--space-md);
  }

  .hq-portrait {
    width: 100px;
    height: 100px;
  }

  .hq-portrait-initials {
    font-size: 36px;
  }

  /* Compact character display in HQ */
  .hq-character-display {
    flex-direction: row;
    gap: var(--space-md);
  }

  /* Victory: compact layout */
  .victory-circle {
    width: 80px;
    height: 80px;
  }

  .victory-title {
    font-size: var(--text-xl);
  }

  /* Puzzle: tighter vertical spacing */
  .puzzle-demon-area {
    padding: var(--space-xs) var(--space-md);
    min-height: auto;
  }

  .puzzle-demon-circle {
    width: 48px;
    height: 48px;
  }

  .pm-star {
    width: 56px;
    height: 56px;
    font-size: 24px;
  }

  .pm-btn {
    height: 60px;
    min-width: 80px;
  }

  /* Hidden items: shorter */
  .hi-scene {
    max-height: 280px;
  }

  /* Demon intro: compact */
  .di-container {
    padding: var(--space-md);
    gap: var(--space-sm);
  }

  .di-demon-sprite {
    width: 120px;
    height: 120px;
    font-size: 40px;
  }

  /* Intro slides: shorter illustrations */
  .intro-illustration {
    max-height: 40vh;
  }

  /* Story overlay: more compact */
  .story-content {
    bottom: 40px;
  }

  .story-portrait {
    width: 56px;
    height: 56px;
    min-width: 56px;
    font-size: var(--text-md);
  }

  /* Splash: compact */
  .splash-title {
    font-size: var(--text-xl);
  }

  .splash-tap {
    margin-top: var(--space-md);
  }

  /* Reward panel: shorter */
  .reward-panel {
    max-height: 90vh;
  }

  /* Wardrobe: compact preview */
  .wardrobe-preview-circle {
    width: 80px;
    height: 80px;
    font-size: 1.8rem;
  }
}
