/* =====================================================
   奧數四城大冒險 — Multi-Accent Colorful Theme
   Dark + Light mode with teal, blue, gold, coral palette
   ===================================================== */

/* ── Dark Theme (default) ── */
:root {
  --bg-deep: #0a0a1a;
  --bg-surface: rgba(16, 16, 38, 0.88);
  --bg-card: rgba(22, 22, 52, 0.82);
  --bg-card-hover: rgba(30, 30, 65, 0.9);
  --bg-input: rgba(30, 30, 60, 0.7);
  --border: rgba(100, 100, 200, 0.12);
  --border-glow: rgba(0, 200, 180, 0.25);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --text: #e8e8ff;
  --text-secondary: #a0a0cc;
  --text-muted: #6a6a99;

  /* Multi-accent palette */
  --teal: #00d4aa;
  --teal-dark: #00a888;
  --teal-glow: rgba(0, 212, 170, 0.3);
  --blue: #4a9eff;
  --blue-light: #7ab8ff;
  --blue-glow: rgba(74, 158, 255, 0.3);
  --coral: #ff6b6b;
  --coral-glow: rgba(255, 107, 107, 0.2);
  --gold: #ffd93d;
  --gold-glow: rgba(255, 217, 61, 0.15);

  --accent-glow: rgba(0, 180, 200, 0.3);
  --success-bg: rgba(0, 212, 170, 0.12);
  --danger-bg: rgba(255, 107, 107, 0.12);

  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px var(--accent-glow);
  --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Light Theme ── */
[data-theme="light"] {
  --bg-deep: #f4f5fa;
  --bg-surface: rgba(255, 255, 255, 0.92);
  --bg-card: rgba(255, 255, 255, 0.95);
  --bg-card-hover: #f0f0ff;
  --bg-input: #eef0f8;
  --border: rgba(0, 0, 0, 0.07);
  --border-glow: rgba(0, 180, 170, 0.2);
  --border-subtle: rgba(0, 0, 0, 0.04);
  --text: #1a1a2e;
  --text-secondary: #4a4a6a;
  --text-muted: #7a7a9a;
  --teal: #00b894;
  --teal-dark: #009678;
  --teal-glow: rgba(0, 184, 148, 0.2);
  --blue: #3b82f6;
  --blue-light: #60a5fa;
  --blue-glow: rgba(59, 130, 246, 0.2);
  --coral: #ef4444;
  --coral-glow: rgba(239, 68, 68, 0.12);
  --gold: #d97706;
  --gold-glow: rgba(217, 119, 6, 0.1);
  --accent-glow: rgba(0, 150, 170, 0.12);
  --success-bg: rgba(0, 184, 148, 0.06);
  --danger-bg: rgba(239, 68, 68, 0.06);
  --shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
  --shadow-glow: 0 4px 16px var(--accent-glow);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg-deep);
  font-family: "Noto Sans TC", "Outfit", sans-serif;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, select, input { font: inherit; }
img { display: block; max-width: 100%; }

/* ===== Animated Background ===== */
.bg-stars {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 10% 15%, rgba(255,255,255,0.25), transparent),
    radial-gradient(1px 1px at 25% 35%, rgba(255,255,255,0.18), transparent),
    radial-gradient(1.5px 1.5px at 45% 10%, rgba(255,255,255,0.2), transparent),
    radial-gradient(1px 1px at 60% 55%, rgba(255,255,255,0.15), transparent),
    radial-gradient(2px 2px at 75% 20%, rgba(74,158,255,0.25), transparent),
    radial-gradient(1px 1px at 85% 70%, rgba(255,255,255,0.2), transparent),
    radial-gradient(1.5px 1.5px at 15% 80%, rgba(255,255,255,0.15), transparent),
    radial-gradient(1px 1px at 35% 65%, rgba(0,212,170,0.2), transparent),
    radial-gradient(1.5px 1.5px at 55% 85%, rgba(255,255,255,0.18), transparent),
    radial-gradient(1px 1px at 90% 40%, rgba(255,255,255,0.12), transparent),
    radial-gradient(2px 2px at 5% 45%, rgba(0,212,170,0.18), transparent),
    radial-gradient(1px 1px at 70% 90%, rgba(255,255,255,0.15), transparent),
    radial-gradient(1.5px 1.5px at 40% 45%, rgba(255,255,255,0.1), transparent),
    radial-gradient(1px 1px at 80% 5%, rgba(0,212,170,0.15), transparent),
    radial-gradient(1.5px 1.5px at 20% 60%, rgba(255,255,255,0.12), transparent),
    radial-gradient(1px 1px at 95% 25%, rgba(255,255,255,0.18), transparent),
    radial-gradient(1.5px 1.5px at 50% 40%, rgba(74,158,255,0.12), transparent),
    radial-gradient(1px 1px at 30% 90%, rgba(255,255,255,0.1), transparent);
  background-size: 100% 100%;
  animation: starsDrift 90s linear infinite alternate;
}

.bg-glow {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 600px 400px at 15% 10%, rgba(0,212,170,0.06), transparent),
    radial-gradient(ellipse 500px 500px at 85% 80%, rgba(74,158,255,0.05), transparent),
    radial-gradient(ellipse 400px 300px at 50% 50%, rgba(255,217,61,0.03), transparent);
}

[data-theme="light"] .bg-stars { opacity: 0; }
[data-theme="light"] .bg-glow {
  background:
    radial-gradient(ellipse 600px 400px at 15% 10%, rgba(0,212,170,0.04), transparent),
    radial-gradient(ellipse 500px 500px at 85% 80%, rgba(74,158,255,0.03), transparent),
    radial-gradient(ellipse 400px 300px at 50% 50%, rgba(255,217,61,0.02), transparent);
}

@keyframes starsDrift {
  0% { transform: translateY(0); }
  100% { transform: translateY(-30px); }
}

/* ===== View System ===== */
.view { display: none; position: relative; z-index: 1; }
.view.active { display: block; animation: viewIn 0.35s ease; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Top Navigation ===== */
.top-bar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1300px; margin: 0 auto;
  padding: 12px 24px;
  background: rgba(10, 10, 26, 0.85);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}
[data-theme="light"] .top-bar {
  background: rgba(255, 255, 255, 0.88);
}

.top-brand {
  display: flex; align-items: center; gap: 8px;
  font-family: "Bungee", sans-serif; font-size: 1rem;
  color: var(--teal);
}
.brand-icon { font-size: 1.3rem; }

.top-tabs { display: flex; gap: 4px; }

.top-tab {
  padding: 8px 18px; border: none; border-radius: 999px;
  background: transparent; color: var(--text-secondary);
  font-weight: 700; font-size: 0.92rem; cursor: pointer;
  transition: all var(--transition);
}
.top-tab:hover { color: var(--text); background: rgba(0,212,170,0.08); }
.top-tab.active { color: #fff; background: linear-gradient(135deg, var(--teal), var(--blue)); box-shadow: 0 0 16px var(--accent-glow); }

/* ===== Theme Toggle ===== */
.theme-toggle {
  position: fixed;
  top: 14px; right: 24px; z-index: 200;
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  color: var(--text-secondary);
  cursor: pointer;
  display: grid; place-items: center;
  transition: all var(--transition);
  font-size: 1.15rem;
  flex-shrink: 0;
}
.theme-toggle:hover {
  border-color: var(--gold);
  color: var(--gold);
}

/* ===== Section Headings ===== */
.sec-head { margin-bottom: 20px; }
.sec-tag {
  display: inline-block; margin-bottom: 4px;
  font-family: "Bungee", sans-serif; font-size: 0.7rem;
  letter-spacing: 0.14em; color: var(--teal);
}
.sec-head h2 {
  margin: 0; font-family: "Outfit", sans-serif;
  font-size: clamp(1.6rem, 3.5vw, 2.4rem); font-weight: 800;
  color: var(--text);
}

/* ===== HERO ===== */
.hero {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: calc(100vh - 60px); text-align: center;
  padding: 40px 24px 20px;
}

.hero-inner { max-width: 620px; }

.hero-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 18px; border-radius: 999px;
  background: rgba(255,217,61,0.12); border: 1px solid rgba(255,217,61,0.2);
  color: var(--gold); font-weight: 700; font-size: 0.88rem;
  animation: badgePulse 3s ease-in-out infinite;
}
@keyframes badgePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,217,61,0.15); }
  50% { box-shadow: 0 0 0 8px rgba(255,217,61,0); }
}

.hero-title {
  margin: 28px 0 16px;
  font-family: "Outfit", sans-serif; font-size: clamp(3rem, 8vw, 5.5rem);
  font-weight: 900; line-height: 1.05;
  background: linear-gradient(135deg, #fff 10%, var(--teal) 30%, var(--blue) 55%, var(--gold) 85%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
[data-theme="light"] .hero-title {
  background: linear-gradient(135deg, #1a1a2e 10%, var(--teal) 30%, var(--blue) 55%, var(--gold) 85%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.title-accent { font-style: italic; }

.hero-sub {
  margin: 0 0 32px; font-size: 1.1rem;
  color: var(--text-secondary); line-height: 1.7;
}

.cta-btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 16px 36px; border: none; border-radius: 999px;
  background: linear-gradient(135deg, var(--teal), var(--blue));
  color: #fff; font-size: 1.15rem; font-weight: 800;
  cursor: pointer; transition: all var(--transition);
  box-shadow: 0 0 24px var(--accent-glow);
  animation: ctaGlow 2.5s ease-in-out infinite;
}
.cta-btn:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 0 40px rgba(0, 180, 200, 0.5);
}
.cta-icon { font-size: 1.3rem; }
@keyframes ctaGlow {
  0%, 100% { box-shadow: 0 0 24px var(--accent-glow); }
  50% { box-shadow: 0 0 40px rgba(0, 180, 200, 0.45); }
}

.hero-scroll {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  margin-top: auto; padding-top: 40px;
  color: var(--text-muted); font-size: 0.8rem;
  animation: scrollBounce 2s ease-in-out infinite;
}
@keyframes scrollBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}

/* ===== Story Cards (Home) ===== */
.home-stories {
  max-width: 1100px; margin: 0 auto;
  padding: 40px 24px 20px;
}

.story-carousel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.scard {
  display: flex; align-items: center; gap: 16px;
  padding: 20px; border-radius: var(--radius-lg);
  background: var(--bg-card); border: 1px solid var(--border);
  cursor: pointer; transition: all var(--transition);
}
.scard:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-glow);
  transform: translateY(-3px);
  box-shadow: var(--shadow-glow);
}
[data-theme="light"] .scard { box-shadow: 0 1px 8px rgba(0,0,0,0.04); }

.scard-emoji { font-size: 2.2rem; flex-shrink: 0; }
.scard-num { font-family: "Bungee", sans-serif; font-size: 0.65rem; letter-spacing: 0.1em; color: var(--teal); }
.scard-body h3 { margin: 2px 0 4px; font-family: "Outfit", sans-serif; font-size: 1.1rem; font-weight: 800; }
.scard-body p { margin: 0; font-size: 0.85rem; color: var(--text-secondary); }

.scard-tea:hover { border-color: rgba(255,217,61,0.4); box-shadow: 0 0 20px rgba(255,217,61,0.15); }
.scard-det:hover { border-color: rgba(74,158,255,0.4); box-shadow: 0 0 20px rgba(74,158,255,0.15); }
.scard-spc:hover { border-color: rgba(0,212,170,0.4); box-shadow: 0 0 20px rgba(0,212,170,0.15); }
.scard-dep:hover { border-color: rgba(255,107,107,0.4); box-shadow: 0 0 20px rgba(255,107,107,0.15); }

/* ===== Quick Stats (Home) ===== */
.home-quick-stats {
  display: flex; align-items: center; justify-content: center; gap: 32px;
  max-width: 500px; margin: 20px auto 60px;
  padding: 24px 32px; border-radius: var(--radius-xl);
  background: var(--bg-card); border: 1px solid var(--border);
}
[data-theme="light"] .home-quick-stats { box-shadow: 0 1px 8px rgba(0,0,0,0.04); }

.qs-card { position: relative; width: 90px; height: 90px; flex-shrink: 0; }
.qs-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.qs-ring-bg { fill: none; stroke: rgba(0,212,170,0.12); stroke-width: 8; }
.qs-ring-fill { fill: none; stroke: var(--teal); stroke-width: 8; stroke-linecap: round; stroke-dasharray: 326.73; stroke-dashoffset: 326.73; transition: stroke-dashoffset 0.8s ease; }
.qs-ring-label {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.qs-ring-label strong { font-size: 1.1rem; font-weight: 900; color: var(--teal); }
.qs-ring-label small { font-size: 0.65rem; color: var(--text-muted); }

.qs-info { display: flex; flex-direction: column; gap: 4px; }
.qs-info p { margin: 0; font-size: 0.92rem; color: var(--text-secondary); }
.qs-info strong { color: var(--text); font-weight: 800; }

.btn-outline {
  margin-top: 8px; padding: 8px 18px;
  border: 1px solid var(--teal); border-radius: 999px;
  background: transparent; color: var(--teal);
  font-weight: 700; font-size: 0.85rem; cursor: pointer;
  transition: all var(--transition);
}
.btn-outline:hover { background: rgba(0,212,170,0.12); }

/* ===== Play Section ===== */
.play-wrap {
  max-width: 1300px; margin: 0 auto;
  padding: 24px 24px 100px;
}

.controls-panel {
  padding: 18px; border-radius: var(--radius-lg);
  background: var(--bg-card); border: 1px solid var(--border);
  margin-bottom: 18px;
}
[data-theme="light"] .controls-panel { box-shadow: 0 1px 8px rgba(0,0,0,0.04); }

.controls-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.ctrl { display: flex; flex-direction: column; gap: 6px; }
.ctrl label { font-weight: 800; font-size: 0.85rem; color: var(--text-secondary); }

select {
  width: 100%; min-height: 44px; padding: 10px 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-input); color: var(--text);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a7a9a' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  transition: border-color var(--transition);
}
select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(74,158,255,0.15); }

input[type="text"] {
  width: 100%; min-height: 44px; padding: 10px 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-input); color: var(--text);
  transition: border-color var(--transition);
}
input[type="text"]:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(74,158,255,0.15); }
input[type="text"]::placeholder { color: var(--text-muted); }

.mode-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.mode-chip {
  padding: 8px 16px; border: 1px solid var(--border); border-radius: 999px;
  background: transparent; color: var(--text-secondary);
  font-weight: 700; font-size: 0.85rem; cursor: pointer;
  transition: all var(--transition);
}
.mode-chip:hover { border-color: var(--blue); color: var(--text); }
.mode-chip.active { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 0 12px var(--blue-glow); }

/* ===== Play Layout ===== */
.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 18px; align-items: start;
}

/* ===== Question Card ===== */
.question-card {
  padding: 24px; border-radius: var(--radius-xl);
  background: var(--bg-card); border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
[data-theme="light"] .question-card { box-shadow: 0 1px 8px rgba(0,0,0,0.04); }

.question-top {
  display: flex; flex-wrap: wrap; justify-content: space-between;
  gap: 10px; margin-bottom: 16px;
}

.question-meta { display: flex; flex-wrap: wrap; gap: 6px; }

.meta-chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 32px; padding: 0 10px; border-radius: 999px;
  background: rgba(74,158,255,0.1); color: var(--blue);
  font-weight: 800; font-size: 0.8rem;
}
.meta-chip.type { background: var(--coral-glow); color: var(--coral); }

.question-tools { display: flex; gap: 6px; }

.tool-btn {
  width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-input); color: var(--text-secondary);
  font-size: 0.9rem; cursor: pointer; display: grid; place-items: center;
  transition: all var(--transition);
}
.tool-btn:hover { border-color: var(--blue); color: var(--text); background: rgba(74,158,255,0.1); }

.question-showcase {
  display: grid;
  gap: 16px;
}

.question-title {
  margin: 0 0 8px; font-family: "Outfit", sans-serif;
  font-size: clamp(1.3rem, 2.5vw, 1.8rem); font-weight: 800;
  line-height: 1.3; color: var(--text);
}

.question-prompt { margin: 0; font-size: 1rem; color: var(--text-secondary); line-height: 1.8; }
.question-extra { min-height: 20px; margin: 8px 0 0; color: var(--text-muted); }

/* ===== Answer Zone ===== */
.answer-zone { display: grid; gap: 12px; margin-top: 12px; }

.choice-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

.choice-button {
  display: flex; align-items: center; gap: 10px;
  min-height: 64px; padding: 14px;
  border-radius: var(--radius-md); border: 1.5px solid var(--border);
  background: var(--bg-input); color: var(--text);
  text-align: left; cursor: pointer; transition: all var(--transition);
}
.choice-button:hover { border-color: rgba(74,158,255,0.3); background: rgba(74,158,255,0.06); }
.choice-button strong {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(74,158,255,0.12); color: var(--blue-light);
  font-size: 0.85rem; flex-shrink: 0;
}
.choice-button.selected { border-color: var(--blue); background: rgba(74,158,255,0.12); box-shadow: 0 0 12px var(--blue-glow); }

.fill-wrap { display: grid; gap: 8px; }
.fill-wrap small { color: var(--text-muted); }

.match-board { display: grid; gap: 12px; }
.match-columns { display: grid; grid-template-columns: 1fr minmax(160px, 0.8fr); gap: 12px; }
.match-row {
  display: grid; gap: 6px; padding: 12px;
  border-radius: var(--radius-md); background: var(--bg-input);
  border: 1px solid var(--border-subtle);
}
.match-row label { color: var(--text-secondary); font-weight: 600; }
.match-right {
  padding: 14px; border-radius: var(--radius-md);
  background: rgba(74,158,255,0.05); border: 1px dashed rgba(74,158,255,0.15);
}
.match-right ul { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 6px; color: var(--text-secondary); }

.sequence-result {
  min-height: 24px; padding: 8px 12px; border-radius: 10px;
  background: rgba(0,212,170,0.06); color: var(--text-secondary);
}

.order-board { display: grid; gap: 10px; }
.order-hint { color: var(--text-muted); margin: 0; }
.order-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

.order-card {
  display: grid; gap: 4px; padding: 14px;
  border-radius: var(--radius-md); border: 1.5px solid var(--border);
  background: var(--bg-input); color: var(--text);
  text-align: left; cursor: pointer; transition: all var(--transition);
}
.order-card:hover { border-color: rgba(0,212,170,0.3); }
.order-card small { color: var(--text-muted); }
.order-card.selected { border-color: var(--teal); background: rgba(0,212,170,0.08); box-shadow: 0 0 10px rgba(0,212,170,0.15); }

/* ===== Question Actions ===== */
.question-actions {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px;
}

.btn-primary, .btn-secondary, .btn-ghost, .btn-danger, .btn-outline, .file-label {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 20px; border: none; border-radius: 999px;
  font-weight: 800; font-size: 0.92rem; cursor: pointer;
  transition: all var(--transition);
}

.btn-primary {
  background: linear-gradient(135deg, var(--teal), var(--blue));
  color: #fff; box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 24px var(--accent-glow); }

.btn-secondary, .file-label {
  background: rgba(0,212,170,0.12); border: 1px solid rgba(0,212,170,0.2);
  color: var(--teal);
}
.btn-secondary:hover, .file-label:hover { background: rgba(0,212,170,0.2); transform: translateY(-1px); }

.btn-ghost {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted);
}
.btn-ghost:hover { border-color: var(--text-secondary); color: var(--text-secondary); }

.btn-danger {
  background: rgba(255,107,107,0.1); border: 1px solid rgba(255,107,107,0.2);
  color: var(--coral);
}
.btn-danger:hover { background: rgba(255,107,107,0.2); }

#import-progress {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
}

/* ===== Feedback Panel ===== */
.feedback-panel {
  margin-top: 16px; padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.03); border: 1px dashed var(--border);
}
[data-theme="light"] .feedback-panel { background: rgba(0,0,0,0.015); }
.feedback-panel p { color: var(--text-secondary); line-height: 1.8; margin: 4px 0; }
.feedback-panel.success { background: var(--success-bg); border-color: rgba(0,212,170,0.3); }
.feedback-panel.error { background: var(--danger-bg); border-color: rgba(255,107,107,0.3); }

.feedback-title { margin: 0 0 6px !important; font-size: 1.05rem; font-weight: 900; color: var(--text) !important; }
.feedback-answer { margin: 6px 0 0 !important; font-weight: 900; color: var(--teal) !important; }
.feedback-placeholder { color: var(--text-muted) !important; }

/* ===== Side Panel ===== */
.side-panel { display: grid; gap: 16px; }

.side-card {
  padding: 20px; border-radius: var(--radius-lg);
  background: var(--bg-card); border: 1px solid var(--border);
  display: grid; gap: 8px;
}
[data-theme="light"] .side-card { box-shadow: 0 1px 8px rgba(0,0,0,0.04); }
.side-card h3 { margin: 0; font-family: "Outfit", sans-serif; font-size: 1.1rem; font-weight: 800; }
.side-card p { margin: 0; color: var(--text-secondary); line-height: 1.7; font-size: 0.92rem; }
.side-note { font-size: 0.82rem !important; color: var(--text-muted) !important; }
.side-card-head { display: flex; justify-content: space-between; align-items: center; }
.side-card-head span { color: var(--text-muted); font-size: 0.85rem; font-weight: 700; }

/* ===== Progress Bar ===== */
.progress-bar {
  width: 100%; height: 8px; border-radius: 999px;
  background: rgba(0,212,170,0.1); overflow: hidden;
}
.progress-fill {
  width: 0; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--blue));
  transition: width 0.6s ease;
}

/* ===== Navigator Grid ===== */
.navigator-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; }

.navigator-button {
  min-height: 38px; border-radius: 10px; border: none;
  background: var(--bg-input); color: var(--text-muted);
  font-weight: 800; font-size: 0.8rem; cursor: pointer;
  transition: all var(--transition);
}
.navigator-button:hover { background: rgba(74,158,255,0.15); color: var(--text); }
.navigator-button.current { background: var(--blue); color: #fff; box-shadow: 0 0 10px var(--blue-glow); }
.navigator-button.mastered { background: rgba(0,212,170,0.15); color: var(--teal); }
.navigator-button.wrong { background: var(--danger-bg); color: var(--coral); }
.navigator-button.unseen { background: var(--bg-input); }

/* ===== MAP VIEW ===== */
.map-wrap, .feat-wrap {
  max-width: 900px; margin: 0 auto;
  padding: 32px 24px;
}

.mission-path {
  display: flex; flex-direction: column; align-items: stretch;
  gap: 0; padding: 0 20px;
}

.mnode {
  display: flex; align-items: center; gap: 18px;
  padding: 22px; border-radius: var(--radius-lg);
  background: var(--bg-card); border: 1px solid var(--border);
  transition: all var(--transition);
}
.mnode:hover { border-color: var(--border-glow); transform: translateX(6px); box-shadow: var(--shadow-glow); }
[data-theme="light"] .mnode { box-shadow: 0 1px 8px rgba(0,0,0,0.04); }

.mnode-n {
  display: grid; place-items: center;
  width: 48px; height: 48px; border-radius: 50%;
  font-family: "Bungee", sans-serif; font-size: 0.9rem;
  flex-shrink: 0;
}

.mnode-1 .mnode-n { background: rgba(255,217,61,0.15); color: var(--gold); }
.mnode-2 .mnode-n { background: rgba(74,158,255,0.15); color: var(--blue); }
.mnode-3 .mnode-n { background: rgba(0,212,170,0.15); color: var(--teal); }
.mnode-4 .mnode-n { background: rgba(255,107,107,0.15); color: var(--coral); }
.mnode-5 .mnode-n { background: rgba(167,139,250,0.15); color: #a78bfa; }

.mnode-body h3 { margin: 0 0 4px; font-family: "Outfit", sans-serif; font-size: 1.1rem; font-weight: 800; }
.mnode-body p { margin: 0; font-size: 0.88rem; color: var(--text-secondary); }

.mline {
  width: 3px; height: 28px; margin-left: 44px;
  background: linear-gradient(180deg, var(--teal), transparent);
  border-radius: 999px;
}

/* ===== Features Grid ===== */
.feat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }

.feat-card {
  padding: 22px; border-radius: var(--radius-lg);
  background: var(--bg-card); border: 1px solid var(--border);
  transition: all var(--transition);
}
.feat-card:hover { border-color: var(--border-glow); transform: translateY(-3px); box-shadow: var(--shadow-glow); }
[data-theme="light"] .feat-card { box-shadow: 0 1px 8px rgba(0,0,0,0.04); }
.feat-icon { font-size: 1.8rem; display: block; margin-bottom: 10px; }
.feat-card h3 { margin: 0 0 6px; font-family: "Outfit", sans-serif; font-size: 1.05rem; font-weight: 800; }
.feat-card p { margin: 0; font-size: 0.88rem; color: var(--text-secondary); line-height: 1.7; }

/* ===== PROFILE VIEW ===== */
.prof-wrap {
  max-width: 800px; margin: 0 auto;
  padding: 32px 24px 100px;
}

.stats-grid {
  display: grid; grid-template-columns: 150px repeat(2, 1fr);
  gap: 14px;
}

.stat-card {
  padding: 20px; border-radius: var(--radius-lg);
  background: var(--bg-card); border: 1px solid var(--border);
  display: flex; flex-direction: column; justify-content: center;
}
[data-theme="light"] .stat-card { box-shadow: 0 1px 8px rgba(0,0,0,0.04); }

.stat-main {
  grid-row: 1 / 3; position: relative;
  display: flex; align-items: center; justify-content: center;
}

.stat-ring { width: 110px; height: 110px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(0,212,170,0.1); stroke-width: 8; }
.ring-fill { fill: none; stroke: var(--teal); stroke-width: 8; stroke-linecap: round; stroke-dasharray: 326.73; stroke-dashoffset: 326.73; transition: stroke-dashoffset 0.8s ease; }

.ring-label {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ring-label strong { font-size: 1.8rem; font-weight: 900; color: var(--teal); }
.ring-label small { font-size: 0.7rem; color: var(--text-muted); }

.stat-name { font-size: 0.82rem; color: var(--text-muted); font-weight: 700; margin-bottom: 4px; }
.stat-val { font-size: 1.5rem; font-weight: 900; color: var(--text); }
.title-val { font-size: 1rem; color: var(--gold); }

.stat-title-card { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 12px; }

/* ===== Backup Grid ===== */
.backup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.bk-card {
  padding: 20px; border-radius: var(--radius-lg);
  background: var(--bg-card); border: 1px solid var(--border);
}
[data-theme="light"] .bk-card { box-shadow: 0 1px 8px rgba(0,0,0,0.04); }
.bk-icon { font-size: 1.8rem; display: block; margin-bottom: 8px; }
.bk-card h3 { margin: 0 0 6px; font-family: "Outfit", sans-serif; font-size: 1.05rem; font-weight: 800; }
.bk-card p { margin: 0; font-size: 0.85rem; color: var(--text-secondary); line-height: 1.7; }

.bk-actions {
  grid-column: 1 / -1; padding: 20px; border-radius: var(--radius-lg);
  background: var(--bg-card); border: 1px solid var(--border);
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center;
  position: relative;
}
[data-theme="light"] .bk-actions { box-shadow: 0 1px 8px rgba(0,0,0,0.04); }

/* ===== Bottom Navigation (Mobile) ===== */
.bottom-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: rgba(10, 10, 26, 0.92); backdrop-filter: blur(18px);
  border-top: 1px solid var(--border);
  padding: 6px 0 env(safe-area-inset-bottom, 6px);
}
[data-theme="light"] .bottom-nav {
  background: rgba(255, 255, 255, 0.92);
}

.bottom-nav { display: grid; grid-template-columns: repeat(4, 1fr); }

.bnav {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0; border: none; background: transparent;
  color: var(--text-muted); font-size: 0.65rem; font-weight: 700;
  cursor: pointer; transition: color var(--transition);
}
.bnav svg { stroke: currentColor; }
.bnav:hover, .bnav.active { color: var(--teal); }
.bnav.active svg { filter: drop-shadow(0 0 6px var(--teal-glow)); }

/* ===== Responsive ===== */

/* Desktop: hide bottom nav */
@media (min-width: 769px) {
  .bottom-nav { display: none !important; }
  body { padding-bottom: 0; }
}

/* Tablet & smaller */
@media (max-width: 1100px) {
  .play-layout { grid-template-columns: 1fr; }
  .controls-row { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: 120px 1fr 1fr; }
}

@media (max-width: 768px) {
  .top-bar { display: none; }
  .bottom-nav { display: grid !important; }
  body { padding-bottom: 72px; }

  .theme-toggle {
    top: 10px; right: 14px;
    width: 36px; height: 36px;
    font-size: 1rem;
  }

  .hero { min-height: calc(100vh - 20px); min-height: calc(100dvh - 20px); padding: 30px 20px 20px; }
  .hero-title { font-size: clamp(2.4rem, 10vw, 4rem); }

  .home-stories, .play-wrap, .map-wrap, .feat-wrap, .prof-wrap { padding-left: 16px; padding-right: 16px; }

  .story-carousel { grid-template-columns: 1fr; }

  .home-quick-stats { flex-direction: column; gap: 16px; margin-left: 16px; margin-right: 16px; }
  .qs-info { align-items: center; text-align: center; }

  .controls-row { grid-template-columns: 1fr 1fr; }

  .question-showcase { grid-template-columns: 1fr; }

  .choice-grid, .order-grid, .match-columns { grid-template-columns: 1fr; }

  .question-actions { flex-direction: column; }
  .question-actions > * { width: 100%; }

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

  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-main { grid-column: 1 / -1; }
  .stat-ring { width: 90px; height: 90px; }

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

  .mission-path { padding: 0; }
  .mnode { padding: 16px; gap: 12px; }
  .mnode-n { width: 40px; height: 40px; font-size: 0.75rem; }
  .mline { margin-left: 36px; height: 20px; }
}

@media (max-width: 400px) {
  .hero-badge { font-size: 0.78rem; padding: 6px 14px; }
  .hero-title { font-size: 2.2rem; }
  .cta-btn { padding: 14px 28px; font-size: 1rem; }
  .question-card { padding: 16px; }
  .side-card { padding: 14px; }
  .scard { padding: 14px; }
}

/* ===== Scroll Reveal Animation ===== */
.reveal {
  opacity: 0; transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.reveal.visible { opacity: 1; transform: translateY(0); }

/* ===== Prologue Button ===== */
.prologue-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 10px 24px;
  border: 1px solid rgba(255, 217, 61, 0.25);
  border-radius: 999px;
  background: rgba(255, 217, 61, 0.08);
  color: var(--gold);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition);
}
.prologue-btn:hover {
  background: rgba(255, 217, 61, 0.18);
  border-color: var(--gold);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px var(--gold-glow);
}

/* ===== Story Dialogue System ===== */
.story-dialogue {
  margin-bottom: 16px;
  display: grid;
  gap: 8px;
}
.story-dialogue:empty { display: none; }

.dialogue-label {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--gold);
  padding: 5px 14px;
  background: var(--gold-glow);
  border: 1px solid rgba(255, 217, 61, 0.18);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-bottom: 4px;
}

.dialogue-bubble, .prologue-line {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: bubbleFadeIn 0.4s ease forwards;
  opacity: 0;
}
.dialogue-bubble:nth-child(2), .prologue-line:nth-child(2) { animation-delay: 0.15s; }
.dialogue-bubble:nth-child(3), .prologue-line:nth-child(3) { animation-delay: 0.3s; }
.dialogue-bubble:nth-child(4), .prologue-line:nth-child(4) { animation-delay: 0.45s; }
.dialogue-bubble:nth-child(5), .prologue-line:nth-child(5) { animation-delay: 0.6s; }

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

.bubble-right { flex-direction: row-reverse; }

.bubble-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bg-input);
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  flex-shrink: 0;
  border: 2px solid var(--border);
}

.bubble-content {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border);
}
.bubble-left .bubble-content {
  border-top-left-radius: 4px;
}
.bubble-right .bubble-content {
  border-top-right-radius: 4px;
  background: rgba(0, 212, 170, 0.08);
  border-color: rgba(0, 212, 170, 0.15);
}
[data-theme="light"] .bubble-right .bubble-content {
  background: rgba(0, 184, 148, 0.06);
  border-color: rgba(0, 184, 148, 0.12);
}

.bubble-name {
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--teal);
  margin-bottom: 2px;
  letter-spacing: 0.02em;
}
.bubble-right .bubble-name { text-align: right; }

.bubble-text {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text);
}

/* ===== Prologue Full-Page View ===== */
.prologue-page {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 20px 40px;
  background: var(--bg);
}

.prologue-skip-btn {
  position: fixed;
  top: 16px;
  right: 24px;
  z-index: 50;
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all var(--transition);
}
.prologue-skip-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.prologue-scroll {
  width: 100%;
  max-width: 520px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 0;
  overflow-y: auto;
}

.prologue-scene-header {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--gold);
  text-align: center;
  padding: 14px 18px;
  background: var(--gold-glow);
  border: 1px solid rgba(255, 217, 61, 0.15);
  border-radius: var(--radius-md);
  margin: 12px 0 4px;
}

.prologue-auto-line {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.prologue-start-wrap {
  padding: 24px 0 0;
  text-align: center;
}
.prologue-start-btn {
  min-width: 220px;
}

.hidden-for-prologue {
  display: none !important;
}

/* ===== Feedback Character Reaction ===== */
.feedback-reaction {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  font-weight: 700;
  font-size: 0.95rem;
}
.reaction-correct {
  background: rgba(0, 212, 170, 0.1);
  border: 1px solid rgba(0, 212, 170, 0.2);
  animation: celebrateIn 0.5s ease;
}
[data-theme="light"] .reaction-correct {
  background: rgba(0, 184, 148, 0.06);
  border-color: rgba(0, 184, 148, 0.15);
}
.reaction-wrong {
  background: rgba(255, 107, 107, 0.08);
  border: 1px solid rgba(255, 107, 107, 0.15);
  animation: shakeIn 0.5s ease;
}
.reaction-avatar { font-size: 1.5rem; flex-shrink: 0; }
.reaction-text { color: var(--text); line-height: 1.5; }

@keyframes celebrateIn {
  0% { transform: scale(0.85); opacity: 0; }
  50% { transform: scale(1.04); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes shakeIn {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

@media (max-width: 768px) {
  .bubble-content { max-width: 78%; }
  .bubble-avatar { width: 36px; height: 36px; font-size: 1.15rem; }
  .prologue-modal { padding: 20px; max-height: 85vh; }
  .prologue-bg { font-size: 0.95rem; padding: 10px 14px; }
}

/* ===== CTA Resume Button ===== */
.cta-resume {
  background: transparent;
  border: 2px solid var(--teal);
  color: var(--teal);
  box-shadow: none;
  animation: none;
  margin-top: 8px;
}
.cta-resume:hover {
  background: rgba(0, 212, 170, 0.12);
  box-shadow: 0 0 24px rgba(0, 212, 170, 0.25);
}

/* ===== Story Select View ===== */
.story-select-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 24px 100px;
  min-height: 80vh;
  display: flex;
  flex-direction: column;
}

.story-select-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin-top: 8px;
  flex: 1;
}

.story-select-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 28px 24px;
  border-radius: var(--radius-xl);
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: all 0.35s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
  opacity: 0;
  transform: translateY(24px);
  animation: storyCardIn 0.5s ease forwards;
}
.story-select-card:nth-child(1) { animation-delay: 0.05s; }
.story-select-card:nth-child(2) { animation-delay: 0.12s; }
.story-select-card:nth-child(3) { animation-delay: 0.19s; }
.story-select-card:nth-child(4) { animation-delay: 0.26s; }

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

.story-select-card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1.5px;
  background: linear-gradient(135deg, transparent 40%, var(--teal) 100%);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}
.story-select-card:hover::before { opacity: 1; }

.story-select-card:hover {
  transform: translateY(-5px);
  border-color: var(--border-glow);
  box-shadow: var(--shadow-glow);
}
[data-theme="light"] .story-select-card {
  box-shadow: 0 1px 8px rgba(0,0,0,0.05);
}
[data-theme="light"] .story-select-card:hover {
  box-shadow: 0 8px 32px rgba(0,0,0,0.08);
}

.ssc-header {
  display: flex;
  align-items: center;
  gap: 14px;
}
.ssc-emoji {
  font-size: 2.6rem;
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: rgba(0, 212, 170, 0.08);
}
.ssc-tea .ssc-emoji { background: rgba(255,217,61,0.1); }
.ssc-det .ssc-emoji { background: rgba(74,158,255,0.1); }
.ssc-spc .ssc-emoji { background: rgba(0,212,170,0.1); }
.ssc-dep .ssc-emoji { background: rgba(255,107,107,0.1); }

.ssc-titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ssc-story-num {
  font-family: "Bungee", sans-serif;
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  color: var(--teal);
}
.ssc-story-name {
  font-family: "Outfit", sans-serif;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
  margin: 0;
}
.ssc-character {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.ssc-desc {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.ssc-progress-wrap {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ssc-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
}
.ssc-progress-bar {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(0, 212, 170, 0.1);
  overflow: hidden;
}
.ssc-progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--blue));
  transition: width 0.6s ease;
}

.back-home-btn {
  display: inline-flex;
  margin-top: 24px;
  align-self: center;
}

@media (max-width: 768px) {
  .story-select-grid {
    grid-template-columns: 1fr;
  }
  .story-select-wrap {
    padding: 24px 16px 100px;
  }
  .story-select-card {
    padding: 20px 18px;
  }
  .ssc-emoji {
    font-size: 2rem;
    width: 46px;
    height: 46px;
    border-radius: 12px;
  }
  .ssc-story-name {
    font-size: 1.05rem;
  }
}
