/* R124 每日口算·练字打卡 */
:root {
  --primary-color: #FF8C42;
  --secondary-color: #5BC0EB;
  --writing-color: #9ED96E;
  --bg-color: #FFF8F0;
  --text-color: #4A3728;
  --highlight-color: #FFD166;
  --border-radius: 16px;
  --font-scale: 1;
  --primary-dark: #E07530;
  --secondary-dark: #3DA8D8;
  --writing-dark: #7CB85A;
  --color-correct: #51CF66;
  --color-wrong: #FF6B6B;
  --nav-height: 56px;
  --contact-footer-h: 72px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body {
  font-family: -apple-system, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg-color, #FFF8F0);
  color: var(--text-color, #4A3728);
  overscroll-behavior: none;
  min-height: 100vh;
  min-height: 100dvh;
}
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; border: none; background: none; min-width: 44px; min-height: 44px; }

body.has-contact-footer {
  padding-bottom: calc(var(--contact-footer-h, 72px) + var(--nav-height, 56px) + env(safe-area-inset-bottom, 0px));
}

/* skeleton */
.skeleton { padding: 24px 16px; }
.sk-hero, .sk-card { background: #EEE; border-radius: 16px; animation: pulse 1.2s infinite; }
.sk-hero { height: 180px; margin-bottom: 16px; }
.sk-card { height: 120px; margin-bottom: 12px; }

#app { padding: 16px 16px 8px; max-width: 480px; margin: 0 auto; }

/* hero */
#hero-section { text-align: center; padding: 12px 0 20px; position: relative; }
.character-avatar {
  width: 88px; height: 88px; margin: 0 auto 12px;
  font-size: 56px; line-height: 88px; border-radius: 50%;
  background: #fff; box-shadow: 0 8px 24px rgba(255,140,66,.25);
}
.character-avatar.bounce-in { animation: bounceUp .6s cubic-bezier(.68,-.55,.265,1.55); }
.character-panel {
  background: #fff; border-radius: var(--border-radius, 16px);
  padding: 16px; margin-bottom: 16px; box-shadow: 0 4px 20px rgba(0,0,0,.08);
}
.character-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.character-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px; border-radius: 12px; background: var(--bg-color);
  border: 2px solid transparent;
}
.character-card:active { border-color: var(--primary-color); transform: scale(.98); }
.char-emoji { font-size: 40px; }

.flame-container { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 12px; }
.flame-days { font-size: 1.5rem; font-weight: 700; color: var(--primary-color); }
.flame-l1, .flame-l2, .flame-l3, .flame-l4, .flame-l5, .flame-l6 { font-size: 2rem; }
.flame-l3, .flame-l4 { animation: flameFlicker 1s ease-in-out infinite; }
.flame-l6 { filter: hue-rotate(45deg); }

.points-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: #fff; padding: 6px 14px; border-radius: 20px;
  font-weight: 600; margin-bottom: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.points-badge.points-bump { animation: bounceUp .3s; }

.btn-pulse {
  width: 140px; height: 140px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color), #FFB347);
  color: #fff; font-size: 1rem; font-weight: 700;
  box-shadow: 0 8px 24px rgba(255,140,66,.4);
  animation: pulse 2s ease-in-out infinite;
  margin: 8px auto 16px;
}

.task-summary-card {
  background: #fff; border-radius: var(--border-radius); padding: 14px 18px;
  box-shadow: 0 2px 12px rgba(0,0,0,.06); text-align: left;
}
.task-progress { display: flex; justify-content: space-between; margin-top: 8px; font-size: .9rem; color: #666; }

/* practice */
.section-title { font-size: 1.1rem; margin: 16px 0 12px; }
.switcher-tabs { display: flex; gap: 8px; margin-bottom: 8px; }
.switcher-tabs .tab {
  flex: 1; padding: 10px; border-radius: 24px; background: #fff;
  font-weight: 600; color: #888;
}
.switcher-tabs .tab.active { background: var(--secondary-color); color: #fff; }
.switcher-tabs .writing-tab.active { background: var(--writing-color); }

.progress-dots { display: flex; justify-content: center; gap: 8px; margin-bottom: 12px; }
.progress-dots .dot { width: 8px; height: 8px; border-radius: 50%; background: #DDD; }
.progress-dots .dot.active { background: var(--primary-color); width: 20px; border-radius: 4px; }

.swiper-container { overflow: hidden; position: relative; }
.panel { display: none; }
.panel.active { display: block; animation: fadeIn .3s; }

.math-progress { text-align: center; color: #888; font-size: .85rem; margin-bottom: 8px; }
.question-card {
  font-size: 2rem; font-weight: 700; text-align: center;
  padding: 24px 16px; background: #fff; border-radius: var(--border-radius);
  box-shadow: 0 4px 16px rgba(91,192,235,.15); margin-bottom: 16px;
}
.question-card.fade-in { animation: fadeIn .25s; }

.options-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; justify-items: center; }
.option-btn {
  width: 88px; height: 88px; border-radius: 16px;
  background: #fff; font-size: 1.75rem; font-weight: 700;
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
  color: var(--secondary-color);
}
.option-btn:active { transform: scale(.95); background: var(--secondary-color); color: #fff; }
.option-btn.highlight-correct { box-shadow: 0 0 0 3px var(--color-correct); color: var(--color-correct); }

.countdown-ring { position: relative; width: 44px; height: 44px; margin: 12px auto; }
.countdown-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.countdown-ring .ring-bg { fill: none; stroke: #EEE; stroke-width: 4; }
.countdown-ring .ring-fg { fill: none; stroke: var(--secondary-color); stroke-width: 4; stroke-linecap: round; }
.countdown-ring #countdown-num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .9rem; }
.countdown-ring.warn .ring-fg { stroke: var(--highlight-color); }
.countdown-ring.urgent { animation: pulse .5s infinite; }
.countdown-ring.urgent .ring-fg { stroke: var(--color-wrong); }

.combo-badge {
  text-align: center; font-size: 1.2rem; font-weight: 800;
  color: var(--highlight-color); margin-top: 8px;
}

.result-card {
  background: #fff; border-radius: var(--border-radius); padding: 20px;
  margin-top: 16px; text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,.1);
  animation: slideUp .4s;
}

/* writing */
.step-bar { display: flex; justify-content: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.step-dot { font-size: .75rem; padding: 6px 10px; border-radius: 16px; background: #EEE; color: #888; }
.step-dot.active { background: var(--writing-color); color: #fff; }
.step-dot.current { font-weight: 700; box-shadow: 0 0 0 2px var(--writing-dark); }

.writing-char-label { text-align: center; font-size: 2.5rem; font-weight: 700; margin-bottom: 8px; }
.grid-area {
  width: 120px; height: 120px; margin: 0 auto 12px; position: relative;
  box-shadow: 0 4px 16px rgba(0,0,0,.08); border-radius: 8px; overflow: hidden;
}
#writing-canvas { touch-action: none; display: block; width: 100%; height: 100%; }
.stroke-overlay { position: absolute; inset: 0; pointer-events: none; width: 100%; height: 100%; }
.stroke-path { fill: none; stroke: var(--primary-color); stroke-width: 3; stroke-dasharray: 120; stroke-dashoffset: 120; animation: strokeDraw 1s forwards; }

.writing-toolbar { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.writing-toolbar button {
  padding: 8px 16px; border-radius: 20px; background: #fff;
  border: 1px solid #DDD; font-size: .85rem;
}

.score-popup {
  position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%);
  background: #fff; padding: 24px 32px; border-radius: 20px;
  text-align: center; font-size: 1.5rem; z-index: 200;
  box-shadow: 0 12px 40px rgba(0,0,0,.15); animation: bounceUp .5s;
}

/* error book */
.filter-bar { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 12px; }
.filter-tab { padding: 6px 12px; border-radius: 16px; background: #fff; font-size: .8rem; white-space: nowrap; }
.filter-tab.active { background: var(--primary-color); color: #fff; }
.error-item {
  background: #fff; border-radius: 12px; padding: 12px; margin-bottom: 8px;
  border-left: 4px solid var(--color-wrong);
}
.error-item.status-learning { border-left-color: var(--highlight-color); }
.error-item.status-mastered { border-left-color: var(--color-correct); }
.error-q { font-weight: 600; margin-bottom: 4px; }
.error-meta { font-size: .8rem; color: #888; margin-bottom: 8px; }
.btn-retry { padding: 6px 14px; background: var(--secondary-color); color: #fff; border-radius: 16px; font-size: .8rem; }
.mastered-item { padding: 8px; background: rgba(81,207,102,.1); border-radius: 8px; margin-bottom: 6px; font-size: .9rem; }
.empty-state { text-align: center; padding: 40px 20px; color: #888; }

/* badges & shop */
.badge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.badge-card {
  background: #fff; border-radius: 12px; padding: 12px 8px; text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
}
.badge-card.locked { opacity: .45; filter: grayscale(.8); }
.badge-card.earned { border: 2px solid var(--highlight-color); }
.badge-icon { font-size: 2rem; display: block; }
.badge-name { font-size: .72rem; font-weight: 600; display: block; margin-top: 4px; }
.badge-desc { font-size: .65rem; color: #888; }

.shop-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; max-height: 50vh; overflow-y: auto; }
.shop-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px; background: var(--bg-color); border-radius: 12px;
}
.shop-item.owned { opacity: .6; }
.shop-icon { font-size: 2rem; }
.shop-cost { font-size: .75rem; color: var(--primary-color); font-weight: 600; }

.adventure-section { margin-top: 20px; }
.adventure-themes { display: grid; gap: 8px; }
.theme-card { background: #fff; padding: 10px 12px; border-radius: 10px; }
.theme-bar { height: 6px; background: #EEE; border-radius: 3px; margin-top: 6px; overflow: hidden; }
.theme-bar div { height: 100%; background: var(--primary-color); border-radius: 3px; }

/* profile */
.profile-card { background: #fff; border-radius: var(--border-radius); padding: 20px; text-align: center; margin-bottom: 12px; }
.profile-avatar { font-size: 4rem; }
.profile-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 12px; font-size: .9rem; }
.btn-outline, .btn-primary {
  display: block; width: 100%; padding: 12px; border-radius: 12px;
  margin-bottom: 10px; font-weight: 600;
}
.btn-outline { background: #fff; border: 2px solid var(--primary-color); color: var(--primary-color); }
.btn-primary { background: var(--primary-color); color: #fff; }

/* parent board */
#parent-board { padding: 16px; max-width: 800px; margin: 0 auto; }
.parent-navbar { margin-bottom: 12px; }
.btn-back-child { padding: 10px 16px; background: #fff; border-radius: 20px; font-weight: 600; }
.report-card { background: #fff; border-radius: var(--border-radius); padding: 16px; margin-bottom: 16px; box-shadow: 0 4px 16px rgba(0,0,0,.06); }
.charts-container { display: grid; grid-template-columns: 1fr; gap: 16px; }
.chart-wrap { background: #fff; border-radius: 12px; padding: 12px; }
.chart-wrap h4 { font-size: .85rem; margin-bottom: 8px; color: #666; }
.chart-wrap canvas { width: 100%; height: 140px; }
.timeline { margin-top: 16px; }
.timeline-thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.timeline-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }

/* bottom nav */
.bottom-navbar {
  position: fixed; bottom: var(--contact-footer-h, 72px); left: 0; right: 0;
  height: var(--nav-height, 56px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: #fff; border-top: 1px solid #EEE;
  display: flex; justify-content: space-around; align-items: center;
  z-index: 90; max-width: 480px; margin: 0 auto;
}
.nav-item {
  display: flex; flex-direction: column; align-items: center;
  font-size: .65rem; color: #888; gap: 2px;
}
.nav-item.active { color: var(--primary-color); font-weight: 700; }
.nav-item span { font-size: .65rem; }

/* modals */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 300; padding: 20px;
}
.modal {
  background: #fff; border-radius: var(--border-radius); padding: 24px;
  width: 100%; max-width: 360px; max-height: 85vh; overflow-y: auto;
  position: relative; animation: slideUp .35s;
}
.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; text-align: center; }
.modal-close, .modal-close-btn {
  position: absolute; top: 12px; right: 12px; width: 36px; height: 36px;
  border-radius: 50%; background: #F0F0F0; font-size: 1.2rem;
}
.modal-close-btn { position: static; width: 100%; margin-top: 16px; background: var(--primary-color); color: #fff; border-radius: 12px; }

#cta-form input, #cta-form select {
  width: 100%; padding: 12px; margin-bottom: 10px; border: 1px solid #DDD;
  border-radius: 10px; font-size: 1rem;
}

.checkin-modal { text-align: center; }
.count-display { font-size: 3rem; font-weight: 800; color: var(--primary-color); }
.heatmap-grid { display: flex; flex-wrap: wrap; gap: 2px; justify-content: center; margin: 16px 0; max-height: 120px; overflow: hidden; }
.heatmap-cell { width: 8px; height: 8px; border-radius: 2px; }

.pin-input-group { display: flex; justify-content: center; gap: 12px; margin: 16px 0; }
.pin-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #CCC; }
.pin-dot.filled { background: var(--primary-color); border-color: var(--primary-color); }
.num-keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pin-key {
  padding: 16px; font-size: 1.25rem; background: #F5F5F5; border-radius: 12px;
}
.pin-modal.shake { animation: shake .4s; }

/* feedback */
.feedback-correct, .feedback-wrong, .combo-number {
  position: fixed; z-index: 250; pointer-events: none; font-size: 2rem; font-weight: 800;
  transform: translate(-50%, -50%);
}
.feedback-correct { color: var(--color-correct); animation: bounceUp .3s; }
.feedback-wrong { color: var(--color-wrong); animation: blink .3s 2; }
.combo-number { animation: comboFloat .8s forwards; }

.overlay-canvas {
  position: fixed; inset: 0; pointer-events: none; z-index: 200;
}
body.flash::after {
  content: ''; position: fixed; inset: 0; background: rgba(255,255,255,.6);
  z-index: 199; animation: lightFlash .2s;
  pointer-events: none;
}

.toast-container { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 400; }
.toast {
  background: rgba(0,0,0,.78); color: #fff; padding: 10px 18px;
  border-radius: 20px; font-size: .9rem; margin-bottom: 8px;
  opacity: 0; transform: translateY(-8px); transition: .3s;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* contact footer */
.contact-footer {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: #fff; border-top: 1px solid #EEE;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
}
.contact-footer__btns {
  display: grid; grid-template-columns: repeat(3, minmax(0, 88px));
  gap: 8px; max-width: 320px; margin: 0 auto; justify-content: center;
}
.contact-footer__cta, .contact-footer__btn {
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; padding: .48rem .2rem; border-radius: 8px;
  text-decoration: none; color: #333; background: #F5F5F5;
}
.contact-footer__cta { background: #c41e1e !important; color: #fff !important; font-weight: 600; }
.contact-footer__brand { text-align: center; font-size: .6rem; color: #999; margin-top: 6px; }

body.has-contact-footer .zw-root .zw-fab {
  bottom: calc(var(--contact-footer-h, 72px) + var(--nav-height, 56px) + 12px + env(safe-area-inset-bottom)) !important;
}

/* share page */
.share-page .share-main { padding: 24px 16px; max-width: 420px; margin: 0 auto; }
.share-card { background: #fff; border-radius: 16px; padding: 24px; text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,.08); }
.share-hero-icon { font-size: 3rem; line-height: 1.2; }
.share-quote { margin: 16px 0; color: #888; font-style: italic; }
.share-cta {
  display: block; width: 100%; text-decoration: none; text-align: center;
  margin: 20px 0 8px; padding: 14px 20px; font-size: 1.05rem; font-weight: 700;
  background: var(--primary-color, #FF8C42);
  color: #fff !important;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(255,140,66,.35);
}
.share-page a.share-cta:visited,
.share-page a.share-cta:hover,
.share-page a.share-cta:active { color: #fff !important; }
.share-divider { font-size: .8rem; color: #AAA; margin: 20px 0 12px; }
.share-divider::before, .share-divider::after { content: ' — '; }
.share-qr { margin: 8px auto 12px; }
.share-hint { font-size: .8rem; color: #888; margin-bottom: 12px; }
.share-copy { margin-top: 4px; }

/* responsive */
@media (max-width: 374px) {
  .option-btn { width: 72px; height: 72px; font-size: 1.4rem; }
  .grid-area { width: 100px; height: 100px; }
}
@media (min-width: 744px) {
  .charts-container { grid-template-columns: repeat(2, 1fr); }
  .options-grid { max-width: 360px; margin: 0 auto; }
}

/* keyframes */
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes bounceUp { 0% { transform: translateY(20px) scale(.8); opacity: 0; } 100% { transform: translateY(0) scale(1); opacity: 1; } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .2; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes flameFlicker { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg) scale(1.05); } }
@keyframes strokeDraw { to { stroke-dashoffset: 0; } }
@keyframes comboFloat { 0% { opacity: 1; transform: translate(-50%, -50%); } 100% { opacity: 0; transform: translate(-50%, -120%); } }
@keyframes lightFlash { 0% { opacity: .8; } 100% { opacity: 0; } }
