:root {
  --bg1: #f4f8ff;
  --bg2: #e7efff;
  --panel: rgba(255, 255, 255, 0.93);
  --border: rgba(76, 101, 160, 0.14);
  --text: #162238;
  --muted: #5e6b86;
  --primary: #4a78ea;
  --primary2: #7d67e6;
  --good: #1f9d67;
  --bad: #c84d67;
  --shadow: 0 18px 44px rgba(54, 76, 130, 0.12);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top, #fff 0%, var(--bg2) 40%, var(--bg1) 100%);
  font-size: 18px;
}
.hidden { display: none !important; }
.bg-spark {
  position: fixed;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  filter: blur(24px);
  opacity: 0.28;
  pointer-events: none;
}
.bg-a { background: #8d6bff; top: -90px; right: -60px; }
.bg-b { background: #ff8bd4; bottom: -100px; left: -80px; }

.app {
  width: min(1160px, calc(100% - 24px));
  margin: 0 auto;
  padding: 18px 0 30px;
  display: grid;
  gap: 14px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}
.eyebrow {
  margin: 0 0 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-size: 0.88rem;
}
h1 {
  margin: 0;
  font-size: clamp(2.1rem, 4vw, 3.2rem);
  line-height: 1.1;
}
.subtitle {
  margin: 10px 0 0;
  color: #51607b;
  line-height: 1.8;
  font-size: 1.05rem;
}
.badge {
  min-width: 120px;
  padding: 16px 18px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(74,120,234,.94), rgba(125,103,230,.9));
  text-align: center;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 12px 28px rgba(74,120,234,.22);
}
.badge span { display: block; font-size: 0.92rem; opacity: 0.92; }
.badge strong { display: block; margin-top: 6px; font-size: 1.3rem; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.stat span { display: block; color: var(--muted); margin-bottom: 8px; }
.stat strong { font-size: 2rem; }

.section-title, .feedback-title, .footer-title { margin: 0 0 8px; font-weight: 800; }
.section-help, .feedback-text, .footer-text { margin: 0; color: var(--text); line-height: 1.85; font-size: 1.04rem; }
.story-card { background: linear-gradient(135deg, rgba(255,255,255,.95), rgba(245,248,255,.9)); }

.section-head, .footer-bar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}
.toggle-wrap { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--text);
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(76, 101, 160, 0.15);
}
.toggle input { width: 18px; height: 18px; }

.intro-page, .story-page {
  display: grid;
  gap: 16px;
}
.intro-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.intro-card {
  border-radius: 18px;
  padding: 16px;
  border: 1px solid rgba(76, 101, 160, 0.14);
  background: rgba(255,255,255,0.88);
}
.intro-card h3 { margin: 0 0 8px; font-size: 1.08rem; }
.intro-card p { margin: 0; color: var(--muted); line-height: 1.7; }
.intro-card.be { box-shadow: inset 0 0 0 2px rgba(74,120,234,.12); }
.intro-card.do { box-shadow: inset 0 0 0 2px rgba(31,157,103,.12); }
.intro-card.modal { box-shadow: inset 0 0 0 2px rgba(125,103,230,.12); }
.intro-card.main { box-shadow: inset 0 0 0 2px rgba(240,166,58,.12); }
.intro-actions { display: flex; justify-content: center; }

.story-pager {
  display: grid;
  gap: 14px;
  padding: 6px 0 0;
}
.story-topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  font-weight: 800;
  color: var(--muted);
}
.story-card-frame {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 14px;
  padding: 14px;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(255,255,255,.95), rgba(244,248,255,.98));
  border: 1px solid rgba(76, 101, 160, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.5);
}
.story-art-wrap {
  min-height: 180px;
  max-height: 240px;
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255,255,255,0.72);
  border: 2px solid rgba(76, 101, 160, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
}
.story-art-img {
  width: 100%;
  height: 100%;
  max-height: 240px;
  display: block;
  object-fit: contain;
  object-position: center;
  background: rgba(255,255,255,0.72);
  opacity: 0.98;
}
.story-slide {
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 4px 2px;
}
.story-main {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.95;
  font-weight: 800;
}
.story-explain {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.95;
  color: var(--text);
}
.story-voice {
  margin: 2px 0 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255,255,255,0.82);
  border: 1px solid rgba(76, 101, 160, 0.12);
  font-weight: 700;
  line-height: 1.8;
}
.story-rule {
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(74,120,234,.10);
  color: #29468f;
  font-weight: 800;
  line-height: 1.8;
}
.story-example {
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(125,103,230,.06);
  line-height: 1.9;
}
.story-example .ex-line {
  display: block;
  margin: 4px 0;
}
.story-keyline {
  margin-top: 2px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(74,120,234,.08);
  color: #29468f;
  font-weight: 800;
}
.story-buttons {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.story-pager.flip { animation: pageFlip .22s ease; }

.word-bank {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}
.box-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.word-card, .box-card, .answer-card {
  border-radius: 18px;
  border: 1px solid rgba(76, 101, 160, 0.18);
  background: rgba(255,255,255,0.88);
  padding: 14px;
}
.word-card {
  cursor: grab;
  text-align: left;
  transition: transform .15s ease, opacity .15s ease, box-shadow .15s ease;
}
.word-card strong { display: block; font-size: 1.26rem; }
.word-card span, .box-card p, .answer-card p { display: block; margin-top: 6px; color: var(--muted); font-size: 0.92rem; }
.word-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(74,120,234,.12); }
.word-card.dragging { opacity: .42; transform: scale(0.98); }

.box-card {
  min-height: 190px;
  position: relative;
  overflow: hidden;
}
.box-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto auto;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  opacity: .18;
  transform: translate(18px, -18px);
}
.box-card.blue::before { background: #4a78ea; }
.box-card.green::before { background: #1f9d67; }
.box-card.purple::before { background: #7d67e6; }
.box-card.orange::before { background: #f0a63a; }
.box-card h3 { margin: 0; font-size: 1.08rem; line-height: 1.45; }
.drop-zone {
  margin-top: 16px;
  padding: 16px;
  border-radius: 14px;
  border: 2px dashed rgba(76, 101, 160, 0.2);
  text-align: center;
  color: var(--muted);
  font-weight: 700;
  background: rgba(255,255,255,0.56);
}
.mini-note {
  margin-top: 12px;
  font-size: 0.88rem;
  color: #73809b;
  line-height: 1.5;
}
.box-card.correct {
  border-color: rgba(66,211,146,0.72);
  box-shadow: 0 0 0 4px rgba(66,211,146,0.12);
  transform: translateY(-2px);
}
.box-card.wrong {
  border-color: rgba(255,111,145,0.72);
  box-shadow: 0 0 0 4px rgba(255,111,145,0.12);
  animation: shake .32s ease;
}
.box-card.pulse { animation: pop .25s ease; }

.feedback {
  display: grid;
  gap: 8px;
  min-height: 106px;
}
.feedback-title { font-size: 1.2rem; }

.primary-btn, .ghost-btn {
  border: none;
  border-radius: 999px;
  padding: 14px 22px;
  font-weight: 800;
  cursor: pointer;
}
.primary-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary2));
  color: #fff;
}
.ghost-btn {
  background: rgba(255,255,255,0.72);
  color: var(--text);
  border: 1px solid rgba(76, 101, 160, 0.16);
}
button:disabled { opacity: .45; cursor: not-allowed; }
.pulse-button { animation: pulseGlow 1.8s infinite; }

.shake { animation: shake .35s ease; }
.pop { animation: pop .3s ease; }

@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}
@keyframes pop {
  0% { transform: scale(.96); }
  100% { transform: scale(1); }
}
@keyframes pageFlip {
  0% { transform: perspective(800px) rotateY(-8deg); opacity: .92; }
  100% { transform: perspective(800px) rotateY(0deg); opacity: 1; }
}
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 12px 24px rgba(74,120,234,.18); transform: translateY(0); }
  50% { box-shadow: 0 16px 34px rgba(74,120,234,.3); transform: translateY(-1px); }
}

@media (max-width: 920px) {
  .stats, .word-bank, .box-grid, .intro-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero, .section-head, .footer-bar, .story-card-frame { flex-direction: column; align-items: flex-start; }
  .story-card-frame { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .stats, .word-bank, .box-grid, .intro-cards { grid-template-columns: 1fr; }
}
