:root {
  --background: #f8faf8;
  --surface: #ffffff;
  --surface-low: #f2f4f2;
  --surface-high: #e6e9e7;
  --primary: #006d43;
  --primary-container: #00a86b;
  --primary-soft: rgba(0, 168, 107, 0.12);
  --secondary: #825500;
  --secondary-container: #fdb64b;
  --tertiary: #0060ac;
  --outline: #bccabe;
  --text: #191c1b;
  --muted: #3d4a41;
  --error: #ba1a1a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--background);
  color: var(--text);
  font-family: Lexend, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; }
.hidden { display: none !important; }
.material-symbols-outlined { font-variation-settings: 'FILL' 0, 'wght' 500, 'GRAD' 0, 'opsz' 24; }

.app-shell {
  max-width: 600px;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--background);
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: rgba(248,250,248,.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--outline);
  box-shadow: 0 2px 12px rgba(0,0,0,.05);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mascot { width: 40px; height: 40px; border-radius: 999px; object-fit: cover; border: 2px solid #78fbb6; }
.brand h1 { margin: 0; color: var(--primary); font-size: 21px; line-height: 1; font-weight: 800; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.icon-button { width: 40px; height: 40px; border: 0; border-radius: 999px; background: transparent; color: var(--primary); display: grid; place-items: center; }
.icon-button:active { transform: translateY(1px); background: var(--surface-high); }
.xp-pill { display: flex; align-items: center; gap: 4px; border-radius: 999px; padding: 5px 10px; background: rgba(253,182,75,.22); color: #704800; font-size: 14px; }
.xp-pill .material-symbols-outlined { font-size: 17px; color: var(--secondary); }

.screen { padding: 20px 20px 34px; }
.center-screen { min-height: calc(100dvh - 84px); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.hero-bear { width: 178px; height: 178px; object-fit: contain; margin-bottom: 22px; }
.hero-bear.small { width: 122px; height: 122px; }
.speech-card {
  position: relative;
  max-width: 310px;
  padding: 15px 16px;
  border: 1px solid rgba(0,168,107,.2);
  border-radius: 16px;
  background: var(--surface);
  text-align: center;
  box-shadow: 0 10px 30px -5px rgba(0,168,107,.15);
}
.speech-card::after {
  content: "";
  position: absolute;
  bottom: -8px;
  left: calc(50% - 8px);
  width: 16px;
  height: 16px;
  background: var(--surface);
  border-right: 1px solid rgba(0,168,107,.2);
  border-bottom: 1px solid rgba(0,168,107,.2);
  transform: rotate(45deg);
}
.speech-card p { margin: 0; color: var(--muted); font-style: italic; line-height: 1.5; }
.speech-card span { display: block; margin-top: 5px; color: var(--primary); font-size: 13px; }
.welcome-title, .mode-title { text-align: center; margin: 28px 0 22px; }
h2 { margin: 0; font-size: 34px; line-height: 1.08; font-weight: 800; letter-spacing: -0.02em; }
.welcome-title p, .mode-title span { margin: 8px 0 0; color: var(--primary); font-size: 22px; font-weight: 700; }

.mode-grid, .two-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.primary-action, .secondary-action {
  border: 0;
  border-radius: 999px;
  min-height: 58px;
  padding: 12px 16px;
  font-weight: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: transform .15s ease, box-shadow .15s ease;
}
.primary-action { background: var(--primary-container); color: white; box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 4px 0 #005232; }
.secondary-action { background: var(--secondary-container); color: #291800; box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 4px 0 #704800; }
.primary-action.full, .secondary-action.full { width: 100%; }
.primary-action:active, .secondary-action:active { transform: translateY(3px); box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 1px 0 rgba(0,0,0,.3); }
.primary-action small, .secondary-action small { opacity: .82; font-size: 12px; }
.primary-action .material-symbols-outlined, .secondary-action .material-symbols-outlined { font-size: 24px; }

.hero-card {
  position: relative;
  overflow: hidden;
  margin: 4px 0 28px;
  padding: 24px;
  border-radius: 18px;
  border: 1px solid rgba(0,109,67,.2);
  background: var(--primary-soft);
}
.hero-card h2 { font-size: 25px; margin-bottom: 8px; }
.hero-card p { margin: 0; color: var(--muted); line-height: 1.5; }
.hero-watermark { position: absolute; right: -16px; bottom: -20px; font-size: 120px; color: var(--primary); opacity: .1; }
.category-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.category-card {
  min-height: 178px;
  border: 1px solid var(--outline);
  border-radius: 18px;
  background: var(--surface);
  padding: 20px 12px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0,0,0,.04);
  transition: transform .15s ease, border-color .15s ease;
}
.category-card:active { transform: scale(.96); }
.category-card:hover { border-color: var(--primary); }
.category-icon { width: 64px; height: 64px; border-radius: 999px; display: grid; place-items: center; margin: 0 auto 14px; background: var(--primary-soft); color: var(--primary); }
.category-icon.secondary { background: rgba(253,182,75,.22); color: var(--secondary); }
.category-icon.tertiary { background: rgba(80,149,231,.18); color: var(--tertiary); }
.category-icon .material-symbols-outlined { font-size: 34px; }
.category-card h3 { margin: 0; color: var(--primary); font-size: 17px; line-height: 1.2; }
.category-card p { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.35; }

.phrase-card, .record-card, .feedback-panel, .info-card, .score-card {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(0,0,0,.05);
}
.phrase-card.big { padding: 22px; text-align: center; }
.category-chip { display: inline-flex; padding: 6px 12px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 12px; margin-bottom: 14px; }
.listen-button { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--outline); border-radius: 999px; background: var(--surface-low); color: var(--primary); padding: 8px 12px; font-weight: 700; }
.zh-text { margin: 24px 0 8px; font-size: 44px; color: var(--text); }
.pinyin { margin: 0; color: var(--primary); font-size: 19px; font-weight: 700; }
.english { margin: 7px 0 0; color: var(--muted); font-size: 16px; }
.record-card { margin: 18px 0; padding: 18px; text-align: center; }
.record-button { width: 156px; height: 156px; border-radius: 999px; border: 8px solid rgba(0,168,107,.18); background: var(--primary-container); color: white; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; box-shadow: 0 12px 28px rgba(0,168,107,.24); }
.record-button .material-symbols-outlined { font-size: 42px; }
.record-button.recording { animation: pulse 1.2s infinite; background: var(--error); border-color: rgba(186,26,26,.2); }
@keyframes pulse { 50% { transform: scale(1.04); box-shadow: 0 0 0 14px rgba(186,26,26,.08); } }
.record-status { color: var(--muted); line-height: 1.45; }

.score-card { width: 100%; padding: 28px 20px; text-align: center; background: linear-gradient(180deg, var(--surface), var(--surface-low)); }
.score-card.celebration { border-color: rgba(0,168,107,.35); }
.score-card .label { margin: 0 0 10px; color: var(--muted); text-transform: uppercase; font-size: 12px; letter-spacing: .08em; font-weight: 800; }
.score-number { font-size: 68px; line-height: 1; font-weight: 800; color: var(--primary); }
.score-number small { font-size: 26px; color: var(--muted); }
.feedback-panel { width: 100%; margin: 18px 0; padding: 18px; }
.feedback-panel h3 { margin: 0 0 7px; color: var(--primary); }
.feedback-panel p { margin: 0 0 16px; color: var(--muted); line-height: 1.5; }
.info-card { width: 100%; padding: 22px; display: flex; gap: 14px; align-items: flex-start; }
.info-card .material-symbols-outlined { color: var(--primary); font-size: 32px; }
.info-card h3 { margin: 0 0 6px; }
.info-card p { margin: 0; color: var(--muted); line-height: 1.45; }
.loading { opacity: .65; pointer-events: none; }
.error-text { color: var(--error); font-weight: 700; }

@media (max-width: 380px) {
  .screen { padding-left: 14px; padding-right: 14px; }
  .category-grid { gap: 12px; }
  .category-card { min-height: 166px; padding: 16px 8px; }
  .zh-text { font-size: 38px; }
}
