:root {
  --primary: #ff9f1c;
  --primary-container: #ffe3c2;
  --on-primary-fixed: #5d3b00;
  --surface: #fffaf3;
  --surface-variant: #f3ece1;
  --surface-container: #ffffff;
  --on-surface: #2b2417;
  --on-surface-variant: #7a6c55;
  --green: #4caf50;
  --blue: #4f8ef7;
  --pink: #f76fa4;
  --radius: 20px;
  --shadow: 0 4px 24px rgba(43, 36, 23, 0.08);
}
* { box-sizing: border-box; margin: 0; }
body {
  background: var(--surface);
  color: var(--on-surface);
  font-family: "Quicksand", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.min-h-screen { min-height: 100vh; padding-bottom: 96px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand-logo { height: 40px; }
.brand-row { display: flex; align-items: center; gap: 8px; }
.brand-name { font-size: 20px; font-weight: 800; color: var(--primary); }
.chip { background: var(--primary-container); color: var(--on-primary-fixed); border-radius: 999px; padding: 2px 10px; font-size: 13px; }
.brand-slogan { font-size: 12px; color: var(--on-surface-variant); }
.top-stats { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.stat-pill {
  background: var(--surface-container); border-radius: 999px; padding: 8px 14px;
  font-size: 14px; box-shadow: var(--shadow); text-decoration: none; color: inherit;
}
.parent-link { background: var(--primary-container); color: var(--on-primary-fixed); cursor: pointer; }
.muted { color: var(--on-surface-variant); font-size: 12px; }

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; justify-content: space-around;
  background: var(--surface-container); box-shadow: 0 -4px 24px rgba(43,36,23,.08);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  text-decoration: none; color: var(--on-surface-variant); font-size: 12px;
  padding: 6px 10px; border-radius: 14px;
}
.bottom-nav a.active { background: var(--primary-container); color: var(--on-primary-fixed); font-weight: 700; }
.nav-ico { font-size: 22px; }

/* ---------- layout ---------- */
#view { max-width: 960px; margin: 0 auto; padding: 20px 16px 40px; }
.page-head { display: flex; align-items: center; gap: 12px; margin: 8px 0 16px; }
.page-head h1 { font-size: 24px; }
.back-link { text-decoration: none; color: var(--on-surface-variant); font-size: 20px; }
.card {
  background: var(--surface-container); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px;
}
.card h2 { font-size: 18px; margin-bottom: 10px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: none; border-radius: 999px; padding: 12px 22px; font-size: 16px; font-weight: 700;
  background: var(--primary); color: #fff; text-decoration: none;
  transition: transform .15s; font-family: inherit;
}
.btn:active { transform: scale(.96); }
.btn.secondary { background: var(--surface-variant); color: var(--on-surface); }
.btn.ghost { background: transparent; color: var(--on-surface-variant); box-shadow: inset 0 0 0 2px var(--surface-variant); }
.progress-track { height: 10px; background: var(--surface-variant); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width .4s; }

/* ---------- home ---------- */
.week-hero {
  background: linear-gradient(135deg, #ff9f1c, #ffb85c);
  color: #fff; border-radius: 24px; padding: 22px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.week-hero h1 { font-size: 22px; margin-bottom: 6px; }
.week-hero .sub { opacity: .92; font-size: 14px; margin-bottom: 14px; }
.hero-track { background: rgba(255,255,255,.25); border-radius: 999px; height: 12px; overflow: hidden; margin-bottom: 6px; }
.hero-track .progress-fill { background: #fff; }
.game-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.game-card {
  background: var(--surface-container); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 8px;
  transition: transform .15s;
}
.game-card:hover { transform: translateY(-3px); }
.game-card img { width: 100%; border-radius: 14px; }
.game-card .g-emoji { font-size: 34px; }
.game-card h3 { font-size: 17px; }
.game-card p { font-size: 13px; color: var(--on-surface-variant); }
.principle {
  background: #e8f5e9; border-radius: var(--radius); padding: 16px 20px;
  color: #2e7d32; font-size: 14px; margin-top: 16px;
}

/* ---------- flashcards ---------- */
.mode-tabs { display: flex; gap: 10px; margin-bottom: 16px; }
.mode-tab {
  flex: 1; text-align: center; padding: 12px; border-radius: 16px; cursor: pointer;
  background: var(--surface-container); box-shadow: var(--shadow); font-weight: 700; color: var(--on-surface-variant);
}
.mode-tab.active { background: var(--primary); color: #fff; }
.pack-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.pack-pill {
  padding: 8px 16px; border-radius: 999px; cursor: pointer; background: var(--surface-container);
  box-shadow: var(--shadow); font-size: 14px; color: var(--on-surface-variant);
}
.pack-pill.active { background: var(--primary-container); color: var(--on-primary-fixed); font-weight: 700; }
.flash-stage { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.flash-card {
  width: min(420px, 88vw); height: 300px; perspective: 1000px; cursor: pointer;
}
.flash-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d; transition: transform .5s;
}
.flash-card.flipped .flash-inner { transform: rotateY(180deg); }
.flash-face {
  position: absolute; inset: 0; backface-visibility: hidden;
  border-radius: 24px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
}
.flash-front { background: var(--surface-container); }
.flash-back { background: var(--primary-container); transform: rotateY(180deg); }
.flash-emoji { font-size: 96px; }
.flash-word { font-size: 34px; font-weight: 800; }
.flash-ipa { color: var(--on-surface-variant); font-size: 16px; }
.flash-zh { font-size: 20px; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-10px)} 75%{transform:translateX(10px)} }
.flash-card.shake { animation: shake .35s; }
.quiz-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: min(560px, 92vw); }
.quiz-opt {
  background: var(--surface-container); border-radius: 18px; box-shadow: var(--shadow);
  padding: 18px 8px; text-align: center; cursor: pointer; font-size: 15px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.quiz-opt .q-emoji { font-size: 48px; }
.quiz-opt.correct { background: #e8f5e9; outline: 3px solid var(--green); }
.quiz-opt.wrong-shake { animation: shake .35s; }
.speak-btn { background: var(--blue); }
.big-prompt { font-size: 22px; font-weight: 700; text-align: center; }

/* ---------- roleplay ---------- */
.scene-card { cursor: pointer; }
.scene-lines { display: flex; flex-direction: column; gap: 10px; }
.line {
  max-width: 85%; padding: 12px 16px; border-radius: 18px; font-size: 15px;
  background: var(--surface-container); box-shadow: var(--shadow);
}
.line.parent { align-self: flex-start; background: #e3f2fd; border-top-left-radius: 4px; }
.line.child { align-self: flex-end; background: var(--primary-container); border-top-right-radius: 4px; }
.line .en { font-weight: 700; display: block; }
.line .zh { color: var(--on-surface-variant); font-size: 13px; }
.line .action { color: var(--pink); font-size: 12px; display: block; margin-top: 4px; }
.line.current { outline: 3px solid var(--primary); }
.line.done { opacity: .55; }
.role-tags { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.role-tag { background: var(--surface-variant); border-radius: 999px; padding: 6px 14px; font-size: 13px; }

/* ---------- hunt ---------- */
.letter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 8px; }
.letter-tile {
  aspect-ratio: 1; border-radius: 14px; display: flex; align-items: center; justify-content: center;
  background: var(--surface-container); box-shadow: var(--shadow); cursor: pointer;
  font-size: 22px; font-weight: 800; color: var(--on-surface-variant);
}
.letter-tile.selected { background: var(--primary-container); color: var(--on-primary-fixed); }
.letter-tile.found { background: #e8f5e9; color: var(--green); }
.hunt-found-banner { font-size: 18px; font-weight: 700; color: var(--green); }

/* ---------- garden ---------- */
.garden-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 14px; }
.flower {
  background: var(--surface-container); border-radius: 18px; box-shadow: var(--shadow);
  padding: 14px 8px; text-align: center; cursor: pointer;
}
.flower .f-emoji { font-size: 40px; }
.flower .f-en { font-weight: 700; font-size: 14px; }
.flower .f-zh { color: var(--on-surface-variant); font-size: 12px; }
.garden-empty { text-align: center; color: var(--on-surface-variant); padding: 30px 0; }

/* ---------- plan ---------- */
.task-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 0; border-bottom: 1px solid var(--surface-variant);
}
.task-row:last-child { border-bottom: none; }
.task-row.done .task-name { text-decoration: line-through; color: var(--green); }
.task-check { font-size: 22px; }
.stage-map { display: flex; flex-direction: column; gap: 14px; }
.stage-block h3 { font-size: 15px; margin-bottom: 8px; }
.week-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.week-tile {
  border-radius: 12px; padding: 8px 4px; text-align: center; cursor: pointer; font-size: 12px;
  background: var(--surface-variant); color: var(--on-surface-variant);
}
.week-tile.current { background: var(--primary); color: #fff; font-weight: 800; }
.week-tile.done { background: #c8e6c9; color: #2e7d32; }
.week-tile.assess { background: #ffe3c2; color: var(--on-primary-fixed); }

/* ---------- parent ---------- */
.parent-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--surface-variant); font-size: 14px; }
.print-list { list-style: none; padding: 0; }
.print-list li { padding: 8px 0; border-bottom: 1px dashed var(--surface-variant); font-size: 14px; display: flex; justify-content: space-between; }
input.parent-pass {
  width: 100%; padding: 12px; border-radius: 14px; border: 2px solid var(--surface-variant);
  font-size: 16px; margin: 10px 0; font-family: inherit;
}
.danger-btn { background: #fdecea; color: #c62828; }

/* ---------- toast & confetti ---------- */
.toast {
  position: fixed; bottom: 110px; left: 50%; transform: translateX(-50%);
  background: var(--on-surface); color: var(--surface); border-radius: 999px;
  padding: 10px 22px; font-size: 14px; z-index: 60; transition: opacity .3s;
}
.hidden { opacity: 0; pointer-events: none; }
.confetti-layer { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.confetti-layer span { position: absolute; font-size: 26px; animation: fall 2.2s ease-in forwards; }
@keyframes fall { to { transform: translateY(85vh) rotate(360deg); opacity: 0; } }

@media (max-width: 640px) {
  .brand-text { display: none; }
  .top-stats { font-size: 12px; }
  .quiz-grid { grid-template-columns: repeat(2, 1fr); }
}
@media print {
  .topbar, .bottom-nav, .btn, #view > *:not(.print-area) { display: none !important; }
  .print-area { display: block !important; }
}
