:root {
  --brand: #5b6cff;
  --brand-dark: #4654e6;
  --brand-soft: #eef0ff;
  --sky: #f4f8ff;
  --ink: #263238;
  --muted: #667085;
  --line: #e2e7f0;
  --card: #ffffff;
  --sun: #ffc94a;
  --success: #34c88a;
  --success-soft: #eafaf3;
  --error: #ff6b6b;
  --error-soft: #fff0f0;
  --purple: #8b5cf6;
  --blue: #3b82f6;
  --orange: #f59e0b;
  --green: #10b981;
  --shadow: 0 12px 32px rgba(38, 50, 56, 0.08);
  --shadow-brand: 0 12px 28px rgba(91, 108, 255, 0.2);
  --radius-card: 20px;
  --radius-control: 16px;
  --radius-pill: 999px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: var(--ink);
  background: var(--sky);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--sky); }

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background: linear-gradient(180deg, #f4f8ff 0%, #f8fbff 64%, #f2f8f4 100%);
}

button { font: inherit; }

button:focus-visible {
  outline: 3px solid rgba(91, 108, 255, 0.35);
  outline-offset: 3px;
}

.page-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.sun-glow {
  position: absolute;
  top: -110px;
  right: -90px;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 201, 74, 0.38) 0 26%, rgba(255, 221, 140, 0.16) 48%, transparent 70%);
}

.cloud {
  position: absolute;
  width: 170px;
  height: 44px;
  border-radius: 50px;
  background: rgba(255, 255, 255, 0.72);
  filter: blur(0.2px);
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  bottom: 12px;
  border-radius: 50%;
  background: inherit;
}

.cloud::before { left: 24px; width: 58px; height: 58px; }
.cloud::after { left: 74px; width: 76px; height: 76px; }
.cloud-one { top: 130px; left: -30px; transform: scale(0.82); }
.cloud-two { top: 260px; right: -48px; transform: scale(0.66); opacity: 0.74; }

.island {
  position: absolute;
  bottom: -100px;
  width: 600px;
  height: 220px;
  border-radius: 50% 50% 0 0;
  background: #bfe9cb;
  opacity: 0.34;
}

.island-back { left: -220px; transform: rotate(-4deg); }
.island-front { right: -220px; bottom: -138px; transform: rotate(6deg); background: #a9dfc0; }

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1080px, calc(100% - 32px));
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0 0 calc(18px + env(safe-area-inset-bottom));
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  gap: 16px;
}

.brand,
.icon-button,
.back-button {
  border: 0;
  cursor: pointer;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  color: var(--ink);
  text-align: left;
  background: transparent;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  font-size: 22px;
  font-weight: 800;
  background: var(--brand);
  box-shadow: 0 5px 12px rgba(91, 108, 255, 0.22);
}

.brand strong { display: block; font-size: 15px; letter-spacing: 0.01em; }
.brand small { display: block; margin-top: 1px; color: var(--muted); font-size: 10px; letter-spacing: 0.06em; }

.header-actions { display: inline-flex; align-items: center; gap: 10px; }
.save-status { color: #82909b; font-size: 12px; }

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(91, 108, 255, 0.14);
  border-radius: 14px;
  color: var(--brand);
  font-size: 20px;
  background: rgba(255, 255, 255, 0.72);
  transition: transform 180ms ease, background 180ms ease;
}

.icon-button:hover { background: #fff; transform: translateY(-2px); }
.icon-button:active { transform: scale(0.97); }

#app { min-height: calc(100dvh - 125px); }

.screen {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 18px 0 28px;
  animation: enter 420ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.screen-wide { width: min(980px, 100%); }

@keyframes enter {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-screen { width: min(980px, 100%); padding-top: 8px; }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(300px, 0.92fr);
  min-height: 650px;
  align-items: center;
  gap: 34px;
  padding: 42px 50px 38px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.84);
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.hero-copy { position: relative; z-index: 1; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 18px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.eyebrow::before { content: "✦"; color: var(--sun); font-size: 15px; }

h1, h2, h3, p { margin: 0; }
h1 { max-width: 8.4em; font-size: clamp(2.25rem, 5vw, 4.5rem); line-height: 1.07; letter-spacing: -0.055em; }
h2 { font-size: clamp(1.65rem, 3vw, 2.4rem); line-height: 1.16; letter-spacing: -0.04em; }
h3 { font-size: 1.05rem; line-height: 1.35; }

.hero-copy h1 span { color: var(--brand); }
.hero-lede { max-width: 23em; margin-top: 20px; color: var(--muted); font-size: 17px; line-height: 1.7; }

.hero-actions { display: flex; align-items: center; gap: 12px; margin-top: 30px; }
.hero-note { margin-top: 12px; color: #87919b; font-size: 12px; }

.primary-button,
.secondary-button {
  min-height: 52px;
  padding: 0 24px;
  border-radius: var(--radius-control);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease, border-color 180ms ease;
}

.primary-button {
  color: #fff;
  border: 1px solid var(--brand);
  background: var(--brand);
  box-shadow: var(--shadow-brand);
}

.primary-button:hover { background: var(--brand-dark); transform: translateY(-2px); box-shadow: 0 15px 30px rgba(91, 108, 255, 0.26); }
.primary-button:active, .secondary-button:active { transform: scale(0.97); }
.primary-button:disabled { cursor: not-allowed; opacity: 0.4; box-shadow: none; }

.secondary-button {
  color: var(--brand);
  border: 1px solid #d9deff;
  background: #fff;
}

.secondary-button:hover { border-color: var(--brand); background: var(--brand-soft); transform: translateY(-1px); }
.secondary-button.compact { min-height: 44px; padding: 0 16px; font-size: 14px; }

.hero-visual {
  position: relative;
  display: grid;
  min-height: 540px;
  place-items: stretch;
  border-radius: 24px;
  background: #cdefff;
  overflow: hidden;
}

.hero-art {
  width: 100%;
  height: 100%;
  min-height: 540px;
  object-fit: cover;
  object-position: 66% 50%;
  animation: hero-breathe 7s ease-in-out infinite;
}

@keyframes hero-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.02); } }

.badge-orbit { position: absolute; z-index: 2; display: grid; width: 54px; height: 54px; place-items: center; border: 4px solid #fff; border-radius: 50%; box-shadow: 0 8px 18px rgba(38, 50, 56, 0.12); font-size: 25px; }
.badge-orbit.one { top: 24%; left: 14%; background: #e8ddff; }
.badge-orbit.two { right: 11%; bottom: 31%; background: #d7ecff; }
.badge-orbit.three { left: 20%; bottom: 16%; background: #fff1bf; }

.ability-preview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
  margin-top: 34px;
}

.ability-chip { padding: 12px 8px 10px; border-radius: 15px; background: rgba(244, 248, 255, 0.84); text-align: center; }
.ability-chip .ability-icon { display: block; margin-bottom: 4px; font-size: 22px; }
.ability-chip span:last-child { color: var(--muted); font-size: 12px; font-weight: 700; }

.step-header { margin-bottom: 28px; }
.step-header h2 { max-width: 16em; }
.step-header p { margin-top: 10px; color: var(--muted); font-size: 15px; line-height: 1.6; }

.progress-wrap { margin-bottom: 24px; }
.step-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.back-button { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 0 4px; color: var(--muted); background: transparent; font-size: 14px; }
.back-button:hover { color: var(--brand); }
.step-count { color: var(--brand); font-size: 13px; font-weight: 800; }
.progress-track { height: 8px; overflow: hidden; border-radius: var(--radius-pill); background: #e9ecf5; }
.progress-fill { height: 100%; border-radius: inherit; background: var(--brand); transition: width 360ms cubic-bezier(0.16, 1, 0.3, 1); }

.guide-row { display: flex; align-items: center; gap: 13px; margin: 0 0 22px; padding: 12px 15px 12px 11px; border: 1px solid rgba(91, 108, 255, 0.1); border-radius: var(--radius-card); background: rgba(255, 255, 255, 0.72); }
.guide-avatar { flex: 0 0 auto; width: 54px; height: 54px; object-fit: cover; object-position: 76% 40%; border-radius: 17px; background: #e9f7f1; }
.guide-bubble { color: var(--ink); font-size: 14px; font-weight: 700; line-height: 1.5; }

.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.choice-card { position: relative; display: flex; align-items: center; gap: 13px; min-height: 88px; padding: 15px; border: 1.5px solid var(--line); border-radius: var(--radius-control); color: var(--ink); background: rgba(255, 255, 255, 0.88); text-align: left; cursor: pointer; box-shadow: 0 4px 12px rgba(38, 50, 56, 0.03); transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease; }
.choice-card:hover { border-color: #b6c0ff; transform: translateY(-2px); box-shadow: 0 9px 20px rgba(91, 108, 255, 0.1); }
.choice-card.selected { border-color: var(--brand); border-width: 2px; background: var(--brand-soft); box-shadow: var(--shadow-brand); transform: translateY(-2px); }
.choice-card.selected::after { content: "✓"; position: absolute; top: 9px; right: 10px; display: grid; width: 22px; height: 22px; place-items: center; border-radius: 50%; color: #fff; font-size: 13px; font-weight: 800; background: var(--brand); }
.choice-icon { display: grid; flex: 0 0 auto; width: 42px; height: 42px; place-items: center; border-radius: 13px; background: #f1f3ff; font-size: 23px; }
.choice-content strong { display: block; font-size: 16px; }
.choice-content small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.35; }

.single-choice-grid { grid-template-columns: 1fr; }
.single-choice-grid .choice-card { min-height: 64px; }

.screen-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 24px; }
.screen-actions .primary-button { min-width: 168px; }

.question-card { padding: clamp(20px, 4vw, 32px); border: 1px solid rgba(255, 255, 255, 0.9); border-radius: var(--radius-card); background: rgba(255, 255, 255, 0.9); box-shadow: var(--shadow); }
.question-label { margin-bottom: 10px; color: var(--brand); font-size: 12px; font-weight: 800; letter-spacing: 0.08em; }
.question-title { font-size: clamp(1.4rem, 3.5vw, 2rem); line-height: 1.35; }
.question-title.english { font-family: Arial, sans-serif; font-size: clamp(1.65rem, 4vw, 2.25rem); letter-spacing: -0.02em; }
.question-help { margin-top: 8px; color: var(--muted); font-size: 14px; line-height: 1.6; }

.image-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 24px; }
.image-option { display: grid; min-height: 146px; align-content: center; justify-items: center; gap: 8px; padding: 14px 10px; border: 1.5px solid var(--line); border-radius: var(--radius-control); color: var(--ink); background: #fff; cursor: pointer; transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease, background 180ms ease; }
.image-option:hover { border-color: #b6c0ff; transform: translateY(-2px); }
.image-option.selected { border-color: var(--brand); background: var(--brand-soft); box-shadow: var(--shadow-brand); }
.image-option.correct { border-color: var(--success); background: var(--success-soft); }
.image-option.wrong { border-color: var(--error); background: var(--error-soft); animation: shake 360ms ease-in-out; }
.image-option .scene { display: grid; width: 74px; height: 74px; place-items: center; border-radius: 23px; background: #f4f8ff; font-size: 44px; }
.image-option strong { font-size: 15px; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.feedback { display: flex; align-items: center; gap: 9px; min-height: 48px; margin-top: 16px; padding: 11px 14px; border-radius: 14px; font-size: 14px; font-weight: 700; line-height: 1.4; }
.feedback.success { color: #207a57; background: var(--success-soft); }
.feedback.error { color: #c64a4a; background: var(--error-soft); }
.feedback-icon { font-size: 20px; }

.audio-box { display: grid; justify-items: center; margin-top: 24px; padding: 24px 18px 20px; border-radius: var(--radius-card); background: #f4f8ff; }
.audio-button { display: grid; width: 76px; height: 76px; place-items: center; border: 0; border-radius: 50%; color: #fff; font-size: 28px; background: var(--brand); box-shadow: var(--shadow-brand); cursor: pointer; transition: transform 180ms ease, background 180ms ease; }
.audio-button:hover { background: var(--brand-dark); transform: scale(1.04); }
.audio-button:active { transform: scale(0.97); }
.audio-button.playing { animation: audio-pulse 1.2s ease-in-out infinite; }
.audio-caption { margin-top: 13px; color: var(--muted); font-size: 13px; }
@keyframes audio-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(91, 108, 255, 0.3), var(--shadow-brand); } 50% { box-shadow: 0 0 0 14px rgba(91, 108, 255, 0), var(--shadow-brand); } }

.sentence-area { margin-top: 24px; }
.sentence-answer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 66px; padding: 12px; border: 1.5px dashed #bdc6e9; border-radius: var(--radius-control); background: #fafbff; }
.sentence-answer.empty::before { content: "点下面的单词，搭好句子"; color: #98a1b2; font-size: 14px; }
.word-chip { min-height: 42px; padding: 0 13px; border: 1px solid #d9deff; border-radius: 12px; color: var(--brand); font-weight: 700; background: #fff; cursor: pointer; transition: transform 160ms ease, background 160ms ease; }
.word-chip:hover { transform: translateY(-2px); background: var(--brand-soft); }
.word-bank { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 13px; }
.word-bank .word-chip.used { color: #a2abc0; border-color: #e9ecf5; background: #f4f6fa; cursor: default; transform: none; }

.reading-passage { margin-top: 24px; padding: 20px; border-radius: 16px; background: #f4f8ff; }
.reading-passage p { font-family: Arial, sans-serif; color: #34434d; font-size: 17px; line-height: 1.85; }
.reading-question { margin-top: 22px; font-size: 18px; font-weight: 800; line-height: 1.5; }
.reading-options { display: grid; gap: 10px; margin-top: 14px; }
.reading-option { min-height: 54px; padding: 0 16px; border: 1.5px solid var(--line); border-radius: var(--radius-control); color: var(--ink); background: #fff; text-align: left; font-size: 16px; font-weight: 700; cursor: pointer; transition: transform 160ms ease, border-color 160ms ease, background 160ms ease; }
.reading-option:hover { border-color: #b6c0ff; transform: translateX(2px); }
.reading-option.selected { border-color: var(--brand); background: var(--brand-soft); }
.reading-option.correct { border-color: var(--success); background: var(--success-soft); }
.reading-option.wrong { border-color: var(--error); background: var(--error-soft); }

.result-screen { width: min(900px, 100%); }
.result-layout { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(280px, 0.92fr); gap: 22px; align-items: stretch; }
.result-card { position: relative; overflow: hidden; padding: 30px; border-radius: 26px; color: #fff; background: linear-gradient(145deg, #5b6cff 0%, #7884ff 52%, #6aa9f2 100%); box-shadow: 0 18px 36px rgba(91, 108, 255, 0.25); }
.result-card::before { content: "✦"; position: absolute; top: -16px; right: 22px; color: rgba(255, 255, 255, 0.3); font-size: 118px; line-height: 1; }
.result-card::after { content: ""; position: absolute; right: -34px; bottom: -50px; width: 190px; height: 190px; border: 22px solid rgba(255, 255, 255, 0.12); border-radius: 50%; }
.result-kicker { position: relative; z-index: 1; color: rgba(255, 255, 255, 0.76); font-size: 13px; font-weight: 700; }
.result-name { position: relative; z-index: 1; max-width: 10em; margin-top: 10px; font-size: clamp(2rem, 4vw, 3rem); line-height: 1.14; letter-spacing: -0.05em; }
.result-description { position: relative; z-index: 1; max-width: 28em; margin-top: 14px; color: rgba(255, 255, 255, 0.88); font-size: 15px; line-height: 1.7; }
.result-character { position: absolute; z-index: 1; right: 12px; bottom: -12px; width: 158px; height: 178px; object-fit: cover; object-position: 76% 40%; border-radius: 82px 82px 18px 18px; opacity: 0.96; filter: drop-shadow(0 12px 14px rgba(38, 50, 56, 0.18)); }
.result-content { padding: 5px 0; }
.result-content h2 { font-size: 1.7rem; }
.result-tip { margin-top: 8px; color: var(--muted); font-size: 14px; line-height: 1.6; }
.energy-list { display: grid; gap: 10px; margin-top: 22px; }
.energy-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 16px; background: rgba(255, 255, 255, 0.8); }
.energy-main { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 800; }
.energy-symbol { display: grid; width: 31px; height: 31px; place-items: center; border-radius: 10px; color: #fff; font-size: 16px; }
.energy-row:nth-child(1) .energy-symbol { background: var(--purple); }
.energy-row:nth-child(2) .energy-symbol { background: var(--blue); }
.energy-row:nth-child(3) .energy-symbol { background: var(--orange); }
.energy-row:nth-child(4) .energy-symbol { background: var(--green); }
.stars { color: var(--sun); font-size: 16px; letter-spacing: 1px; white-space: nowrap; }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.result-actions .primary-button, .result-actions .secondary-button { min-height: 48px; font-size: 15px; }

.loading-state, .error-state { display: grid; justify-items: center; padding: 64px 24px; border-radius: var(--radius-card); background: rgba(255, 255, 255, 0.84); box-shadow: var(--shadow); text-align: center; }
.loading-state img { width: 140px; height: 100px; margin-bottom: 14px; border-radius: 20px; object-fit: cover; object-position: 70% 45%; animation: hero-breathe 2.8s ease-in-out infinite; }
.loading-state p, .error-state p { margin-top: 9px; color: var(--muted); font-size: 14px; }
.error-state strong { font-size: 20px; }

.toast { position: fixed; z-index: 5; left: 50%; bottom: calc(26px + env(safe-area-inset-bottom)); max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 14px; color: #fff; background: rgba(38, 50, 56, 0.92); box-shadow: 0 12px 24px rgba(38, 50, 56, 0.18); font-size: 14px; font-weight: 700; opacity: 0; transform: translate(-50%, 10px); pointer-events: none; transition: opacity 180ms ease, transform 180ms ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.app-footer { display: flex; justify-content: center; gap: 8px; padding: 8px 0; color: #95a0ab; font-size: 11px; }
.footer-separator { color: #c4cbd2; }

@media (max-width: 800px) {
  .hero-grid { grid-template-columns: 1fr; min-height: auto; padding: 34px 26px 26px; }
  .hero-copy { text-align: center; }
  h1 { margin: 0 auto; }
  .hero-lede { margin-right: auto; margin-left: auto; }
  .hero-actions { justify-content: center; }
  .hero-visual { min-height: 360px; }
  .hero-art { min-height: 360px; }
  .result-layout { grid-template-columns: 1fr; }
  .result-card { min-height: 284px; }
}

@media (max-width: 560px) {
  .app-shell { width: min(100% - 24px, 720px); }
  .app-header { min-height: 68px; }
  .save-status { display: none; }
  .screen { padding-top: 12px; }
  .hero-grid { gap: 24px; padding: 28px 17px 18px; border-radius: 24px; }
  .hero-visual { min-height: 300px; border-radius: 20px; }
  .hero-actions { flex-direction: column; align-items: stretch; }
  .hero-actions .primary-button, .hero-actions .secondary-button { width: 100%; }
  .ability-preview { gap: 6px; margin-top: 26px; }
  .ability-chip { padding: 10px 5px 8px; }
  .ability-chip .ability-icon { font-size: 19px; }
  .ability-chip span:last-child { font-size: 11px; }
  .choice-grid, .image-options { grid-template-columns: 1fr 1fr; gap: 9px; }
  .choice-card { min-height: 82px; padding: 12px 10px; gap: 9px; }
  .choice-icon { width: 35px; height: 35px; font-size: 19px; }
  .choice-content strong { font-size: 14px; }
  .choice-content small { font-size: 11px; }
  .image-option { min-height: 126px; }
  .image-option .scene { width: 60px; height: 60px; font-size: 35px; }
  .screen-actions { flex-direction: column-reverse; align-items: stretch; }
  .screen-actions button { width: 100%; }
  .result-card { padding: 24px 20px; }
  .result-character { width: 122px; height: 138px; right: -2px; bottom: -5px; border-radius: 64px 64px 12px 12px; }
  .result-description { max-width: 17em; padding-bottom: 50px; }
  .result-actions { flex-direction: column; }
  .result-actions button { width: 100%; }
  .app-footer { flex-wrap: wrap; padding-bottom: 12px; text-align: center; }
}

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