/* 數學小勇士 — 森林主題 · 咩咩 & 都都 */
:root {
  --bg: #e8f5e9;
  --surface: #fffef7;
  --ink: #1b3a2a;
  --muted: #5a7264;
  --primary: #2e7d4f;
  --primary-dark: #1b5e3a;
  --primary-light: #66bb6a;
  --accent: #f4a261;
  --leaf: #81c784;
  --moss: #a5d6a7;
  --sky: #b3e5d0;
  --pink: #e8919a;
  --ok: #43a047;
  --bad: #e57373;
  --wood: #8d6e63;
  --radius: 22px;
  --shadow: 0 10px 28px rgba(27, 94, 58, 0.14);
  --tap: 52px;
  --font: "Noto Sans TC", "Nunito", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
}

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

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    /* soft canopy glow */
    radial-gradient(ellipse 90% 55% at 8% -5%, #c8e6c9 0%, transparent 55%),
    radial-gradient(ellipse 70% 45% at 95% 0%, #ffe0b2 0%, transparent 48%),
    radial-gradient(ellipse 60% 40% at 50% 105%, #a5d6a7 0%, transparent 50%),
    /* leaf dots */
    radial-gradient(circle at 12% 28%, rgba(129, 199, 132, 0.35) 0 8px, transparent 9px),
    radial-gradient(circle at 88% 42%, rgba(165, 214, 167, 0.4) 0 6px, transparent 7px),
    radial-gradient(circle at 70% 78%, rgba(102, 187, 106, 0.25) 0 10px, transparent 11px),
    radial-gradient(circle at 25% 85%, rgba(255, 224, 178, 0.45) 0 7px, transparent 8px);
  min-height: 100vh;
  line-height: 1.55;
  position: relative;
}

/* woodland side trees (decorative) */
body::before,
body::after {
  content: "";
  pointer-events: none;
  position: fixed;
  bottom: 0;
  width: 120px;
  height: 220px;
  z-index: 0;
  opacity: 0.22;
  background:
    radial-gradient(ellipse 70% 40% at 50% 18%, #2e7d4f 0 40%, transparent 42%),
    linear-gradient(180deg, transparent 28%, #5d4037 28% 100%);
  background-size: 100% 100%, 18px 100%;
  background-position: center, center;
  background-repeat: no-repeat;
}
body::before { left: -20px; transform: scaleX(-1); }
body::after { right: -20px; }

img { max-width: 100%; height: auto; }
button, input, select { font: inherit; }

.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--primary); color: #fff; padding: 0.5rem 1rem; z-index: 100;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

.app-header {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(12px);
  background: rgba(255, 254, 247, 0.93);
  border-bottom: 3px solid #a5d6a7;
  padding: 0.65rem 1rem;
}

.header-inner {
  max-width: 1040px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; flex-wrap: wrap;
  position: relative; z-index: 1;
}

.logo {
  display: flex; align-items: center; gap: 0.45rem;
  font-weight: 900; font-size: 1.15rem;
  color: var(--primary-dark); text-decoration: none;
}
.logo-mascots {
  display: flex; align-items: flex-end; gap: 0;
  margin-right: 0.15rem;
}
.logo-mascots img {
  width: 40px; height: 48px; object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(27, 94, 58, 0.2));
}
.logo-mascots img:first-child { margin-right: -6px; }
.logo-text { letter-spacing: 0.02em; }
.logo-sub {
  display: block; font-size: 0.65rem; font-weight: 700;
  color: var(--muted); margin-top: -2px;
}

.nav { display: flex; gap: 0.35rem; flex-wrap: wrap; }

.nav-btn {
  min-height: 44px; padding: 0.4rem 0.75rem;
  border-radius: 999px; border: 2px solid transparent;
  background: #f1f8e9; color: var(--ink);
  font-weight: 700; font-size: 0.9rem; cursor: pointer;
  transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
}
.nav-btn:hover { transform: translateY(-1px); background: #c8e6c9; }
.nav-btn.is-active {
  background: linear-gradient(135deg, #2e7d4f, #66bb6a);
  color: #fff; box-shadow: 0 4px 14px rgba(46, 125, 79, 0.4);
}

.user-chip {
  display: flex; align-items: center; gap: 0.45rem;
  background: #fffef7; border: 2px solid #a5d6a7;
  border-radius: 999px; padding: 0.25rem 0.5rem 0.25rem 0.35rem;
  font-weight: 700; font-size: 0.85rem;
}
.user-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }

main {
  max-width: 1040px; margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
  position: relative; z-index: 1;
}

.view[hidden] { display: none !important; }

.section-head { margin-bottom: 1rem; }
.section-head h2 { margin: 0 0 0.35rem; font-size: 1.65rem; font-weight: 900; color: var(--primary-dark); }
.section-head p { margin: 0; color: var(--muted); }

/* Mascot helpers */
.mascot {
  display: block; object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(27, 94, 58, 0.18));
}
.mascot-pair {
  display: flex; align-items: flex-end; justify-content: center;
  gap: 0.5rem; margin: 0.5rem 0 0.75rem;
}
.mascot-pair img { height: 110px; width: auto; }
.mascot-solo { height: 100px; width: auto; margin: 0 auto; }
.mascot-tiny { height: 56px; width: auto; }
.mascot-label {
  font-size: 0.75rem; font-weight: 800; color: var(--primary-dark);
  text-align: center; margin-top: 0.15rem;
}
.ask-chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: #e8f5e9; border: 2px solid #a5d6a7;
  border-radius: 999px; padding: 0.25rem 0.7rem 0.25rem 0.3rem;
  font-weight: 800; font-size: 0.8rem; color: var(--primary-dark);
}
.ask-chip img { height: 28px; width: auto; }

.hero {
  background: linear-gradient(180deg, #fffef7 0%, #f1f8e9 100%);
  border-radius: calc(var(--radius) + 6px);
  padding: 1.75rem 1.5rem;
  box-shadow: var(--shadow);
  border: 3px solid #a5d6a7;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: "🌿";
  position: absolute; top: 0.75rem; left: 1rem;
  font-size: 1.4rem; opacity: 0.7;
}
.hero::after {
  content: "🍃";
  position: absolute; top: 0.75rem; right: 1rem;
  font-size: 1.4rem; opacity: 0.7;
}
.hello { margin: 0; font-weight: 800; color: var(--primary); font-size: 1.05rem; }
.hero h1 { margin: 0.35rem 0 0.5rem; font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 900; color: var(--primary-dark); }
.hero-lead { color: var(--muted); margin: 0 auto 1rem; max-width: 36rem; }

.hero-badges {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  justify-content: center; margin-bottom: 1.25rem;
}
.pill {
  background: #e8f5e9; color: var(--primary-dark);
  border-radius: 999px; padding: 0.35rem 0.85rem;
  font-weight: 700; font-size: 0.85rem;
  border: 2px solid #a5d6a7;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
  margin-top: 0.5rem;
}
@media (min-width: 720px) {
  .feature-grid { grid-template-columns: repeat(4, 1fr); }
}

.feature-card {
  display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
  padding: 1.1rem 0.75rem;
  border-radius: var(--radius);
  border: 3px solid #c8e6c9;
  background: linear-gradient(180deg, #fffef7 0%, #f1f8e9 100%);
  cursor: pointer; font-weight: 700;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  min-height: 120px;
  color: var(--ink);
}
.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: #66bb6a;
}
.feature-card strong { font-size: 1.05rem; }
.feature-card span:last-child { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.feature-emoji { font-size: 2rem; line-height: 1; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-top: 1.25rem;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow);
  border: 2px solid #c8e6c9;
  display: flex; flex-direction: column; gap: 0.2rem;
}
.stat-num { font-size: 1.75rem; font-weight: 900; color: var(--primary-dark); }
.stat-label { font-size: 0.85rem; color: var(--muted); font-weight: 700; }

.btn {
  min-height: var(--tap);
  padding: 0.65rem 1.25rem;
  border-radius: 999px;
  border: 3px solid transparent;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, #2e7d4f, #66bb6a);
  color: #fff;
  box-shadow: 0 6px 18px rgba(46, 125, 79, 0.4);
}
.btn-secondary {
  background: #fffef7;
  color: var(--primary-dark);
  border-color: #a5d6a7;
}
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: #c8e6c9;
}
.btn-tiny {
  min-height: 32px; padding: 0.2rem 0.65rem;
  font-size: 0.75rem; border-radius: 999px;
  background: #e8f5e9; border: none; font-weight: 700; cursor: pointer;
}
.btn-block { width: 100%; margin-top: 0.75rem; }

.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: center; }
.actions.wrap { justify-content: flex-start; margin: 0.75rem 0; }

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  border: 2px solid #c8e6c9;
}

.login-card {
  max-width: 520px; margin: 1rem auto;
  background: linear-gradient(180deg, #fffef7 0%, #f1f8e9 100%);
  border-radius: calc(var(--radius) + 8px);
  padding: 2rem 1.5rem;
  box-shadow: var(--shadow);
  border: 3px solid #a5d6a7;
  text-align: center;
}
.login-mascots {
  display: flex; justify-content: center; align-items: flex-end;
  gap: 0.75rem; margin-bottom: 0.5rem;
}
.login-mascots img { height: 120px; width: auto; }
.login-ask {
  display: flex; justify-content: center; gap: 0.5rem; flex-wrap: wrap;
  margin: 0.5rem 0 0.75rem;
}
.login-card h1 { margin: 0.25rem 0; font-size: 1.75rem; font-weight: 900; color: var(--primary-dark); }
.login-box {
  text-align: left; margin-top: 1.25rem;
  padding: 1rem; border-radius: 16px;
  background: rgba(255,255,255,0.7); border: 2px dashed #81c784;
}
.login-box h2 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.google-slot { min-height: 44px; display: flex; justify-content: center; margin: 0.5rem 0; }
.auth-hint, .muted-sm { font-size: 0.85rem; color: var(--muted); margin: 0.35rem 0; }

.fill-label {
  display: block; font-weight: 700; margin: 0.75rem 0 0.35rem; font-size: 0.9rem;
}
.fill-input, .select-input {
  width: 100%; min-height: var(--tap);
  padding: 0.65rem 1rem;
  border-radius: 14px;
  border: 3px solid #c8e6c9;
  background: #fffef7;
  outline: none;
}
.fill-input:focus, .select-input:focus {
  border-color: #66bb6a;
  box-shadow: 0 0 0 4px rgba(102, 187, 106, 0.28);
}

.grade-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.85rem;
}
.grade-card {
  border: none; cursor: pointer;
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  background: #fffef7;
  box-shadow: var(--shadow);
  border-bottom: 6px solid var(--grade-color, #2e7d4f);
  display: flex; flex-direction: column; align-items: center; gap: 0.35rem;
  transition: transform 0.15s;
  min-height: 130px;
  color: var(--ink);
}
.grade-card:hover { transform: translateY(-4px) scale(1.02); }
.grade-emoji { font-size: 2rem; }
.grade-name { font-weight: 900; font-size: 1.15rem; }
.grade-meta { font-size: 0.75rem; color: var(--muted); font-weight: 600; text-align: center; }

.lesson-list { display: flex; flex-direction: column; gap: 0.75rem; }
.lesson-card {
  text-align: left; width: 100%;
  border: 3px solid #c8e6c9; background: #fffef7;
  border-radius: var(--radius); padding: 1rem 1.1rem;
  cursor: pointer; box-shadow: 0 4px 12px rgba(27, 94, 58, 0.06);
  transition: border-color 0.15s, transform 0.15s;
  color: var(--ink);
}
.lesson-card:hover { border-color: #66bb6a; transform: translateX(4px); }
.lesson-top { display: flex; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.lesson-desc { margin: 0.4rem 0; color: var(--muted); font-size: 0.9rem; }
.lesson-topic { font-size: 0.8rem; font-weight: 700; color: var(--primary); }
.badge {
  font-size: 0.75rem; font-weight: 800;
  padding: 0.2rem 0.55rem; border-radius: 999px;
  background: #e8f5e9; color: var(--muted);
}
.badge-ok { background: #c8e6c9; color: #1b5e3a; }
.badge-new { background: #ffe0b2; color: #e65100; }

.toolbar { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.85rem; }

.quiz-card, .result-card {
  background: var(--surface);
  border-radius: calc(var(--radius) + 4px);
  padding: 1.35rem;
  box-shadow: var(--shadow);
  border: 3px solid #a5d6a7;
}
.quiz-top { display: flex; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; align-items: baseline; }
.quiz-top h2 { margin: 0; font-size: 1.35rem; color: var(--primary-dark); }
.quiz-meta { font-size: 0.85rem; color: var(--muted); font-weight: 700; }
.progress-bar-wrap {
  height: 12px; background: #e0efe3; border-radius: 999px;
  margin: 0.85rem 0; overflow: hidden;
}
.progress-bar {
  height: 100%; width: 0;
  background: linear-gradient(90deg, #2e7d4f, #81c784, #f4a261);
  border-radius: 999px; transition: width 0.25s ease;
}
.quiz-step { font-weight: 800; color: var(--primary); margin-bottom: 0.75rem; }
.q-prompt { font-size: 1.25rem; font-weight: 800; margin: 0 0 1rem; }

.choices { display: flex; flex-direction: column; gap: 0.6rem; }
.choice-btn {
  display: flex; align-items: center; gap: 0.75rem;
  min-height: var(--tap); padding: 0.75rem 1rem;
  border-radius: 16px; border: 3px solid #c8e6c9;
  background: #fffef7; cursor: pointer; font-weight: 700; text-align: left;
  transition: border-color 0.12s, background 0.12s;
  color: var(--ink);
}
.choice-btn.is-selected, .choice-btn[aria-pressed="true"] {
  border-color: #2e7d4f; background: #e8f5e9;
}
.choice-letter {
  width: 36px; height: 36px; border-radius: 12px;
  background: #c8e6c9; display: grid; place-items: center;
  font-weight: 900; color: var(--primary-dark); flex-shrink: 0;
}
.quiz-actions {
  display: flex; justify-content: space-between; gap: 0.75rem;
  margin-top: 1.25rem; flex-wrap: wrap;
}

.result-hero { text-align: center; margin-bottom: 1rem; }
.result-mascots {
  display: flex; justify-content: center; align-items: flex-end;
  gap: 0.5rem; margin-bottom: 0.35rem;
}
.result-mascots img { height: 90px; width: auto; }
.result-stars { font-size: 2.5rem; }
.result-score { font-size: 2.25rem; font-weight: 900; color: var(--primary-dark); }
.result-percent { font-size: 1.5rem; font-weight: 800; color: var(--accent); }
.result-msg { font-weight: 700; color: var(--muted); }
.result-item {
  border-radius: 14px; padding: 0.85rem 1rem; margin-bottom: 0.65rem;
  border: 2px solid #c8e6c9; background: #f1f8e9;
}
.result-item.is-correct { border-color: #81c784; background: #e8f5e9; }
.result-item.is-wrong { border-color: #ef9a9a; background: #fff5f5; }
.result-item-head { font-weight: 900; margin-bottom: 0.35rem; }
.result-explain { color: var(--muted); margin: 0.35rem 0 0; }
.result-prompt { font-weight: 700; }

.camera-zone {
  position: relative;
  background: linear-gradient(160deg, #1b3a2a, #2e4a3a);
  border-radius: 18px;
  min-height: 220px;
  overflow: hidden;
  display: grid; place-items: center;
}
.camera-preview, .solve-preview {
  width: 100%; max-height: 360px; object-fit: contain; display: block;
}
.camera-placeholder {
  color: #a5d6a7; text-align: center; padding: 2rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
}
.camera-placeholder .mascot-tiny { opacity: 0.95; filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3)); }
.camera-placeholder p { margin: 0; font-weight: 700; }
.file-btn {
  position: relative;
  cursor: pointer;
  overflow: hidden;
}
/* Cover the label so taps hit the real file input (display:none / hidden breaks mobile pickers) */
.file-input-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 0;
  z-index: 2;
}
.camera-placeholder {
  cursor: pointer;
}
.camera-placeholder:focus-visible {
  outline: 3px solid #a5d6a7;
  outline-offset: 4px;
}
.solve-status { margin-top: 0.75rem; font-weight: 700; color: var(--primary); }
.solve-result {
  margin-top: 1rem; padding: 1rem;
  border-radius: 16px; background: #e8f5e9; border: 2px solid #81c784;
}
.solve-result h3 { margin: 0 0 0.5rem; color: var(--primary-dark); }
.solve-result ol { margin: 0.5rem 0; padding-left: 1.25rem; }
.solve-result li { margin-bottom: 0.35rem; font-weight: 600; }
.solve-tip {
  margin-top: 0.75rem; padding: 0.65rem 0.85rem;
  background: #fff3e0; border-radius: 12px; font-weight: 700;
  border: 2px solid #ffe0b2;
}

.report-hero {
  background: linear-gradient(135deg, #1b5e3a, #2e7d4f 45%, #66bb6a);
  color: #fff; border-radius: var(--radius);
  padding: 1.5rem; text-align: center;
  margin-bottom: 1rem; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.report-hero .report-mascots {
  display: flex; justify-content: center; align-items: flex-end;
  gap: 0.35rem; margin-bottom: 0.35rem;
}
.report-hero .report-mascots img {
  height: 72px; width: auto;
  opacity: 1;
  mix-blend-mode: normal;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,0.25));
}
.report-hero .stars { font-size: 2rem; }
.report-hero .rate { font-size: 2.5rem; font-weight: 900; }
.report-hero p { margin: 0.35rem 0 0; font-weight: 700; opacity: 0.95; }

.empty-state {
  text-align: center; padding: 1.5rem 1rem;
  color: var(--muted); font-weight: 700;
}
.empty-state img { height: 80px; width: auto; margin: 0 auto 0.5rem; display: block; }
.empty { text-align: center; color: var(--muted); padding: 1.25rem !important; }

.progress-row {
  display: grid;
  grid-template-columns: 90px 1fr 100px;
  gap: 0.5rem; align-items: center;
  margin-bottom: 0.65rem;
}
@media (max-width: 520px) {
  .progress-row { grid-template-columns: 1fr; gap: 0.25rem; }
}
.progress-row-label { font-weight: 800; }
.progress-track {
  height: 14px; background: #e0efe3; border-radius: 999px; overflow: hidden;
}
.progress-fill { height: 100%; border-radius: 999px; }
.progress-row-meta { font-size: 0.8rem; color: var(--muted); font-weight: 700; text-align: right; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.65rem 0.5rem; text-align: left; border-bottom: 1px solid #c8e6c9; }
th { font-weight: 800; color: var(--muted); font-size: 0.8rem; }
.footnote { font-size: 0.8rem; color: var(--muted); margin-top: 0.75rem; }

.app-footer {
  text-align: center; padding: 1.5rem 1rem 2.5rem;
  color: var(--muted); font-size: 0.85rem; font-weight: 600;
  position: relative; z-index: 1;
}
.footer-mascots {
  display: flex; justify-content: center; align-items: flex-end;
  gap: 0.25rem; margin-bottom: 0.35rem;
}
.footer-mascots img { height: 40px; width: auto; opacity: 0.9; }

@media (max-width: 640px) {
  .nav-btn { font-size: 0.78rem; padding: 0.35rem 0.55rem; }
  .logo-text { font-size: 0.95rem; }
  .logo-mascots img { width: 32px; height: 40px; }
  .mascot-pair img { height: 88px; }
  .login-mascots img { height: 96px; }
  body::before, body::after { opacity: 0.12; width: 70px; height: 140px; }
}

/* ---- Feature grid 6 ---- */
.feature-grid-6 {
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 720px) {
  .feature-grid-6 { grid-template-columns: repeat(3, 1fr); }
}

/* ---- 開格遊戲 ---- */
.tg-status-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.85rem;
  font-weight: 800; color: var(--primary-dark);
}
.tg-board-wrap {
  position: relative;
  width: 100%;
  max-width: 420px;
  margin: 0 auto 1rem;
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  overflow: hidden;
  border: 4px solid #2e7d4f;
  box-shadow: var(--shadow);
  background: #1b3a2a;
}
.tg-reward-bg {
  position: absolute; inset: 0;
  z-index: 0;
  display: grid; place-items: center;
  background: linear-gradient(160deg, #e8f5e9, #fff8e1);
}
.tg-reward-bg img {
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 0.5rem;
}
.tg-grid {
  position: absolute; inset: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 3px;
  padding: 3px;
}
.tg-tile {
  background: linear-gradient(145deg, #66bb6a, #2e7d4f);
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,0.25);
  display: grid; place-items: center;
  font-weight: 900; color: rgba(255,255,255,0.85);
  font-size: 1.1rem;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.35s ease, transform 0.35s ease, visibility 0.35s ease;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.15);
  /* fully cover cell so reward cannot show until opened */
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
}
.tg-tile.is-open {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(0.85);
}
.tg-question { margin-top: 0.5rem; }
.tg-celebrate {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(27, 58, 42, 0.72);
  display: grid; place-items: center;
  padding: 1rem;
}
/* author display:grid would otherwise override the hidden attribute */
.tg-celebrate[hidden] {
  display: none !important;
}
.tg-celebrate-inner {
  background: linear-gradient(180deg, #fffef7, #f1f8e9);
  border-radius: 24px;
  border: 4px solid #a5d6a7;
  padding: 1.5rem;
  text-align: center;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
  animation: tg-pop 0.45s ease;
}
.tg-celebrate-inner img {
  max-height: 280px; width: auto;
  margin: 0 auto 0.75rem;
  filter: drop-shadow(0 8px 16px rgba(27,94,58,0.25));
}
.tg-celebrate-inner h3 {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
  color: var(--primary-dark);
}
@keyframes tg-pop {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ---- 直式練習 ---- */
.vert-layout {
  background: #fffef7;
  border: 3px dashed #81c784;
  border-radius: 16px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  overflow-x: auto;
}
.vert-pre {
  margin: 0;
  font-family: "Courier New", ui-monospace, monospace;
  font-size: clamp(1.35rem, 4vw, 1.85rem);
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
  text-align: right;
  letter-spacing: 0.08em;
  white-space: pre;
}
.vert-guide {
  background: #e8f5e9;
  border: 2px solid #a5d6a7;
  border-radius: 16px;
  padding: 1rem;
  margin-bottom: 1rem;
}
.vert-guide h3 {
  margin: 0 0 0.35rem;
  color: var(--primary-dark);
  font-size: 1.1rem;
}
.vert-guide p { margin: 0 0 0.75rem; font-weight: 600; }
.vert-check {
  border-top: 2px dashed #c8e6c9;
  padding-top: 0.75rem;
}
.feedback-ok { color: var(--ok) !important; }
.feedback-bad { color: #c62828 !important; }
.feedback-hint { color: var(--primary) !important; }

/* ---- Level / XP badge ---- */
.level-panel { margin: 0.75rem 0 1rem; }
.level-badge {
  background: linear-gradient(135deg, #fffde7, #e8f5e9);
  border: 3px solid #81c784;
  border-radius: 18px;
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow);
}
.level-badge-top {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 0.45rem 0.65rem; margin-bottom: 0.55rem;
}
.level-grade-pill {
  background: #2e7d4f; color: #fff;
  font-weight: 900; font-size: 0.75rem;
  padding: 0.2rem 0.55rem; border-radius: 999px;
  letter-spacing: 0.02em;
}
.level-title {
  font-weight: 900; color: var(--primary-dark);
  font-size: 1.05rem; flex: 1;
}
.level-num {
  font-weight: 900; color: #ef6c00;
  background: #fff3e0; border: 2px solid #ffe0b2;
  padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.85rem;
}
.level-xp-row { display: grid; gap: 0.35rem; }
.level-xp-track {
  height: 14px; background: #c8e6c9; border-radius: 999px; overflow: hidden;
  border: 1px solid #a5d6a7;
}
.level-xp-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, #66bb6a, #ffd54f 70%, #ffb300);
  border-radius: 999px;
  transition: width 0.45s ease;
}
.level-xp-label {
  font-size: 0.8rem; font-weight: 700; color: var(--muted);
}

/* ---- Collection album ---- */
.coll-album-head { margin-bottom: 1rem; }
.coll-album-head p { margin: 0 0 0.5rem; font-weight: 700; }
.coll-progress { margin: 0.35rem 0 0.65rem; max-width: 320px; }
.coll-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.85rem;
}
.coll-card {
  --coll-bg: #e8f5e9;
  --coll-accent: #2e7d4f;
  border-radius: 16px;
  border: 3px solid var(--coll-accent);
  background: var(--coll-bg);
  box-shadow: 0 6px 16px rgba(27, 94, 58, 0.18);
  overflow: hidden;
  position: relative;
  min-height: 220px;
}
.coll-card-inner {
  padding: 0.65rem 0.7rem 0.85rem;
  display: flex; flex-direction: column; align-items: center;
  text-align: center; height: 100%;
}
.coll-card h3 {
  margin: 0.35rem 0 0.2rem; font-size: 0.92rem;
  color: var(--ink); font-weight: 900;
}
.coll-card p {
  margin: 0; font-size: 0.75rem; font-weight: 600;
  color: var(--muted); line-height: 1.35;
}
.coll-card.is-dark h3 { color: #fff; }
.coll-card.is-dark p { color: rgba(255,255,255,0.85); }
.coll-rarity {
  align-self: flex-start;
  font-size: 0.68rem; font-weight: 900;
  background: rgba(255,255,255,0.85);
  color: var(--coll-accent);
  border: 1px solid var(--coll-accent);
  padding: 0.1rem 0.4rem; border-radius: 999px;
  margin-bottom: 0.25rem;
}
.coll-card.is-dark .coll-rarity {
  background: rgba(0,0,0,0.35); color: #fff; border-color: rgba(255,255,255,0.5);
}
.coll-card-imgs {
  width: 100%; height: 110px;
  display: grid; place-items: center;
  margin: 0.15rem 0;
}
.coll-card-imgs img {
  max-height: 110px; max-width: 100%;
  width: auto; height: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
}
.coll-card-imgs.dual {
  display: flex; justify-content: center; align-items: flex-end; gap: 0.15rem;
}
.coll-card-imgs.dual img { max-height: 95px; max-width: 48%; }
.coll-card-imgs.locked-silhouette {
  font-size: 2.5rem; opacity: 0.45;
}
.coll-card.is-locked {
  background: #eceff1; border-color: #b0bec5;
  filter: grayscale(0.35);
}
.coll-card.is-locked h3 { color: #78909c; }
.coll-count, .coll-new {
  position: absolute; top: 0.45rem; right: 0.45rem;
  font-weight: 900; font-size: 0.75rem;
  background: #fff; border-radius: 999px;
  padding: 0.15rem 0.45rem;
  border: 2px solid var(--coll-accent);
  color: var(--coll-accent);
}
.coll-new {
  background: #ff6f00; color: #fff; border-color: #e65100;
  animation: coll-pop 0.6s ease;
}
@keyframes coll-pop {
  0% { transform: scale(0.5); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.global-toast {
  position: fixed; left: 50%; bottom: 1.5rem;
  transform: translateX(-50%);
  z-index: 100;
  max-width: min(92vw, 420px);
  background: #1b5e3a; color: #fff;
  padding: 0.85rem 1.1rem; border-radius: 16px;
  font-weight: 800; text-align: center;
  box-shadow: 0 10px 28px rgba(0,0,0,0.28);
  border: 3px solid #a5d6a7;
}
.global-toast.is-show { display: block; }
.xp-gain-flash {
  display: inline-block; margin-left: 0.35rem;
  color: #ffd54f; font-weight: 900;
}


/* Rank / score */
.rank-card { grid-column: 1 / -1; background: linear-gradient(135deg, #e8f5e9, #fff8e1); border: 2px solid #a5d6a7; }
.rank-bar { height: 10px; background: #c8e6c9; border-radius: 999px; margin: 0.45rem 0 0.25rem; overflow: hidden; }
.rank-bar-fill { height: 100%; background: linear-gradient(90deg, #43a047, #fdd835); border-radius: 999px; transition: width 0.4s ease; }
.rank-meta { display: block; font-size: 0.8rem; font-weight: 700; color: var(--primary-dark); opacity: 0.9; }
.rank-badge {
  display: inline-block; margin-top: 0.55rem;
  background: rgba(255,255,255,0.22); border: 2px solid rgba(255,255,255,0.45);
  border-radius: 999px; padding: 0.3rem 0.85rem; font-weight: 900; font-size: 0.95rem;
}
.rank-toast {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%);
  z-index: 9999; background: #1b5e3a; color: #fff;
  padding: 0.75rem 1.25rem; border-radius: 999px; font-weight: 900;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25); max-width: 92vw; text-align: center;
}

/* OCR result */
.ocr-box {
  background: #f1f8e9; border: 2px dashed #81c784; border-radius: 12px;
  padding: 0.75rem 1rem; margin-bottom: 0.85rem;
}
.ocr-box strong { color: var(--primary-dark); }
.ocr-box pre {
  margin: 0.4rem 0 0; white-space: pre-wrap; word-break: break-word;
  font-family: "Noto Sans TC", Nunito, sans-serif; font-weight: 700; font-size: 0.95rem;
}
.ocr-box-warn { background: #fff8e1; border-color: #ffcc80; }
.ocr-box-warn p { margin: 0.35rem 0 0; font-weight: 600; color: var(--muted); }

/* Ensure mascots stay opaque (esp. white Dottie on green) */
.report-mascots img, .ask-chip img, .empty-state img, .mascot {
  opacity: 1 !important;
  mix-blend-mode: normal !important;
}


/* ---- Geometry diagrams (圖形與空間) ---- */
.q-diagram {
  margin: 0 0 1.1rem;
  padding: 0.85rem 0.75rem 0.5rem;
  background: linear-gradient(180deg, #f8fff4 0%, #e8f5e1 100%);
  border: 3px solid #8bc34a;
  border-radius: 18px;
  box-shadow: 0 4px 0 #689f38;
  text-align: center;
  max-width: 420px;
}
.q-diagram .geo-svg {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
  min-height: 140px;
  max-height: 220px;
}
.q-diagram-cap {
  margin: 0.35rem 0 0.15rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: #2e7d32;
}
.result-item .q-diagram {
  margin-top: 0.5rem;
  max-width: 280px;
  box-shadow: none;
  border-width: 2px;
}
.result-item .q-diagram .geo-svg {
  min-height: 100px;
  max-height: 160px;
}

/* ---- Multi-subject ---- */
.subject-pick-title {
  margin: 1.25rem 0 0.65rem;
  font-size: 1.15rem;
  color: var(--primary-dark);
  font-weight: 900;
  text-align: center;
}
.subject-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin: 0.5rem 0 0.75rem;
}
@media (min-width: 720px) {
  .subject-grid { grid-template-columns: repeat(4, 1fr); }
}
.subject-card {
  border: 3px solid #c8e6c9;
  background: linear-gradient(180deg, #fffef7 0%, #f1f8e9 100%);
  border-radius: var(--radius);
  padding: 1rem 0.75rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-height: 110px;
  color: var(--ink);
  box-shadow: var(--shadow);
  border-bottom: 6px solid var(--subject-color, #2e7d4f);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.subject-card:hover { transform: translateY(-3px) scale(1.02); }
.subject-card.is-active {
  border-color: var(--subject-color, #2e7d4f);
  box-shadow: 0 0 0 4px rgba(46, 125, 79, 0.22);
  background: #fff;
}
.subject-emoji { font-size: 2rem; line-height: 1; }
.subject-name { font-weight: 900; font-size: 1.15rem; }
.subject-tag { font-size: 0.72rem; color: var(--muted); font-weight: 600; text-align: center; }

.report-subject-block {
  margin: 0.75rem 0 1.1rem;
  padding: 0.75rem 0.85rem;
  border-radius: 16px;
  border: 2px solid #c8e6c9;
  border-left: 6px solid var(--subject-color, #2e7d4f);
  background: #fffef7;
}
.report-subject-title {
  margin: 0 0 0.55rem;
  font-size: 1rem;
  font-weight: 900;
  color: var(--primary-dark);
}

.coll-card-imgs img {
  max-width: 100%;
  max-height: 140px;
  object-fit: contain;
  border-radius: 12px;
}

/* ---- 收藏卡獎勵（隨機卡） ---- */
.result-card-reward { flex-direction: column; align-items: center; }
.result-card-img { height: auto !important; width: min(260px, 70vw) !important; aspect-ratio: 4/3; object-fit: cover; border-radius: 16px; border: 4px solid #a5d6a7; box-shadow: 0 6px 18px rgba(27,94,58,0.2); background: #f1f8e9; }
.result-card-img[src=""] { display: none; }
.result-card-label { margin: 0.4rem 0 0; font-weight: 800; color: var(--primary-dark); }
.tg-reward-bg img { object-fit: cover; padding: 0; }
.tg-celebrate-inner img { width: 100%; max-width: 360px; height: auto; max-height: 280px; object-fit: cover; border-radius: 16px; }
#tg-choices { margin: 0.5rem 0; }
#tg-choices .choice-btn.is-wrong { opacity: 0.45; text-decoration: line-through; }
.card-toast { position: fixed; right: 1rem; bottom: 4.5rem; z-index: 10000; display: flex; gap: 0.75rem; align-items: center; background: #fffef7; border: 3px solid #81c784; border-radius: 18px; padding: 0.6rem 0.9rem 0.6rem 0.6rem; box-shadow: 0 10px 28px rgba(0,0,0,0.25); max-width: min(360px, 92vw); animation: tg-pop 0.35s ease-out; }
.card-toast[hidden] { display: none !important; }
.card-toast img { width: 96px; height: 72px; object-fit: cover; border-radius: 10px; }
.card-toast strong { display: block; color: #1b5e3a; font-size: 0.95rem; }
.card-toast span { display: block; font-weight: 800; color: #444; font-size: 0.9rem; }

/* =====================================================================
   學生中心 v2：側邊欄、儀表板、魔法測驗、字卡、遊戲、成長、主題、氛圍
   ===================================================================== */
:root { --sb-w: 236px; --bn-h: 68px; }
[hidden] { display: none !important; }

/* ---------- header tools ---------- */
.header-tools { display: flex; align-items: center; gap: 0.4rem; margin-left: auto; }
.hdr-pill { background: #fff8e1; border: 2px solid #ffe082; border-radius: 999px; padding: 0.2rem 0.65rem; font-weight: 900; font-size: 0.9rem; }
.hdr-btn { min-height: 44px; min-width: 44px; border-radius: 999px; border: 2px solid #a5d6a7; background: #f1f8e9; font-size: 1.1rem; cursor: pointer; display: inline-flex; align-items: center; gap: 0.25rem; padding: 0 0.7rem; font-weight: 800; color: var(--primary-dark); }
.hdr-btn:hover { background: #c8e6c9; }
.hdr-btn-label { font-size: 0.85rem; }
body:not(.is-authed) .header-tools .hdr-pill { display: none; }

/* ---------- sidebar ---------- */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: var(--sb-w); z-index: 70;
  background: linear-gradient(180deg, #fffef7 0%, #eef7ee 100%);
  border-right: 3px solid #a5d6a7; padding: 0.85rem 0.7rem 1rem;
  display: flex; flex-direction: column; gap: 0.6rem; overflow-y: auto;
  transform: translateX(-105%); transition: transform 0.25s ease;
  box-shadow: 6px 0 24px rgba(27, 94, 58, 0.12);
}
body.sb-open .sidebar { transform: translateX(0); }
.sb-backdrop { position: fixed; inset: 0; background: rgba(20, 50, 30, 0.35); z-index: 65; }
.sidebar-head { display: flex; align-items: center; gap: 0.55rem; padding: 0.4rem; background: #fff; border-radius: 18px; border: 2px solid #c8e6c9; }
.sidebar-head strong { display: block; font-size: 1rem; color: var(--primary-dark); }
.sb-mascot { width: 48px; height: 52px; object-fit: contain; }
.sb-level { font-size: 0.75rem; color: var(--muted); font-weight: 700; }
.sb-close { margin-left: auto; border: none; background: #e8f5e9; border-radius: 50%; width: 36px; height: 36px; font-size: 1rem; cursor: pointer; }
.side-nav { display: flex; flex-direction: column; gap: 0.3rem; }
.side-link { display: flex; align-items: center; gap: 0.6rem; width: 100%; text-align: left; border-radius: 16px; min-height: 50px; font-size: 1rem; padding: 0.45rem 0.8rem; background: transparent; }
.side-link .ico { font-size: 1.3rem; width: 1.6rem; text-align: center; }
.side-link:hover { background: #e8f5e9; transform: translateX(3px); }
.sb-tip { margin-top: auto; display: flex; gap: 0.5rem; align-items: flex-end; background: #fff8e1; border: 2px dashed #ffd54f; border-radius: 16px; padding: 0.5rem; }
.sb-tip img { width: 44px; height: auto; }
.sb-tip p { margin: 0; font-size: 0.8rem; font-weight: 700; color: #6d4c41; }
body:not(.is-authed) .sidebar, body:not(.is-authed) .bottom-nav, body:not(.is-authed) #btn-mood { display: none !important; }

@media (min-width: 1000px) {
  body.is-authed .sidebar { transform: none; box-shadow: none; }
  body.is-authed .sb-close, body.is-authed .sb-backdrop { display: none !important; }
  body.is-authed .app-header, body.is-authed main, body.is-authed .app-footer { margin-left: var(--sb-w); }
  body.is-authed .app-header .logo { visibility: hidden; width: 0; overflow: hidden; }
  main { max-width: 1120px; }
}

/* ---------- bottom nav (mobile) ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; height: calc(var(--bn-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255, 254, 247, 0.97); border-top: 3px solid #a5d6a7; backdrop-filter: blur(10px);
}
.bn { border: none; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.1rem; font-weight: 800; font-size: 0.75rem; color: var(--muted); cursor: pointer; border-radius: 16px; margin: 0.3rem 0.15rem; min-height: 52px; padding: 0; }
.bn span { font-size: 1.45rem; line-height: 1; }
.bn.is-active { background: linear-gradient(135deg, #2e7d4f, #66bb6a); color: #fff; box-shadow: 0 4px 12px rgba(46,125,79,.35); }
@media (max-width: 999px) {
  body.is-authed main { padding-bottom: calc(var(--bn-h) + 2rem); }
  body.is-authed .app-footer { padding-bottom: calc(var(--bn-h) + 1rem); }
}
@media (min-width: 1000px) { .bottom-nav { display: none; } }

/* ---------- shared ---------- */
.view:not([hidden]) { animation: viewIn 0.35s ease both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.fade-in { animation: viewIn 0.3s ease both; }
.btn-sm { min-height: 44px; padding: 0.35rem 0.9rem; font-size: 0.9rem; }
.btn-xl { min-height: 60px; font-size: 1.15rem; }
.btn-ico { height: 26px; width: auto; }
.link-btn { border: none; background: none; color: var(--primary); font-weight: 800; cursor: pointer; font-size: 0.85rem; float: right; min-height: 32px; }
.muted-sm { color: var(--muted); font-size: 0.85rem; }
.dash-section-title { margin: 1.4rem 0 0.6rem; font-size: 1.2rem; font-weight: 900; color: var(--primary-dark); }
.toolbar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; margin: 0.75rem 0; }
.select-sm { width: auto; min-height: 44px; padding: 0.3rem 0.6rem; }
.inline-label { display: inline-flex; gap: 0.4rem; align-items: center; font-weight: 800; }
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { display: flex; gap: 0.5rem; align-items: center; padding: 0.5rem 0; border-bottom: 1px dashed #c8e6c9; }
.plain-list li span:first-child { flex: 1; }
.badge-ok { background: #c8e6c9; }
:focus-visible { outline: 3px solid #ffb300; outline-offset: 2px; }

.mascot-tip { display: flex; align-items: flex-end; gap: 0.6rem; margin: 0 0 1rem; }
.mascot-tip img { width: 64px; height: auto; flex: none; animation: bob 3s ease-in-out infinite; }
.mascot-tip .bubble { position: relative; background: #fff; border: 2px solid #a5d6a7; border-radius: 18px 18px 18px 4px; padding: 0.65rem 0.9rem; font-weight: 700; box-shadow: var(--shadow); }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.bounce { animation: bounceIn 0.7s cubic-bezier(.28,1.6,.5,1) both; }
.bounce-slow { animation: bob 3.2s ease-in-out infinite; }
@keyframes bounceIn { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.shake { animation: shake 0.38s; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.seg { display: inline-flex; flex-wrap: wrap; gap: 0.35rem; background: #f1f8e9; border-radius: 999px; padding: 0.25rem; border: 2px solid #c8e6c9; }
.seg-btn { min-height: 44px; border: none; border-radius: 999px; padding: 0.3rem 0.9rem; background: transparent; font-weight: 800; cursor: pointer; color: var(--ink); }
.seg-btn.is-on { background: linear-gradient(135deg, #2e7d4f, #66bb6a); color: #fff; box-shadow: 0 3px 10px rgba(46,125,79,.3); }

.modal { position: fixed; inset: 0; z-index: 120; background: rgba(20, 50, 30, 0.45); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal-card { position: relative; background: var(--surface); border-radius: 24px; padding: 1.25rem; width: min(440px, 100%); max-height: 85vh; overflow: auto; box-shadow: var(--shadow); border: 3px solid #a5d6a7; animation: bounceIn 0.35s both; }
.modal-x { position: absolute; top: 0.6rem; right: 0.6rem; width: 40px; height: 40px; border-radius: 50%; border: none; background: #e8f5e9; cursor: pointer; font-size: 1rem; }
.board { list-style: none; padding: 0; margin: 0.5rem 0; }
.board li { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.6rem; border-radius: 14px; margin-bottom: 0.35rem; background: #f7fbf6; font-weight: 800; }
.board li.is-me { background: #fff8e1; border: 2px solid #ffd54f; }
.board img { width: 32px; height: 36px; object-fit: contain; }
.board .nm { flex: 1; }
.board .medal { width: 1.8rem; text-align: center; font-size: 1.2rem; }

/* ---------- dashboard ---------- */
.dashboard { margin-bottom: 0.5rem; }
.dash-hero {
  display: flex; gap: 1rem; align-items: center; padding: 1.25rem 1.4rem; border-radius: 28px;
  background: var(--dash-bg, linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 55%, #a5d6a7 100%));
  border: 3px solid rgba(46,125,79,.25); box-shadow: var(--shadow); position: relative; overflow: hidden; color: var(--dash-ink, var(--ink));
}
.dash-hero::after { content: "🌲🌳🌲"; position: absolute; right: 1rem; bottom: -0.3rem; font-size: 2.6rem; opacity: 0.25; letter-spacing: -0.4rem; }
.dash-hero-mascots { position: relative; flex: none; width: 140px; height: 140px; }
.dash-hero-mascots img:first-child { height: 130px; width: auto; position: absolute; left: 0; bottom: 0; filter: drop-shadow(0 6px 10px rgba(0,0,0,.15)); }
.dash-buddy { height: 74px; width: auto; position: absolute; right: -6px; bottom: 0; }
.dash-hello { margin: 0 0 0.4rem; font-size: clamp(1.35rem, 3.5vw, 1.9rem); font-weight: 900; }
.speech { background: #fff; color: var(--ink); border-radius: 18px 18px 18px 4px; padding: 0.55rem 0.85rem; font-weight: 700; display: inline-block; box-shadow: 0 4px 12px rgba(0,0,0,.08); margin-bottom: 0.6rem; }
.dash-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.5rem; }
.dchip { background: rgba(255,255,255,.85); color: var(--ink); border-radius: 999px; padding: 0.25rem 0.7rem; font-weight: 800; font-size: 0.88rem; }
.dash-xp { max-width: 360px; }
.dash-xp-label { color: inherit; opacity: 0.85; }
.dash-grid { display: grid; gap: 1rem; margin-top: 1rem; grid-template-columns: 1fr; }
@media (min-width: 760px) { .dash-grid { grid-template-columns: 1fr 1fr; } }
.dash-grid h3 { margin: 0 0 0.6rem; }
.quest { display: flex; align-items: center; gap: 0.6rem; width: 100%; padding: 0.6rem 0.7rem; border-radius: 16px; border: 2px solid #e0eee3; background: #fff; margin-bottom: 0.5rem; cursor: pointer; text-align: left; min-height: 56px; color: var(--ink); }
.quest:hover { border-color: #66bb6a; }
.quest.is-done { background: #f1f8e9; border-color: #a5d6a7; }
.quest-emoji { font-size: 1.5rem; }
.quest-main { flex: 1; display: flex; flex-direction: column; gap: 0.3rem; }
.quest-bar { display: block; height: 10px; border-radius: 999px; background: #e8f5e9; overflow: hidden; }
.quest-bar i { display: block; height: 100%; background: linear-gradient(90deg, #66bb6a, #ffd54f); border-radius: 999px; transition: width .6s; }
.quest-val { font-weight: 900; font-size: 0.85rem; color: var(--primary-dark); white-space: nowrap; }
.cont-item { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0; border-bottom: 1px dashed #c8e6c9; }
.cont-item div { flex: 1; display: flex; flex-direction: column; }
.cont-emoji { font-size: 1.6rem; }
.mini-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; }
.mini-card { border: 2px solid #e0eee3; border-radius: 14px; background: #fff; padding: 0.3rem; cursor: pointer; font-size: 0.72rem; font-weight: 700; display: flex; flex-direction: column; gap: 0.2rem; color: var(--ink); }
.mini-card img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 10px; }
.mini-card:hover { transform: translateY(-3px) rotate(-1deg); box-shadow: var(--shadow); }
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; }
.quick { min-height: 76px; border-radius: 18px; border: 2px solid #c8e6c9; background: linear-gradient(180deg, #fffef7, #f1f8e9); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.2rem; font-weight: 800; font-size: 0.82rem; cursor: pointer; color: var(--ink); }
.quick span { font-size: 1.6rem; }
.quick:hover { transform: translateY(-3px); border-color: #66bb6a; }
@media (max-width: 520px) { .quick-grid { grid-template-columns: repeat(4, 1fr); } .dash-hero { flex-direction: column; text-align: center; } .dash-chips { justify-content: center; } .dash-xp { margin: 0 auto; } }

/* ---------- 魔法測驗 ---------- */
.mode-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.mode-card { border-radius: 22px; border: 3px solid #c8e6c9; background: #fff; padding: 1rem; display: flex; flex-direction: column; gap: 0.3rem; align-items: flex-start; cursor: pointer; text-align: left; min-height: 120px; color: var(--ink); transition: transform .15s, box-shadow .15s; }
.mode-card strong { font-size: 1.15rem; }
.mode-card span:last-child { color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.mode-emoji { font-size: 2rem; }
.mode-card.is-on { border-color: #2e7d4f; background: linear-gradient(160deg, #f1f8e9, #dcedc8); box-shadow: 0 8px 20px rgba(46,125,79,.25); transform: translateY(-2px); }
.magic-form .form-row { margin-bottom: 0.75rem; }
.magic-form .fill-label { display: block; }
.quiz-timer { margin-left: auto; background: #fff8e1; border: 2px solid #ffe082; border-radius: 999px; padding: 0.15rem 0.6rem; font-weight: 900; }
.mascot-hint { margin-top: 0.85rem; background: #fffde7; border: 2px dashed #ffd54f; border-radius: 18px; padding: 0.7rem 0.9rem; }
.hint-head { display: flex; align-items: center; gap: 0.5rem; }
.hint-head img { height: 40px; width: auto; }
.hint-steps { margin: 0.5rem 0 0.25rem 1.2rem; padding: 0; }
.hint-step { margin-bottom: 0.3rem; font-weight: 700; animation: viewIn .3s both; }

/* ---------- 錯題簿 ---------- */
.wb-list { display: grid; gap: 0.6rem; }
.wb-item { background: #fff; border: 2px solid #ffccbc; border-radius: 18px; padding: 0.75rem 0.9rem; }
.wb-item.is-mastered { border-color: #a5d6a7; background: #f7fbf6; }
.wb-meta { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin-bottom: 0.35rem; }
.wb-prompt { font-weight: 700; margin-bottom: 0.4rem; }
.wb-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.wb-foot .btn { margin-left: auto; }
.wb-dots { display: inline-flex; gap: 0.25rem; }
.wb-dots i { width: 14px; height: 14px; border-radius: 50%; background: #e0e0e0; display: inline-block; }
.wb-dots i.on { background: #66bb6a; box-shadow: 0 0 0 2px #c8e6c9; }

/* ---------- 字卡 ---------- */
.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.75rem; margin: 0.75rem 0; }
.deck-card { border: 3px solid #e0eee3; border-radius: 20px; background: #fff; padding: 0.85rem; display: flex; flex-direction: column; gap: 0.3rem; cursor: pointer; text-align: left; color: var(--ink); }
.deck-card.is-on { border-color: #2e7d4f; box-shadow: 0 6px 16px rgba(46,125,79,.2); }
.deck-stack { width: 56px; height: 44px; border-radius: 10px; background: var(--c); position: relative; display: flex; align-items: center; justify-content: center; box-shadow: 4px -4px 0 rgba(0,0,0,.08), 8px -8px 0 rgba(0,0,0,.05); }
.deck-stack b { font-size: 1.4rem; }
.flash-wrap { max-width: 560px; margin: 0 auto; }
.flash-top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.5rem; font-weight: 800; }
.flashcard { display: block; width: 100%; height: 300px; border: none; background: none; perspective: 1200px; cursor: pointer; margin: 1rem 0; padding: 0; }
.fc-inner { position: relative; display: block; width: 100%; height: 100%; transition: transform 0.55s cubic-bezier(.4,1.4,.6,1); transform-style: preserve-3d; }
.flashcard.is-flipped .fc-inner { transform: rotateY(180deg); }
.fc-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 28px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.6rem; padding: 1.25rem; box-shadow: var(--shadow); border: 4px solid #a5d6a7; }
.fc-front { background: linear-gradient(160deg, #fffef7, #e8f5e9); }
.fc-back { background: linear-gradient(160deg, #fff8e1, #ffe0b2); transform: rotateY(180deg); border-color: #ffcc80; }
.fc-text { font-size: clamp(1.6rem, 6vw, 2.4rem); font-weight: 900; color: var(--primary-dark); text-align: center; }
.fc-text.small { font-size: clamp(1.1rem, 4vw, 1.5rem); color: #5d4037; }
.fc-hint { font-size: 0.85rem; color: var(--muted); font-weight: 700; }
.fc-ex { font-size: 1rem; color: #6d4c41; font-weight: 700; text-align: center; }
.flash-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

/* ---------- 遊戲 ---------- */
.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0.85rem; }
.game-card { background: #fff; border-radius: 22px; border: 3px solid color-mix(in srgb, var(--gc) 40%, #fff); padding: 0.9rem; display: flex; flex-direction: column; gap: 0.35rem; position: relative; transition: transform .15s, box-shadow .15s; }
.game-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.game-card h3 { margin: 0; font-size: 1.1rem; }
.game-card p { margin: 0; font-size: 0.85rem; color: var(--muted); font-weight: 600; flex: 1; }
.gc-top { display: flex; justify-content: space-between; align-items: center; }
.gc-emoji { font-size: 2.1rem; width: 58px; height: 58px; border-radius: 18px; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--gc) 18%, #fff); }
.gc-meta { display: flex; flex-wrap: wrap; gap: 0.3rem; font-size: 0.75rem; font-weight: 800; }
.gc-meta span { background: #f5f5f5; border-radius: 999px; padding: 0.15rem 0.5rem; }
.gc-diff.d-easy { background: #c8e6c9 !important; } .gc-diff.d-mid { background: #fff59d !important; } .gc-diff.d-hard { background: #ffccbc !important; }
.gc-actions { display: flex; gap: 0.4rem; margin-top: 0.3rem; }
.gc-note { font-size: 0.72rem; color: #bf360c; font-weight: 700; }
.gp-card { background: var(--surface); border-radius: 28px; padding: 1rem 1.1rem 1.4rem; box-shadow: var(--shadow); border: 3px solid #a5d6a7; max-width: 760px; margin: 0 auto; }
.gp-top { display: flex; gap: 0.75rem; align-items: center; }
.gp-titles h2 { margin: 0; font-size: 1.4rem; color: var(--primary-dark); }
.gp-titles p { margin: 0; }
.gp-hud { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.6rem 0; }
.gp-hud span { background: #f1f8e9; border-radius: 999px; padding: 0.3rem 0.8rem; font-weight: 900; }
.gp-hud span:empty { display: none; }
.gp-mascot { display: flex; align-items: flex-end; gap: 0.4rem; min-height: 54px; }
.gp-mascot img { height: 52px; width: auto; }
.gp-mascot .bubble { background: #fff; border: 2px solid #a5d6a7; border-radius: 16px 16px 16px 4px; padding: 0.35rem 0.7rem; font-weight: 800; font-size: 0.9rem; }
.gp-mascot.pop .bubble { animation: bounceIn .4s both; }
.gp-stage { min-height: 260px; }
.gp-prompt { font-size: clamp(1.3rem, 4.5vw, 1.9rem); font-weight: 900; text-align: center; margin: 0.6rem 0; color: var(--primary-dark); }
.gp-prompt.small { font-size: 1.05rem; }
.gp-visual { display: flex; justify-content: center; margin: 0.5rem 0; }
.gp-visual .diagram-wrap, .gp-visual figure { margin: 0 auto; }
.gp-emoji { font-size: 2.6rem; vertical-align: middle; }
.gp-word { font-family: "Nunito", monospace; letter-spacing: 0.25em; font-size: 2rem; }
.gp-clock { width: 170px; height: 170px; }
.gp-coins { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: center; }
.gp-coin { width: 62px; height: 62px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff8e1, #ffca28 60%, #f9a825); display: inline-flex; align-items: center; justify-content: center; font-weight: 900; box-shadow: inset 0 -3px 0 rgba(0,0,0,.12), 0 3px 6px rgba(0,0,0,.15); }
.gp-coin.is-small { width: 48px; height: 48px; font-size: 0.8rem; background: radial-gradient(circle at 35% 30%, #fff, #d7ccc8 60%, #a1887f); }
.gp-coin.is-note { width: 86px; border-radius: 10px; background: linear-gradient(135deg, #b39ddb, #7e57c2); color: #fff; }
.gp-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-top: 0.75rem; }
.gp-choice { min-height: 64px; border-radius: 18px; border: 3px solid #c8e6c9; background: #fff; font-size: 1.15rem; font-weight: 800; cursor: pointer; display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.8rem; color: var(--ink); transition: transform .1s; }
.gp-choice:hover { transform: translateY(-2px); border-color: #66bb6a; }
.gp-choices.is-big .gp-choice { min-height: 88px; font-size: 1.5rem; justify-content: center; }
.gp-choice.is-right { background: #c8e6c9; border-color: #43a047; animation: bounceIn .3s; }
.gp-choice.is-wrong { background: #ffebee; border-color: #e57373; opacity: .7; }
.gp-hint { min-height: 2rem; margin-top: 0.6rem; font-weight: 700; color: #6d4c41; display: flex; gap: 0.4rem; align-items: center; justify-content: center; text-align: center; }
.gp-hint img { height: 36px; width: auto; }
.gp-mole-q { font-size: 1.8rem; font-weight: 900; text-align: center; color: var(--primary-dark); margin: 0.4rem 0 0.8rem; }
.mole-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; max-width: 420px; margin: 0 auto; }
.mole-hole { aspect-ratio: 1.2; border-radius: 50% 50% 24px 24px; border: none; background: radial-gradient(ellipse at 50% 85%, #5d4037 0 35%, #8d6e63 36% 48%, #a5d6a7 49%); position: relative; overflow: hidden; cursor: pointer; }
.mole { position: absolute; left: 50%; bottom: -80%; transform: translateX(-50%); transition: bottom .2s ease; display: flex; flex-direction: column; align-items: center; }
.mole-hole.up .mole { bottom: 8%; }
.mole-face { font-size: 2.2rem; line-height: 1; }
.mole-val { background: #fff; border-radius: 10px; padding: 0.05rem 0.45rem; font-weight: 900; font-size: 1.05rem; border: 2px solid #8d6e63; white-space: nowrap; }
.mole-hole.hit .mole-val { background: #c8e6c9; border-color: #43a047; }
.mole-hole.miss .mole-val { background: #ffcdd2; }
.mem-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; max-width: 560px; margin: 0 auto; }
.mem-card { aspect-ratio: 1; border: none; background: none; perspective: 700px; cursor: pointer; padding: 0; }
.mem-inner { position: relative; display: block; width: 100%; height: 100%; transition: transform .4s; transform-style: preserve-3d; }
.mem-card.is-flipped .mem-inner { transform: rotateY(180deg); }
.mem-front, .mem-back { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 16px; display: flex; align-items: center; justify-content: center; padding: 0.3rem; font-weight: 900; text-align: center; }
.mem-front { background: linear-gradient(135deg, #66bb6a, #2e7d4f); font-size: 1.8rem; box-shadow: 0 4px 10px rgba(0,0,0,.15); }
.mem-back { background: #fff; border: 3px solid #a5d6a7; transform: rotateY(180deg); font-size: clamp(0.8rem, 3vw, 1.1rem); }
.mem-card.is-matched .mem-back { background: #c8e6c9; border-color: #43a047; }
.match-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
.match-col { display: flex; flex-direction: column; gap: 0.5rem; }
.match-item { min-height: 56px; border-radius: 16px; border: 3px solid #c8e6c9; background: #fff; font-weight: 800; cursor: pointer; padding: 0.4rem 0.6rem; color: var(--ink); font-size: 1rem; }
.match-item.is-right-col { font-size: 0.9rem; }
.match-item.is-sel { border-color: #ffb300; background: #fff8e1; }
.match-item.is-done { border-color: #43a047; background: #c8e6c9; opacity: .75; }
.tok-line, .tok-pool { display: flex; flex-wrap: wrap; gap: 0.45rem; justify-content: center; min-height: 64px; padding: 0.6rem; border-radius: 18px; }
.tok-line { background: #fffde7; border: 3px dashed #ffd54f; margin: 0.6rem 0; }
.tok { min-height: 52px; min-width: 52px; border-radius: 14px; border: 3px solid #a5d6a7; background: #fff; font-weight: 900; font-size: 1.15rem; padding: 0.3rem 0.8rem; cursor: pointer; color: var(--ink); }
.tok.is-placed { border-color: #ffb300; }
.tok.is-locked { background: #c8e6c9; border-color: #43a047; cursor: default; }
.tok.is-ghost { opacity: .2; border: 3px dashed #c8e6c9; display: inline-flex; align-items: center; padding: 0.3rem 0.8rem; border-radius: 14px; }
.is-letters .tok { font-family: "Nunito", sans-serif; text-transform: lowercase; min-width: 52px; font-size: 1.5rem; }
.sort-item { font-size: 2.3rem; font-weight: 900; text-align: center; margin: 0.6rem auto; background: #fff; border-radius: 22px; border: 3px solid #a5d6a7; padding: 0.8rem 1.2rem; width: fit-content; box-shadow: var(--shadow); }
.sort-bins { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0.6rem; }
.sort-bin { min-height: 80px; border-radius: 18px; border: 3px solid #c8e6c9; background: linear-gradient(180deg, #fff, #f1f8e9); font-weight: 900; font-size: 1.05rem; cursor: pointer; color: var(--ink); }
.sort-bin.is-right { background: #c8e6c9; border-color: #43a047; }
.sort-bin.is-wrong { background: #ffebee; border-color: #e57373; }
.gp-end-card { text-align: center; padding: 1rem 0.5rem; }
.gp-end-mascot { height: 120px; width: auto; }
.gp-end-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; margin: 0.8rem 0; }
.gp-end-stats div { background: #f1f8e9; border-radius: 16px; padding: 0.6rem 0.3rem; display: flex; flex-direction: column; }
.gp-end-stats strong { font-size: 1.4rem; color: var(--primary-dark); }
.gp-end-stats span { font-size: 0.78rem; color: var(--muted); font-weight: 800; }
.gp-end-reward { display: inline-flex; align-items: center; gap: 0.6rem; background: #fff8e1; border: 2px solid #ffd54f; border-radius: 18px; padding: 0.4rem 0.8rem 0.4rem 0.4rem; margin: 0.4rem 0 0.8rem; font-weight: 800; animation: bounceIn .5s .2s both; }
.gp-end-reward img { width: 84px; height: 63px; object-fit: cover; border-radius: 12px; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 130; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 10px; height: 16px; border-radius: 3px; animation: fall 2.2s ease-in forwards; }
@keyframes fall { to { top: 105%; transform: rotate(540deg) translateX(40px); } }

/* ---------- 成長 ---------- */
.growth-stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat-ico { font-size: 1.6rem; }
.xp-chart { width: 100%; height: auto; }
.xp-line { stroke-dasharray: 2000; stroke-dashoffset: 2000; animation: draw 1.4s ease forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.mastery-grid { display: grid; gap: 0.85rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.mastery-card { border-top: 6px solid var(--subject-color); }
.mastery-card h4 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.mt-row { display: grid; grid-template-columns: 6.5rem 1fr 2.6rem; gap: 0.5rem; align-items: center; margin-bottom: 0.4rem; font-size: 0.85rem; font-weight: 800; }
.mt-bar { display: flex; height: 14px; border-radius: 999px; background: #eceff1; overflow: hidden; }
.mt-bar .m { background: #2e7d4f; } .mt-bar .g { background: #aed581; }
.mt-num { text-align: right; color: var(--muted); }
.mt-lessons { list-style: none; padding: 0; margin: 0.4rem 0 0; font-size: 0.85rem; }
.mt-lessons li { padding: 0.25rem 0; display: flex; gap: 0.4rem; align-items: center; }
.st { border-radius: 999px; padding: 0.05rem 0.45rem; font-size: 0.72rem; font-weight: 900; white-space: nowrap; }
.st-mastered { background: #c8e6c9; } .st-growing { background: #f0f4c3; } .st-starting { background: #eceff1; }
details summary { cursor: pointer; font-weight: 800; color: var(--primary); min-height: 36px; display: flex; align-items: center; }

/* ---------- 主題 ---------- */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0.85rem; }
.theme-card { background: #fff; border-radius: 22px; border: 3px solid #e0eee3; padding: 0.7rem; display: flex; flex-direction: column; gap: 0.35rem; align-items: flex-start; }
.theme-card.is-active { border-color: #2e7d4f; box-shadow: 0 6px 18px rgba(46,125,79,.25); }
.theme-card h3 { margin: 0; font-size: 1.05rem; } .theme-card p { margin: 0; font-size: 0.82rem; color: var(--muted); flex: 1; }
.theme-preview { width: 100%; height: 110px; border-radius: 16px; position: relative; display: flex; align-items: flex-end; justify-content: center; gap: 0.2rem; overflow: hidden; }
.theme-preview span { position: absolute; top: 0.4rem; left: 0.6rem; font-size: 1.6rem; }
.theme-preview img { height: 70px; width: auto; }

body.theme-sunrise { --bg: #fff3e0; --dash-bg: linear-gradient(135deg, #fff3e0, #ffcc80 55%, #ff8a65); background-color: #fff3e0; }
body.theme-sunrise .app-header { background: rgba(255, 248, 235, .95); border-bottom-color: #ffcc80; }
body.theme-starry { --bg: #eef0fb; --dash-bg: linear-gradient(135deg, #1a237e, #3949ab 60%, #7e57c2); --dash-ink: #fff; }
body.theme-sakura { --bg: #fdeef4; --dash-bg: linear-gradient(135deg, #fce4ec, #f8bbd0 60%, #f48fb1); background-color: #fdeef4; }
body.theme-sakura .app-header { border-bottom-color: #f8bbd0; }
body.theme-seaside { --bg: #e0f7fa; --dash-bg: linear-gradient(135deg, #e0f7fa, #80deea 60%, #4fc3f7); background-color: #e0f7fa; }
body.theme-seaside .app-header { border-bottom-color: #80deea; }
body.theme-autumn { --bg: #fff8e1; --dash-bg: linear-gradient(135deg, #fff8e1, #ffb74d 55%, #e57373); background-color: #fff8e1; }
body.theme-snow { --bg: #f5fbff; --dash-bg: linear-gradient(135deg, #ffffff, #e3f2fd 55%, #b3d4ef); background-color: #f5fbff; }
body.theme-starry .dash-hero::after { content: "✨🌙✨"; opacity: .6; }
body.theme-sakura .dash-hero::after { content: "🌸🌸🌸"; }
body.theme-seaside .dash-hero::after { content: "🌴🌊🌴"; }
body.theme-autumn .dash-hero::after { content: "🍁🍂🍁"; }
body.theme-snow .dash-hero::after { content: "🌲⛄🌲"; }
body.theme-sunrise .dash-hero::after { content: "🌅🌳🌅"; }

/* ---------- 氛圍 ---------- */
#mood-canvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 55; }
#mood-canvas[hidden] { display: none; }
.mood-panel { position: fixed; top: 70px; right: 12px; z-index: 110; width: min(360px, calc(100vw - 24px)); background: var(--surface); border: 3px solid #a5d6a7; border-radius: 24px; box-shadow: var(--shadow); padding: 1rem; animation: bounceIn .3s both; }
.mood-panel[hidden] { display: none; }
.mood-head { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; position: relative; padding-right: 2.5rem; }
.mood-head img { height: 48px; width: auto; }
.mood-head div { display: flex; flex-direction: column; }
.mood-panel .seg { margin-bottom: 0.5rem; }
.range { width: 100%; accent-color: #2e7d4f; min-height: 36px; }

/* ---------- 夢想 ---------- */
.career-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.7rem; }
.career-card { border-radius: 20px; border: 3px solid #e0eee3; background: #fff; padding: 0.8rem; display: flex; flex-direction: column; align-items: center; gap: 0.25rem; cursor: pointer; text-align: center; color: var(--ink); min-height: 150px; }
.career-card span { font-size: 2.4rem; }
.career-card small { color: var(--muted); font-weight: 600; }
.career-card.is-on { border-color: #ab47bc; background: #f3e5f5; }
.career-card:hover { transform: translateY(-3px); }
.dream-hero { display: flex; align-items: center; gap: 1rem; background: linear-gradient(135deg, #f3e5f5, #e1f5fe); }
.dream-hero h3 { margin: 0; }
.dream-hero p { margin: 0.2rem 0; }
.dream-emoji { font-size: 3.5rem; }
.dream-cols { display: grid; gap: 1rem; margin-top: 1rem; grid-template-columns: 1fr; }
@media (min-width: 760px) { .dream-cols { grid-template-columns: 1fr 1.3fr; } }
.dream-sub { display: grid; grid-template-columns: 5.5rem 4.5rem 1fr; gap: 0.4rem; align-items: center; padding: 0.4rem 0; border-bottom: 1px dashed #e0e0e0; }
.dream-cols .quest { cursor: default; }

/* ---------- 筆記 ---------- */
.notes-layout { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 900px) { .notes-layout { grid-template-columns: 1fr 1.2fr; align-items: start; } .note-editor { position: sticky; top: 90px; } }
.form-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.note-text { min-height: 140px; resize: vertical; font-family: inherit; }
.note-list { display: grid; gap: 0.7rem; }
.note-card { background: #fffef0; border-radius: 18px; border: 2px solid #e0eee3; border-left: 8px solid var(--subject-color); padding: 0.8rem 1rem; box-shadow: 0 4px 12px rgba(0,0,0,.05); }
.note-card h4 { margin: 0.3rem 0; font-size: 1.1rem; }
.note-card p { margin: 0 0 0.4rem; white-space: normal; }
.note-top { display: flex; justify-content: space-between; align-items: center; }

/* ---------- 設定：檔案 ---------- */
.avatar-pick { display: flex; gap: 0.6rem; margin: 0.3rem 0 0.6rem; }
.avatar-opt { border: 3px solid #e0eee3; background: #fff; border-radius: 20px; padding: 0.5rem 1rem; display: flex; flex-direction: column; align-items: center; cursor: pointer; font-weight: 800; min-width: 96px; color: var(--ink); }
.avatar-opt img { height: 72px; width: auto; }
.avatar-opt.is-on { border-color: #2e7d4f; background: #f1f8e9; box-shadow: 0 4px 14px rgba(46,125,79,.25); }
.toggle-row { display: flex; align-items: center; gap: 0.5rem; font-weight: 800; margin: 0.8rem 0; min-height: 44px; }
.toggle-row input { width: 26px; height: 26px; accent-color: #2e7d4f; }
#profile-panel .seg { margin-bottom: 0.3rem; }
#profile-panel[hidden] { display: none; }

/* ---------- print：成績表 ---------- */
.print-area { display: none; }
@media print {
  body * { visibility: hidden !important; }
  body { background: #fff !important; }
  .print-area, .print-area * { visibility: visible !important; }
  .print-area { display: block !important; position: absolute; left: 0; top: 0; width: 100%; padding: 12mm; color: #000; font-size: 12pt; }
  .pr-head { display: flex; align-items: center; justify-content: space-between; gap: 10mm; border-bottom: 3px solid #2e7d4f; padding-bottom: 4mm; }
  .pr-head img { height: 22mm; width: auto; }
  .pr-head h1 { margin: 0; font-size: 20pt; color: #1b5e3a; text-align: center; }
  .pr-head p { margin: 2mm 0 0; text-align: center; }
  .print-area h2 { font-size: 14pt; color: #1b5e3a; margin: 6mm 0 2mm; }
  .pr-table { width: 100%; border-collapse: collapse; }
  .pr-table th, .pr-table td { border: 1px solid #9ccc9c; padding: 2mm 3mm; text-align: left; }
  .pr-table th { background: #e8f5e9 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .pr-msg { margin-top: 6mm; font-weight: 700; }
  .pr-sign { display: flex; justify-content: space-between; margin-top: 12mm; }
  #mood-canvas, .sidebar, .bottom-nav, .app-header { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* =====================================================================
   V2 VISUAL POLISH — clean sky canvas, white cards, generous whitespace
   ===================================================================== */
:root {
  --canvas: #f4f9f6;
  --card: #ffffff;
  --line: #e3eee6;
  --soft-shadow: 0 6px 22px rgba(31, 72, 48, 0.07);
  --lift-shadow: 0 14px 34px rgba(31, 72, 48, 0.12);
  --sky: linear-gradient(180deg, #eaf5ff 0%, #f4f9f6 340px, #f4f9f6 100%);
}
body.is-authed {
  background: var(--sky);
  background-attachment: fixed;
}
body.is-authed::before, body.is-authed::after { opacity: 0.12; }
body.theme-sunrise.is-authed { --sky: linear-gradient(180deg, #fff1e0 0%, #fffaf4 340px); }
body.theme-starry.is-authed { --sky: radial-gradient(circle at 15% 6%, #fff 0 1.5px, transparent 2px), radial-gradient(circle at 70% 4%, #fff 0 1.5px, transparent 2px), radial-gradient(circle at 42% 10%, #fff 0 1px, transparent 2px), linear-gradient(180deg, #d9ddf7 0%, #f1f2fb 360px); }
body.theme-sakura.is-authed { --sky: linear-gradient(180deg, #fde7f0 0%, #fff7fa 340px); }
body.theme-seaside.is-authed { --sky: linear-gradient(180deg, #dcf5fb 0%, #f3fbfd 340px); }
body.theme-autumn.is-authed { --sky: linear-gradient(180deg, #fff0d6 0%, #fffaf0 340px); }
body.theme-snow.is-authed { --sky: linear-gradient(180deg, #e8f2fc 0%, #fbfdff 340px); }

/* ---- header: slim bar beside the sidebar ---- */
.app-header { padding: 0.55rem 1.25rem; background: rgba(255, 255, 255, 0.88); border-bottom: 1px solid var(--line); box-shadow: 0 2px 14px rgba(31,72,48,.04); }
.header-inner { flex-wrap: nowrap; max-width: 1120px; min-height: 52px; }
.hdr-title { display: none; margin: 0; font-size: 1.15rem; font-weight: 900; color: var(--primary-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hdr-pill { background: #fff; border: 1px solid #ffe08a; box-shadow: none; }
.hdr-btn { border: 1px solid var(--line); background: #fff; }
.user-chip { border: 1px solid var(--line); background: #fff; }
@media (min-width: 1000px) {
  body.is-authed .app-header .logo { display: none; visibility: visible; width: auto; }
  body.is-authed .hdr-title { display: block; }
}
@media (max-width: 640px) {
  .app-header { padding: 0.45rem 0.75rem; }
  .logo-sub, .hdr-btn-label, #user-name { display: none; }
  .logo { font-size: 1rem; }
  .logo-mascots img { width: 30px; height: 36px; }
  .header-tools { gap: 0.3rem; }
  .hdr-pill { padding: 0.15rem 0.5rem; font-size: 0.82rem; }
  .user-chip { padding: 0.15rem 0.3rem; }
}

/* ---- sidebar: crisp white ---- */
.sidebar { background: #fff; border-right: 1px solid var(--line); box-shadow: none; padding: 1rem 0.8rem; }
.sidebar-head { border: 1px solid var(--line); background: linear-gradient(135deg, #f3faf4, #fff); box-shadow: none; }
.side-link { color: #33493c; font-weight: 800; }
.side-link:hover { background: #f1f8f2; transform: none; }
.side-link.is-active { background: linear-gradient(135deg, #2e7d4f, #5cb874) !important; color: #fff !important; box-shadow: 0 6px 16px rgba(46,125,79,.28); }
.sb-tip { border: 1px solid #ffe7a3; border-style: solid; background: #fffbea; }

/* ---- layout rhythm ---- */
main { padding: 1.75rem 1.5rem 3.5rem; }
.section-head { margin-bottom: 1.25rem; }
.section-head h2 { font-size: 1.8rem; letter-spacing: 0.01em; }
.section-head p { font-size: 1rem; margin-top: 0.15rem; }
.dash-section-title { margin: 2rem 0 0.85rem; }
.panel, .stat-card { background: var(--card); border: 1px solid var(--line); box-shadow: var(--soft-shadow); border-radius: 24px; }
.panel { padding: 1.4rem; }
.panel h3 { margin-top: 0; font-size: 1.12rem; }
.stats-row { gap: 1rem; }
.stat-card { padding: 1.1rem 0.9rem; }
.feature-card, .mode-card, .deck-card, .career-card, .theme-card, .wb-item, .note-card, .quest, .quick, .mini-card { border-width: 1px; border-color: var(--line); box-shadow: var(--soft-shadow); }
.feature-card { background: #fff; }
.feature-card:hover, .mode-card:hover, .deck-card:hover, .career-card:hover, .quick:hover { box-shadow: var(--lift-shadow); border-color: #a5d6a7; }
.hero { background: #fff; border: 1px solid var(--line); box-shadow: var(--soft-shadow); }
.seg { background: #f3f8f4; border: 1px solid var(--line); }

/* ---- page banner (mascot + illustration) ---- */
.mascot-tip { margin: 0 0 1.25rem; }
.mascot-tip.has-art { align-items: stretch; gap: 0; background: #fff; border: 1px solid var(--line); border-radius: 26px; box-shadow: var(--soft-shadow); overflow: hidden; }
.mascot-tip.has-art > img { width: 76px; align-self: flex-end; margin: 0 0 0.6rem 1rem; }
.mascot-tip.has-art .bubble { flex: 1; align-self: center; border: none; box-shadow: none; background: transparent; font-size: 1.02rem; line-height: 1.6; padding: 1.1rem 1rem; }
.tip-art { width: 220px; flex: none; object-fit: cover; aspect-ratio: 4/3; border-left: 1px solid var(--line); }
@media (max-width: 640px) { .tip-art { width: 110px; } .mascot-tip.has-art > img { width: 52px; margin-left: 0.6rem; } .mascot-tip.has-art .bubble { font-size: 0.92rem; padding: 0.8rem 0.6rem; } }

/* ---- dashboard hero v2 ---- */
.dash-hero { display: grid; grid-template-columns: 1fr 300px; gap: 1.5rem; align-items: center; padding: 1.75rem 1.9rem; border: 1px solid var(--line); border-radius: 30px; box-shadow: var(--soft-shadow);
  background: var(--dash-bg, linear-gradient(120deg, #ffffff 0%, #effaf1 55%, #e3f2ff 100%)); }
.dash-hero::after { display: none; }
.dash-hello { font-size: clamp(1.5rem, 3.2vw, 2.1rem); margin-bottom: 0.65rem; }
.dash-say { display: flex; align-items: flex-end; gap: 0.6rem; margin-bottom: 0.9rem; }
.dash-say img { width: 60px; height: auto; animation: bob 3.4s ease-in-out infinite; flex: none; }
.speech { margin: 0; border: 1px solid var(--line); box-shadow: 0 4px 14px rgba(0,0,0,.05); font-size: 1rem; }
.dchip { background: #fff; border: 1px solid var(--line); padding: 0.32rem 0.8rem; }
.dash-ctas { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1rem; }
.dash-art { position: relative; }
.dash-art .art { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 24px; box-shadow: 0 14px 30px rgba(31,72,48,.16); border: 5px solid #fff; transform: rotate(1.5deg); }
.dash-art .m1, .dash-art .m2 { position: absolute; bottom: -14px; width: auto; filter: drop-shadow(0 6px 10px rgba(0,0,0,.18)); }
.dash-art .m1 { left: -26px; height: 104px; animation: bob 3.2s ease-in-out infinite; }
.dash-art .m2 { right: -12px; height: 86px; animation: bob 3.6s ease-in-out infinite .4s; }
.dash-art .cap { position: absolute; top: 10px; left: 12px; background: rgba(255,255,255,.92); border-radius: 999px; padding: 0.2rem 0.65rem; font-size: 0.78rem; font-weight: 800; }
body.theme-starry .dash-hero .speech, body.theme-starry .dash-hero .dchip { color: var(--ink); }
@media (max-width: 860px) { .dash-hero { grid-template-columns: 1fr; text-align: left; } .dash-art { max-width: 340px; margin: 0.5rem auto 0.6rem; } }
@media (max-width: 520px) { .dash-hero { padding: 1.2rem; } .dash-chips { justify-content: flex-start; } }
.dash-grid { gap: 1.25rem; margin-top: 1.25rem; }
.quest { box-shadow: none; background: #fbfdfb; }
.quest.is-done { background: #f0f8f1; }
.mini-cards { gap: 0.7rem; }
.mini-card { padding: 0.35rem; }

/* ---- magic mode cards with art ---- */
.mode-grid { gap: 1rem; }
.mode-card { padding: 0; overflow: hidden; min-height: 0; background: #fff; }
.mode-card .mode-art { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }
.mode-card .mode-txt { padding: 0.85rem 1rem 1rem; display: flex; flex-direction: column; gap: 0.2rem; }
.mode-card .mode-txt span { color: var(--muted); font-size: 0.86rem; font-weight: 600; }
.mode-card.is-on { border: 2px solid #2e7d4f; box-shadow: 0 12px 28px rgba(46,125,79,.2); background: #fff; }
.mode-card.is-on .mode-txt strong::after { content: " ✓"; color: #2e7d4f; }
.magic-form .form-row { margin-bottom: 1.1rem; }
.magic-form { max-width: 760px; }

/* ---- games lobby: uniform cards ---- */
.game-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); grid-auto-rows: 1fr; gap: 1.1rem; }
.game-card { border: 1px solid var(--line); box-shadow: var(--soft-shadow); padding: 1.1rem; gap: 0.5rem; height: 100%; }
.game-card::before { display: none; }
.game-card:hover { box-shadow: var(--lift-shadow); }
.game-card h3 { font-size: 1.08rem; min-height: 1.4em; }
.game-card p { flex: 0 0 auto; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em; line-height: 1.45; }
.gc-meta { gap: 0.35rem; min-height: 3.6em; align-content: flex-start; }
.gc-meta span { background: #f4f7f5; }
.gc-actions { margin-top: auto; }
.gc-actions .btn { flex: 1; }
.gc-lock { background: #fff3e0 !important; color: #bf360c; }

/* ---- gameplay ---- */
.gp-card { background: #fff; border: 1px solid var(--line); box-shadow: var(--soft-shadow); padding: 1.4rem 1.5rem 1.75rem; }
.gp-hud span { background: #f3f8f4; border: 1px solid var(--line); }
.gp-choice, .sort-bin, .match-item, .tok, .mole-hole { box-shadow: 0 3px 0 rgba(31,72,48,.08); }
.gp-choice { border-width: 2px; border-color: var(--line); }

/* ---- flash / growth / misc ---- */
.deck-card { border-width: 1px; }
.deck-card.is-on { border: 2px solid #2e7d4f; }
.fc-face { border-width: 2px; }
.xp-line { stroke-dasharray: none; stroke-dashoffset: 0; animation: none; }
.mastery-card { border-top: 6px solid var(--subject-color); }
.empty-state { text-align: center; padding: 2rem 1rem; background: #fff; border-radius: 24px; border: 1px dashed #b7dcbf; }
.empty-state img { height: 88px; width: auto; }

/* ---- toast stack: bottom-right, never blocks clicks ---- */
.toast-stack { position: fixed; right: 1rem; bottom: 1rem; z-index: 140; display: flex; flex-direction: column-reverse; gap: 0.5rem; align-items: flex-end; pointer-events: none; max-width: min(340px, calc(100vw - 2rem)); }
.toast-stack > .global-toast, .toast-stack > .rank-toast, .toast-stack > .card-toast {
  position: static !important; inset: auto !important; transform: none !important; left: auto !important; right: auto !important; bottom: auto !important; top: auto !important;
  margin: 0 !important; pointer-events: none; max-width: 100%; width: auto;
  background: #fff; color: var(--ink); border: 1px solid var(--line); border-left: 5px solid #66bb6a; border-radius: 16px; box-shadow: var(--lift-shadow);
  padding: 0.6rem 0.9rem; font-weight: 800; font-size: 0.92rem; animation: toastIn .3s ease both;
}
.toast-stack > .rank-toast { border-left-color: #ffb300; }
.toast-stack > .card-toast { display: flex; gap: 0.6rem; align-items: center; padding: 0.45rem 0.7rem 0.45rem 0.45rem; border-left-color: #ab47bc; }
.toast-stack > .card-toast img { width: 64px; height: 48px; }
.toast-stack > [hidden] { display: none !important; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (max-width: 999px) { body.is-authed .toast-stack { bottom: calc(var(--bn-h) + 0.75rem + env(safe-area-inset-bottom)); } }

/* ---- bottom nav ---- */
.bottom-nav { background: rgba(255,255,255,.97); border-top: 1px solid var(--line); box-shadow: 0 -4px 18px rgba(31,72,48,.06); }

/* ---- mobile rhythm ---- */
@media (max-width: 640px) {
  main { padding: 1rem 0.85rem 3rem; }
  .section-head h2 { font-size: 1.45rem; }
  .panel { padding: 1.05rem; }
  .gp-card { padding: 1rem; }
  .game-grid { grid-template-columns: 1fr 1fr; gap: 0.7rem; }
  .game-card { padding: 0.8rem; }
  .game-card p { font-size: 0.78rem; }
  .gc-meta span:nth-child(n+3) { display: none; }
  .gc-actions { flex-direction: column; }
  .quick-grid { gap: 0.4rem; }
  .mini-cards { grid-template-columns: repeat(2, 1fr); }
}
.hdr-title { flex: 1; min-width: 0; }
.header-tools { margin-left: auto; }
/* v2 fixes: mascot tiles, banner art, decorations */
body.is-authed::before, body.is-authed::after { display: none; }
.mascot-tip > img:first-child, .dash-say img { background: #f9f5e9; border-radius: 18px; box-shadow: 0 0 0 3px #fff, 0 4px 12px rgba(31,72,48,.12); }
.mascot-tip.has-art > img:first-child { width: 64px; align-self: center; margin: 0.8rem 0 0.8rem 1.1rem; }
.mascot-tip.has-art .tip-art { width: 200px; height: auto; align-self: stretch; object-fit: cover; aspect-ratio: auto; animation: none; border-radius: 0; margin: 0; }
.dash-say img { width: 52px; animation: none; }
.dash-art .m1, .dash-art .m2 { height: auto; background: #f9f5e9; border-radius: 20px; border: 4px solid #fff; box-shadow: 0 8px 18px rgba(31,72,48,.18); filter: none; }
.dash-art .m1 { width: 74px; left: -22px; bottom: -16px; }
.dash-art .m2 { width: 64px; right: -10px; bottom: -12px; }
.magic-form { max-width: none; }
@media (max-width: 640px) { .mascot-tip.has-art .tip-art { width: 96px; } .mascot-tip.has-art > img:first-child { width: 46px; margin-left: 0.6rem; } }
.growth-stats { display: grid; grid-template-columns: repeat(4, 1fr); }
@media (max-width: 640px) { .growth-stats { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) {
  .header-inner { gap: 0.4rem; min-height: 46px; }
  .hdr-pill, .logo-text, .user-chip, .user-chip * , .hdr-btn { white-space: nowrap; }
  .logo-mascots img + img { display: none; }
  .logo-text { font-size: 1rem; }
  #btn-mood { padding: 0.25rem 0.45rem; }
  .user-chip #user-avatar { display: none; }
  .dash-art { order: -1; max-width: none; width: 100%; margin: 0 0 0.4rem; }
  .dash-art .art { aspect-ratio: 16/8; transform: none; border-width: 3px; }
  .dash-art .m1, .dash-art .m2 { display: none; }
  .dash-hero { gap: 0.8rem; }
  .dash-ctas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; }
  .dash-ctas .btn { padding: 0.55rem 0.3rem; font-size: 0.85rem; white-space: nowrap; }
  .dash-say img { width: 44px; }
  .speech { font-size: 0.92rem; }
}
@media (max-width: 640px) {
  .toolbar .seg { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; border-radius: 999px; }
  .toolbar .seg::-webkit-scrollbar { display: none; }
  .toolbar .seg-btn { white-space: nowrap; flex: none; }
}
.deck-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
@media (max-width: 640px) { .deck-grid { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; } }
.dash-hero .btn-ghost, .dash-hero .btn-secondary { background: #fff; color: #2e7d4f; }
.dash-art .cap { color: #1b5e3a; }
.dash-hero .dash-xp-label { color: inherit; opacity: .8; }
/* ===== Subject picker ===== */
.legacy-home { display: none !important; }
.picker-hero { display: flex; gap: 1.25rem; align-items: center; justify-content: space-between; background: #fff; border: 1px solid var(--line, #e3eee6); border-radius: 28px; padding: 1.4rem 1.6rem; box-shadow: var(--soft-shadow, 0 6px 22px rgba(31,72,48,.07)); margin-bottom: 1.25rem; }
.picker-lead { color: var(--muted, #5a6b60); margin: 0.35rem 0 0.75rem; max-width: 36rem; line-height: 1.55; }
.picker-mascots { display: flex; gap: 0.4rem; }
.picker-mascots img { width: 72px; height: auto; background: #f9f5e9; border-radius: 18px; border: 3px solid #fff; box-shadow: 0 6px 14px rgba(0,0,0,.1); }
.picker-title { font-size: 1.35rem; margin: 0.5rem 0 0.85rem; color: var(--primary-dark, #1b5e3a); }
.pick-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
@media (min-width: 900px) { .pick-grid { grid-template-columns: repeat(4, 1fr); } }
.pick-card { display: flex; flex-direction: column; align-items: flex-start; text-align: left; background: #fff; border: 2px solid var(--line, #e3eee6); border-radius: 24px; overflow: hidden; padding: 0; cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s; box-shadow: var(--soft-shadow, 0 6px 22px rgba(31,72,48,.07)); color: inherit; font: inherit; }
.pick-card:hover { transform: translateY(-4px); border-color: var(--subject-color, #2e7d4f); box-shadow: 0 14px 30px rgba(31,72,48,.14); }
.pick-art { width: 100%; aspect-ratio: 4/3; object-fit: cover; }
.pick-emoji { font-size: 1.8rem; margin: 0.7rem 1rem 0; }
.pick-name { font-size: 1.25rem; font-weight: 900; margin: 0.15rem 1rem; color: var(--subject-color, #1b5e3a); }
.pick-tag { margin: 0 1rem; color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.pick-meta { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.55rem 1rem; }
.pick-meta i { font-style: normal; background: #f3f8f4; border-radius: 999px; padding: 0.15rem 0.55rem; font-size: 0.78rem; font-weight: 700; }
.pick-go { margin: auto 1rem 1rem; font-weight: 900; color: var(--subject-color, #2e7d4f); }
.picker-global { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.25rem; }
.subj-lock-banner { display: inline-flex; align-items: center; gap: 0.75rem; background: #f3faf4; border: 1px solid var(--line); border-radius: 999px; padding: 0.35rem 0.85rem; font-weight: 800; margin: 0 0 0.85rem; }
.subj-lock-banner .link-btn { border: none; background: none; color: #2e7d4f; font-weight: 800; cursor: pointer; text-decoration: underline; }
.subject-pill { border-color: var(--subject-color, #2e7d4f) !important; color: var(--subject-color, #1b5e3a); }

/* Sidebar subject switch */
.sb-switch { display: flex; align-items: center; gap: 0.55rem; width: 100%; margin: 0.4rem 0 0.7rem; padding: 0.55rem 0.65rem; border-radius: 16px; border: 2px solid var(--subject-color, #2e7d4f); background: linear-gradient(135deg, #fff, #f3faf4); cursor: pointer; text-align: left; font: inherit; color: inherit; }
.sb-switch-emoji { font-size: 1.4rem; }
.sb-switch-txt { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.sb-switch-txt small { color: var(--muted); font-weight: 600; font-size: 0.72rem; }
.sb-switch-go { font-size: 0.78rem; font-weight: 900; color: var(--subject-color, #2e7d4f); white-space: nowrap; }
body:not(.in-subject) .side-subj { display: none !important; }

/* ===== Google login primary ===== */
.login-primary { border: 2px solid #4285f4; background: linear-gradient(180deg, #f8fbff, #fff); }
.login-primary h2 { color: #1a73e8; }
.google-slot { min-height: 44px; display: flex; justify-content: center; align-items: center; margin: 0.75rem 0; }
.google-hint-card { display: flex; gap: 0.75rem; align-items: flex-start; background: #fff8e7; border: 1px solid #ffe08a; border-radius: 16px; padding: 0.85rem; margin-bottom: 0.75rem; text-align: left; }
.google-hint-card .gh-mascot { width: 52px; background: #f9f5e9; border-radius: 12px; }
.google-hint-card p { margin: 0.25rem 0 0; font-size: 0.9rem; line-height: 1.45; }
.login-guest { margin-top: 1rem; border-radius: 16px; background: #f7faf8; border: 1px dashed #c5d6cb; padding: 0.4rem 0.85rem; }
.login-guest summary { cursor: pointer; font-weight: 800; color: #5a6b60; padding: 0.5rem 0; list-style: none; }
.login-guest summary::-webkit-details-marker { display: none; }
.login-guest-box { border: none; box-shadow: none; background: transparent; padding: 0.4rem 0 0.8rem; }

/* ===== Stories + adventure path ===== */
.adv-path { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; margin-bottom: 1.25rem; padding: 0.85rem; background: #fff; border: 1px solid var(--line); border-radius: 22px; }
.adv-spot { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; min-width: 88px; padding: 0.55rem 0.45rem; border-radius: 16px; border: 2px solid var(--line); background: #fbfdfb; cursor: pointer; font: inherit; color: inherit; position: relative; }
.adv-spot.is-done { border-color: #66bb6a; background: #f0faf1; }
.adv-spot.is-locked { opacity: 0.45; cursor: not-allowed; }
.adv-emoji { font-size: 1.5rem; }
.adv-spot strong { font-size: 0.82rem; }
.adv-badge { font-size: 0.75rem; font-weight: 900; }
.adv-join { color: #9aaa9f; font-weight: 900; }
.story-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.story-card { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: 22px; overflow: hidden; box-shadow: var(--soft-shadow, 0 6px 22px rgba(31,72,48,.07)); }
.story-cover { width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.story-txt { padding: 0.85rem 1rem 1rem; display: flex; flex-direction: column; gap: 0.25rem; }
.story-actions { display: flex; gap: 0.4rem; margin-top: 0.55rem; flex-wrap: wrap; }
.story-player { max-width: 720px; margin: 0 auto; }
.sp-top { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; justify-content: space-between; margin-bottom: 0.6rem; }
.sp-stage { position: relative; background: linear-gradient(180deg, #e8f5e9, #fff); border: 1px solid var(--line); border-radius: 24px; padding: 1.25rem; min-height: 180px; overflow: hidden; }
.sp-stage.is-anim { background: linear-gradient(160deg, #e3f2fd, #fce4ec 50%, #fff8e1); }
.sp-bg { position: absolute; right: 0.6rem; top: 0.4rem; font-size: 3.5rem; opacity: 0.35; pointer-events: none; }
.sp-cast { display: flex; gap: 0.75rem; align-items: flex-end; position: relative; z-index: 1; }
.sp-mascot { width: 72px; background: #f9f5e9; border-radius: 16px; border: 3px solid #fff; box-shadow: 0 6px 14px rgba(0,0,0,.12); }
.sp-bubble { flex: 1; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 0.85rem 1rem; font-size: 1.05rem; line-height: 1.55; box-shadow: 0 4px 14px rgba(0,0,0,.05); }
.sp-quiz { margin-top: 1rem; }
.sp-q-label { font-weight: 900; color: #2e7d4f; margin: 0 0 0.5rem; }
.sp-hint { margin-top: 0.6rem; display: flex; gap: 0.4rem; align-items: center; font-weight: 700; }
.sp-hint img { width: 36px; }
@keyframes bob { 0%,100%{ transform: translateY(0);} 50%{ transform: translateY(-6px);} }
.sp-mascot.bounce { animation: bob 1.2s ease-in-out infinite; }

@media (max-width: 640px) {
  .picker-hero { flex-direction: column; align-items: flex-start; }
  .picker-mascots img { width: 56px; }
  .pick-grid { grid-template-columns: 1fr 1fr; gap: 0.65rem; }
  .pick-name { font-size: 1.05rem; }
  .adv-spot { min-width: 72px; }
}


/* ===== Stories CSS moved/extended in css/stories.css (story module agent) ===== */
/* Baby mascots 小咩 小都 */
.login-mascots { display: flex; gap: 0.45rem; justify-content: center; flex-wrap: wrap; }
.login-mascots img { width: 64px; height: 64px; object-fit: cover; border-radius: 18px; background: #f9f5e9; border: 3px solid #fff; box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.login-mascots img.baby { width: 48px; height: 48px; align-self: flex-end; }
.baby-row { display: flex; gap: 0.5rem; align-items: flex-end; margin-top: 0.5rem; }
.baby-row img { width: 52px; height: 52px; border-radius: 14px; background: #f9f5e9; border: 3px solid #fff; }
.picker-mascots img.baby { width: 48px; }
.ask-chip.baby-chip img { width: 22px; height: 22px; }
.avatar-opt img { width: 64px; height: 64px; object-fit: cover; border-radius: 16px; }


/* ===== Forest forward-runner game ===== */
.run-stage {
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  background: linear-gradient(180deg, #87ceeb 0%, #c8e6c9 55%, #8d6e63 55%, #6d4c41 100%);
  padding-bottom: 0.5rem;
}
.run-sky { position: absolute; inset: 0 0 45% 0; pointer-events: none; }
.run-sun { position: absolute; right: 12%; top: 10%; font-size: 2rem; animation: runSun 4s ease-in-out infinite; }
.run-cloud { position: absolute; font-size: 1.6rem; animation: runCloud 10s linear infinite; }
.run-cloud.c1 { top: 18%; left: -20%; }
.run-cloud.c2 { top: 32%; left: -40%; animation-duration: 14s; animation-delay: -3s; }
@keyframes runCloud { from { transform: translateX(0); } to { transform: translateX(140vw); } }
@keyframes runSun { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.run-track { position: relative; height: 168px; margin: 0.5rem 0 0; overflow: hidden; }
.run-parallax.trees, .run-parallax.bushes {
  position: absolute; left: 0; right: 0; height: 70px;
  background-repeat: repeat-x;
  background-size: 120px 70px;
  animation: runScroll 1.1s linear infinite;
  opacity: 0.9;
}
.run-parallax.trees {
  bottom: 48px;
  background-image: radial-gradient(circle at 50% 80%, #2e7d4f 28px, transparent 29px),
    radial-gradient(circle at 50% 100%, #5d4037 8px, transparent 9px);
  animation-duration: 1.6s;
}
.run-parallax.bushes {
  bottom: 36px; height: 36px;
  background-image: radial-gradient(circle at 40% 100%, #66bb6a 16px, transparent 17px),
    radial-gradient(circle at 70% 100%, #43a047 14px, transparent 15px);
  animation-duration: 1.0s;
}
@keyframes runScroll { from { background-position: 0 0; } to { background-position: -120px 0; } }
.run-ground {
  position: absolute; left: 0; right: 0; bottom: 0; height: 42px;
  background: repeating-linear-gradient(90deg, #8d6e63 0 28px, #a1887f 28px 56px);
  animation: runScroll 0.55s linear infinite;
}
.run-hero-wrap { position: absolute; left: 12%; bottom: 28px; z-index: 2; }
.run-hero {
  width: 72px; height: auto;
  filter: drop-shadow(0 6px 8px rgba(0,0,0,.25));
  transform-origin: 50% 100%;
}
.run-hero.is-running { animation: runBounce 0.35s ease-in-out infinite; }
.run-hero.is-dash { animation: runDash 0.55s ease-out both; }
.run-hero.is-trip { animation: runTrip 0.45s ease-out both; }
@keyframes runBounce {
  0%,100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-14px) rotate(4deg); }
}
@keyframes runDash {
  0% { transform: translateX(0) scale(1); }
  60% { transform: translateX(70px) scale(1.08); }
  100% { transform: translateX(40px) scale(1); }
}
@keyframes runTrip {
  0% { transform: translateX(0) rotate(0); }
  40% { transform: translateX(-8px) rotate(-18deg); }
  100% { transform: translateX(0) rotate(0); }
}
.run-meter {
  position: absolute; left: 12px; right: 12px; top: 8px; z-index: 3;
  height: 18px; border-radius: 999px; background: rgba(255,255,255,.55);
  overflow: hidden; font-size: 0.72rem; font-weight: 800; color: #1b4332;
}
.run-meter i { display: block; height: 100%; background: linear-gradient(90deg, #66bb6a, #ffd54f); width: 0; transition: width .4s ease; }
.run-meter span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.run-gate { background: rgba(255,255,255,.94); margin: 0.4rem 0.6rem 0.6rem; border-radius: 18px; padding: 0.75rem 0.85rem; box-shadow: 0 8px 22px rgba(0,0,0,.08); }
.run-prompt { font-weight: 900; font-size: 1.05rem; margin-bottom: 0.65rem; color: #1b4332; text-align: center; }
.run-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
.run-choice {
  display: flex; flex-direction: column; align-items: center; gap: 0.35rem;
  border: 3px solid #a5d6a7; border-radius: 16px; background: #f1f8e9;
  padding: 0.65rem 0.4rem; font-weight: 800; cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.run-choice:hover { transform: translateY(-3px); box-shadow: 0 8px 16px rgba(46,125,79,.2); }
.run-choice:active { transform: scale(0.97); }
.run-door { font-size: 0.75rem; color: #2e7d4f; background: #fff; border-radius: 999px; padding: 0.1rem 0.45rem; }
.run-ans { font-size: 1.05rem; color: #1b4332; }
.run-choice.is-right { background: #c8e6c9; border-color: #2e7d4f; }
.run-choice.is-wrong { background: #ffcdd2; border-color: #e57373; opacity: 0.75; }
.run-hint { margin-top: 0.55rem; min-height: 1.4em; }
@media (max-width: 520px) {
  .run-choices { grid-template-columns: 1fr; }
  .run-choice { flex-direction: row; justify-content: flex-start; padding-left: 0.75rem; }
}


/* ---- Collection download / detail / nudge ---- */
.coll-card.is-owned { cursor: pointer; transition: transform .15s, box-shadow .15s; }
.coll-card.is-owned:hover, .coll-card.is-owned:focus-visible {
  transform: translateY(-4px) rotate(-0.5deg);
  box-shadow: 0 12px 24px rgba(27, 94, 58, 0.28);
  outline: none;
}
.coll-tap-hint {
  margin-top: 0.35rem;
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--coll-accent);
  background: rgba(255,255,255,0.75);
  border-radius: 999px;
  padding: 0.12rem 0.45rem;
}
.coll-card.is-dark .coll-tap-hint {
  background: rgba(0,0,0,0.35);
  color: #fff;
}
.coll-save-tip { color: #2e7d4f !important; font-weight: 800 !important; }

.coll-detail-modal {
  position: fixed; inset: 0; z-index: 130;
  background: rgba(20, 50, 30, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.coll-detail-modal[hidden] { display: none !important; }
.coll-detail-card {
  position: relative;
  background: #fffef7;
  border: 3px solid #81c784;
  border-radius: 24px;
  padding: 1.1rem 1rem 1.25rem;
  width: min(420px, 100%);
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 16px 40px rgba(0,0,0,0.28);
  animation: bounceIn 0.35s both;
}
.coll-detail-x {
  position: absolute; top: 0.55rem; right: 0.55rem;
  width: 40px; height: 40px; border-radius: 50%;
  border: none; background: #e8f5e9; cursor: pointer; font-size: 1rem; z-index: 2;
}
.coll-detail-preview { min-height: 0; margin-bottom: 0.85rem; }
.coll-detail-imgwrap { height: auto !important; min-height: 180px; }
.coll-detail-imgwrap img {
  max-height: min(42vh, 280px) !important;
  max-width: 100% !important;
  width: auto; height: auto;
  object-fit: contain;
  border-radius: 14px;
  -webkit-touch-callout: default;
  user-select: none;
}
.coll-detail-actions {
  display: flex; flex-direction: column; gap: 0.55rem; align-items: stretch;
}
.coll-detail-actions .btn { width: 100%; justify-content: center; text-align: center; text-decoration: none; }
.coll-dl-btn { font-size: 1.05rem; }
.coll-mobile-hint { margin: 0.15rem 0 0; text-align: center; line-height: 1.4; }

.coll-nudge {
  position: fixed; left: 50%; bottom: calc(var(--bn-h, 68px) + 1rem);
  transform: translateX(-50%);
  z-index: 125;
  display: flex; gap: 0.65rem; align-items: flex-end;
  background: #fffef7;
  border: 3px solid #ffb300;
  border-radius: 20px;
  padding: 0.75rem 0.9rem 0.85rem;
  box-shadow: 0 12px 32px rgba(0,0,0,0.28);
  max-width: min(420px, 94vw);
  width: max-content;
  animation: tg-pop 0.35s ease-out;
}
.coll-nudge[hidden] { display: none !important; }
.coll-nudge-mascot { width: 56px; height: auto; flex: none; }
.coll-nudge-body { flex: 1; min-width: 0; }
.coll-nudge-title { display: block; color: #1b5e3a; font-size: 1rem; margin-bottom: 0.2rem; }
.coll-nudge-msg { margin: 0 0 0.55rem; font-weight: 700; font-size: 0.88rem; color: #444; line-height: 1.35; }
.coll-nudge-cta { min-height: 44px; width: 100%; }
.coll-nudge-x {
  position: absolute; top: 0.35rem; right: 0.35rem;
  width: 32px; height: 32px; border-radius: 50%;
  border: none; background: #fff8e1; cursor: pointer; font-size: 0.85rem;
}
@media (min-width: 1000px) {
  .coll-nudge { bottom: 1.5rem; }
}
.card-toast { cursor: pointer; }
.card-toast:hover { border-color: #ffb300; }
