/* ============================================
   AP INTERACTIVE — Global Stylesheet
   Aesthetic: Educational Dark Luxury
   Fonts & theme colors are injected by PHP
   via getThemeHeadHTML() — see includes/theme.php
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Figtree:wght@700;800;900&family=Nunito:wght@400;600;700;800&display=swap');

/* ── Shorai Sans — variable font (single file covers all weights 100–900) ── */
@font-face {
  font-family: 'Shorai Sans';
  src: url('../fonts/ShoraiSansStdNVar.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ── CSS Variable Fallback Defaults ── */
/* These are overridden at runtime by the PHP-injected <style> block */
:root {
  --bg-deep: #1a2744;
  --bg-panel: #f0ebe0;
  --bg-card: #faf6ee;
  --bg-card-hover: #f0ead8;
  --border: rgba(201, 120, 10, 0.18);
  --border-bright: rgba(201, 120, 10, 0.45);
  --gold: #c9780a;
  --gold-light: #e8a030;
  --gold-dim: #7a4808;
  --gold-bright: #f0b840;
  --rose: #4a7a2e;
  --teal: #2d6a8f;
  --text-primary: #2c2416;
  --text-secondary: #6b5c44;
  --text-dim: #4d618c;
  --gem-blue: #2d6a8f;
  --ticket-amber: #e8a43a;
  --danger: #c0392b;
  --success: #27ae60;

  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Source Serif 4', Georgia, serif;
  --font-ui: 'DM Sans', sans-serif;
  --font-display-weight: normal;
  --font-body-weight: normal;
  --font-ui-weight: normal;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(201, 160, 48, 0.15);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  /* Computed by PHP theme injection; fallbacks defined here */
  --navbar-bg: rgba(26, 39, 68, 0.97);
  --bg-deep-98: rgba(26, 39, 68, 0.98);
  --bg-deep-92: rgba(26, 39, 68, 0.92);
  --primary-08: rgba(201, 120, 10, 0.08);
  --primary-10: rgba(201, 120, 10, 0.10);
  --primary-15: rgba(201, 120, 10, 0.15);
  --primary-20: rgba(201, 120, 10, 0.40);
  --primary-30: rgba(201, 120, 10, 0.30);
  --primary-50: rgba(201, 120, 10, 0.50);
  --primary-70: rgba(201, 120, 10, 0.70);
  --primary-80: rgba(201, 120, 10, 0.80);
  --primary-90: rgba(201, 120, 10, 0.90);
  --secondary-06: rgba(74, 122, 46, 0.06);
  --accent-05: rgba(45, 106, 143, 0.05);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text-primary);
  font-size: 1.05rem;
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--gold);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--gold-dim);
}

img {
  max-width: 100%;
  display: block;
}

button {
  cursor: pointer;
  font-family: var(--font-ui);
}

input,
textarea,
select {
  font-family: var(--font-ui);
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-deep);
}

::-webkit-scrollbar-thumb {
  background: var(--gold-dim);
  border-radius: 3px;
}

/* ── Noise texture overlay ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: 0.4;
}

/* ══════════════════════════════════════
   NAVIGATION
══════════════════════════════════════ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--navbar-bg);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  height: 64px;
}

.nav-logo {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: 0.05em;
  margin-right: auto;
}

.nav-logo span {
  font-style: italic;
  color: #fff;
}

.nav-links {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.nav-link {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.nav-link.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.nav-currency {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.3rem 0.9rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 99px;
}

.currency-item {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.currency-item.gems {
  color: var(--gem-blue);
}

.currency-item.tickets {
  color: var(--ticket-amber);
}

.nav-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--gold-dim);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: border-color var(--transition);
}

.nav-avatar {
  cursor: pointer;
}

.nav-avatar:hover {
  border-color: var(--gold);
}

/* Dropdown - Clickable */
.nav-user-menu {
  position: relative;
}

.nav-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 3px solid #4aaa46;
  border-radius: 16px;
  padding: 0.45rem;
  min-width: 210px;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.15), 0 12px 28px rgba(0, 0, 0, 0.14);
  z-index: 1000;
  animation: dropdownSlideIn 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-dropdown.active {
  display: block;
}

@keyframes dropdownSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.nav-dropdown a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 0.85rem;
  font-family: 'Nunito', sans-serif;
  font-size: 0.88rem;
  font-weight: 800;
  color: #1a3a0d;
  text-decoration: none;
  border-radius: 10px;
  transition: background 0.13s, color 0.13s, padding-left 0.13s;
  border-bottom: none;
}

.nav-dropdown a:last-child {
  border-bottom: none;
}

.nav-dropdown a:first-child {
  border-radius: 10px;
}

.nav-dropdown a:last-child {
  border-radius: 10px;
}

.nav-dropdown a:hover {
  background: #e8f8e0;
  color: #2d7a2a;
  padding-left: 1.1rem;
}

.nav-dropdown hr {
  border: none;
  border-top: 2px solid rgba(74, 170, 70, 0.2);
  margin: 0.3rem 0.4rem;
}

/* ══════════════════════════════════════
   BUTTONS
══════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.5rem;
  transition: all var(--transition);
  cursor: pointer;
  text-decoration: none;
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: #0d0a04;
}

.btn-gold:hover {
  background: linear-gradient(135deg, var(--gold-light), var(--gold-bright));
  box-shadow: 0 4px 16px var(--primary-20);
  color: #0d0a04;
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-bright);
  color: var(--gold);
}

.btn-outline:hover {
  background: var(--primary-08);
  border-color: var(--gold);
  color: var(--gold-light);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #e74c3c;
}

.btn-lg {
  padding: 0.85rem 2rem;
  font-size: 0.85rem;
}

.btn-sm {
  padding: 0.4rem 0.9rem;
  font-size: 0.72rem;
}

/* ══════════════════════════════════════
   CARDS
══════════════════════════════════════ */
.story-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition);
  cursor: pointer;
  position: relative;
}

.story-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-bright);
  box-shadow: var(--shadow-card), var(--shadow-glow);
}

.story-cover {
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  position: relative;
  overflow: hidden;
}

.story-cover::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 30%, rgba(0, 0, 0, 0.7));
}

.story-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  z-index: 1;
}

.badge-featured {
  background: var(--gold);
  color: #0d0a04;
}

.badge-genre {
  top: auto;
  bottom: 10px;
  right: 10px;
  left: auto;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.story-info {
  padding: 1rem 1.2rem 1.2rem;
}

.story-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
  line-height: 1.3;
}

.story-author {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

.story-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 0.8rem;
}

.story-meta {
  display: flex;
  gap: 1rem;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

/* ══════════════════════════════════════
   GRID LAYOUTS
══════════════════════════════════════ */
.page-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.stories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.2rem;
}

.section-header {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--text-primary);
}

.section-sub {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* ══════════════════════════════════════
   FORMS
══════════════════════════════════════ */
.form-group {
  margin-bottom: 1.2rem;
}

.form-label {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.form-control {
  width: 100%;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.7rem 1rem;
  font-size: 0.95rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 3px var(--primary-08);
}

.form-control::placeholder {
  color: var(--text-dim);
}

textarea.form-control {
  resize: vertical;
  min-height: 100px;
}

select.form-control option {
  background: var(--bg-panel);
}

/* ══════════════════════════════════════
   ALERTS / FLASH MESSAGES
══════════════════════════════════════ */
.alert {
  padding: 0.8rem 1.2rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  border-left: 3px solid;
}

.alert-error {
  background: rgba(192, 57, 43, 0.12);
  border-color: var(--danger);
  color: #e74c3c;
}

.alert-success {
  background: rgba(39, 174, 96, 0.12);
  border-color: var(--success);
  color: #2ecc71;
}

.alert-info {
  background: rgba(74, 144, 217, 0.12);
  border-color: var(--gem-blue);
  color: var(--gem-blue);
}

/* ══════════════════════════════════════
   HERO BANNER
══════════════════════════════════════ */
.hero {
  position: relative;
  padding: 5rem 2rem 4rem;
  text-align: center;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, var(--primary-08) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 20% 80%, var(--secondary-06) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 80% 80%, var(--accent-05) 0%, transparent 60%);
  pointer-events: none;
}

.hero-eyebrow {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.8rem;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 700;
  line-height: 1.1;
  background: linear-gradient(135deg, var(--text-primary), var(--gold-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
}

.hero-sub {
  font-size: 1.15rem;
  color: var(--text-secondary);
  max-width: 520px;
  margin: 0 auto 2rem;
  font-weight: 300;
  letter-spacing: 0.02em;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ══════════════════════════════════════
   GENRE FILTER PILLS
══════════════════════════════════════ */
.genre-filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.genre-pill {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.35rem 0.9rem;
  border-radius: 99px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  transition: all var(--transition);
}

.genre-pill:hover,
.genre-pill.active {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--primary-08);
}

/* ══════════════════════════════════════
   GAME ENGINE STYLES
   Portrait / Story-style layout
══════════════════════════════════════ */

/* Same width cap as admin/episode-editor.php .ed-canvas-wrap.bg-preview-desktop */
:root {
  --ep-story-portrait-max-w: 800px;
  /* Episode editor canvas only (real chrome). Not used on game.php — see --ep-story-player-chrome-h */
  --ep-story-editor-chrome-h: 164px;
  /* game.php desktop frame: tiny inset only (no editor UI). Taller frame ⇒ wider at 9:16 */
  --ep-story-player-chrome-h: 36px;
}

/* Dark backdrop behind the portrait frame */
body.game-page {
  margin: 0;
  padding: 0;
  background: #0a0a0f;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  overflow: hidden;
}

body.game-page::before {
  display: none;
}

/* The portrait phone-frame wrapper */
.game-frame {
  position: relative;
  width: 100%;
  max-width: 420px;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  border-radius: 0;
  box-shadow: none;
}

/* Mobile browser UI safe viewport support (Chrome/Safari address/tab bars) */
@supports (height: 100dvh) {
  body.game-page { min-height: 100dvh; }
  .game-frame { height: 100dvh; max-height: 100dvh; }
}
@supports (height: 100svh) {
  /* Prefer small viewport to avoid bottom UI being covered */
  .game-frame { height: 100svh; max-height: 100svh; }
}

/*
 * Wide screens: 9:16 portrait frame. Uses --ep-story-player-chrome-h (not editor chrome) so the play
 * view is taller and reads wider; episode editor preview still uses its real UI height (164px).
 */
@media (min-width: 481px) {
  .game-frame {
    flex-shrink: 0;
    width: auto;
    height: calc(100vh - var(--ep-story-player-chrome-h));
    max-height: calc(100vh - var(--ep-story-player-chrome-h));
    aspect-ratio: 9 / 12;
    max-width: min(
      var(--ep-story-portrait-max-w),
      calc((100vh - var(--ep-story-player-chrome-h)) * 9 / 12)
    );
    border-radius: 24px;

    box-shadow:
      0 0 0 3px rgba(255, 255, 255, 0.08),
      0 20px 60px rgba(0, 0, 0, 0.6),
      0 0 120px rgba(92, 200, 87, 0.06);
  }
}

/* Prefer dynamic viewport on desktop too (overrides 100vh block above when supported) */
@supports (height: 100dvh) {
  @media (min-width: 481px) {
    .game-frame {
      height: calc(100dvh - var(--ep-story-player-chrome-h));
      max-height: calc(100dvh - var(--ep-story-player-chrome-h));
      max-width: min(
        var(--ep-story-portrait-max-w),
        calc((100dvh - var(--ep-story-player-chrome-h)) * 9 / 12)
      );
    }
  }
}

.game-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: #000;
  overflow: hidden;
}

/* Background scenes — outer fades; inner holds image + transforms + motion */
.scene-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  transition: opacity 0.35s ease;
  overflow: hidden;
}

.scene-bg-fill {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
}

.scene-bg-fill.scene-bg-custom {
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center center;
}

/* Position-based presets use --bg-pos-x / --bg-pos-y set from JS (user framing). */
@keyframes ep-bg-pan-slow {
  0%,
  100% {
    background-position: calc(var(--bg-pos-x, 50%) - 7%) calc(var(--bg-pos-y, 0%) - 4%);
  }
  50% {
    background-position: calc(var(--bg-pos-x, 50%) + 7%) calc(var(--bg-pos-y, 0%) + 4%);
  }
}

@keyframes ep-bg-pan-vertical {
  0%,
  100% {
    background-position: var(--bg-pos-x, 50%) calc(var(--bg-pos-y, 0%) - 6%);
  }
  50% {
    background-position: var(--bg-pos-x, 50%) calc(var(--bg-pos-y, 0%) + 6%);
  }
}

@keyframes ep-bg-drift {
  0%,
  100% {
    background-position: calc(var(--bg-pos-x, 50%) - 3%) calc(var(--bg-pos-y, 0%) - 2.5%);
  }
  33% {
    background-position: calc(var(--bg-pos-x, 50%) + 4%) calc(var(--bg-pos-y, 0%) - 3%);
  }
  66% {
    background-position: calc(var(--bg-pos-x, 50%) + 2%) calc(var(--bg-pos-y, 0%) + 3.5%);
  }
}

@keyframes ep-bg-breathe {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.93;
  }
}

@keyframes ep-bg-shimmer {
  0%,
  100% {
    filter: brightness(1) saturate(1);
  }
  50% {
    filter: brightness(1.08) saturate(1.04);
  }
}

/* --bg-anim-speed: unitless multiplier on “slowness”; higher = faster (duration = base / speed). Set from editor / game JS. */
.scene-bg-fill.bg-anim-pan-slow,
.ed-bg.bg-anim-pan-slow {
  animation-name: ep-bg-pan-slow;
  animation-duration: calc(12s / var(--bg-anim-speed, 1));
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-direction: alternate;
}

.scene-bg-fill.bg-anim-pan-vertical,
.ed-bg.bg-anim-pan-vertical {
  animation-name: ep-bg-pan-vertical;
  animation-duration: calc(10s / var(--bg-anim-speed, 1));
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-direction: alternate;
}

.scene-bg-fill.bg-anim-drift,
.ed-bg.bg-anim-drift {
  animation-name: ep-bg-drift;
  animation-duration: calc(18s / var(--bg-anim-speed, 1));
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}

.scene-bg-fill.bg-anim-breathe,
.ed-bg.bg-anim-breathe {
  animation-name: ep-bg-breathe;
  animation-duration: calc(2.2s / var(--bg-anim-speed, 1));
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}

.scene-bg-fill.bg-anim-shimmer,
.ed-bg.bg-anim-shimmer {
  animation-name: ep-bg-shimmer;
  animation-duration: calc(1.8s / var(--bg-anim-speed, 1));
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}

@media (prefers-reduced-motion: reduce) {
  .scene-bg-fill[class*='bg-anim-'],
  .ed-bg[class*='bg-anim-'] {
    animation: none !important;
  }
}

/* Gradient fallbacks (shown while image loads or if image missing) */
.bg-park {
  background-color: #0d2b1a;
  background-image: url('../images/backgrounds/park.svg');
}

.bg-manor_exterior {
  background-color: #0a0f1a;
  background-image: url('../images/backgrounds/manor_exterior.svg');
}

.bg-manor_hall {
  background-color: #15100a;
  background-image: url('../images/backgrounds/manor_hall.svg');
}

.bg-dark_road {
  background-color: #050508;
  background-image: url('../images/backgrounds/dark_road.svg');
}

.bg-city {
  background-color: #0a0a18;
  background-image: url('../images/backgrounds/city.svg');
}

.bg-coffee_shop {
  background-color: #1a1208;
  background-image: url('../images/backgrounds/coffee_shop.svg');
}

.bg-beach {
  background-color: #0a1a2e;
  background-image: url('../images/backgrounds/beach.svg');
}

/* ── Agos ng Pagbabago Backgrounds ── */
.bg-coastal_town {
  background-color: #87CEEB;
  background-image: url('../images/backgrounds/coastal_town.svg');
}

.bg-sari_sari_store {
  background-color: #F5ECD5;
  background-image: url('../images/backgrounds/sari_sari_store.svg');
}

.bg-estero_canal {
  background-color: #CDE8F5;
  background-image: url('../images/backgrounds/estero_canal.svg');
}

.bg-typhoon_night {
  background-color: #0A0A18;
  background-image: url('../images/backgrounds/typhoon_night.svg');
}

.bg-evacuation_center {
  background-color: #D8CEB8;
  background-image: url('../images/backgrounds/evacuation_center.svg');
}

.bg-flooded_street {
  background-color: #5A6878;
  background-image: url('../images/backgrounds/flooded_street.svg');
}

.bg-ruined_town {
  background-color: #8A9AA8;
  background-image: url('../images/backgrounds/ruined_town.svg');
}

.bg-community_hall {
  background-color: #EEE8D8;
  background-image: url('../images/backgrounds/community_hall.svg');
}

.bg-mountain_view {
  background-color: #87CEEB;
  background-image: url('../images/backgrounds/mountain_view.svg');
}

/* Character display */
.character-area {
  position: absolute;
  top: 55px;
  left: 0;
  right: 0;
  bottom: 180px;
  z-index: 1;
  pointer-events: none;
  overflow: visible;
}

.character-sprite {
  position: absolute;
  bottom: 0;
  transform: translateX(-50%);
  width: 200px;
  height: 375px;
  transition: opacity 0.4s ease;
  /* transform is set inline (x/y/scale) */
  animation: none;
}

@keyframes characterEntrance {
  from {
    transform: translateX(-50%) translateY(24px) scale(0.96);
    opacity: 0;
  }

  to {
    transform: translateX(-50%) translateY(0) scale(1);
    opacity: 1;
  }
}

.char-body {
  width: 100%;
  height: 100%;
  border-radius: 60% 60% 0 0 / 50% 50% 0 0;
  position: relative;
  overflow: hidden;
}

/* NPC character image */
.npc-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
  display: block;
  filter: drop-shadow(0 4px 20px rgba(0, 0, 0, 0.6));
}

/* Player avatar image — matches NPC sizing */
#playerAvatar,
.player-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
  display: block;
  filter: drop-shadow(0 4px 20px rgba(0, 0, 0, 0.6));
}

/* Dialogue box */
.dialogue-box {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, var(--bg-deep-98) 0%, var(--bg-deep-92) 100%);
  border-top: 1px solid var(--border);
  padding: 1rem 1.4rem 1.2rem;
  padding-bottom: calc(1.2rem + env(safe-area-inset-bottom));
  z-index: 10;
  min-height: 170px;
}

.speaker-name {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
  text-shadow: 0 0 20px var(--primary-20);
}

.dialogue-text {
  font-family: var(--font-body);
  font-size: 1.1rem;
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 52px;
}

.dialogue-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--gold);
  margin-left: 2px;
  animation: blink 0.8s step-end infinite;
  vertical-align: text-bottom;
}

@keyframes blink {

  0%,
  100% {
    opacity: 1
  }

  50% {
    opacity: 0
  }
}

.tap-prompt {
  position: absolute;
  bottom: calc(1.2rem + env(safe-area-inset-bottom));
  right: 1.8rem;
  font-family: var(--font-ui);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-dim);
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 0.4
  }

  50% {
    opacity: 1
  }
}

/* Choice panel */
.choice-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, var(--bg-deep-98), var(--bg-deep-92));
  border-top: 1px solid var(--border);
  padding: 1.5rem 1.8rem 2rem;
  padding-bottom: calc(2rem + env(safe-area-inset-bottom));
  z-index: 10;
}

.choice-label {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 1rem;
}

.choice-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.2rem;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 0.6rem;
}

.choice-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-bright);
  transform: translateX(4px);
}

.choice-btn.gem-choice {
  border-color: rgba(74, 144, 217, 0.3);
}

.choice-btn.gem-choice:hover {
  border-color: var(--gem-blue);
}

.gem-cost {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gem-blue);
  background: rgba(74, 144, 217, 0.12);
  border: 1px solid rgba(74, 144, 217, 0.25);
  padding: 0.25rem 0.7rem;
  border-radius: 99px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Game UI overlay */
.game-ui-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 0.6rem 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent);
  z-index: 20;
}

.game-episode-title {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-style: italic;
  color: var(--text-secondary);
  margin-right: auto;
}

.game-btn {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 0.35rem 0.8rem;
  font-family: var(--font-ui);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all var(--transition);
}

.game-btn:hover {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

/* End of episode screen */
.episode-end {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, var(--bg-card) 0%, var(--bg-deep) 70%);
  z-index: 30;
  text-align: center;
  padding: 2rem;
  animation: fadeIn 0.8s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0
  }

  to {
    opacity: 1
  }
}

.end-ornament {
  font-size: 3rem;
  margin-bottom: 1.5rem;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0)
  }

  50% {
    transform: translateY(-10px)
  }
}

.end-title {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-style: italic;
  color: var(--gold-light);
  margin-bottom: 0.5rem;
}

.end-sub {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 1.25rem;
}

/* ── Episode end reward box ── */
.end-reward-box {
  border: 2px solid var(--gold);
  border-radius: var(--radius-md);
  padding: 1rem 2rem;
  text-align: center;
  margin: 0.5rem 0 1rem;
  animation: fadeIn 0.6s ease;
  min-width: 220px;
}

.end-reward-box.tier-silver {
  border-color: #9e9e9e;
}

.end-reward-box.tier-none {
  border-color: var(--border);
  opacity: 0.75;
}

.end-reward-icon {
  font-size: 2.2rem;
  line-height: 1;
  margin-bottom: 0.4rem;
}

.end-reward-xp {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--gold-bright);
  letter-spacing: 0.02em;
}

.tier-silver .end-reward-xp {
  color: #bdbdbd;
}

.tier-none .end-reward-xp {
  color: var(--text-secondary);
  font-size: 1.4rem;
}

.end-reward-msg {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 0.35rem;
  line-height: 1.4;
}

/* ══════════════════════════════════════
   CHARACTER CUSTOMIZATION  (v2 — mobile-first)
══════════════════════════════════════ */

/* ── Root layout ── */
.cust-page {
  background: var(--bg-panel);
}

.cust-root {
  display: flex;
  min-height: calc(100vh - 64px);
  align-items: flex-start;
}

/* ── Sidebar (avatar preview) ── */
.cust-sidebar {
  width: 280px;
  flex-shrink: 0;
  /* background: var(--bg-deep); */
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 1.75rem 1.25rem 1.5rem;
  gap: 0.75rem;
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.cust-avatar-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  min-height: 0;
}

.cust-preview-label {
  font-family: var(--font-ui);
  font-size: 0.58rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.75;
  margin-bottom: 0.25rem;
}

.cust-avatar-figure {
  width: 160px;
  height: 256px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 10px 28px rgba(0, 0, 0, 0.55));
}

.cust-avatar-figure svg {
  width: 100%;
  height: 100%;
}

.cust-avatar-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  text-align: center;
  margin-top: 0.25rem;
  line-height: 1.2;
}

.cust-avatar-handle {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.38);
  letter-spacing: 0.07em;
}

.cust-level-pill {
  background: var(--gold-dim);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.22rem 0.8rem;
  border-radius: 999px;
  margin-top: 0.1rem;
}

.cust-sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.cust-sidebar-actions .btn {
  justify-content: center;
  width: 100%;
}

/* ── Main content ── */
.cust-main {
  flex: 1;
  min-width: 0;
  padding: 2rem 2rem 6rem;
  overflow-y: auto;
}

.cust-main-header {
  margin-bottom: 1.75rem;
}

.cust-main-header h1 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.15;
}

.cust-main-header p {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-top: 0.3rem;
}

.cust-alert {
  margin-bottom: 1.5rem;
}

/* ── Section cards ── */
.cust-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.cust-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

.cust-card:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

.cust-card-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(201, 120, 10, 0.04);
}

.cust-card-icon {
  font-size: 1rem;
  line-height: 1;
}

.cust-card-title {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold);
}

.cust-card-body {
  padding: 1.25rem;
}

/* ── Gender selector ── */
.cust-gender-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.cust-gender-opt {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  background: var(--bg-panel);
  user-select: none;
  text-align: center;
}

.cust-gender-opt:hover {
  border-color: var(--gold);
  background: var(--primary-08);
}

.cust-gender-opt.active {
  border-color: var(--gold);
  background: var(--primary-10);
  box-shadow: 0 0 0 3px var(--primary-08);
}

.cust-gender-opt input[type="radio"] {
  display: none;
}

.cgo-emoji {
  font-size: 2.2rem;
  line-height: 1;
}

.cgo-label {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-primary);
}

.cgo-desc {
  font-size: 0.68rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ── Swatch rows (skin / hair / eye) ── */
.cust-swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

.cust-swatch {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  flex-shrink: 0;
  position: relative;
}

.cust-swatch:hover {
  transform: scale(1.12);
}

.cust-swatch.active {
  border-color: var(--gold);
  transform: scale(1.15);
  box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 5px var(--gold);
}

.cust-swatch.active::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
  font-weight: 800;
}

/* Eye swatches — pill shape */
.cust-eye-swatch {
  width: 52px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
  flex-shrink: 0;
  position: relative;
}

.cust-eye-swatch:hover {
  transform: scale(1.08);
}

.cust-eye-swatch.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--gold);
}

/* ── Color picker row (custom color) ── */
.cust-picker-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.cust-picker-label {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.cust-picker-swatch {
  width: 44px;
  height: 36px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
  padding: 2px;
  flex-shrink: 0;
}

.cust-picker-hex {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

/* ── Extras section ── */
.cust-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0;
  margin-bottom: 1.25rem;
}

.cust-toggle-label {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--text-primary);
}

.cust-subsection-label {
  font-family: var(--font-ui);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

.cust-acc-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
}

.cust-acc-opt {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease;
  background: var(--bg-panel);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--text-secondary);
  user-select: none;
  text-align: center;
}

.cust-acc-opt:hover {
  border-color: var(--gold);
  background: var(--primary-08);
  color: var(--gold);
}

.cust-acc-opt.active {
  border-color: var(--gold);
  background: var(--primary-10);
  color: var(--gold);
  font-weight: 700;
}

.cust-acc-opt input[type="radio"] {
  display: none;
}

.cust-acc-icon {
  font-size: 1.5rem;
  line-height: 1;
}

/* ── Form footer (inside form, visible on tablet+) ── */
.cust-form-footer {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding-top: 0.5rem;
}

/* ── Mobile: sticky bottom save bar ── */
.cust-mobile-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--bg-deep);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.75rem 1.25rem;
  padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
  gap: 0.75rem;
  align-items: center;
}

.cust-mobile-bar .btn {
  flex: 1;
  justify-content: center;
}

/* ── Mobile avatar strip (compact top preview) ── */
.cust-mobile-preview {
  display: none;
  background: var(--bg-deep);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 1rem 1.25rem;
  gap: 1rem;
  align-items: center;
}

.cust-mobile-preview-fig {
  width: 72px;
  height: 116px;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
}

.cust-mobile-preview-fig svg {
  width: 100%;
  height: 100%;
}

.cust-mobile-preview-info {
  flex: 1;
  min-width: 0;
}

.cust-mobile-preview-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cust-mobile-preview-handle {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 0.1rem;
}

.cust-mobile-preview-level {
  display: inline-block;
  background: var(--gold-dim);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.18rem 0.65rem;
  border-radius: 999px;
  margin-top: 0.4rem;
}

.cust-mobile-preview-tap {
  font-family: var(--font-ui);
  font-size: 0.65rem;
  color: var(--gold);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Blush / toggle component (shared) ── */
.blush-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.blush-toggle {
  position: relative;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.blush-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.blush-toggle .toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--bg-panel);
  border: 2px solid var(--border);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.blush-toggle input:checked+.toggle-track {
  background: var(--gold);
  border-color: var(--gold-dim);
}

.blush-toggle .toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.blush-toggle input:checked+.toggle-track::after {
  transform: translateX(22px);
}

.blush-label {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* ── Legacy aliases (keep for backward compat) ── */
.customize-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 0;
  min-height: calc(100vh - 64px);
}

.avatar-preview-wrap {
  background: var(--bg-deep);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
}

.avatar-preview-figure {
  width: 175px;
  height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-preview-figure svg {
  width: 100%;
  height: 100%;
}

.color-swatch {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
  position: relative;
}

.color-swatch:hover {
  transform: scale(1.12);
}

.color-swatch.active {
  border-color: var(--gold);
  transform: scale(1.15);
  box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--gold);
}

.color-swatch.active::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  font-weight: 700;
}

.eye-swatch {
  width: 42px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
}

.eye-swatch.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--gold);
}

.swatch-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.accessory-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.accessory-option {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  background: var(--bg-card);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--text-secondary);
  user-select: none;
}

.accessory-option.active {
  border-color: var(--gold);
  background: var(--primary-10);
  color: var(--gold);
}

.accessory-option input[type="radio"] {
  display: none;
}

.accessory-option .acc-icon {
  font-size: 1.2rem;
}

.style-option {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-secondary);
  background: var(--bg-card);
}

.style-option:hover,
.style-option.active {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--primary-08);
}

/* ── Avatar preview panel (left sticky column) ── */
.avatar-preview-wrap {
  background: var(--bg-deep);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow: hidden;
}

.avatar-preview-wrap .preview-label {
  font-family: var(--font-ui);
  font-size: 0.65rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.8;
}

.avatar-preview-figure {
  width: 175px;
  height: 280px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.5));
}

.avatar-preview-figure svg {
  width: 100%;
  height: 100%;
}

.avatar-preview-name {
  font-family: var(--font-display);
  font-size: 1rem;
  color: #fff;
  text-align: center;
}

.avatar-preview-meta {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 0.08em;
  text-align: center;
}

/* Legacy alias kept for backward compat */
.character-preview-panel {
  padding: 2rem 1.5rem;
}

.preview-character {
  width: 160px;
  height: 280px;
  position: relative;
  margin: 1.5rem auto;
}

.preview-layer {
  position: absolute;
  inset: 0;
  border-radius: 50% 50% 0 0 / 40% 40% 0 0;
}

/* ── Customize options panel (right scrollable column) ── */
.customize-panel {
  padding: 2rem 2.5rem;
  overflow-y: auto;
  background: var(--bg-panel);
}

.customize-page-title {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.customize-page-sub {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

/* ── Section ── */
.customize-category {
  margin-bottom: 2rem;
}

.category-title {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.45rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* ── Gender toggle ── */
.gender-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  max-width: 380px;
}

.gender-option {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--bg-card);
  user-select: none;
}

.gender-option:hover {
  border-color: var(--gold);
  background: var(--primary-08);
}

.gender-option.active {
  border-color: var(--gold);
  background: var(--primary-10);
  box-shadow: 0 0 0 3px var(--primary-08);
}

.gender-option input[type="radio"] {
  display: none;
}

.gender-option .gender-icon {
  font-size: 2rem;
  line-height: 1;
}

.gender-option .gender-label {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-primary);
}

.gender-option .gender-desc {
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-align: center;
}

/* ── Skin swatches ── */
.swatch-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.color-swatch {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
  position: relative;
}

.color-swatch:hover {
  transform: scale(1.12);
}

.color-swatch.active {
  border-color: var(--gold);
  transform: scale(1.15);
  box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--gold);
}

.color-swatch.active::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  font-weight: 700;
}

/* ── Hair style grid ── */
.hair-style-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.65rem;
  max-width: 460px;
}

.hair-option {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.4rem 0.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, transform 0.15s ease;
  background: var(--bg-card);
  user-select: none;
  position: relative;
}

.hair-option:hover {
  border-color: var(--gold);
  background: var(--primary-08);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.hair-option.active {
  border-color: var(--gold);
  background: var(--primary-10);
  box-shadow: 0 0 0 3px var(--primary-15);
}

.hair-option.active::after {
  content: '✓';
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--gold);
}

.hair-option input[type="radio"] {
  display: none;
}

/* Mini SVG preview inside each hair card */
.hair-preview-svg {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg-panel);
  overflow: hidden;
  flex-shrink: 0;
}

.hair-preview-svg svg {
  width: 100%;
  height: 100%;
}

.hair-option .hair-label {
  font-family: var(--font-ui);
  font-size: 0.63rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: center;
  color: var(--text-secondary);
  line-height: 1.3;
  white-space: nowrap;
}

.hair-option.active .hair-label {
  color: var(--gold);
  font-weight: 700;
}

/* ── Eye color swatches (same as color-swatch but rectangular) ── */
.eye-swatch {
  width: 42px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
  position: relative;
}

.eye-swatch:hover {
  transform: scale(1.1);
}

.eye-swatch.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--bg-card), 0 0 0 4px var(--gold);
}

/* ── Accessory grid ── */
.accessory-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.accessory-option {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.18s ease;
  background: var(--bg-card);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--text-secondary);
  user-select: none;
}

.accessory-option:hover {
  border-color: var(--gold);
  background: var(--primary-08);
}

.accessory-option.active {
  border-color: var(--gold);
  background: var(--primary-10);
  color: var(--gold);
}

.accessory-option input[type="radio"] {
  display: none;
}

.accessory-option .acc-icon {
  font-size: 1.2rem;
}

/* ── Blush toggle ── */
.blush-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.blush-toggle {
  position: relative;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.blush-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.blush-toggle .toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.blush-toggle input:checked+.toggle-track {
  background: var(--gold);
  border-color: var(--gold-dim);
}

.blush-toggle .toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.blush-toggle input:checked+.toggle-track::after {
  transform: translateX(22px);
}

.blush-label {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--text-secondary);
}

/* ── Style option (text pill, kept for backward compat) ── */
.style-option {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-secondary);
  background: var(--bg-card);
}

.style-option:hover,
.style-option.active {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--primary-08);
}

/* ══════════════════════════════════════
   ADMIN STYLES
══════════════════════════════════════ */
.admin-layout {
  display: flex;
  min-height: calc(100vh - 64px);
}

.admin-sidebar {
  width: 220px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0;
  flex-shrink: 0;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
}

.sidebar-section {
  padding: 0 1rem;
  margin-bottom: 1.5rem;
}

.sidebar-label {
  font-family: var(--font-ui);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0 0.5rem;
  margin-bottom: 0.4rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  transition: all var(--transition);
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.sidebar-link.active {
  background: var(--primary-08);
  color: var(--gold);
}

.admin-content {
  flex: 1;
  padding: 2rem;
}

/* Teacher shell (shared sidebar with admin-sidebar) */
.teacher-layout-shell .teacher-sidebar {
  display: flex;
  flex-direction: column;
}

.teacher-sidebar-brand {
  padding: 0 1rem 1rem;
  margin-bottom: 0.25rem;
  border-bottom: 1px solid var(--border);
}

.teacher-sidebar .tsb-kicker {
  font-family: var(--font-ui);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.35rem;
}

.teacher-sidebar .tsb-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--text-primary);
  line-height: 1.2;
  margin: 0;
}

.teacher-sidebar .tsb-sub {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--text-dim);
  margin: 0.45rem 0 0;
}

.teacher-sidebar .tsb-admin-note {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  line-height: 1.4;
  color: var(--text-secondary);
  margin: 0.65rem 0 0;
  padding: 0.5rem 0.55rem;
  border-radius: var(--radius-sm);
  background: var(--primary-08);
  border: 1px solid var(--border);
}

.sidebar-link.teacher-sidebar-admin-link {
  margin-top: 0.35rem;
  padding-top: 0.65rem;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
  font-size: 0.78rem;
}

.sidebar-link.teacher-sidebar-admin-link:hover {
  color: var(--gold);
}

.teacher-sidebar-account {
  margin-top: auto;
  padding-top: 1rem;
}

.teacher-sidebar-empty {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--text-dim);
  padding: 0.35rem 0.5rem 0.75rem;
}

.sidebar-link.teacher-class-link {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.teacher-class-ico {
  flex-shrink: 0;
}

.teacher-class-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.teacher-class-badge {
  flex-shrink: 0;
  font-family: var(--font-ui);
  font-size: 0.68rem;
  color: var(--text-dim);
  opacity: 0.9;
}

.teacher-create-class-form {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0 0.25rem;
}

.teacher-create-class-input,
.teacher-create-class-select {
  width: 100%;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.6rem;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 0.82rem;
}

.teacher-create-class-btn {
  width: 100%;
}

.teacher-sidebar-err {
  color: #df7f7f;
  font-size: 0.75rem;
  font-family: var(--font-ui);
  padding: 0.25rem 0.25rem 0;
}

.teacher-main {
  max-width: 1200px;
}

/* Teacher dashboard content blocks */
.teacher-dash-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}

.teacher-dash-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  font-family: var(--font-ui);
}

.teacher-dash-card .tdc-val {
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--gold);
  line-height: 1.2;
}

.teacher-dash-card .tdc-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

.teacher-code-display {
  font-family: monospace;
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 0.25em;
  color: var(--gold);
  background: var(--bg-deep);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  user-select: all;
  transition: border-color 0.15s;
  display: inline-block;
}

.teacher-code-display:hover {
  border-color: var(--gold);
}

.teacher-module-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
}

.teacher-module-emoji {
  font-size: 1.5rem;
  flex-shrink: 0;
}

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

.teacher-module-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
}

.teacher-module-meta {
  font-size: 0.72rem;
  font-family: var(--font-ui);
  color: var(--text-dim);
}

.teacher-student-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.teacher-student-av {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-10);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.9rem;
  color: var(--gold);
  flex-shrink: 0;
}

.teacher-section-title {
  font-family: var(--font-display);
  font-size: 1rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.teacher-story-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  max-height: 340px;
  overflow-y: auto;
  padding: 0.25rem;
}

.teacher-picker-card {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.teacher-picker-card .tpc-emoji {
  font-size: 1.8rem;
}

.teacher-picker-card .tpc-title {
  font-family: var(--font-display);
  font-size: 0.85rem;
}

.teacher-picker-card .tpc-meta {
  font-size: 0.68rem;
  font-family: var(--font-ui);
  color: var(--text-dim);
}

.teacher-tabs-inner {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.teacher-tab-btn {
  padding: 0.6rem 1.25rem;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  cursor: pointer;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.teacher-tab-btn.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.teacher-tab-panel {
  display: none;
}

.teacher-tab-panel.active {
  display: block;
}

.teacher-status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 0.3rem;
}

.teacher-status-dot.dot-green {
  background: #3adf7a;
}

.teacher-status-dot.dot-gray {
  background: var(--text-dim);
}

.teacher-empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-dim);
  font-family: var(--font-ui);
}

.teacher-empty-state .tes-icon {
  font-size: 2.75rem;
  margin-bottom: 1rem;
}

.teacher-empty-state .tes-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.teacher-empty-state .tes-body {
  font-size: 0.85rem;
  max-width: 360px;
  margin: 0 auto;
  line-height: 1.45;
}

.teacher-notice {
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  margin-bottom: 1rem;
}

.teacher-notice.ok {
  background: #1a3a1a;
  border: 1px solid #2a6a2a;
  color: #7fdf7f;
}

.teacher-notice.warn {
  background: #3a1a1a;
  border: 1px solid #6a2a2a;
  color: #df7f7f;
}

.teacher-class-header {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.teacher-class-header-main {
  flex: 1;
  min-width: 0;
}

.teacher-class-kicker {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.3rem;
}

.teacher-class-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.teacher-class-meta {
  display: flex;
  gap: 1rem;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--text-dim);
  flex-wrap: wrap;
}

.teacher-join-block {
  text-align: center;
}

.teacher-join-label {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
}

.teacher-code-hint {
  font-size: 0.7rem;
  font-family: var(--font-ui);
  color: var(--text-dim);
  margin-top: 0.3rem;
}

.teacher-panel-muted {
  padding: 1.5rem;
  text-align: center;
  color: var(--text-dim);
  font-family: var(--font-ui);
  font-size: 0.85rem;
  background: var(--bg-deep);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.teacher-student-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.teacher-student-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-size: 0.88rem;
}

.teacher-form-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.5rem;
  max-width: 480px;
}

.teacher-module-quarter-form {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.teacher-select-sm {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.4rem;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 0.72rem;
  cursor: pointer;
  min-width: 5.5rem;
}

.teacher-inline-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .teacher-layout-shell {
    flex-direction: column;
  }

  .teacher-layout-shell .admin-sidebar {
    width: 100%;
    height: auto;
    position: relative;
    top: 0;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-align: left;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
}

.admin-table td {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  vertical-align: middle;
}

.admin-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.status-badge {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
}

.status-published {
  background: rgba(39, 174, 96, 0.15);
  color: var(--success);
  border: 1px solid rgba(39, 174, 96, 0.3);
}

.status-draft {
  background: rgba(90, 82, 72, 0.3);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

/* Scene editor */
.scene-editor-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.5rem;
  height: calc(100vh - 120px);
}

.scene-list {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-y: auto;
}

.scene-item {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
  font-size: 0.85rem;
}

.scene-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.scene-item.active {
  background: var(--primary-08);
  border-left: 2px solid var(--gold);
}

.scene-edit-form {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  overflow-y: auto;
}

/* ══════════════════════════════════════
   THEME SETTINGS — Color Picker Grid
══════════════════════════════════════ */
.theme-color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.theme-color-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.theme-color-item label {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  flex: 1;
}

.theme-color-swatch {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border-bright);
  cursor: pointer;
  padding: 0;
  background: none;
  flex-shrink: 0;
}

.font-preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.font-preset-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.font-preset-card:hover {
  border-color: var(--border-bright);
}

.font-preset-card.selected {
  border-color: var(--gold);
  background: var(--primary-08);
}

.font-preset-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.font-preset-name {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.font-preset-sample {
  font-size: 1.1rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.theme-section-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.3rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.2rem;
}

.theme-preview-bar {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

/* ══════════════════════════════════════
   PROFILE / LIBRARY
══════════════════════════════════════ */
.profile-header {
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  padding: 2rem;
  display: flex;
  align-items: center;
  gap: 2rem;
}

.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid var(--gold-dim);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
}

.profile-info h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin-bottom: 0.3rem;
}

.stats-row {
  display: flex;
  gap: 2rem;
  margin-top: 0.5rem;
}

.stat-item {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.stat-item strong {
  color: var(--text-primary);
  font-size: 1rem;
  display: block;
}

/* ══════════════════════════════════════
   LOADING / TRANSITIONS
══════════════════════════════════════ */
.page-transition {
  animation: pageIn 0.4s ease;
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ══════════════════════════════════════
   GAMIFIED DASHBOARD — index.php
══════════════════════════════════════ */

/* ── Overall page body override for dashboard ── */
.dashboard-page {
  background: var(--bg-panel);
  color: var(--text-primary);
  min-height: 100vh;
}

/* ── Two-column layout ── */
.dashboard-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

/* ── Welcome banner ── */
.welcome-banner {
  background: linear-gradient(120deg, var(--bg-deep) 0%, #243060 100%);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
  color: #fff;
}

.welcome-banner::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.welcome-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  overflow: hidden;
  box-shadow: 0 0 0 3px rgba(201, 120, 10, 0.25);
}

/* Avatar image headshot in welcome banner */
.welcome-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 8%;
  border-radius: 50%;
  display: block;
}

/* Crop the full-body SVG to a face headshot (legacy fallback) */
.welcome-avatar svg {
  width: 96px;
  height: 224px;
  position: absolute;
  left: -16px;
  top: -10px;
}

.welcome-text {
  flex: 1;
  position: relative;
  z-index: 1;
}

.welcome-text h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: #fff;
}

.welcome-text .welcome-sub {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 0.6rem;
}

.welcome-xp {
  position: relative;
  z-index: 1;
  text-align: right;
  min-width: 130px;
}

.welcome-xp .level-badge {
  display: inline-block;
  background: var(--gold);
  color: #fff;
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  margin-bottom: 0.4rem;
}

.welcome-xp .xp-label {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 0.3rem;
}

/* ── XP progress bars ── */
.xp-bar-track {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
}

.xp-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.xp-bar-dark .xp-bar-track {
  background: rgba(0, 0, 0, 0.12);
}

.xp-bar-dark .xp-bar-fill {
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
}

/* ── Section headings ── */
.dash-section-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.04em;
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.dash-section-title span.section-icon {
  font-size: 1.1rem;
}

/* ── Topic grid (AP subject banner cards) ── */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.topic-card {
  border-radius: var(--radius);
  padding: 1rem 1rem 0.85rem;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  position: relative;
  overflow: hidden;
  min-height: 90px;
}

.topic-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
}

.topic-card::before {
  content: '';
  position: absolute;
  top: -20px;
  right: -20px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
}

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

.topic-card .topic-label {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 600;
}

.topic-card .topic-name {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

/* ── Mission section ── */
.mission-section {
  margin-bottom: 1.5rem;
}

.activity-cards {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.activity-card {
  background: var(--bg-card);
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: box-shadow 0.18s ease, transform 0.15s ease, border-color 0.18s ease;
  text-decoration: none;
  color: var(--text-primary);
  cursor: pointer;
}

.activity-card:hover {
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.1);
  color: var(--text-primary);
  border-color: var(--gold);
  transform: translateX(3px);
}

.activity-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
  background: var(--primary-10);
}

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

.activity-info .activity-episode {
  font-size: 0.72rem;
  font-family: var(--font-ui);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 0.2rem;
}

.activity-info .activity-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-info .activity-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-action {
  flex-shrink: 0;
}

.btn-activity {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  background: var(--gold);
  color: #fff;
  transition: background 0.18s ease, transform 0.12s ease;
}

.btn-activity:hover {
  background: var(--gold-dim);
  transform: scale(1.04);
  color: #fff;
}

.btn-activity.btn-continue {
  background: var(--teal);
}

.btn-activity.btn-continue:hover {
  background: var(--accent);
}

/* ── XP feedback toast bar ── */
.xp-feedback-bar {
  background: linear-gradient(90deg, var(--bg-deep), #1e3a60);
  color: #fff;
  border-radius: var(--radius);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.88rem;
  margin-bottom: 1.5rem;
  border-left: 3px solid var(--gold);
}

.xp-feedback-bar .xp-icon {
  font-size: 1.3rem;
}

/* ── Dashboard Sidebar ── */
.dashboard-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sidebar-card {
  background: var(--bg-card);
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-radius: var(--radius);
  overflow: hidden;
}

.sidebar-card-header {
  background: var(--bg-deep);
  color: #fff;
  padding: 0.65rem 1rem;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.sidebar-card-body {
  padding: 1rem;
}

/* ── Progress card (sidebar) ── */
.progress-level {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.progress-level-badge {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  color: #fff;
  font-weight: 800;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.progress-level-info .level-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
}

.progress-level-info .level-sub {
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.progress-xp-bar-wrap {
  margin-bottom: 0.5rem;
}

.progress-xp-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

.progress-badges {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.badge-count {
  background: var(--primary-15);
  color: var(--gold);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

/* ── Leaderboard card (sidebar) ── */
.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.leaderboard-row:hover {
  background: var(--primary-08);
}

.leaderboard-row.is-me {
  background: var(--primary-10);
}

.lb-rank {
  width: 20px;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-secondary);
  text-align: center;
}

.lb-rank.top1 {
  color: #ffc107;
}

.lb-rank.top2 {
  color: #9e9e9e;
}

.lb-rank.top3 {
  color: #cd7f32;
}

.lb-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg-card-hover);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  border: 1.5px solid var(--border);
}

/* Headshot crop for leaderboard avatars */
.lb-avatar-headshot {
  overflow: hidden;
  position: relative;
}

.lb-avatar-headshot svg {
  width: 50px;
  height: 117px;
  position: absolute;
  left: -10px;
  top: -7px;
}

.lb-name {
  flex: 1;
  font-size: 0.82rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-xp {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
}

/* ── Guest hero (warm restyled) ── */
.hero-warm {
  background: linear-gradient(160deg, var(--bg-deep) 0%, #243060 60%, #1a3050 100%);
  padding: 4rem 2rem 3.5rem;
  text-align: center;
}

.hero-warm .hero-eyebrow {
  color: var(--gold-light);
}

.hero-warm .hero-title {
  color: #fff;
}

.hero-warm .hero-lead {
  color: rgba(255, 255, 255, 0.7);
}

/* ══════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════ */
@media (max-width: 900px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .dashboard-sidebar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .topic-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Customize: narrower sidebar on tablet */
  .cust-sidebar {
    width: 240px;
    padding: 1.25rem 1rem;
  }

  .cust-avatar-figure {
    width: 130px;
    height: 210px;
  }

  .cust-main {
    padding: 1.5rem 1.25rem 5rem;
  }
}

@media (max-width: 768px) {
  .navbar {
    padding: 0 1rem;
    gap: 1rem;
  }

  .nav-links {
    display: none;
  }

  .stories-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .customize-layout {
    grid-template-columns: 1fr;
  }

  .character-preview-panel {
    position: static;
    height: auto;
  }

  .admin-sidebar {
    display: none;
  }

  .hero {
    padding: 3rem 1rem 2.5rem;
  }

  .scene-editor-grid {
    grid-template-columns: 1fr;
  }

  .topic-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-sidebar {
    display: flex;
    flex-direction: column;
  }

  /* Customize: switch to stacked layout */
  .cust-root {
    flex-direction: column;
  }

  .cust-sidebar {
    display: none;
  }

  /* Hidden — replaced by mobile preview strip */
  .cust-mobile-preview {
    display: flex;
  }

  /* Show compact top strip */
  .cust-mobile-bar {
    display: flex;
  }

  /* Show sticky bottom save bar */
  .cust-main {
    padding: 1.25rem 1rem 5rem;
  }

  .cust-main-header {
    display: none;
  }

  /* Avoid duplicate title on mobile */
  .cust-form-footer {
    display: none;
  }

  /* Bottom bar handles save on mobile */
  .cust-acc-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .cust-gender-grid {
    gap: 0.5rem;
  }
}

@media (max-width: 480px) {
  .stories-grid {
    grid-template-columns: 1fr;
  }

  .cust-swatch-row {
    gap: 0.5rem;
  }

  .cust-swatch {
    width: 40px;
    height: 40px;
  }

  .cust-eye-swatch {
    width: 46px;
    height: 30px;
  }

  .cust-card-body {
    padding: 1rem;
  }
}

/* ══════════════════════════════════════
   GAME DASHBOARD THEME
   Applied when <body> has .game-dashboard
══════════════════════════════════════ */

.game-dashboard {
  --gm-green: #5cc857;
  --gm-green-dk: #3a9436;
  --gm-green-border: #4aaa46;
  --gm-sky: #87CEEB;
  --gm-sky-dk: #5ab0d8;
  --gm-panel-bg: #b5ef98;
  --gm-white: #ffffff;
  --gm-orange: #f5a623;
  --gm-orange-dk: #c8831a;
  --gm-coin: #f5c842;
  --gm-gem: #6ec6f5;
  --gm-text: #1a3a0d;
  --gm-text-light: #ffffff;
  --gm-radius: 14px;
  --gm-radius-lg: 20px;
  --gm-border: 3px solid var(--gm-green-border);
  --gm-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
  --gm-font: 'Shorai Sans', 'Figtree', 'Nunito', sans-serif;
  --gm-font-body: 'Shorai Sans', 'Figtree', 'Nunito', sans-serif;

  background: linear-gradient(180deg, #87CEEB 0%, #b8e4f7 40%, #d4f0b0 100%);
  min-height: 100vh;
  font-family: var(--gm-font-body);
  font-weight: 700;
}

/* Remove the noise overlay on game dashboard */
.game-dashboard::before {
  display: none;
}

/* Decorative sky background layer */
.game-dashboard .game-bg-decor {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.game-dashboard .game-bg-decor::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 200px;
  background: linear-gradient(180deg, transparent 0%, rgba(100, 180, 60, 0.3) 100%);
}

/* ── Game Navbar ── */
.game-navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: transparent;
  border-bottom: none;
  backdrop-filter: none;
  padding: 0.6rem 1rem;
  height: auto;
}

.game-navbar-inner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 1100px;
  margin: 0 auto;
}

.game-nav-logo {
  font-family: var(--gm-font);
  font-weight: 900;
  font-size: 2rem;
  letter-spacing: -0.01em;
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 0;
  text-decoration: none;
  filter: drop-shadow(2px 3px 0 rgba(0, 0, 0, 0.3));
}

.game-nav-logo .logo-edu {
  background: #1a5cde;
  color: #fff;
  padding: 0.1rem 0.35rem;
  border-radius: 8px 0 0 8px;
  font-size: 1.1rem;
}

.game-nav-logo .logo-play {
  background: var(--gm-green);
  padding: 0.1rem 0.35rem;
  border-radius: 0 8px 8px 0;
  font-size: 1.1rem;
  color: #fff;
  letter-spacing: -0.01em;
}

.game-nav-links-box {
  display: flex;
  align-items: center;
  gap: 0;
  background: rgba(255, 255, 255, 0.7);
  border: 2px solid var(--gm-green-border);
  border-radius: var(--gm-radius);
  padding: 0.25rem 0.5rem;
  gap: 0.25rem;
}

.game-nav-link {
  font-family: var(--gm-font);
  font-weight: 900;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  color: var(--gm-text);
  padding: 0.15rem 0.55rem;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.game-nav-link:hover,
.game-nav-link.active {
  background: var(--gm-green);
  color: #fff;
}

.game-nav-currency-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.7);
  border: 2px solid var(--gm-orange);
  border-radius: var(--gm-radius);
  padding: 0.25rem 0.85rem;
  margin-left: auto;
}

.game-nav-coin {
  font-family: var(--gm-font);
  font-weight: 900;
  font-size: 1rem;
  color: var(--gm-orange-dk);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  letter-spacing: -0.01em;
}

.game-nav-lang {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.game-nav-lang a {
  font-family: 'Nunito', sans-serif;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  padding: 0.22rem 0.5rem;
  border-radius: 8px;
  border: 2px solid var(--gm-green-border, #4aaa46);
  text-decoration: none;
  color: #1a3a0d;
  background: rgba(255, 255, 255, 0.85);
  line-height: 1.2;
}

.game-nav-lang a.active {
  background: var(--gm-green, #5cc857);
  color: #fff;
  border-color: var(--gm-green-dk, #3a9436);
}

.game-nav-user {
  margin-left: 0.35rem;
  flex-shrink: 0;
}

.game-nav-gem {
  font-family: var(--gm-font);
  font-weight: 900;
  font-size: 1rem;
  color: #2a7abf;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  letter-spacing: -0.01em;
}

/* ── Game Layout Wrapper ── */
.game-layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1rem;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.75rem 1rem 3rem;
}

/* ── Welcome Banner ── */
.game-welcome {
  background: var(--gm-green);
  border: 3px solid var(--gm-green-dk);
  border-radius: var(--gm-radius-lg);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.85rem;
  box-shadow: var(--gm-shadow);
}

.game-welcome-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2);
}

.game-welcome-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 8%;
  border-radius: 50%;
  display: block;
}

.game-welcome-avatar svg {
  width: 110px;
  height: 260px;
  position: absolute;
  left: -15px;
  top: -10px;
}

.game-welcome-name {
  font-family: var(--gm-font);
  font-weight: 900;
  font-size: 2rem;
  color: #fff;
  letter-spacing: -0.02em;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.2);
  line-height: 1.1;
}

/* ── Section Headers ── */
.game-section-header {
  display: block;
  width: 100%;
  background: var(--gm-green);
  border: 3px solid var(--gm-green-dk);
  border-radius: var(--gm-radius);
  padding: 0.35rem 1.25rem;
  margin-bottom: 0.65rem;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2);
  text-align: center;
}

.game-section-header span {
  font-family: var(--gm-font);
  font-weight: 900;
  font-size: 1.4rem;
  color: #fff;
  letter-spacing: -0.02em;
  text-shadow: 1px 2px 0 rgba(0, 0, 0, 0.2);
}

/* ── Quarter Grid ── */
.game-quarter-wrap {
  background: rgba(255, 255, 255, 0.92);
  border: 3px solid var(--gm-green-border);
  border-radius: var(--gm-radius-lg);
  padding: 0.75rem;
  margin-bottom: 0.85rem;
  box-shadow: var(--gm-shadow);
}

.game-quarter-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
}

.game-quarter-tile {
  position: relative;
  border-radius: var(--gm-radius);
  overflow: hidden;
  height: 150px;
  border: 3px solid var(--gm-green-dk);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
  text-decoration: none;
  display: block;
  transition: transform 0.15s, box-shadow 0.15s;
}

/* <button class="game-quarter-tile"> must stay clickable (student dashboard) */
button.game-quarter-tile {
  width: 100%;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  font: inherit;
  color: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.game-quarter-tile:hover {
  transform: translateY(-3px);
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.2);
}

.game-quarter-tile-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  transition: transform 0.3s;
}

.game-quarter-tile:hover .game-quarter-tile-bg {
  transform: scale(1.04);
}

.game-quarter-tile-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 30%, rgba(0, 0, 0, 0.55) 100%);
}

.game-quarter-tile-label {
  position: absolute;
  bottom: 0.5rem;
  left: 0.6rem;
  font-family: var(--gm-font);
  font-weight: 900;
  font-size: 2.6rem;
  color: #fff;
  text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.4);
  letter-spacing: -0.01em;
  line-height: 1;
}

.game-quarter-tile-name {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-family: var(--gm-font-body);
  font-weight: 700;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 6px;
  padding: 0.15rem 0.5rem;
  max-width: 120px;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

/* Quarter background images */
.game-q1-bg {
  background: url('../images/landing/bg_q1.png') center/cover no-repeat;
}

.game-q2-bg {
  background: url('../images/landing/bg_q2.png') center/cover no-repeat;
}

.game-q3-bg {
  background: url('../images/landing/bg_q3.png') center/cover no-repeat;
}

.game-q4-bg {
  background: url('../images/landing/bg_q4.png') center/cover no-repeat;
}

/* Locked quarter tile */
.game-quarter-tile.locked {
  opacity: 0.6;
  /* Still clickable — opens modal (empty quarter message) */
  cursor: pointer;
}

.game-quarter-tile.locked:hover {
  transform: none;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
}

.game-quarter-tile-lock {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

/* ── Missions Section ── */
.game-missions-wrap {
  background: rgba(255, 255, 255, 0.92);
  border: 3px solid var(--gm-green-border);
  border-radius: var(--gm-radius-lg);
  padding: 0.75rem;
  box-shadow: var(--gm-shadow);
}

.game-mission-card {
  background: #fff;
  border: 2px solid var(--gm-green-border);
  border-radius: var(--gm-radius);
  padding: 0.7rem 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--gm-text);
  transition: transform 0.15s, box-shadow 0.15s;
  margin-bottom: 0.5rem;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.15);
}

.game-mission-card:last-child {
  margin-bottom: 0;
}

.game-mission-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.15);
  color: var(--gm-text);
}

.game-mission-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--gm-panel-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

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

.game-mission-title {
  font-family: var(--gm-font-body);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--gm-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-mission-sub {
  font-size: 0.75rem;
  color: #5a7a4a;
  margin-top: 0.1rem;
}

.game-mission-btn {
  font-family: var(--gm-font);
  font-weight: 900;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  padding: 0.3rem 0.9rem;
  border-radius: 8px;
  background: var(--gm-green);
  color: #fff;
  box-shadow: 0 3px 0 var(--gm-green-dk);
  transition: transform 0.1s, box-shadow 0.1s;
  white-space: nowrap;
  flex-shrink: 0;
}

.game-mission-btn:hover {
  transform: translateY(1px);
  box-shadow: 0 2px 0 var(--gm-green-dk);
}

.game-mission-empty {
  text-align: center;
  padding: 1.25rem;
  font-family: var(--gm-font-body);
  font-weight: 700;
  color: #5a7a4a;
  font-size: 0.88rem;
}

/* ── Join class form in game theme ── */
.game-join-wrap {
  background: rgba(255, 255, 255, 0.92);
  border: 3px solid var(--gm-green-border);
  border-radius: var(--gm-radius-lg);
  padding: 0.85rem 1rem;
  margin-top: 0.85rem;
  box-shadow: var(--gm-shadow);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.game-join-label {
  font-family: var(--gm-font);
  font-weight: 900;
  font-size: 1.1rem;
  color: var(--gm-text);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.game-join-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex: 1;
  flex-wrap: wrap;
}

.game-join-input {
  font-family: monospace;
  font-size: 1rem;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  background: #fff;
  border: 2px solid var(--gm-green-border);
  border-radius: 10px;
  padding: 0.45rem 0.9rem;
  color: var(--gm-text);
  width: 160px;
  transition: border-color 0.15s;
}

.game-join-input:focus {
  outline: none;
  border-color: var(--gm-green-dk);
}

.game-join-btn {
  font-family: var(--gm-font);
  font-weight: 900;
  font-size: 1rem;
  letter-spacing: -0.02em;
  background: var(--gm-green);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0.45rem 1.1rem;
  box-shadow: 0 3px 0 var(--gm-green-dk);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}

.game-join-btn:hover {
  transform: translateY(1px);
  box-shadow: 0 2px 0 var(--gm-green-dk);
}

/* ── Sidebar ── */
.game-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.game-sidebar-card {
  background: rgba(255, 255, 255, 0.92);
  border: 3px solid var(--gm-green-border);
  border-radius: var(--gm-radius-lg);
  overflow: hidden;
  box-shadow: var(--gm-shadow);
}

.game-sidebar-header {
  background: var(--gm-green);
  padding: 0.35rem 0.9rem;
  font-family: var(--gm-font);
  font-weight: 900;
  font-size: 1.3rem;
  color: #fff;
  letter-spacing: -0.02em;
  text-shadow: 1px 2px 0 rgba(0, 0, 0, 0.2);
  border-bottom: 2px solid var(--gm-green-dk);
}

.game-sidebar-body {
  padding: 0.75rem;
  font-family: var(--gm-font-body);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--gm-text);
}

/* Progress inside sidebar */
.game-progress-level {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.game-level-badge {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--gm-green);
  border: 3px solid var(--gm-green-dk);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--gm-font);
  font-weight: 900;
  font-size: 1.3rem;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2);
}

.game-level-info {
  flex: 1;
}

.game-level-title {
  font-weight: 700;
  font-size: 0.85rem;
}

.game-level-sub {
  font-size: 0.72rem;
  color: #5a7a4a;
}

.game-xp-bar-track {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
  margin-top: 0.4rem;
}

.game-xp-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gm-green), #8de83a);
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Leaderboard inside sidebar */
.game-lb-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.25rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
  font-size: 0.82rem;
}

.game-lb-row:last-child {
  border-bottom: none;
}

.game-lb-rank {
  font-family: var(--gm-font);
  font-weight: 900;
  font-size: 1.1rem;
  width: 22px;
  text-align: center;
  color: var(--gm-text);
  flex-shrink: 0;
}

.game-lb-rank.top1 {
  color: #f5c842;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.2);
}

.game-lb-rank.top2 {
  color: #c0c0c0;
}

.game-lb-rank.top3 {
  color: #cd7f32;
}

.game-lb-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--gm-green-border);
  background: var(--gm-panel-bg);
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.game-lb-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 8%;
  border-radius: 50%;
  display: block;
}

.game-lb-avatar svg {
  width: 44px;
  height: 100px;
  position: absolute;
  left: -8px;
  top: -5px;
}

.game-lb-name {
  flex: 1;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8rem;
}

.game-lb-xp {
  font-family: var(--gm-font);
  font-weight: 900;
  font-size: 0.85rem;
  color: var(--gm-orange-dk);
  white-space: nowrap;
}

.game-lb-me .game-lb-name {
  color: var(--gm-green-dk);
}

/* ── Classrooms list sidebar card ── */
.game-classroom-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.25rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
  font-size: 0.82rem;
}

.game-classroom-row:last-child {
  border-bottom: none;
}

/* ── Empty state ── */
.game-empty-state {
  background: rgba(255, 255, 255, 0.92);
  border: 3px solid var(--gm-green-border);
  border-radius: var(--gm-radius-lg);
  padding: 2.5rem 1.5rem;
  text-align: center;
  box-shadow: var(--gm-shadow);
  margin-bottom: 0.85rem;
}

.game-empty-state .es-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
}

.game-empty-state .es-title {
  font-family: var(--gm-font);
  font-weight: 900;
  font-size: 1.5rem;
  color: var(--gm-text);
  margin-bottom: 0.4rem;
  letter-spacing: -0.02em;
}

.game-empty-state .es-sub {
  font-size: 0.88rem;
  color: #5a7a4a;
  max-width: 300px;
  margin: 0 auto 1.25rem;
}

/* ── Feedback / alert bars ── */
.game-feedback-bar,
.game-error-bar {
  max-width: 1100px;
  margin: 0.5rem auto;
  padding: 0.6rem 1.25rem;
  border-radius: var(--gm-radius);
  font-family: var(--gm-font-body);
  font-weight: 700;
  font-size: 0.9rem;
}

.game-feedback-bar {
  background: var(--gm-green);
  border: 2px solid var(--gm-green-dk);
  color: #fff;
  box-shadow: 0 3px 0 var(--gm-green-dk);
}

.game-error-bar {
  background: #fff0f0;
  border: 2px solid #e05555;
  color: #c02020;
  box-shadow: 0 3px 0 rgba(200, 50, 50, 0.2);
}

/* ── Responsive ── */
@media (max-width: 860px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .game-sidebar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .game-quarter-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .game-sidebar {
    display: flex;
    flex-direction: column;
  }

  .game-navbar {
    padding: 0.5rem 0.75rem;
  }

  /* Keep dashboard nav usable on small screens (student / profile / customize) */
  .game-navbar--dashboard .game-navbar-inner {
    flex-wrap: wrap;
    row-gap: 0.5rem;
  }

  .game-navbar--dashboard .game-nav-logo {
    order: 1;
  }

  .game-navbar--dashboard .game-nav-currency-box {
    order: 2;
    margin-left: auto;
  }

  .game-navbar--dashboard .game-nav-lang {
    order: 3;
  }

  .game-navbar--dashboard .game-nav-user {
    order: 4;
  }

  .game-navbar--dashboard .game-nav-links-box {
    display: flex;
    flex-wrap: wrap;
    order: 10;
    flex-basis: 100%;
    width: 100%;
    justify-content: center;
    padding: 0.35rem 0.45rem;
    gap: 0.2rem;
  }

  .game-navbar--dashboard .game-nav-link {
    font-size: 0.82rem;
    padding: 0.12rem 0.45rem;
  }

  .game-nav-links-box {
    display: none;
  }

  .game-navbar--dashboard .game-nav-links-box {
    display: flex;
  }
}
