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

:root {
  /* Display font — decorative headings & poster words only */
  --font-display: 'Fraunces', Georgia, serif;
  /* UI font — everything a child needs to READ */
  --font-ui:      'DM Sans', system-ui, sans-serif;
  /* Body font — atmospheric italic text (endings, meta) */
  --font-body:    'Lora', Georgia, serif;

  --accent:    #e8507a;
  --bg:        #0e0818;
  --bg-left:   #130a20;
  --text:      rgba(255,255,255,0.88);
  --text-dim:  rgba(255,255,255,0.42);
  --rule:      rgba(255,255,255,0.08);
  --btn:       #e8507a;
  --btn-hover: #c93d64;
  --dot:       #e8507a;
}

[data-theme="kpop"]       { --accent:#ff5a8a; --bg:#0e0818; --bg-left:#160a26; --btn:#ff5a8a; --btn-hover:#d03a68; --dot:#ff5a8a; }
[data-theme="gaming"]     { --accent:#00d8f0; --bg:#040812; --bg-left:#060c20; --btn:#00a8bc; --btn-hover:#008090; --dot:#00d8f0; }
[data-theme="football"]   { --accent:#d4a010; --bg:#060c06; --bg-left:#091409; --btn:#2a8840; --btn-hover:#1e6630; --dot:#d4a010; }
[data-theme="ronaldo"]    { --accent:#f5c518; --bg:#080600; --bg-left:#110e00; --btn:#c89e00; --btn-hover:#a07e00; --dot:#f5c518; }
[data-theme="brawlstars"] { --accent:#ff6b35; --bg:#0d0a1a; --bg-left:#150d28; --btn:#e05528; --btn-hover:#bc4420; --dot:#ff6b35; }
[data-theme="anime"]      { --accent:#ff80c0; --bg:#0a0012; --bg-left:#12001e; --btn:#e060a8; --btn-hover:#c04890; --dot:#ff80c0; }
[data-theme="jjk"]        { --accent:#9b5de5; --bg:#050508; --bg-left:#0a0810; --btn:#7b3dc5; --btn-hover:#6030a8; --dot:#9b5de5; }
[data-theme="geography"]  { --accent:#1e90ff; --bg:#030d18; --bg-left:#051525; --btn:#1670cc; --btn-hover:#1058a8; --dot:#1e90ff; }

html {
  scroll-behavior: smooth;
  /* Prevent horizontal overflow on iOS Safari (overflow-x: hidden alone leaks on html) */
  overflow-x: hidden;
  max-width: 100%;
}

body {
  font-family: var(--font-ui);
  background: var(--bg);
  min-height: 100vh;
  color: var(--text);
  transition: background 0.5s ease;
  overflow-x: hidden;
  max-width: 100%;
  /* iOS-safe: never let content push width past viewport */
  width: 100%;
  position: relative;
}

#app { max-width: 100%; overflow-x: hidden; }

/* Subtle grid for gaming theme */
body[data-theme="gaming"] {
  background-image:
    repeating-linear-gradient(0deg,  transparent, transparent 40px, rgba(0,200,240,0.02) 40px, rgba(0,200,240,0.02) 41px),
    repeating-linear-gradient(90deg, transparent, transparent 40px, rgba(0,200,240,0.02) 40px, rgba(0,200,240,0.02) 41px);
}

/* Pitch stripes for football */
body[data-theme="football"]::before {
  content: '';
  position: fixed; inset: 0;
  background-image: repeating-linear-gradient(
    0deg, transparent, transparent 100px,
    rgba(255,255,255,0.022) 100px, rgba(255,255,255,0.022) 102px
  );
  pointer-events: none; z-index: 0;
}

#app { position: relative; z-index: 1; min-height: 100vh; }

/* ── Background decorations ─────────────────── */
.bg-deco { position: fixed; pointer-events: none; z-index: 0; user-select: none; }

.star-deco { line-height: 1; animation: twinkle ease-in-out infinite; }
@keyframes twinkle {
  0%,100% { transform: scale(1) rotate(0deg);   opacity: 0.2; }
  50%      { transform: scale(1.5) rotate(15deg); opacity: 0.7; }
}

.pixel-deco { border-radius: 2px; animation: pixelfloat ease-in-out infinite; }
@keyframes pixelfloat {
  0%,100% { transform: translateY(0)    rotate(0deg);  opacity: 0.2; }
  50%      { transform: translateY(-18px) rotate(45deg); opacity: 0.5; }
}

/* ============================================
   HOME SCREEN — base (overridden by image-assets section below)
   ============================================ */
.home-screen {
  position: relative;
  z-index: 1;
}

/* ── Background orbs ─────────────────────────── */
.home-orbs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.18;
  animation: orb-drift 14s ease-in-out infinite alternate;
}
.orb-1 {
  width: 480px; height: 480px;
  background: radial-gradient(circle, #7040ff, transparent 70%);
  top: -120px; left: -100px;
  animation-duration: 16s;
}
.orb-2 {
  width: 360px; height: 360px;
  background: radial-gradient(circle, #ff3090, transparent 70%);
  top: 30%; right: -80px;
  animation-duration: 11s;
  animation-delay: -4s;
}
.orb-3 {
  width: 320px; height: 320px;
  background: radial-gradient(circle, #0090ff, transparent 70%);
  bottom: -80px; left: 35%;
  animation-duration: 13s;
  animation-delay: -8s;
}
@keyframes orb-drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(40px, 30px) scale(1.12); }
}

/* ── BETA badge ───────────────────────────────── */
.beta-badge {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 0.65rem;
  font-weight: 800;
  font-style: normal;
  letter-spacing: 0.12em;
  color: var(--bg);
  background: linear-gradient(120deg, #FFD700, #FF80AA);
  border-radius: 4px;
  padding: 3px 7px;
  vertical-align: middle;
  margin-left: 12px;
  transform: translateY(-6px);
  box-shadow: 0 2px 12px rgba(255,180,100,0.4);
  animation: badge-pulse 3s ease-in-out infinite;
}
@keyframes badge-pulse {
  0%,100% { box-shadow: 0 2px 12px rgba(255,180,100,0.4); }
  50%      { box-shadow: 0 2px 20px rgba(255,180,100,0.7); }
}

/* ── Hero ────────────────────────────────────── */
.home-hero {
  padding: 52px 60px 44px;
  width: 100%;
  max-width: 1400px;
  border-bottom: 1px solid var(--rule);
}

.home-eyebrow {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-dim);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 16px;
  display: block;
}

.home-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 900;
  line-height: 0.88;
  letter-spacing: -0.04em;
}

.home-title .line1 {
  display: block;
  font-size: clamp(3.6rem, 8vw, 7rem);
  background: linear-gradient(120deg, #FFD700, #FF80AA 55%, #C070FF);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.home-title .line2 {
  display: block;
  font-size: clamp(2.6rem, 5.5vw, 5rem);
  color: #fff;
  font-style: normal;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.home-sub {
  font-family: var(--font-ui);
  font-size: 0.88rem;
  font-weight: 400;
  color: var(--text-dim);
  margin-top: 18px;
  display: block;
}

/* ── Theme grid (4 × 2) ─────────────────────── */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: 100%;
  max-width: 1400px;
  flex: 1;
}

.theme-bar {
  padding: 36px 32px;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  transition: background 0.2s ease;
  background: none;
  border-top: none;
  border-left: none;
  text-align: left;
  color: inherit;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  min-height: 200px;
}
/* Remove right border from every 4th card */
.theme-bar:nth-child(4n) { border-right: none; }
.theme-bar:hover  { background: rgba(255,255,255,0.028); }
.theme-bar:focus  { outline: 2px solid var(--accent); outline-offset: -2px; }

.theme-bar-icon {
  font-size: 2.2rem;
  display: block;
  margin-bottom: 18px;
  line-height: 1;
}

.theme-bar-name {
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: clamp(1.05rem, 1.6vw, 1.45rem);
  letter-spacing: -0.01em;
  line-height: 1.15;
  margin-bottom: 8px;
  display: block;
  overflow-wrap: break-word;
}

.theme-bar.kpop        .theme-bar-name { color: #ff5a8a; }
.theme-bar.gaming      .theme-bar-name { color: #00d8f0; }
.theme-bar.football    .theme-bar-name { color: #d4a010; }
.theme-bar.ronaldo     .theme-bar-name { color: #f5c518; }
.theme-bar.brawlstars  .theme-bar-name { color: #ff6b35; }
.theme-bar.anime       .theme-bar-name { color: #ff80c0; }
.theme-bar.jjk         .theme-bar-name { color: #9b5de5; }
.theme-bar.geography   .theme-bar-name { color: #1e90ff; }

.theme-bar-tagline {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-dim);
  line-height: 1.5;
  flex: 1;
  margin-bottom: 20px;
}

.theme-bar-progress {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.theme-bar-progress.done { color: var(--accent); }

/* Ghost number */
.theme-bar::after {
  content: attr(data-n);
  font-family: var(--font-display);
  font-weight: 900;
  font-style: italic;
  font-size: 12rem;
  line-height: 1;
  color: rgba(255,255,255,0.018);
  position: absolute;
  bottom: -24px;
  right: -12px;
  pointer-events: none;
  transition: color 0.3s;
}
.theme-bar:hover::after { color: rgba(255,255,255,0.036); }

/* ============================================
   CHAPTER SCREEN — Full-viewport split layout
   ============================================ */

/* Centered single-panel chapter — split into story + math phases */
.chapter-screen {
  height: 100vh;
  display: grid;
  grid-template-rows: 56px 1fr;
  position: relative;
  overflow: hidden;
  z-index: 1;
}

.ch-stage {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 24px;
  overflow-y: auto;
}

.ch-panel {
  position: relative;
  width: 100%;
  max-width: 720px;
  padding: 36px 44px 32px;
  background: linear-gradient(180deg, rgba(8,4,18,0.78) 0%, rgba(8,4,18,0.65) 100%);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 20px;
  box-shadow:
    0 24px 60px rgba(0,0,0,0.55),
    inset 0 1px 0 rgba(255,255,255,0.06);
  animation: ch-panel-in 0.45s cubic-bezier(0.18, 0.89, 0.32, 1.18);
}
@keyframes ch-panel-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

.ch-phase-tag {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  padding: 4px 12px;
  margin-bottom: 14px;
}
.ch-phase-tag.math { color: #ffd060; }

.ch-continue-btn {
  margin-top: 28px;
  width: 100%;
  padding: 16px 32px;
  background: var(--btn);
  color: #fff;
  border: none;
  border-radius: 50px;
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 6px 28px rgba(0,0,0,0.40);
}
.ch-continue-btn:hover {
  background: var(--btn-hover);
  transform: translateY(-2px);
  box-shadow: 0 10px 40px rgba(0,0,0,0.50);
}
.ch-continue-btn:active { transform: translateY(0); }

.back-to-story-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.55);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0;
  margin-bottom: 14px;
  letter-spacing: 0.04em;
  transition: color 0.18s;
  align-self: flex-start;
}
.back-to-story-btn:hover { color: #fff; }

/* ── Topbar — part of the grid, NOT fixed ───── */
.chapter-topbar {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--rule);
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  position: relative;
  z-index: 50;
  gap: 16px;
}

.back-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-dim);
  border-radius: 50px;
  padding: 6px 16px;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.back-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* Center meta label in topbar */
.ch-meta {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-align: center;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-dots {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-shrink: 0;
}
.dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  transition: all 0.3s;
  flex-shrink: 0;
}
.dot.completed { background: var(--dot); }
.dot.current   { background: transparent; border: 2px solid var(--dot); transform: scale(1.45); }

/* ── Giant poster words (fixed backdrop) ─────── */
.ch-poster {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
  z-index: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.ch-poster-word {
  display: block;
  font-family: var(--font-display);
  font-weight: 900;
  font-style: italic;
  font-size: 22vw;
  line-height: 0.82;
  letter-spacing: -0.04em;
  color: var(--accent);
  opacity: 0.055;
  white-space: nowrap;
}
.ch-poster-word:nth-child(odd)  { margin-left: -0.04em; }
.ch-poster-word:nth-child(even) { text-align: right; margin-right: -0.04em; }

/* ── Left panel — story ─────────────────────── */
.ch-left {
  grid-column: 1;
  grid-row: 2;
  padding: 44px 52px 40px;
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow-y: auto;
}

/* ── Right panel — question & answer ────────── */
.ch-right {
  grid-column: 2;
  grid-row: 2;
  padding: 44px 52px 40px;
  position: relative;
  z-index: 2;
  border-left: 1px solid var(--rule);
  background: rgba(0,0,0,0.22);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow-y: auto;
}

/* ── Chapter title ───────────────────────────── */
.ch-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 900;
  font-size: clamp(2.2rem, 4.5vw, 4rem);
  line-height: 0.9;
  color: var(--accent);
  letter-spacing: -0.03em;
  margin-bottom: 24px;
  overflow-wrap: break-word;
}

/* ── Story text ──────────────────────────────── */
.story-text {
  font-family: var(--font-ui);
  font-size: clamp(0.88rem, 1.1vw, 1rem);
  font-weight: 400;
  line-height: 1.75;
  color: rgba(255,255,255,0.72);
}
.story-text p + p { margin-top: 1em; }

/* ── Question ────────────────────────────────── */
.question-text {
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: clamp(1.25rem, 2vw, 1.6rem);
  line-height: 1.35;
  color: #fff;
  margin-bottom: 20px;
  letter-spacing: -0.01em;
}

/* ── Math tip ────────────────────────────────── */
.math-note {
  border-left: 2px solid var(--accent);
  padding: 0 0 0 16px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.math-note-label {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}
.math-note-body {
  font-family: var(--font-ui);
  font-size: 0.84rem;
  font-weight: 400;
  color: rgba(255,255,255,0.5);
  line-height: 1.5;
}

/* ============================================
   ANSWER FORM
   ============================================ */
.answer-form {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 12px;
}

.answer-input {
  flex: 1;
  font-family: var(--font-ui);
  font-size: 1.3rem;
  font-weight: 700;
  padding: 13px 20px;
  background: rgba(255,255,255,0.06);
  border: 2px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  color: #fff;
  outline: none;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  caret-color: var(--accent);
  min-height: 52px;
}
.answer-input::placeholder {
  color: rgba(255,255,255,0.22);
  font-weight: 400;
}
.answer-input:focus {
  border-color: var(--accent);
  background: rgba(255,255,255,0.09);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent);
}
.answer-input.correct {
  border-color: #50e888;
  background: rgba(80,232,136,0.08);
}
.answer-input.wrong {
  border-color: #e85050;
  animation: shake 0.32s ease;
}
@keyframes shake {
  0%,100% { transform: translateX(0);   }
  20%      { transform: translateX(-7px); }
  40%      { transform: translateX(7px);  }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px);  }
}

.submit-btn {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 13px 22px;
  background: var(--btn);
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 52px;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.submit-btn:hover  { background: var(--btn-hover); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(0,0,0,0.3); }
.submit-btn:active { transform: translateY(0); }
.submit-btn:disabled { opacity: 0.35; cursor: default; transform: none; box-shadow: none; }

/* ============================================
   FEEDBACK
   ============================================ */
.feedback {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.5;
  border-radius: 8px;
  transition: all 0.2s;
  min-height: 0;
}
.feedback.success {
  color: #70f0a0;
  padding: 8px 0;
  animation: pop-in 0.3s cubic-bezier(0.175,0.885,0.32,1.275);
}
.feedback.error {
  color: rgba(255,255,255,0.45);
  padding: 8px 0;
}
@keyframes pop-in {
  from { transform: scale(0.88); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

/* ============================================
   HINT SECTION
   ============================================ */
.hint-section {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, opacity 0.3s ease;
  opacity: 0;
}
.hint-section.open { max-height: 260px; opacity: 1; }

.hint-box {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 10px;
  padding: 14px 18px;
  margin: 10px 0 0;
}
.hint-title {
  font-family: var(--font-ui);
  font-weight: 700;
  color: rgba(255,230,120,0.85);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.hint-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 400;
  color: rgba(255,255,255,0.55);
  line-height: 1.5;
}
.hint-num {
  background: rgba(255,230,120,0.14);
  color: rgba(255,230,120,0.9);
  width: 20px; height: 20px;
  border-radius: 50%;
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

/* ============================================
   ACTION BUTTONS
   ============================================ */
.card-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
  align-items: center;
}

.hint-btn {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 8px 16px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.2s;
}
.hint-btn:hover { border-color: rgba(255,230,120,0.35); color: rgba(255,230,120,0.8); }

.next-btn {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 10px 26px;
  background: var(--btn);
  color: #fff;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.25s;
  display: none;
  box-shadow: 0 4px 20px rgba(0,0,0,0.28);
  letter-spacing: 0.01em;
}
.next-btn.visible {
  display: block;
  animation: bounce-in 0.36s cubic-bezier(0.175,0.885,0.32,1.275);
}
.next-btn:hover { background: var(--btn-hover); transform: translateY(-2px); box-shadow: 0 6px 24px rgba(0,0,0,0.36); }

@keyframes bounce-in {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* ============================================
   COMPLETE SCREEN
   ============================================ */
.complete-screen {
  min-height: 100vh;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 42% 1fr;
  grid-template-rows: 1fr auto;
  position: relative;
  z-index: 1;
}

.complete-left {
  background: var(--bg-left);
  border-right: 1px solid var(--rule);
  padding: 80px 52px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.complete-left::before {
  content: '★';
  font-size: min(50vw, 60vh);
  color: rgba(255,255,255,0.02);
  position: absolute; bottom: -60px; left: -30px;
  font-family: var(--font-display);
  pointer-events: none;
}

.complete-trophy {
  font-size: 4rem;
  display: block;
  margin-bottom: 24px;
  animation: trophy-in 0.5s cubic-bezier(0.175,0.885,0.32,1.275) 0.3s both;
  position: relative; z-index: 1;
}
@keyframes trophy-in {
  from { transform: scale(0) rotate(-20deg); opacity: 0; }
  to   { transform: scale(1) rotate(0);      opacity: 1; }
}

.complete-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 900;
  font-size: clamp(2.4rem, 5vw, 5.5rem);
  line-height: 0.92;
  color: var(--accent);
  letter-spacing: -0.03em;
  position: relative; z-index: 1;
}

.complete-right {
  padding: 80px 60px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.complete-story {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 1.05rem;
  line-height: 1.85;
  color: var(--text);
  margin-bottom: 44px;
}
.complete-story p + p { margin-top: 1em; }

.home-btn {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 13px 32px;
  background: var(--btn);
  color: #fff;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.25s;
  align-self: flex-start;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.home-btn:hover { background: var(--btn-hover); transform: translateY(-2px); }

/* ============================================
   CONFETTI
   ============================================ */
.confetti-piece {
  position: fixed; top: -16px; z-index: 9999; pointer-events: none;
  animation: fall linear forwards;
}
@keyframes fall {
  0%   { transform: translateY(0)     rotate(0deg)   scale(1);   opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translateY(110vh) rotate(700deg) scale(0.5); opacity: 0; }
}

/* ============================================
   CONFIG SCREEN ("Tilpas dit eventyr")
   ============================================ */
.config-screen {
  position: relative;
  height: 100vh;
  overflow: hidden;
  z-index: 1;
  display: grid;
  grid-template-rows: 52px 1fr;
}

/* ── Fullscreen cinematic background ── */
.config-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}
.config-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  filter: saturate(1.2);
  animation: config-bg-pan 20s ease-in-out infinite alternate;
}
/* Slideshow — multiple images stacked, cross-fade between them */
.config-bg-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 1200ms ease-in-out;
  will-change: opacity;
}
.config-bg-slide.active { opacity: 1; }
@keyframes config-bg-pan {
  from { transform: scale(1.04) translate(-1%, 0); }
  to   { transform: scale(1.08) translate( 1%, 0); }
}
.config-bg-grain {
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 180px 180px;
  mix-blend-mode: overlay;
  opacity: 0.16;
  pointer-events: none;
}
.config-bg-sweep {
  position: absolute; inset: -10%;
  background: linear-gradient(115deg, transparent 42%, rgba(255,255,255,0.08) 50%, transparent 58%);
  mix-blend-mode: screen;
  animation: config-sweep 9s ease-in-out infinite;
  pointer-events: none;
}
@keyframes config-sweep {
  0%   { transform: translateX(-60%); opacity: 0; }
  50%  { opacity: 0.8; }
  100% { transform: translateX( 60%); opacity: 0; }
}
.config-bg-overlay {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 100% 80% at 50% 100%, rgba(8,4,18,0.80) 0%, rgba(8,4,18,0.40) 50%, transparent 100%),
    linear-gradient(180deg, rgba(8,4,18,0.70) 0%, rgba(8,4,18,0.15) 40%, rgba(8,4,18,0.50) 100%);
  pointer-events: none;
}
.config-bg-vignette {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 90% 90% at 50% 50%, transparent 45%, rgba(8,4,18,0.55) 90%, rgba(8,4,18,0.85) 100%);
  pointer-events: none;
}

/* ── Top navigation bar ── */
.config-topbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 52px;
  background: rgba(8,4,18,0.68);
  backdrop-filter: blur(16px) saturate(1.1);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  border-bottom: 1px solid rgba(255,255,255,0.10);
  flex-shrink: 0;
}
.config-topbar-title {
  font-family: var(--font-display, inherit);
  font-weight: 900;
  font-style: italic;
  font-size: 1.0rem;
  color: #fff;
  text-shadow: 0 0 22px rgba(255,180,80,0.50);
}

/* ── Centered glass overlay panel ── */
.config-overlay {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 24px 28px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.config-overlay-header {
  text-align: center;
  margin-bottom: 18px;
  max-width: 820px;
  width: 100%;
}
.config-overlay-name {
  font-family: var(--font-display, inherit);
  font-weight: 900;
  font-style: italic;
  font-size: clamp(1.8rem, 4vw, 3rem);
  color: #fff;
  line-height: 1;
  text-shadow: 0 4px 24px rgba(0,0,0,0.90), 0 0 50px rgba(255,180,80,0.30);
  letter-spacing: -0.02em;
}
.config-overlay-sub {
  font-size: 0.80rem;
  color: rgba(255,255,255,0.58);
  margin-top: 6px;
  letter-spacing: 0.05em;
}
.config-overlay .config-section { max-width: 820px; width: 100%; }
.config-overlay .start-btn      { margin-top: 18px; max-width: 820px; width: 100%; }

.config-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 36px;
  padding: 40px 24px 48px;
  position: relative;
  z-index: 2;
  overflow-y: auto;
}

.config-hero {
  text-align: center;
}
.config-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 900;
  font-size: clamp(2.4rem, 5.5vw, 4.5rem);
  line-height: 0.9;
  color: #fff;
  letter-spacing: -0.03em;
}
.config-sub {
  font-family: var(--font-ui);
  font-size: 0.88rem;
  color: var(--text-dim);
  margin-top: 10px;
}

.config-section {
  width: 100%;
  max-width: 800px;
}
.config-label {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.config-label-icon { font-size: 0.85rem; }

/* ── Choice cards (both rows) ─────────────── */
.cfg-choices {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.cfg-choice {
  background: rgba(10,6,22,0.94);
  backdrop-filter: blur(16px) saturate(1.1);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  border: 1.5px solid rgba(255,255,255,0.22);
  border-radius: 14px;
  padding: 18px 20px 20px;
  cursor: pointer;
  text-align: center;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  justify-content: center;
  transition: background 0.18s, border-color 0.18s, box-shadow 0.18s, transform 0.14s;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 26px rgba(0,0,0,0.45);
}
.cfg-choice:hover {
  background: rgba(22,14,42,0.96);
  border-color: rgba(255,255,255,0.40);
  transform: translateY(-1px);
  box-shadow: 0 12px 34px rgba(0,0,0,0.55);
}
.cfg-choice.active {
  background: rgba(22,14,42,0.97);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 10px 34px rgba(0,0,0,0.55);
}
.cfg-choice.active::before {
  content: '✓';
  position: absolute;
  top: 10px; right: 14px;
  font-size: 0.72rem;
  font-weight: 800;
  font-family: var(--font-ui);
  color: var(--accent);
}

.cfg-choice-badge {
  font-size: 0.95rem;
  color: var(--accent);
  letter-spacing: 0.06em;
  display: block;
  text-align: center;
  margin-bottom: 2px;
}
.cfg-choice-name {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 900;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  line-height: 0.95;
  color: #fff;
  letter-spacing: 0.01em;
  text-align: center;
  display: block;
  width: 100%;
}
.cfg-choice-desc {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.45;
  text-align: center;
  display: block;
  width: 100%;
  margin-top: 2px;
}
.cfg-choice-example {
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--accent);
  margin-top: 8px;
  letter-spacing: 0.01em;
  text-align: center;
  display: block;
  width: 100%;
}

/* Story choices: 3 columns, no example row */
.story-choices .cfg-choice { padding: 16px 20px 18px; }

/* ── Start button ─────────────────────────── */
.start-btn {
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 1rem;
  padding: 16px 52px;
  border-radius: 50px;
  border: none;
  cursor: not-allowed;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.3);
  transition: all 0.25s;
  letter-spacing: 0.01em;
}
.start-btn.ready {
  background: var(--btn);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(0,0,0,0.35);
}
.start-btn.ready:hover {
  background: var(--btn-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 36px rgba(0,0,0,0.45);
}
.start-btn.ready:active {
  transform: translateY(0);
}

/* ── Story bonus paragraph (Dyb mode) ──────── */
.story-bonus {
  border-left: 2px solid var(--accent);
  padding-left: 14px;
  color: rgba(255,255,255,0.55) !important;
  font-style: italic;
  margin-top: 4px;
  opacity: 0;
  animation: bonus-in 0.5s 0.2s ease both;
}
@keyframes bonus-in {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ============================================
   RESPONSIVE
   ============================================ */

/* ── Medium screens ─── */
@media (max-width: 1100px) {
  .ch-left  { padding: 36px 36px 32px; }
  .ch-right { padding: 36px 36px 32px; }
  .ch-title { font-size: clamp(2rem, 4vw, 3.2rem); }
}

/* ── Tablet ─── */
@media (max-width: 900px) {
  /* Home grid: 2 columns */
  .theme-grid { grid-template-columns: repeat(2, 1fr); }
  .theme-bar:nth-child(4n) { border-right: 1px solid var(--rule); }
  .theme-bar:nth-child(2n) { border-right: none; }

  /* Config screen: stack choice cards */
  .cfg-choices { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .cfg-choice  { padding: 14px 14px 16px; }
  .cfg-choice-name { font-size: 1.4rem; }
  .config-panel { gap: 24px; padding: 24px 16px 36px; }
}

/* ── Mobile ─── */
@media (max-width: 700px) {
  .chapter-screen {
    height: auto;
    min-height: 100vh;
    grid-template-rows: auto 1fr;
    overflow: auto;
  }
  .ch-stage  { padding: 14px 12px; align-items: flex-start; }
  .ch-panel  { padding: 22px 20px 24px; border-radius: 16px; }

  .ch-meta  { display: none; }
  .ch-title { font-size: clamp(1.6rem, 7vw, 2.4rem); margin-bottom: 14px; }
  .ch-poster-word  { font-size: 30vw; }
  .question-text   { font-size: clamp(1.15rem, 5vw, 1.4rem); }
  .answer-form     { flex-direction: column; }
  .submit-btn      { width: 100%; }
  .card-actions    { flex-direction: column; }
  .next-btn, .hint-btn { width: 100%; text-align: center; justify-content: center; }

  .theme-grid      { grid-template-columns: 1fr; }
  .theme-bar       { border-right: none; min-height: 140px; padding: 28px 24px; }
  .home-hero       { padding: 36px 24px 28px; }
  .home-title .line1 { font-size: clamp(3.2rem, 14vw, 5.5rem); }
  .home-title .line2 { font-size: clamp(2.4rem, 10vw, 4rem); }

  .complete-screen {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .complete-left   { min-height: auto; border-right: none; border-bottom: 1px solid var(--rule); padding: 32px 20px; }
  .complete-right  { padding: 28px 20px 44px; }
  .coll-grid       { grid-template-columns: repeat(5, 1fr); }
}

/* ── Phone (iPhone-sized) — tight topbar + score cluster ─── */
@media (max-width: 520px) {
  .chapter-topbar {
    padding: 0 10px !important;
    gap: 8px;
  }
  .back-btn {
    padding: 5px 10px;
    font-size: 0.72rem;
  }
  .ch-score-cluster {
    gap: 5px;
    flex-wrap: nowrap;
  }
  .ch-score-chip,
  .ch-highscore-chip {
    padding: 3px 7px;
    font-size: 0.66rem;
  }
  .progress-dots {
    gap: 3px;
  }
  .dot {
    width: 5px;
    height: 5px;
  }
  .ch-stage  { padding: 12px 10px; }
  .ch-panel  { padding: 18px 16px 22px; border-radius: 14px; }
  .ch-poster-word  { font-size: 26vw; }

  .complete-left   { padding: 28px 16px; }
  .complete-right  { padding: 24px 16px 40px; }
  .complete-collection { padding: 18px 16px 24px; }
  .coll-grid { grid-template-columns: repeat(5, 1fr); gap: 6px; }
  .complete-score-panel { padding: 18px 18px 22px; }
  .score-value { font-size: clamp(2.4rem, 12vw, 3.6rem); }
}

/* Very narrow phones — drop highscore chip in chapter topbar to keep it 1 line */
@media (max-width: 380px) {
  .ch-highscore-chip { display: none; }
  .progress-dots .dot:nth-child(n+8) { display: none; }
}

/* ============================================
   COLLECTIBLE TOAST
   ============================================ */
.collectible-toast {
  position: fixed;
  bottom: 32px;
  right: 32px;
  background: rgba(20, 12, 36, 0.96);
  border: 1px solid var(--accent);
  border-radius: 16px;
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 9999;
  min-width: 160px;
  max-width: 210px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05);
  transform: translateX(260px);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.175,0.885,0.32,1.275), opacity 0.4s ease;
  pointer-events: none;
}
.collectible-toast.visible {
  transform: translateX(0);
  opacity: 1;
}
.ct-new {
  font-family: var(--font-ui);
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}
.ct-icon {
  font-size: 2.6rem;
  line-height: 1;
  margin: 4px 0;
  animation: ct-pop 0.5s 0.15s cubic-bezier(0.175,0.885,0.32,1.275) both;
}
@keyframes ct-pop {
  from { transform: scale(0.3) rotate(-20deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg);     opacity: 1; }
}
.ct-name {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.82rem;
  color: #fff;
  line-height: 1.3;
}
.ct-desc {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.4;
}

/* ============================================
   THEME BAR COLLECTION COUNT
   ============================================ */
.theme-bar-collect {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.06em;
  margin-top: 4px;
  opacity: 0.85;
  display: block;
}

/* ============================================
   COMPLETE SCREEN — COLLECTION GRID
   ============================================ */
.complete-collection {
  grid-column: 1 / -1;
  padding: 28px 52px 44px;
  border-top: 1px solid var(--rule);
  background: rgba(0,0,0,0.2);
}
.coll-title {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 14px;
}
.coll-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 8px;
}
.coll-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 10px 4px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
  transition: all 0.2s;
  min-width: 0;
}
.coll-item.collected {
  border-color: rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.05);
  animation: coll-in 0.4s ease both;
}
@keyframes coll-in {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.coll-icon {
  font-size: 1.5rem;
  line-height: 1;
}
.coll-item.locked .coll-icon {
  font-size: 1.1rem;
  opacity: 0.2;
  filter: grayscale(1);
}
.coll-name {
  font-family: var(--font-ui);
  font-size: 0.52rem;
  font-weight: 600;
  color: rgba(255,255,255,0.45);
  text-align: center;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}
.coll-item.collected .coll-name { color: rgba(255,255,255,0.7); }
.coll-item.locked    .coll-name { color: rgba(255,255,255,0.18); }

/* ============================================
   ANSWER EXPLANATION (after correct answer)
   ============================================ */
.answer-explanation {
  display: none;
  font-family: var(--font-ui);
  font-size: 0.82rem;
  font-weight: 400;
  color: rgba(255,255,255,0.5);
  line-height: 1.55;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  margin-top: 8px;
  animation: pop-in 0.3s ease both;
}
.answer-explanation.visible { display: block; }
.exp-label {
  font-weight: 700;
  color: rgba(255,230,120,0.8);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 4px;
}

/* ============================================
   NØRD — 4-option math grid (2×2)
   ============================================ */
.cfg-choices.math-choices {
  grid-template-columns: repeat(2, 1fr);
}

/* ============================================
   STORY BONUS (Dyb mode)
   ============================================ */
.story-bonus {
  border-left: 2px solid var(--accent);
  padding-left: 14px;
  font-style: italic;
  color: rgba(255,255,255,0.6);
  margin-top: 1em;
  animation: bonus-in 0.5s 0.2s ease both;
}
@keyframes bonus-in {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ============================================
   COLLECTIBLE REVEAL OVERLAY
   ============================================ */
.collect-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  transition: background 0.32s ease;
  cursor: pointer;
}
.collect-overlay.visible { background: rgba(0,0,0,0.88); }

.collect-modal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  opacity: 0;
  transform: scale(0.5) translateY(48px);
  transition:
    opacity  0.48s cubic-bezier(0.175,0.885,0.32,1.275),
    transform 0.48s cubic-bezier(0.175,0.885,0.32,1.275);
  pointer-events: none;
}
.collect-overlay.visible .collect-modal {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

.cm-badge {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--accent);
  animation: cm-badge-pulse 1.8s ease-in-out infinite;
}
.collect-modal.is-rare    .cm-badge { color: #FFD700; }
.collect-modal.is-perfect .cm-badge { color: rgba(255,255,255,0.9); }
@keyframes cm-badge-pulse {
  0%,100% { opacity: 1; }
  50%     { opacity: 0.4; }
}

/* ════════════════════════════════════════════
   COLLECTIBLE TRADING CARD
   ════════════════════════════════════════════ */
.cm-card {
  --card-w: 270px;
  --card-h: 380px;
  --card-bg-1: #1a0d2e;
  --card-bg-2: #0a0418;
  --card-accent: #e8507a;
  --card-accent-2: #ff80c0;
  --card-frame: rgba(255,255,255,0.18);

  width: var(--card-w);
  height: var(--card-h);
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  padding: 14px 14px 16px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
  background:
    linear-gradient(160deg, var(--card-bg-1) 0%, var(--card-bg-2) 100%);
  border: 2px solid var(--card-frame);
  box-shadow:
    0 30px 80px rgba(0,0,0,0.75),
    inset 0 1px 0 rgba(255,255,255,0.10),
    inset 0 -1px 0 rgba(0,0,0,0.40),
    0 0 0 1px rgba(0,0,0,0.55);
  animation: cm-card-land 0.62s 0.12s cubic-bezier(0.175,0.885,0.32,1.275) both;
}
.collect-modal.is-rare .cm-card {
  --card-frame: rgba(255,215,0,0.65);
  box-shadow:
    0 30px 80px rgba(0,0,0,0.75),
    0 0 70px rgba(255,215,0,0.30),
    inset 0 1px 0 rgba(255,255,255,0.20),
    inset 0 -1px 0 rgba(0,0,0,0.40),
    0 0 0 1px rgba(255,215,0,0.30);
}
.collect-modal.is-perfect .cm-card {
  --card-frame: rgba(255,255,255,0.45);
  box-shadow:
    0 30px 80px rgba(0,0,0,0.75),
    0 0 70px rgba(255,255,255,0.18),
    inset 0 1px 0 rgba(255,255,255,0.18),
    0 0 0 1px rgba(255,255,255,0.22);
}
@keyframes cm-card-land {
  0%   { transform: rotate(-7deg) scale(0.78); }
  45%  { transform: rotate( 4deg) scale(1.07); }
  72%  { transform: rotate(-1deg) scale(1.02); }
  100% { transform: rotate( 0deg) scale(1); }
}

/* Holographic gradient layer (theme accent shimmer) */
.cm-holo {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg,
      transparent 0%,
      rgba(var(--card-accent-rgb, 232,80,122), 0.18) 30%,
      rgba(var(--card-accent2-rgb, 255,128,192), 0.14) 50%,
      rgba(var(--card-accent-rgb, 232,80,122), 0.18) 70%,
      transparent 100%);
  mix-blend-mode: screen;
  pointer-events: none;
  z-index: 1;
  opacity: 0.85;
}

/* Rotating shine across the whole card */
.cm-shine {
  position: absolute;
  inset: -50%;
  width: 200%; height: 200%;
  background: conic-gradient(
    from 0deg at 50% 50%,
    transparent       0deg,
    rgba(255,255,255,0.06) 25deg,
    transparent      55deg);
  mix-blend-mode: screen;
  animation: cm-shine-rot 6s linear infinite;
  pointer-events: none;
  z-index: 2;
}
.collect-modal.is-rare .cm-shine {
  background: conic-gradient(
    from 0deg at 50% 50%,
    transparent       0deg,
    rgba(255,215,0,0.18)  25deg,
    rgba(255,255,255,0.10) 35deg,
    transparent      55deg);
}
@keyframes cm-shine-rot {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Theme pattern (overridden per theme below) */
.cm-pattern {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.18;
}

/* Card header bar */
.cm-card-header {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.14);
}
.cm-card-set {
  font-family: var(--font-ui);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.78);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cm-card-number {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 900;
  color: var(--card-accent, #fff);
  letter-spacing: 0.04em;
  white-space: nowrap;
  text-shadow: 0 0 12px rgba(0,0,0,0.6);
}
.cm-card-total {
  opacity: 0.55;
  font-size: 0.62rem;
  font-weight: 700;
  margin-left: 1px;
}

/* "Photo" area — the icon as the card art */
.cm-card-photo {
  position: relative;
  z-index: 5;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(ellipse 70% 70% at 50% 40%,
      rgba(var(--card-accent-rgb, 232,80,122), 0.32) 0%,
      transparent 70%),
    linear-gradient(160deg,
      rgba(255,255,255,0.06) 0%,
      rgba(0,0,0,0.20) 100%);
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.10),
    inset 0 0 40px rgba(0,0,0,0.35);
}
.cm-photo-glow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 50% 50% at 50% 50%,
      rgba(var(--card-accent-rgb, 232,80,122), 0.35) 0%,
      transparent 70%);
  mix-blend-mode: screen;
  filter: blur(20px);
  pointer-events: none;
  animation: cm-photo-pulse 3s ease-in-out infinite;
}
@keyframes cm-photo-pulse {
  0%, 100% { opacity: 0.6; transform: scale(0.95); }
  50%      { opacity: 1;   transform: scale(1.05); }
}

.cm-icon {
  position: relative;
  z-index: 2;
  font-size: 5rem;
  line-height: 1;
  filter:
    drop-shadow(0 6px 18px rgba(0,0,0,0.55))
    drop-shadow(0 0 28px rgba(var(--card-accent-rgb, 232,80,122), 0.55));
  animation: cm-icon-pop 0.6s 0.28s cubic-bezier(0.175,0.885,0.32,1.275) both;
}
@keyframes cm-icon-pop {
  from { transform: scale(0.05) rotate(-28deg); opacity: 0; }
  to   { transform: scale(1)    rotate(0deg);   opacity: 1; }
}

/* Card footer — title + description */
.cm-card-footer {
  position: relative;
  z-index: 5;
  padding: 8px 6px 4px;
  border-top: 1px solid rgba(255,255,255,0.12);
  text-align: center;
}
.cm-name {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 900;
  font-size: 1.05rem;
  color: #fff;
  line-height: 1.1;
  letter-spacing: -0.01em;
  text-shadow: 0 2px 8px rgba(0,0,0,0.55);
}
.cm-desc {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.62);
  line-height: 1.35;
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cm-perfect-tag {
  display: inline-block;
  margin-top: 6px;
  font-family: var(--font-ui);
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #ffd060;
  background: rgba(255,200,80,0.14);
  border: 1px solid rgba(255,200,80,0.40);
  border-radius: 999px;
  padding: 2px 8px;
}

/* ════════════════════════════════════════════
   PER-THEME CARD STYLES — each tema gets its own vibe
   ════════════════════════════════════════════ */

/* K-POP — holographic photocard, hearts pattern */
.cm-card[data-card-theme="kpop"] {
  --card-bg-1: #2a0e36;
  --card-bg-2: #18051f;
  --card-accent: #ff5a8a;
  --card-accent-2: #ff80c0;
  --card-accent-rgb: 255,90,138;
  --card-accent2-rgb: 255,128,192;
}
.cm-card[data-card-theme="kpop"] .cm-pattern {
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,0.30) 1px, transparent 2px),
    radial-gradient(circle at 80% 60%, rgba(255,200,230,0.25) 1px, transparent 2px),
    radial-gradient(circle at 50% 80%, rgba(255,255,255,0.30) 1px, transparent 2px),
    radial-gradient(circle at 30% 90%, rgba(255,200,230,0.25) 1px, transparent 2px),
    radial-gradient(circle at 90% 20%, rgba(255,255,255,0.30) 1px, transparent 2px);
  background-size: 100% 100%;
  opacity: 0.55;
}
.cm-card[data-card-theme="kpop"] .cm-card-photo {
  background:
    radial-gradient(ellipse 70% 70% at 50% 40%, rgba(255,90,138,0.45), transparent 70%),
    linear-gradient(160deg, #ff80c0 0%, #c43d7a 100%);
}

/* GAMING — neon scanlines, cyan glow */
.cm-card[data-card-theme="gaming"] {
  --card-bg-1: #0a1530;
  --card-bg-2: #04081a;
  --card-accent: #00d8f0;
  --card-accent-2: #7c3aff;
  --card-accent-rgb: 0,216,240;
  --card-accent2-rgb: 124,58,255;
}
.cm-card[data-card-theme="gaming"] .cm-pattern {
  background:
    repeating-linear-gradient(0deg,
      transparent 0,
      transparent 3px,
      rgba(0,216,240,0.12) 3px,
      rgba(0,216,240,0.12) 4px);
}
.cm-card[data-card-theme="gaming"] .cm-card-photo {
  background:
    radial-gradient(ellipse 60% 60% at 50% 40%, rgba(0,216,240,0.40), transparent 70%),
    linear-gradient(160deg, #1a2858 0%, #050818 100%);
  border-color: rgba(0,216,240,0.40);
}

/* FOOTBALL — stadium green + gold trim */
.cm-card[data-card-theme="football"] {
  --card-bg-1: #0d2a14;
  --card-bg-2: #051208;
  --card-accent: #f5c518;
  --card-accent-2: #2a8840;
  --card-accent-rgb: 245,197,24;
  --card-accent2-rgb: 42,136,64;
}
.cm-card[data-card-theme="football"] .cm-pattern {
  background:
    repeating-linear-gradient(90deg,
      transparent 0,
      transparent 14px,
      rgba(255,255,255,0.06) 14px,
      rgba(255,255,255,0.06) 15px);
}
.cm-card[data-card-theme="football"] .cm-card-photo {
  background:
    radial-gradient(ellipse 60% 60% at 50% 40%, rgba(245,197,24,0.30), transparent 70%),
    linear-gradient(160deg, #2a8840 0%, #0d3818 100%);
  border-color: rgba(245,197,24,0.45);
}

/* RONALDO — gold metallic */
.cm-card[data-card-theme="ronaldo"] {
  --card-bg-1: #2a1c00;
  --card-bg-2: #100a00;
  --card-accent: #ffd700;
  --card-accent-2: #ffaa00;
  --card-accent-rgb: 255,215,0;
  --card-accent2-rgb: 255,170,0;
}
.cm-card[data-card-theme="ronaldo"] .cm-pattern {
  background:
    repeating-linear-gradient(45deg,
      transparent 0,
      transparent 18px,
      rgba(255,215,0,0.10) 18px,
      rgba(255,215,0,0.10) 19px);
}
.cm-card[data-card-theme="ronaldo"] .cm-card-photo {
  background:
    radial-gradient(ellipse 60% 60% at 50% 40%, rgba(255,215,0,0.55), transparent 70%),
    linear-gradient(160deg, #ffaa00 0%, #6b4500 100%);
  border-color: rgba(255,215,0,0.55);
}
.cm-card[data-card-theme="ronaldo"] .cm-card-set {
  color: #ffd700;
}

/* BRAWL STARS — cartoon pop, comic dots */
.cm-card[data-card-theme="brawlstars"] {
  --card-bg-1: #2c0e1a;
  --card-bg-2: #110410;
  --card-accent: #ff6b35;
  --card-accent-2: #ffd700;
  --card-accent-rgb: 255,107,53;
  --card-accent2-rgb: 255,215,0;
}
.cm-card[data-card-theme="brawlstars"] .cm-pattern {
  background-image:
    radial-gradient(circle at 50% 50%, rgba(255,255,255,0.18) 1.5px, transparent 2.5px);
  background-size: 14px 14px;
}
.cm-card[data-card-theme="brawlstars"] .cm-card-photo {
  background:
    radial-gradient(ellipse 60% 60% at 50% 40%, rgba(255,107,53,0.50), transparent 70%),
    linear-gradient(160deg, #ff6b35 0%, #802a10 100%);
  border-color: rgba(255,107,53,0.50);
}

/* ANIME — cherry-blossom pastel */
.cm-card[data-card-theme="anime"] {
  --card-bg-1: #2a0e2a;
  --card-bg-2: #14041a;
  --card-accent: #ff80c0;
  --card-accent-2: #c896ff;
  --card-accent-rgb: 255,128,192;
  --card-accent2-rgb: 200,150,255;
}
.cm-card[data-card-theme="anime"] .cm-pattern {
  background-image:
    radial-gradient(circle at 25% 25%, rgba(255,200,230,0.40) 2px, transparent 4px),
    radial-gradient(circle at 75% 30%, rgba(255,180,220,0.35) 2.5px, transparent 5px),
    radial-gradient(circle at 50% 75%, rgba(255,210,240,0.40) 2px, transparent 4px),
    radial-gradient(circle at 80% 90%, rgba(200,150,255,0.30) 2px, transparent 4px);
  background-size: 100% 100%;
}
.cm-card[data-card-theme="anime"] .cm-card-photo {
  background:
    radial-gradient(ellipse 60% 60% at 50% 40%, rgba(255,128,192,0.50), transparent 70%),
    linear-gradient(160deg, #ffaad8 0%, #5a2848 100%);
  border-color: rgba(255,128,192,0.45);
}

/* JJK — chaotic purple void */
.cm-card[data-card-theme="jjk"] {
  --card-bg-1: #14081f;
  --card-bg-2: #050208;
  --card-accent: #9b5de5;
  --card-accent-2: #ff5a8a;
  --card-accent-rgb: 155,93,229;
  --card-accent2-rgb: 255,90,138;
}
.cm-card[data-card-theme="jjk"] .cm-pattern {
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(155,93,229,0.25), transparent 60%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(255,90,138,0.18), transparent 60%),
    repeating-linear-gradient(135deg,
      transparent 0, transparent 30px,
      rgba(155,93,229,0.10) 30px, rgba(155,93,229,0.10) 31px);
}
.cm-card[data-card-theme="jjk"] .cm-card-photo {
  background:
    radial-gradient(ellipse 60% 60% at 50% 40%, rgba(155,93,229,0.55), transparent 70%),
    linear-gradient(160deg, #4a1f80 0%, #0a0210 100%);
  border-color: rgba(155,93,229,0.45);
}

/* GEOGRAPHY — vintage map paper */
.cm-card[data-card-theme="geography"] {
  --card-bg-1: #0a1a2e;
  --card-bg-2: #04080f;
  --card-accent: #1e90ff;
  --card-accent-2: #f5c518;
  --card-accent-rgb: 30,144,255;
  --card-accent2-rgb: 245,197,24;
}
.cm-card[data-card-theme="geography"] .cm-pattern {
  background:
    repeating-linear-gradient(0deg,
      transparent 0, transparent 19px,
      rgba(255,255,255,0.05) 19px, rgba(255,255,255,0.05) 20px),
    repeating-linear-gradient(90deg,
      transparent 0, transparent 19px,
      rgba(255,255,255,0.05) 19px, rgba(255,255,255,0.05) 20px);
}
.cm-card[data-card-theme="geography"] .cm-card-photo {
  background:
    radial-gradient(ellipse 60% 60% at 50% 40%, rgba(30,144,255,0.40), transparent 70%),
    linear-gradient(160deg, #2a6ba8 0%, #0a2040 100%);
  border-color: rgba(30,144,255,0.45);
}

.cm-dismiss {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.2);
  animation: cm-dismiss-blink 2.8s 1s ease-in-out infinite;
}
@keyframes cm-dismiss-blink {
  0%,100% { opacity: 0.3; }
  50%     { opacity: 1; }
}

/* ============================================
   STREAK BADGE (inside topbar ch-meta)
   ============================================ */
.streak-badge {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 700;
  color: #FF9040;
  background: rgba(255,144,64,0.13);
  border: 1px solid rgba(255,144,64,0.24);
  border-radius: 20px;
  padding: 2px 10px 2px 8px;
  white-space: nowrap;
  display: inline-block;
  vertical-align: middle;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.streak-badge.hidden  { opacity: 0; pointer-events: none; transform: scale(0.75); }
.streak-badge.active  { animation: streak-pop 0.38s cubic-bezier(0.175,0.885,0.32,1.275); }
@keyframes streak-pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.4); }
  100% { transform: scale(1); }
}

/* ============================================
   SKIP BUTTON
   ============================================ */
.skip-btn {
  display: none;
  font-family: var(--font-ui);
  font-size: 0.74rem;
  font-weight: 500;
  color: rgba(255,255,255,0.26);
  background: none;
  border: 1px dashed rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 8px 18px;
  cursor: pointer;
  margin-top: 6px;
  transition: color 0.2s, border-color 0.2s;
}
.skip-btn.visible { display: block; animation: pop-in 0.3s ease both; }
.skip-btn:hover { color: rgba(255,255,255,0.48); border-color: rgba(255,255,255,0.2); }

/* ============================================
   FEEDBACK VARIANTS
   ============================================ */
.feedback.skip-msg {
  color: rgba(255,255,255,0.44);
  background: rgba(255,255,255,0.04);
  border-left: 2px solid rgba(255,255,255,0.12);
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
  margin-top: 6px;
}
.feedback.success.perfect { color: #FFD060; }

/* ============================================
   SOUND BUTTON (home screen, top-right)
   ============================================ */
.sound-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 50%;
  width: 40px; height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: background 0.2s, transform 0.15s;
  z-index: 10;
}
.sound-btn:hover  { background: rgba(255,255,255,0.1); transform: scale(1.1); }
.sound-btn:active { transform: scale(0.93); }

/* ============================================
   IMAGE ASSETS — backgrounds, banners, effects
   ============================================ */

/* Reusable film-grain texture (SVG noise) — used on multiple layers */
.fx-grain {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.6 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 180px 180px;
  mix-blend-mode: overlay;
  opacity: 0.18;
  pointer-events: none;
}

/* ============================================
   HOME — topbar + full-bleed game catalog
   ============================================ */
.home-screen {
  isolation: isolate;
  position: relative;
  height: 100vh;
  max-height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: #08040f;
  box-sizing: border-box;
}

/* ── Compact top bar ── */
.home-topbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 52px;
  background: rgba(8,4,18,0.80);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.home-topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  user-select: none;
}

/* Logo mark — bold "4Y" tile */
.brand-mark {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  min-width: 50px;
  padding: 0 10px;
  border-radius: 9px;
  background:
    linear-gradient(135deg, #ff3da6 0%, #ff5b7c 45%, #ff9747 100%);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.18) inset,
    0 0 22px rgba(255,80,180,0.55),
    0 6px 18px rgba(0,0,0,0.45);
  transform: skewX(-6deg);
  font-family: var(--font-display, inherit);
  font-weight: 900;
  font-style: italic;
  font-size: 1.1rem;
  letter-spacing: 0.01em;
  color: #fff;
  text-shadow: 0 1px 0 rgba(0,0,0,0.25);
}
.brand-mark::after {
  content: '';
  position: absolute;
  inset: 1px;
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,0.22), rgba(255,255,255,0) 55%);
  pointer-events: none;
}
.brand-mark-num {
  display: inline-block;
  transform: skewX(6deg) translateY(-1px);
  font-size: 1.25rem;
}
.brand-mark-y {
  display: inline-block;
  transform: skewX(6deg) translate(2px, -6px);
  font-size: 0.78rem;
  font-weight: 800;
  opacity: 0.95;
}
.brand-mark-text {
  display: inline-block;
  transform: skewX(6deg);
  font-family: var(--font-display, inherit);
  font-weight: 900;
  font-style: italic;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
}

/* Wordmark beside the tile */
.brand-wordmark {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-display, inherit);
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.92);
}
.brand-wordmark-line {
  display: inline-block;
}
.brand-wordmark-dot {
  display: inline-block;
  font-size: 0.5rem;
  color: #ff3da6;
  text-shadow: 0 0 8px rgba(255,80,180,0.9);
  transform: translateY(-1px);
}

/* Info button */
.info-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.85);
  font-family: var(--font-display, inherit);
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 160ms ease, transform 160ms ease, border-color 160ms ease;
}
.info-btn:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.4);
  transform: translateY(-1px);
}
.info-btn:active {
  transform: translateY(0);
}
.home-topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
/* Move sound-btn into topbar flow */
.home-topbar .sound-btn {
  position: static;
  width: 34px;
  height: 34px;
  font-size: 0.85rem;
}

/* Animated stage behind everything */
.home-stage {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

/* Aurora — slowly drifting colored fog */
.hp-aurora {
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(ellipse 50% 40% at 25% 30%, rgba(255,80,160,0.22), transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 20%, rgba(0,180,255,0.18), transparent 60%),
    radial-gradient(ellipse 55% 45% at 50% 80%, rgba(140,80,255,0.22), transparent 60%),
    radial-gradient(ellipse 45% 35% at 90% 70%, rgba(255,160,40,0.14), transparent 60%);
  filter: blur(40px) saturate(1.2);
  animation: hp-aurora-drift 22s ease-in-out infinite alternate;
  mix-blend-mode: screen;
}
@keyframes hp-aurora-drift {
  0%   { transform: translate(-3%, -2%) scale(1) rotate(0deg); }
  50%  { transform: translate( 4%,  3%) scale(1.08) rotate(2deg); }
  100% { transform: translate(-2%,  2%) scale(1.04) rotate(-1deg); }
}

/* Light rays from top, animated */
.hp-rays {
  position: absolute;
  inset: -10%;
  background:
    conic-gradient(from 200deg at 50% -10%,
      transparent 0deg,
      rgba(255,255,255,0.05) 8deg,
      transparent 16deg,
      transparent 28deg,
      rgba(255,180,255,0.06) 36deg,
      transparent 44deg,
      transparent 56deg,
      rgba(180,220,255,0.05) 64deg,
      transparent 72deg,
      transparent 360deg);
  mix-blend-mode: screen;
  opacity: 0.7;
  animation: hp-rays-spin 60s linear infinite;
}
@keyframes hp-rays-spin {
  to { transform: rotate(360deg); }
}

/* Faint perspective grid */
.hp-grid {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 55%;
  background:
    linear-gradient(180deg, transparent 0%, rgba(255,80,160,0.06) 100%),
    repeating-linear-gradient(90deg,
      rgba(255,80,200,0.18) 0,
      rgba(255,80,200,0.18) 1px,
      transparent 1px,
      transparent 60px),
    repeating-linear-gradient(0deg,
      rgba(80,200,255,0.14) 0,
      rgba(80,200,255,0.14) 1px,
      transparent 1px,
      transparent 60px);
  transform: perspective(800px) rotateX(62deg);
  transform-origin: bottom center;
  mask-image: linear-gradient(180deg, transparent 0%, black 30%, black 100%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, black 30%, black 100%);
  opacity: 0.45;
  animation: hp-grid-pan 8s linear infinite;
}
@keyframes hp-grid-pan {
  from { background-position: 0 0, 0 0, 0 0; }
  to   { background-position: 0 0, 0 60px, 0 60px; }
}

/* Floating particle stars */
.hp-particles {
  position: absolute;
  inset: 0;
}
.hp-particle {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: white;
  box-shadow:
    0 0 10px 2px rgba(255,255,255,0.9),
    0 0 22px 4px rgba(255,180,220,0.55);
  opacity: 0.0;
  animation: hp-twinkle 5s ease-in-out infinite;
  animation-delay: var(--d);
  pointer-events: none;
}
.hp-p1 { background: #ff70c8; box-shadow: 0 0 10px 2px rgba(255,112,200,0.9), 0 0 22px 4px rgba(255,112,200,0.5); width:5px;height:5px; }
.hp-p2 { background: #80f0ff; box-shadow: 0 0 10px 2px rgba(128,240,255,0.9), 0 0 22px 4px rgba(128,240,255,0.5); width:4px;height:4px; }
.hp-p3 { background: #ffd070; box-shadow: 0 0 10px 2px rgba(255,208,112,0.9), 0 0 22px 4px rgba(255,208,112,0.5); width:6px;height:6px; }
.hp-p4 { background: #c896ff; box-shadow: 0 0 10px 2px rgba(200,150,255,0.9), 0 0 22px 4px rgba(200,150,255,0.5); width:5px;height:5px; }
.hp-p5 { background: #ffffff; width: 3px; height: 3px; }
.hp-p6 { background: #ff90b0; box-shadow: 0 0 10px 2px rgba(255,144,176,0.9); width:7px;height:7px; }
@keyframes hp-twinkle {
  0%, 100% { opacity: 0; transform: scale(0.6) translateY(0); }
  20%      { opacity: 1; transform: scale(1.2) translateY(-4px); }
  50%      { opacity: 0.8; transform: scale(1) translateY(-2px); }
  80%      { opacity: 0.4; transform: scale(0.9) translateY(0); }
}

/* Top-level vignette */
.hp-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 100% 100% at 50% 50%, transparent 50%, rgba(8,4,18,0.55) 90%, rgba(8,4,18,0.85) 100%);
  pointer-events: none;
}

/* ── Hero — compact header, logo crisp and clear ── */
.home-hero {
  grid-area: hero;
  position: relative;
  z-index: 2;
  height: clamp(170px, 30vh, 310px);
  padding: 14px 24px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  isolation: isolate;
  gap: 8px;
}

.home-hero-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

/* Pulsing radial glow behind logo */
.home-hero-pulse {
  position: absolute;
  top: 45%;
  left: 50%;
  width: 60vmin;
  height: 60vmin;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle,
    rgba(255,80,180,0.30) 0%,
    rgba(140,80,255,0.18) 35%,
    transparent 70%);
  filter: blur(18px);
  animation: hero-pulse 4s ease-in-out infinite;
  mix-blend-mode: screen;
}
@keyframes hero-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(0.95); opacity: 0.6; }
  50%      { transform: translate(-50%, -50%) scale(1.08); opacity: 1; }
}

/* Reduced logo — visible but not dominant */
.home-hero-logo {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  min-height: 0;
  width: auto;
  height: auto;
  max-height: 100%;
  max-width: min(78vw, 720px);
  object-fit: contain;
  filter: saturate(1.18) contrast(1.06) drop-shadow(0 0 40px rgba(255,80,180,0.55)) drop-shadow(0 6px 30px rgba(140,80,255,0.40));
  animation: home-logo-breathe 6s ease-in-out infinite;
  will-change: transform, filter;
  user-select: none;
  -webkit-user-drag: none;
}
@keyframes home-logo-breathe {
  0%,100% {
    transform: scale(1) translateY(0);
    filter: saturate(1.18) contrast(1.06) drop-shadow(0 0 35px rgba(255,80,180,0.50)) drop-shadow(0 6px 30px rgba(140,80,255,0.40));
  }
  50% {
    transform: scale(1.018) translateY(-3px);
    filter: saturate(1.32) contrast(1.10) drop-shadow(0 0 60px rgba(255,90,200,0.80)) drop-shadow(0 8px 40px rgba(160,80,255,0.60));
  }
}

.home-hero-glow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 65% 50% at 50% 45%, rgba(255,80,160,0.22) 0%, transparent 65%),
    radial-gradient(ellipse 70% 60% at 25% 70%, rgba(120,80,255,0.18) 0%, transparent 65%),
    radial-gradient(ellipse 60% 50% at 80% 30%, rgba(0,200,255,0.13) 0%, transparent 65%);
  animation: home-glow-shift 14s ease-in-out infinite alternate;
  mix-blend-mode: screen;
}
@keyframes home-glow-shift {
  from { transform: translate(-2%, -1%) scale(1); }
  to   { transform: translate( 2%,  1%) scale(1.06); }
}

.home-hero-sweep {
  position: absolute;
  inset: -25%;
  background: linear-gradient(
    115deg,
    transparent 30%,
    rgba(255,255,255,0.08) 45%,
    rgba(255,200,255,0.18) 50%,
    rgba(255,255,255,0.08) 55%,
    transparent 70%
  );
  mix-blend-mode: screen;
  animation: home-sweep 8s ease-in-out infinite;
  pointer-events: none;
}
@keyframes home-sweep {
  0%   { transform: translateX(-65%); opacity: 0; }
  30%  { opacity: 0.7; }
  50%  { transform: translateX(0%);   opacity: 1; }
  70%  { opacity: 0.7; }
  100% { transform: translateX(65%);  opacity: 0; }
}

.home-hero-grain {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.55'/></svg>");
  opacity: 0.12;
  mix-blend-mode: overlay;
  pointer-events: none;
}

.home-hero-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 110% 100% at 50% 50%, transparent 55%, rgba(8,4,18,0.45) 85%, rgba(8,4,18,0.85) 100%),
    linear-gradient(180deg, rgba(8,4,18,0.20) 0%, transparent 25%, transparent 70%, rgba(8,4,18,0.85) 100%);
  pointer-events: none;
}

.home-eyebrow {
  position: relative;
  z-index: 2;
  font-size: 0.66rem;
  letter-spacing: 0.18em;
  margin: 0;
  padding: 4px 12px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: rgba(8,4,18,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}
.home-hero .beta-badge { margin-left: 4px; transform: none; }

/* ── CTA bar — primary action, visually central, above the fold ── */
.home-cta-bar {
  grid-area: cta;
  z-index: 4;
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  padding: 14px 20px 16px;
  flex-wrap: wrap;
}

.hero-cta {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 200px;
  padding: 14px 28px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(8,4,18,0.55);
  backdrop-filter: blur(12px) saturate(1.1);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
  color: #fff;
  font-family: var(--font-body, inherit);
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.175,0.885,0.32,1.275),
              box-shadow 0.25s ease,
              background 0.25s ease;
  text-align: center;
  line-height: 1.1;
  box-shadow: 0 4px 18px rgba(0,0,0,0.45);
}
.hero-cta:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 28px rgba(0,0,0,0.55);
}
.hero-cta:active { transform: translateY(0) scale(0.99); }
.hero-cta-label {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.hero-cta-sub {
  font-size: 0.7rem;
  opacity: 0.78;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Primary — accent gradient, pulsing call-to-action */
.hero-cta-primary {
  background: linear-gradient(135deg, #ff5fa3 0%, #b04bff 50%, #6e3bff 100%);
  border-color: rgba(255,255,255,0.22);
  box-shadow: 0 6px 22px rgba(255,80,180,0.45),
              0 0 0 0 rgba(255,80,180,0.55);
  animation: cta-pulse 2.4s ease-in-out infinite;
}
.hero-cta-primary:hover {
  background: linear-gradient(135deg, #ff7eb6 0%, #c25fff 50%, #8654ff 100%);
}
@keyframes cta-pulse {
  0%, 100% { box-shadow: 0 6px 22px rgba(255,80,180,0.45), 0 0 0 0 rgba(255,80,180,0.55); }
  50%      { box-shadow: 0 8px 28px rgba(255,80,180,0.55), 0 0 0 12px rgba(255,80,180,0.0); }
}

/* Secondary — subtle glass */
.hero-cta-secondary {
  background: rgba(8,4,18,0.55);
}
.hero-cta-secondary:hover {
  background: rgba(20,10,40,0.70);
  border-color: rgba(255,255,255,0.22);
}

/* ============================================
   GAME CATALOG — full-bleed 4×2 cover grid
   ============================================ */
.theme-catalog {
  position: relative;
  z-index: 3;
  width: 100%;
  height: 100%;                          /* fill the grid row */
  padding: 10px 14px 12px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);    /* 2 equal rows — no scroll */
  gap: 10px;
  overflow: hidden;
  box-sizing: border-box;
}

/* ============================================
   GAME COVER CARDS — image-dominant, game catalog style
   ============================================ */
.theme-card {
  position: relative;
  width: 100%;
  height: 100%;                  /* fill the catalog grid cell */
  background: #090416;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.10);
  overflow: hidden;
  cursor: pointer;
  transition:
    transform 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    box-shadow 0.28s ease,
    border-color 0.28s ease;
  text-align: left;
}
@media (hover: hover) {
  .theme-card:hover {
    transform: scale(1.04) translateY(-3px);
    border-color: rgba(255,255,255,0.40);
    box-shadow:
      0 20px 50px rgba(0,0,0,0.75),
      0 0 0 1px rgba(255,255,255,0.16),
      0 0 40px rgba(255,80,160,0.22);
    z-index: 10;
  }
}
.theme-card:active { transform: scale(0.985); }

/* Full-bleed cover image */
.theme-card-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  filter: saturate(1.3) contrast(1.05);
  transition: filter 0.5s ease, transform 0.6s ease;
}
/* Hover effects only on devices that actually have hover (not touch) */
@media (hover: hover) {
  .theme-card:hover .theme-card-img {
    filter: saturate(1.55) contrast(1.12) brightness(1.08);
    transform: scale(1.06);
  }
}

/* Centered title needs a radial dim — image readable, title pops */
.theme-card-overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 75% 60% at 50% 50%,
      rgba(0,0,0,0.55) 0%,
      rgba(0,0,0,0.30) 45%,
      rgba(0,0,0,0.10) 75%,
      transparent 100%),
    linear-gradient(180deg,
      rgba(0,0,0,0.25) 0%,
      transparent 30%,
      transparent 70%,
      rgba(0,0,0,0.35) 100%);
  pointer-events: none;
  z-index: 1;
}

/* Accent glow on hover */
.theme-card-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 90% 60% at 50% 110%, var(--accent, #e8507a) 0%, transparent 65%);
  mix-blend-mode: screen;
  opacity: 0;
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.45s ease;
}
@media (hover: hover) {
  .theme-card:hover .theme-card-glow { opacity: 0.35; }
}

/* Diagonal light sweep on hover */
.theme-card-sweep {
  position: absolute;
  inset: -40%;
  background: linear-gradient(
    115deg,
    transparent 38%,
    rgba(255,255,255,0.18) 50%,
    transparent 62%
  );
  mix-blend-mode: screen;
  opacity: 0;
  transform: translateX(-70%);
  pointer-events: none;
  z-index: 2;
  transition: opacity 0.1s;
}
@media (hover: hover) {
  .theme-card:hover .theme-card-sweep {
    opacity: 1;
    animation: card-shine 0.9s ease-out forwards;
  }
}
@keyframes card-shine {
  from { transform: translateX(-70%); }
  to   { transform: translateX(70%);  }
}

/* Film grain over art */
.theme-card-grain {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.5 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 160px 160px;
  mix-blend-mode: overlay;
  opacity: 0.14;
  pointer-events: none;
  z-index: 3;
}

/* Progress / done badge in top-right of art */
.theme-card-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 4;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  backdrop-filter: blur(8px);
}
.theme-card-badge.done     { background: rgba(80,220,120,0.25); border: 1px solid rgba(80,220,120,0.55); color: #60f090; }
.theme-card-badge.progress { background: rgba(255,200,80,0.20); border: 1px solid rgba(255,200,80,0.50); color: #ffd060; }

/* Title + tagline — centered as a poster title across the whole card */
.theme-card-body {
  position: absolute;
  inset: 0;
  padding: 14px 14px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}
.theme-card-title {
  font-family: var(--font-display, inherit);
  font-weight: 900;
  font-style: italic;
  font-size: clamp(1.1rem, 2.6vw, 1.9rem);
  line-height: 1.05;
  color: #fff;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
  text-shadow:
    0 2px 0 rgba(0,0,0,0.55),
    0 4px 18px rgba(0,0,0,0.95),
    0 0 22px rgba(0,0,0,0.7);
}
.theme-card-tagline {
  font-size: clamp(0.6rem, 1.1vw, 0.78rem);
  color: rgba(255,255,255,0.92);
  line-height: 1.3;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  max-width: 90%;
  text-shadow: 0 1px 6px rgba(0,0,0,1), 0 0 14px rgba(0,0,0,0.85);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================
   LEVEL SELECT — fullscreen cinematic bg + overlay
   ============================================ */
/* (replaces old .config-banner approach) */
.config-banner {
  position: relative;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  height: clamp(220px, 32vh, 360px);
  overflow: hidden;
  border-bottom: 1px solid var(--rule);
  z-index: 1;
  isolation: isolate;
}
.config-banner-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  filter: saturate(1.15);
  animation: banner-zoom 16s ease-in-out infinite alternate;
}
@keyframes banner-zoom {
  from { transform: scale(1.0)  translateX(-1%); }
  to   { transform: scale(1.08) translateX(1%); }
}
.config-banner-grain {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.6 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 180px 180px;
  mix-blend-mode: overlay;
  opacity: 0.16;
  pointer-events: none;
}
.config-banner-sweep {
  position: absolute;
  inset: -10%;
  background: linear-gradient(
    115deg,
    transparent 40%,
    rgba(255,255,255,0.10) 49%,
    rgba(255,220,255,0.16) 50%,
    rgba(255,255,255,0.10) 51%,
    transparent 60%
  );
  mix-blend-mode: screen;
  animation: banner-sweep 7s ease-in-out infinite;
  pointer-events: none;
}
@keyframes banner-sweep {
  0%   { transform: translateX(-50%); opacity: 0; }
  40%  { opacity: 0.9; }
  100% { transform: translateX(50%);  opacity: 0; }
}
.config-banner-overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 100%, rgba(8,4,18,0.0) 0%, rgba(8,4,18,0.55) 60%, var(--bg) 100%),
    linear-gradient(180deg, rgba(8,4,18,0.0) 0%, rgba(8,4,18,0.0) 50%, rgba(8,4,18,0.55) 100%);
  pointer-events: none;
}
.config-banner + .config-panel { padding-top: 24px; }

/* ============================================
   CHAPTER — image is primary background
   ============================================ */
.chapter-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.chapter-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0.95;
  filter: saturate(1.15);
  animation: chapter-bg-pan 30s ease-in-out infinite alternate;
}
@keyframes chapter-bg-pan {
  from { transform: scale(1.04) translateX(-1%); }
  to   { transform: scale(1.10) translateX(1%); }
}
.chapter-bg-grain {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.6 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 180px 180px;
  mix-blend-mode: overlay;
  opacity: 0.18;
  pointer-events: none;
}
.chapter-bg-sweep {
  position: absolute;
  inset: -10%;
  background: linear-gradient(
    115deg,
    transparent 42%,
    rgba(255,255,255,0.06) 50%,
    transparent 58%
  );
  mix-blend-mode: screen;
  animation: chapter-sweep 12s ease-in-out infinite;
  pointer-events: none;
}
@keyframes chapter-sweep {
  0%   { transform: translateX(-60%); opacity: 0; }
  50%  { opacity: 0.6; }
  100% { transform: translateX(60%);  opacity: 0; }
}
/* Vignette + bottom darkening so text stays readable but image dominates */
.chapter-bg-overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 110% 90% at 50% 50%, transparent 35%, rgba(8,4,18,0.45) 80%, rgba(8,4,18,0.70) 100%),
    linear-gradient(180deg, rgba(8,4,18,0.20) 0%, transparent 30%, rgba(8,4,18,0.30) 100%);
  pointer-events: none;
}

/* Image is now FULLY dominant — boost saturation and reduce overlay darkness */
.chapter-bg img {
  opacity: 1 !important;
  filter: saturate(1.25) contrast(1.05) !important;
}
/* Smooth fade-in when chapter changes (different image per chapter) */
.chapter-bg-img {
  animation: ch-bg-fade 700ms ease-out;
}
@keyframes ch-bg-fade {
  from { opacity: 0; transform: scale(1.06); }
  to   { opacity: 1; transform: scale(1); }
}
/* Lighter overlay so image shines through */
.chapter-bg-overlay {
  background:
    radial-gradient(ellipse 110% 90% at 50% 50%, transparent 45%, rgba(8,4,18,0.30) 85%, rgba(8,4,18,0.55) 100%),
    linear-gradient(180deg, rgba(8,4,18,0.15) 0%, transparent 40%, rgba(8,4,18,0.25) 100%) !important;
}

/* Topbar — subtle floating bar */
.chapter-topbar {
  background: rgba(8,4,18,0.55) !important;
  backdrop-filter: blur(12px) saturate(1.1);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

/* Story panel: floating glass card aligned to LEFT — image still visible around it */
.ch-left {
  background: linear-gradient(180deg, rgba(8,4,18,0.65) 0%, rgba(8,4,18,0.50) 100%);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  border-right: 1px solid rgba(255,255,255,0.10);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.06),
    8px 0 40px rgba(0,0,0,0.45);
  margin: 18px 0 18px 18px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.10);
  padding: 28px 32px !important;
}
/* Right (question) panel: floating glass card aligned to RIGHT */
.ch-right {
  background: linear-gradient(180deg, rgba(8,4,18,0.78) 0%, rgba(8,4,18,0.68) 100%);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  margin: 18px 18px 18px 0;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.12);
  border-left: 1px solid rgba(255,255,255,0.10);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.08),
    -8px 0 40px rgba(0,0,0,0.45);
  padding: 28px 32px !important;
}
/* Hide the giant poster words — image now does that visual work */
.ch-poster { display: none; }

/* Cinematic effects on top of chapter image */
.chapter-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 30% 25%, rgba(255,80,180,0.10) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 75% 70%, rgba(80,200,255,0.10) 0%, transparent 60%);
  mix-blend-mode: screen;
  animation: chapter-color-drift 18s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes chapter-color-drift {
  from { transform: translate(-1%, -1%); opacity: 0.7; }
  to   { transform: translate( 2%,  1%); opacity: 1; }
}

/* ============================================
   COMPLETE — image is primary background
   ============================================ */
.complete-screen { position: relative; isolation: isolate; }
.complete-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.complete-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0.85;
  filter: saturate(1.2);
  animation: complete-bg-pan 24s ease-in-out infinite alternate;
}
@keyframes complete-bg-pan {
  from { transform: scale(1.02); }
  to   { transform: scale(1.10); }
}
.complete-bg-overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 70% at 30% 50%, rgba(8,4,18,0.20) 0%, rgba(8,4,18,0.65) 75%),
    linear-gradient(180deg, rgba(8,4,18,0.30) 0%, rgba(8,4,18,0.65) 100%);
}
.complete-left,
.complete-right {
  background: rgba(8,4,18,0.55);
  backdrop-filter: blur(12px) saturate(1.1);
  -webkit-backdrop-filter: blur(12px) saturate(1.1);
}
.complete-icon {
  display: none; /* removed — backdrop image carries the theme */
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
  .theme-catalog { gap: 8px; padding: 8px 10px 10px; }
}

/* ── Tablet: 2 columns, scrollable ── */
@media (max-width: 760px) {
  .home-screen {
    height: auto;
    min-height: 100vh;
    max-height: none;
    width: 100%;
    max-width: 100vw;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
  }
  .theme-catalog {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: none;
    grid-auto-rows: minmax(150px, auto);
    gap: 10px;
    padding: 12px 12px 24px;
    height: auto;
    overflow: visible;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  /* Aspect 16/9 matches the source images (1672×941) — no side-crop */
  .theme-card {
    aspect-ratio: 16 / 9;
    min-height: 0;
    width: 100%;
    max-width: 100%;
  }
}

/* ── Phone: single column stacked, full-width cards ── */
@media (max-width: 520px) {
  .theme-catalog {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
    gap: 10px;
    padding: 10px 12px 28px;
  }
  .theme-card {
    aspect-ratio: 16 / 9;
    min-height: 0;
    border-radius: 14px;
  }
  .theme-card-title {
    font-size: clamp(1.4rem, 6vw, 2rem) !important;
  }
  .theme-card-tagline {
    font-size: 0.78rem !important;
  }
  /* Legacy config-overlay tweaks (in case it ever shows on small screens) */
  .config-overlay-name { font-size: 1.5rem; }
  .cfg-choices { grid-template-columns: 1fr 1fr; }
  .math-choices { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .config-bg img,
  .config-bg-sweep,
  .chapter-bg img,
  .chapter-bg-sweep,
  .complete-bg img,
  .hp-aurora,
  .hp-rays,
  .hp-particle { animation: none !important; }
}

/* ─────────────────────────────────────────────
   GVS MATH LEAGUE — HIGHSCORE UI
   ───────────────────────────────────────────── */

/* Live score chip in chapter topbar */
.ch-score-cluster {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.ch-score-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(120,200,255,0.18), rgba(255,80,180,0.16));
  border: 1px solid rgba(255,255,255,0.18);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 1px 0 rgba(0,0,0,0.4);
  box-shadow: 0 0 14px rgba(120,200,255,0.18) inset;
  transition: transform 220ms cubic-bezier(0.18,0.89,0.32,1.4), background 220ms ease;
}
.ch-score-chip strong {
  font-weight: 900;
  color: #c9f0ff;
  font-variant-numeric: tabular-nums;
}
.ch-score-chip.bump {
  transform: scale(1.18);
  background: linear-gradient(135deg, rgba(255,210,120,0.45), rgba(255,80,180,0.35));
}

.ch-highscore-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(8,4,18,0.55);
  border: 1px solid rgba(255,210,120,0.35);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: rgba(255,225,170,0.92);
  font-variant-numeric: tabular-nums;
}
.ch-highscore-chip.beat {
  background: linear-gradient(135deg, rgba(255,210,120,0.32), rgba(255,80,180,0.30));
  border-color: rgba(255,225,140,0.85);
  color: #fff;
  box-shadow: 0 0 16px rgba(255,210,120,0.45);
  animation: hi-beat-pulse 1.4s ease-in-out infinite;
}
@keyframes hi-beat-pulse {
  0%,100% { box-shadow: 0 0 14px rgba(255,210,120,0.40); }
  50%     { box-shadow: 0 0 22px rgba(255,210,120,0.85); }
}

/* Highscore badge on theme cards (home) */
.theme-card-hiscore {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255,210,120,0.95), rgba(255,160,80,0.95));
  color: #1a0a06;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.4) inset,
    0 4px 14px rgba(255,160,80,0.55),
    0 6px 18px rgba(0,0,0,0.4);
  pointer-events: none;
}

/* Highscore line on level-select panel */
.config-highscore {
  margin-top: 10px;
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255,210,120,0.20), rgba(255,80,180,0.16));
  border: 1px solid rgba(255,210,120,0.4);
  color: #ffe6b5;
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.config-highscore strong {
  color: #fff;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  margin: 0 2px;
}
.config-highscore.muted {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.7);
}

/* Score panel on completion screen */
.complete-score-panel {
  margin-top: 18px;
  padding: 18px 22px 20px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(8,4,18,0.78) 0%, rgba(8,4,18,0.62) 100%);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 18px 44px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.08);
  text-align: center;
  position: relative;
  overflow: hidden;
  animation: score-panel-in 0.5s cubic-bezier(0.18,0.89,0.32,1.18);
}
@keyframes score-panel-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.complete-score-panel.new-highscore {
  border-color: rgba(255,210,120,0.7);
  background: linear-gradient(180deg, rgba(60,30,10,0.85) 0%, rgba(40,18,38,0.75) 100%);
  box-shadow:
    0 0 32px rgba(255,210,120,0.45),
    0 18px 48px rgba(0,0,0,0.55),
    inset 0 1px 0 rgba(255,225,160,0.25);
}
.complete-score-panel.new-highscore::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: conic-gradient(from 0deg, transparent 0%, rgba(255,210,120,0.4) 30%, transparent 60%, rgba(255,80,180,0.3) 80%, transparent 100%);
  filter: blur(14px);
  animation: hi-rotate 6s linear infinite;
  z-index: -1;
}
@keyframes hi-rotate { to { transform: rotate(360deg); } }

.score-banner {
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #ffd87a;
  margin-bottom: 10px;
  text-shadow: 0 0 14px rgba(255,210,120,0.7);
}
.score-banner.muted {
  color: rgba(255,255,255,0.6);
  text-shadow: none;
  letter-spacing: 0.14em;
}
.complete-score-panel.new-highscore .score-banner {
  font-size: 0.92rem;
  animation: hi-banner-pop 0.55s cubic-bezier(0.18,0.89,0.32,1.6);
}
@keyframes hi-banner-pop {
  0%   { transform: scale(0.5); opacity: 0; }
  60%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}

.score-final {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 12px;
  margin-bottom: 10px;
}
.score-final .score-label {
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.7);
}
.score-final .score-value {
  font-family: var(--font-display, inherit);
  font-weight: 900;
  font-style: italic;
  font-size: 2.4rem;
  color: #fff;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 20px rgba(255,210,120,0.4);
}
.complete-score-panel.new-highscore .score-value {
  background: linear-gradient(135deg, #fff5d2 0%, #ffd166 50%, #ff8a5b 100%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 22px rgba(255,210,120,0.7));
}

.score-prev {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.65);
  margin-bottom: 6px;
}
.score-prev-value {
  font-weight: 800;
  color: rgba(255,255,255,0.9);
  font-variant-numeric: tabular-nums;
}
.score-diff {
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 14px;
  letter-spacing: 0.02em;
}
.score-diff.pos { color: #82e6a0; text-shadow: 0 0 12px rgba(110,230,160,0.5); }
.score-diff.neg { color: #ff9a9a; }
.score-diff.eq  { color: rgba(255,255,255,0.7); }

.replay-btn {
  margin-top: 4px;
  padding: 12px 22px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #ff3da6 0%, #ff5b7c 50%, #ff9747 100%);
  color: #fff;
  font-family: var(--font-display, inherit);
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.2) inset,
    0 8px 22px rgba(255,80,180,0.45),
    0 4px 12px rgba(0,0,0,0.4);
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.replay-btn:hover {
  transform: translateY(-2px);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.3) inset,
    0 12px 28px rgba(255,80,180,0.6),
    0 6px 16px rgba(0,0,0,0.45);
}
.replay-btn:active {
  transform: translateY(0);
}

/* ─────────────────────────────────────────────
   THE MATH ARENA — gamified topbar
   ───────────────────────────────────────────── */

.arena-topbar {
  height: 78px !important;
  padding: 0 18px !important;
  background:
    linear-gradient(180deg, rgba(8,4,18,0.92) 0%, rgba(8,4,18,0.78) 100%) !important;
  border-bottom: 1px solid rgba(255,255,255,0.08) !important;
  display: grid !important;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}

/* LEFT — rank tile */
.arena-rank {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-self: start;
  user-select: none;
}
.rank-tile {
  position: relative;
  width: 54px;
  height: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--rank-color) 35%, #1a0a2c) 0%, color-mix(in srgb, var(--rank-color) 18%, #08040f) 100%);
  border: 1.5px solid var(--rank-color);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.12) inset,
    0 0 18px color-mix(in srgb, var(--rank-glow) 50%, transparent),
    0 4px 12px rgba(0,0,0,0.5);
  font-family: var(--font-display, inherit);
  font-weight: 900;
}
.rank-tile-div {
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  color: rgba(255,255,255,0.65);
  margin-top: 4px;
}
.rank-tile-letter {
  font-size: 1.5rem;
  font-style: italic;
  color: var(--rank-glow);
  text-shadow: 0 0 12px var(--rank-glow);
  line-height: 0.9;
}
.rank-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 130px;
}
.rank-name {
  font-family: var(--font-display, inherit);
  font-weight: 900;
  font-style: italic;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  color: #fff;
}
.rank-bar {
  position: relative;
  display: block;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,0.10);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
}
.rank-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  box-shadow: 0 0 8px rgba(255,255,255,0.45) inset;
  transition: width 380ms ease;
}
.rank-points {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.6);
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}

/* CENTER — official arena title */
.arena-title-wrap {
  text-align: center;
  user-select: none;
  pointer-events: none;
}
.arena-title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.arena-title-bar {
  height: 2px;
  width: 56px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.7));
  position: relative;
}
.arena-title-bar-r {
  background: linear-gradient(90deg, rgba(255,255,255,0.7), transparent);
}
.arena-title-bar::after {
  content: '◆';
  position: absolute;
  top: 50%;
  font-size: 0.55rem;
  color: #ffd87a;
  text-shadow: 0 0 6px rgba(255,210,120,0.8);
  transform: translateY(-50%);
}
.arena-title-bar-l::after { right: -4px; }
.arena-title-bar-r::after { left: -4px; }
.arena-title {
  margin: 0;
  font-family: var(--font-display, inherit);
  font-weight: 900;
  font-style: italic;
  font-size: 1.55rem;
  letter-spacing: 0.06em;
  background: linear-gradient(180deg, #fff5d2 0%, #ffd166 50%, #ff8a5b 100%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 16px rgba(255,210,120,0.45)) drop-shadow(0 2px 0 rgba(0,0,0,0.5));
  white-space: nowrap;
}
.arena-subtitle {
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-display, inherit);
  font-weight: 700;
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  color: rgba(255,255,255,0.6);
}
.arena-sub-pill {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.78);
}
.arena-sub-dot {
  font-size: 0.5rem;
  color: #ff3da6;
  text-shadow: 0 0 6px rgba(255,80,180,0.85);
}
.arena-sub-season {
  color: #ffd87a;
}

/* RIGHT — counter chips */
.arena-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: end;
}
.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.02) 100%);
  border: 1px solid rgba(255,255,255,0.14);
  font-family: var(--font-display, inherit);
  font-weight: 800;
  font-size: 0.78rem;
  color: #fff;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.06);
  transition: transform 160ms ease, border-color 160ms ease;
}
.stat-chip:hover { transform: translateY(-1px); border-color: rgba(255,255,255,0.30); }
.stat-chip .stat-icon {
  font-size: 0.95rem;
  filter: drop-shadow(0 0 4px rgba(255,255,255,0.3));
}
.stat-chip .stat-num {
  letter-spacing: 0.02em;
}
.stat-chip .stat-num-total {
  color: rgba(255,255,255,0.55);
  font-weight: 700;
  font-size: 0.7rem;
  margin-left: 1px;
}
.stat-trophy { border-color: rgba(255,210,120,0.45); }
.stat-trophy .stat-icon { color: #ffd87a; }
.stat-trophy .stat-num  { color: #ffe6b5; }
.stat-cards { border-color: rgba(120,200,255,0.4); }
.stat-cards .stat-icon { color: #a6e1ff; }
.stat-cards .stat-num  { color: #d6efff; }
.stat-streak { border-color: rgba(255,140,80,0.45); }
.stat-streak .stat-icon { color: #ff9a4d; }
.stat-streak .stat-num  { color: #ffd0a8; }
.arena-sound-btn {
  margin-left: 4px;
}

/* PERFECT RUN emblem on theme cards */
.theme-card-perfect {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fff5d2 0%, #ffd166 50%, #ff8a5b 100%);
  color: #2a1206;
  font-family: var(--font-display, inherit);
  font-weight: 900;
  font-style: italic;
  font-size: 0.66rem;
  letter-spacing: 0.10em;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.5) inset,
    0 0 18px rgba(255,210,120,0.7),
    0 4px 12px rgba(0,0,0,0.4);
  pointer-events: none;
  animation: perfect-shimmer 2.5s ease-in-out infinite;
}
@keyframes perfect-shimmer {
  0%, 100% { box-shadow: 0 0 0 1px rgba(255,255,255,0.5) inset, 0 0 14px rgba(255,210,120,0.55), 0 4px 12px rgba(0,0,0,0.4); }
  50%      { box-shadow: 0 0 0 1px rgba(255,255,255,0.6) inset, 0 0 24px rgba(255,210,120,0.95), 0 4px 14px rgba(0,0,0,0.45); }
}
.theme-card.is-perfect {
  border-color: rgba(255,210,120,0.5);
  box-shadow: 0 0 0 1px rgba(255,210,120,0.3), 0 12px 28px rgba(0,0,0,0.5);
}

/* COMBO FLASH — full-screen multiplier banner on streak hit */
.combo-flash {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 180ms ease;
}
.combo-flash.show { opacity: 1; }
.combo-flash.out  { opacity: 0; }
.combo-flash-inner {
  text-align: center;
  transform: scale(0.6) rotate(-4deg);
  animation: combo-pop 0.5s cubic-bezier(0.18, 0.89, 0.32, 1.6) forwards;
}
@keyframes combo-pop {
  to { transform: scale(1) rotate(-4deg); }
}
.combo-flash-streak {
  font-family: var(--font-display, inherit);
  font-weight: 900;
  font-style: italic;
  font-size: 1.6rem;
  letter-spacing: 0.16em;
  color: #ff9a4d;
  text-shadow:
    0 0 18px rgba(255,140,80,0.9),
    0 4px 0 rgba(0,0,0,0.45);
  margin-bottom: 4px;
}
.combo-flash-mult {
  font-family: var(--font-display, inherit);
  font-weight: 900;
  font-style: italic;
  font-size: 4.5rem;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #fff5d2 0%, #ffd166 40%, #ff5b7c 100%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 22px rgba(255,210,120,0.7)) drop-shadow(0 6px 0 rgba(0,0,0,0.55));
}

/* Responsive: collapse arena topbar on narrow screens */
@media (max-width: 900px) {
  .arena-topbar {
    grid-template-columns: 1fr 1fr;
    height: auto !important;
    padding: 8px 12px !important;
  }
  .arena-rank { grid-row: 1; }
  .arena-stats { grid-row: 1; justify-self: end; }
  .arena-title-wrap { grid-column: 1 / -1; grid-row: 2; padding-top: 6px; }
  .arena-title { font-size: 1.3rem; }
  .arena-title-bar { width: 36px; }
  .stat-chip { padding: 5px 9px; font-size: 0.7rem; }
}

/* Phone: tighter topbar, smaller rank tile, hide stat-chip total counter */
@media (max-width: 520px) {
  .arena-topbar {
    padding: 6px 10px !important;
    gap: 8px;
  }
  .rank-tile { width: 42px; height: 42px; }
  .rank-tile-letter { font-size: 1.15rem; }
  .rank-tile-div { font-size: 0.55rem; margin-top: 2px; }
  .rank-info { gap: 1px; }
  .rank-name { font-size: 0.7rem; }
  .rank-bar { height: 4px; }
  .rank-points { font-size: 0.62rem; }
  .arena-title { font-size: 1.05rem; letter-spacing: 0.04em; }
  .arena-title-bar { width: 24px; }
  .arena-subtitle { font-size: 0.6rem; gap: 6px; }
  .arena-sub-pill { padding: 2px 8px; }
  .arena-stats { gap: 4px; }
  .stat-chip { padding: 4px 7px; font-size: 0.62rem; gap: 4px; }
  .stat-chip .stat-icon { font-size: 0.85rem; }
  .arena-sound-btn { width: 30px; height: 30px; font-size: 1rem; }
}

/* Very narrow phones (< 380px) — drop streak chip to save horizontal room */
@media (max-width: 380px) {
  .stat-chip.stat-streak { display: none; }
  .arena-title { font-size: 0.95rem; }
}

/* ============================================
   MATH-TYPE SELECTOR (Matematrix-inspired)
   7-option compact grid, 4 cols on wide screens
   ============================================ */
.config-label-hint {
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: none;
  color: rgba(255,255,255,0.45);
  margin-left: 6px;
  font-size: 0.68rem;
}
.cfg-choices.type-choices {
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.cfg-choice-type {
  padding: 10px 10px 12px;
  gap: 2px;
  min-height: 0;
}
.cfg-choice-type .cfg-choice-badge {
  font-size: 1.3rem;
  margin-bottom: 0;
}
.cfg-choice-type .cfg-choice-name {
  font-size: clamp(0.95rem, 1.6vw, 1.15rem);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-style: normal;
}
.cfg-choice-type .cfg-choice-desc {
  font-size: 0.68rem;
  line-height: 1.3;
  margin-top: 0;
}
/* "Bog-rækkefølge" gets a subtle gold accent so the default reads as the recommended path */
.cfg-choice-type[data-payload="mix"] .cfg-choice-badge {
  color: #ffd87a;
  filter: drop-shadow(0 0 4px rgba(255,216,122,0.4));
}
.cfg-choice-type[data-payload="mix"] {
  border-color: rgba(255,216,122,0.32);
}
.cfg-choice-type[data-payload="mix"].active {
  border-color: #ffd87a;
  box-shadow: 0 0 0 1px #ffd87a, 0 10px 34px rgba(0,0,0,0.55);
}

@media (max-width: 720px) {
  .cfg-choices.type-choices { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 480px) {
  .cfg-choices.type-choices { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   MATCH SETUP — Gaming "loadout / build-your-game" screen
   Replaces the old .config-screen / .config-overlay layout.
   ============================================================ */
.config-screen-v2 {
  position: relative;
  min-height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  color: var(--text);
  isolation: isolate;
  padding-bottom: 110px; /* room for sticky deploy bar */
}

/* Bg already styled by .config-bg/.config-bg-slide rules — overlay tint deepened for contrast */
.config-screen-v2 .config-bg-overlay {
  background:
    linear-gradient(180deg, rgba(8,4,18,0.55) 0%, rgba(8,4,18,0.78) 35%, rgba(8,4,18,0.92) 100%);
}
.config-screen-v2 .config-bg-vignette {
  background: radial-gradient(ellipse 90% 70% at 50% 30%, transparent 0%, rgba(0,0,0,0.55) 100%);
}

/* ── Hero (top): theme name + match meta ─────────────────── */
.match-hero {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 24px 40px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.match-hero-back {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 100px;
  padding: 10px 18px;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background .18s, border-color .18s, color .18s;
}
.match-hero-back:hover {
  background: rgba(0,0,0,0.7);
  border-color: rgba(255,255,255,0.4);
  color: #fff;
}
.match-hero-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  text-align: center;
}
.match-hero-eyebrow {
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 0.64rem;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: rgba(255,216,122,0.85);
  background: rgba(255,216,122,0.08);
  padding: 4px 12px;
  border-radius: 100px;
  border: 1px solid rgba(255,216,122,0.28);
  margin-bottom: 4px;
}
.match-hero-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 900;
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 0.95;
  letter-spacing: 0.01em;
  color: #fff;
  margin: 0;
  text-shadow: 0 2px 0 rgba(0,0,0,0.4), 0 6px 24px rgba(0,0,0,0.7);
}
.match-hero-tagline {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: rgba(255,255,255,0.6);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 2px;
}
.match-hero-stats {
  display: flex;
  gap: 10px;
}
.match-stat {
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 100px;
  backdrop-filter: blur(8px);
}
.match-stat-label {
  font-family: var(--font-ui);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.5);
}
.match-stat-val {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 900;
  font-size: 1.15rem;
  color: #fff;
  letter-spacing: 0.02em;
}
.match-stat-sub {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.5);
  font-weight: 600;
}

/* ── Loadout stack ────────────────────────────────────────── */
.loadout-stack {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 32px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.loadout-slot {
  background: linear-gradient(180deg, rgba(20,12,40,0.72) 0%, rgba(10,6,22,0.82) 100%);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 18px;
  padding: 18px 22px 22px;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  box-shadow: 0 16px 40px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.08);
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.loadout-slot::before {
  content: '';
  position: absolute;
  left: 0; top: 0;
  width: 4px; height: 100%;
  background: linear-gradient(180deg, transparent 0%, rgba(255,255,255,0.12) 50%, transparent 100%);
  opacity: 0.6;
}
.loadout-slot.is-set {
  border-color: rgba(124,227,212,0.42);
  box-shadow: 0 0 0 1px rgba(124,227,212,0.28), 0 16px 40px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.08);
}
.loadout-slot.is-set::before {
  background: linear-gradient(180deg, transparent 0%, var(--accent, #7ce3d4) 50%, transparent 100%);
  opacity: 1;
}

.loadout-slot-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px dashed rgba(255,255,255,0.10);
}
.loadout-num {
  font-family: var(--font-ui);
  font-weight: 900;
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  color: rgba(255,216,122,0.95);
  background: rgba(255,216,122,0.12);
  border: 1px solid rgba(255,216,122,0.32);
  padding: 4px 10px;
  border-radius: 6px;
  font-feature-settings: "tnum";
}
.loadout-cat {
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 0.92rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #fff;
  flex: 1;
}
.loadout-current {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 900;
  font-size: 1rem;
  color: rgba(255,255,255,0.92);
  letter-spacing: 0.02em;
  background: rgba(0,0,0,0.4);
  padding: 4px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.12);
}
.loadout-slot.is-set .loadout-current {
  color: var(--accent, #7ce3d4);
  border-color: rgba(124,227,212,0.45);
  background: rgba(124,227,212,0.08);
}

/* ── Tile grids ──────────────────────────────────────────── */
.loadout-tiles {
  display: grid;
  gap: 10px;
}
.loadout-tiles.four-up  { grid-template-columns: repeat(4, 1fr); }
.loadout-tiles.three-up { grid-template-columns: repeat(3, 1fr); }
.loadout-tiles.seven-up { grid-template-columns: repeat(7, 1fr); }

/* ── Loadout tile (individual option) ────────────────────── */
.loadout-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  padding: 14px 10px 14px;
  background: rgba(8,4,18,0.7);
  border: 1.5px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  color: #fff;
  font-family: var(--font-ui);
  transition: transform .14s, background .18s, border-color .18s, box-shadow .18s;
  overflow: hidden;
  min-height: 92px;
}
.loadout-tile::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.04) 0%, transparent 50%);
  pointer-events: none;
}
.loadout-tile:hover {
  background: rgba(22,14,42,0.9);
  border-color: rgba(255,255,255,0.32);
  transform: translateY(-1px);
}
.loadout-tile.active {
  background: linear-gradient(180deg, rgba(124,227,212,0.18) 0%, rgba(22,14,42,0.95) 60%);
  border-color: var(--accent, #7ce3d4);
  box-shadow: 0 0 0 1px var(--accent, #7ce3d4), 0 10px 28px rgba(124,227,212,0.18);
}
.loadout-tile.active::after {
  content: '✓';
  position: absolute;
  top: 6px; right: 8px;
  font-size: 0.68rem;
  font-weight: 900;
  color: var(--accent, #7ce3d4);
  background: rgba(0,0,0,0.55);
  width: 18px; height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--accent, #7ce3d4);
}
.lo-tile-rank {
  font-size: 1.3rem;
  letter-spacing: 0.04em;
  color: #ffd87a;
  filter: drop-shadow(0 0 6px rgba(255,216,122,0.35));
  margin-bottom: 2px;
}
.lo-tile-name {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 900;
  font-size: clamp(0.95rem, 1.6vw, 1.25rem);
  letter-spacing: 0.02em;
  color: #fff;
  line-height: 1;
}
.lo-tile-meta {
  font-family: var(--font-ui);
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  color: rgba(255,255,255,0.6);
  line-height: 1.35;
  margin-top: 2px;
}
.loadout-tile.active .lo-tile-meta {
  color: rgba(255,255,255,0.85);
}

/* "Random" math-type tile gets a special chaos shimmer */
.lo-tile-type.is-random .lo-tile-rank {
  background: linear-gradient(135deg, #ff5b7c 0%, #ffd87a 50%, #7ce3d4 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 8px rgba(255,216,122,0.45));
}
.lo-tile-type.is-random {
  border-color: rgba(255,216,122,0.32);
}
.lo-tile-type.is-random.active {
  background: linear-gradient(180deg, rgba(255,216,122,0.18) 0%, rgba(22,14,42,0.95) 60%);
  border-color: #ffd87a;
  box-shadow: 0 0 0 1px #ffd87a, 0 10px 28px rgba(255,216,122,0.22);
}
.lo-tile-type.is-random.active::after {
  color: #ffd87a;
  border-color: #ffd87a;
}

/* ── Sticky deploy footer ────────────────────────────────── */
.match-deploy {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 14px 32px;
  background: linear-gradient(180deg, rgba(8,4,18,0.78) 0%, rgba(8,4,18,0.96) 100%);
  border-top: 1px solid rgba(255,255,255,0.10);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  box-shadow: 0 -8px 32px rgba(0,0,0,0.5);
}
.match-deploy-summary {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.match-deploy-label {
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 0.62rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: rgba(255,216,122,0.85);
}
.match-deploy-build {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 900;
  font-size: 1.05rem;
  color: #fff;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.match-deploy-sep {
  color: rgba(255,255,255,0.3);
  margin: 0 6px;
  font-style: normal;
}
.match-deploy-flavor {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.deploy-btn {
  font-family: var(--font-ui);
  font-weight: 900;
  font-size: 0.95rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 16px 32px;
  border-radius: 100px;
  border: 1.5px solid rgba(255,255,255,0.16);
  background: rgba(0,0,0,0.5);
  color: rgba(255,255,255,0.55);
  cursor: not-allowed;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  transition: transform .14s, box-shadow .2s, background .2s, border-color .2s, color .2s;
  min-width: 220px;
  justify-content: center;
}
.deploy-btn-arrow {
  font-size: 1.2rem;
  letter-spacing: 0;
}
.deploy-btn.ready {
  cursor: pointer;
  background: linear-gradient(135deg, #ffd87a 0%, #ff5b7c 100%);
  border-color: #ffd87a;
  color: #1a0a2a;
  box-shadow: 0 0 0 1px rgba(255,216,122,0.5), 0 8px 28px rgba(255,91,124,0.45), 0 0 32px rgba(255,216,122,0.4);
  animation: deploy-pulse 1.6s ease-in-out infinite;
}
.deploy-btn.ready:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 0 0 1px #ffd87a, 0 12px 36px rgba(255,91,124,0.55), 0 0 44px rgba(255,216,122,0.55);
}
@keyframes deploy-pulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(255,216,122,0.5), 0 8px 28px rgba(255,91,124,0.45), 0 0 32px rgba(255,216,122,0.4); }
  50%      { box-shadow: 0 0 0 1px rgba(255,216,122,0.7), 0 10px 32px rgba(255,91,124,0.55), 0 0 44px rgba(255,216,122,0.6); }
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1000px) {
  .loadout-tiles.seven-up { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 760px) {
  .match-hero {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: 12px;
    padding: 18px 18px 14px;
  }
  .match-hero-back { justify-self: start; }
  .match-hero-stats { justify-self: stretch; justify-content: space-between; }
  .loadout-stack { padding: 18px 14px 12px; gap: 14px; }
  .loadout-slot { padding: 14px 16px 16px; }
  .loadout-slot-head { gap: 10px; flex-wrap: wrap; }
  .loadout-tiles.four-up  { grid-template-columns: repeat(2, 1fr); }
  .loadout-tiles.three-up { grid-template-columns: repeat(3, 1fr); }
  .loadout-tiles.seven-up { grid-template-columns: repeat(3, 1fr); }
  .match-deploy {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px 16px;
  }
  .deploy-btn { width: 100%; }
}
@media (max-width: 480px) {
  .match-hero-title { font-size: 1.8rem; }
  .loadout-tiles.seven-up { grid-template-columns: repeat(2, 1fr); }
  .lo-tile-meta { font-size: 0.62rem; }
}

/* Complete-screen mode chips: which build did you just finish? */
.complete-mode-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 6px;
}
.complete-mode-chip {
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.92);
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 100px;
  padding: 6px 14px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.complete-score-panel.new-highscore .complete-mode-chip {
  border-color: rgba(255,216,122,0.55);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(255,216,122,0.25);
}
