:root {
  --ink: #3b2a5c;
  --ink-soft: #7a6a99;
  --card: rgba(255, 255, 255, 0.88);
  --pink: #ff8fb8;
  --purple: #a78bfa;
  --sky: #38bdf8;
  --gold: #fbbf24;
  --mint: #6ee7b7;
  --accent: var(--purple);
  --radius: 26px;
  --shadow: 0 10px 30px rgba(120, 80, 180, 0.18), 0 2px 6px rgba(120, 80, 180, 0.08);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; min-height: 100%; }

body {
  color: var(--ink);
  background: linear-gradient(160deg, #fde4f2 0%, #e9ddff 45%, #d6efff 100%) fixed;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-user-select: none;
  user-select: none;
}

/* ---------- floating sparkles background ---------- */
#sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
#sky span {
  position: absolute; bottom: -40px; font-size: 18px; opacity: 0.0;
  animation: floatUp linear infinite;
}
@keyframes floatUp {
  0% { transform: translateY(0) rotate(0deg); opacity: 0; }
  10% { opacity: 0.7; }
  90% { opacity: 0.6; }
  100% { transform: translateY(-110vh) rotate(360deg); opacity: 0; }
}

/* ---------- layout ---------- */
#app {
  position: relative; z-index: 1;
  max-width: 1100px; margin: 0 auto; padding: 18px 18px 40px;
  min-height: 100vh; display: flex; flex-direction: column;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 14px; min-height: 52px;
}
.brand { font-weight: 800; font-size: 20px; letter-spacing: 0.3px; display: flex; align-items: center; gap: 8px; }
.brand .logo { font-size: 28px; animation: bob 3s ease-in-out infinite; }
.star-count {
  background: var(--card); border-radius: 999px; padding: 8px 16px; font-weight: 800; font-size: 20px;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 6px;
}
.star-count .s { display: inline-block; }
.star-count.pop .s { animation: pop 0.5s ease; }

.screen { flex: 1; display: flex; flex-direction: column; animation: fadeIn 0.35s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.6) rotate(-15deg); } 100% { transform: scale(1); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 26px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}

h1, h2, h3 { margin: 0 0 10px; line-height: 1.2; }
h1 { font-size: clamp(30px, 5vw, 48px); }
h2 { font-size: clamp(24px, 3.6vw, 34px); }
p { line-height: 1.5; }

/* ---------- buttons ---------- */
.btn {
  appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 800;
  font-size: 22px; color: white; padding: 16px 34px; border-radius: 999px;
  background: linear-gradient(135deg, #ff8fb8, #a78bfa);
  box-shadow: 0 8px 0 #7c5cc4, 0 12px 24px rgba(124, 92, 196, 0.35);
  transition: transform 0.1s ease, box-shadow 0.1s ease, opacity 0.2s;
}
.btn:active { transform: translateY(6px); box-shadow: 0 2px 0 #7c5cc4, 0 4px 10px rgba(124, 92, 196, 0.3); }
.btn[disabled] { opacity: 0.35; cursor: default; transform: none; }
.btn.big { font-size: 28px; padding: 20px 46px; }
.btn.ghost {
  background: white; color: var(--ink); box-shadow: 0 6px 0 #d9cdf5, 0 10px 18px rgba(124, 92, 196, 0.15);
}
.btn.ghost:active { box-shadow: 0 1px 0 #d9cdf5; }

.speak {
  appearance: none; border: 0; cursor: pointer; font-size: 26px; width: 56px; height: 56px; border-radius: 50%;
  background: white; box-shadow: var(--shadow); flex: none;
}
.speak:active { transform: scale(0.92); }
.speak.talking { animation: wiggle 0.4s ease infinite; background: #fff4c2; }

/* ---------- welcome ---------- */
.welcome { align-items: center; justify-content: center; text-align: center; gap: 22px; }
.mascot { font-size: 110px; animation: bob 2.6s ease-in-out infinite; filter: drop-shadow(0 10px 14px rgba(124, 92, 196, 0.3)); }
.bubble {
  position: relative; background: white; border-radius: 26px; padding: 18px 26px; font-size: 22px; max-width: 620px;
  box-shadow: var(--shadow);
}
.bubble::before {
  content: ""; position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  border: 14px solid transparent; border-top: 0; border-bottom-color: white;
}
.lands-preview { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.lands-preview div {
  background: var(--card); border-radius: 20px; padding: 12px 16px; font-weight: 700; box-shadow: var(--shadow);
  font-size: 18px;
}
.lands-preview b { font-size: 30px; display: block; }

/* ---------- map ---------- */
.map { align-items: center; gap: 24px; }
.map h2 { text-align: center; }
.path { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; width: 100%; }
.land {
  border: 0; font: inherit; color: var(--ink); text-align: center; cursor: pointer;
  border-radius: 30px; padding: 24px 14px; background: var(--card); box-shadow: var(--shadow);
  position: relative; transition: transform 0.2s;
}
.land .icon { font-size: 70px; display: block; }
.land .name { font-weight: 800; font-size: 22px; margin-top: 6px; display: block; }
.land .sub { color: var(--ink-soft); font-size: 16px; margin-top: 4px; display: block; }
.land.locked { opacity: 0.5; cursor: default; filter: grayscale(0.6); }
.land.done::after {
  content: "✓"; position: absolute; top: 10px; right: 14px; width: 36px; height: 36px; border-radius: 50%;
  background: var(--mint); color: white; font-weight: 900; font-size: 22px; line-height: 36px;
}
.land.current { outline: 4px solid var(--accent); animation: bob 2s ease-in-out infinite; }

/* ---------- intro ---------- */
.intro { align-items: center; justify-content: center; text-align: center; gap: 20px; }
.intro .icon { font-size: 120px; animation: bob 2.4s ease-in-out infinite; }
.intro .row { display: flex; gap: 14px; align-items: center; justify-content: center; }

/* ---------- question ---------- */
.progress { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 14px; }
.progress i {
  width: 18px; height: 18px; border-radius: 50%; background: rgba(255, 255, 255, 0.7); display: inline-block;
  box-shadow: inset 0 0 0 2px rgba(124, 92, 196, 0.15);
}
.progress i.done { background: var(--accent); }
.progress i.now { background: white; box-shadow: 0 0 0 3px var(--accent); }

.q-layout { display: grid; gap: 20px; grid-template-columns: 1fr; flex: 1; align-items: start; }
.q-layout.with-passage { grid-template-columns: 1.15fr 1fr; }
@media (max-width: 820px) { .q-layout.with-passage { grid-template-columns: 1fr; } }

.passage { max-height: calc(100vh - 170px); overflow-y: auto; -webkit-user-select: text; user-select: text; }
.passage h3 { font-size: 26px; }
.passage .tag {
  display: inline-block; background: var(--accent); color: white; font-weight: 800; font-size: 14px;
  padding: 4px 12px; border-radius: 999px; margin-bottom: 8px;
}
.passage p { font-size: 21px; line-height: 1.7; margin: 0 0 14px; }
@media (max-width: 820px) { .passage { max-height: 42vh; } }

.prompt { font-size: clamp(22px, 2.8vw, 28px); font-weight: 700; margin: 0 0 18px; line-height: 1.4; }
.options { display: grid; gap: 14px; }
.opt {
  appearance: none; border: 3px solid transparent; font: inherit; color: var(--ink); text-align: left; cursor: pointer;
  display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: 22px;
  background: white; font-size: 22px; font-weight: 600; box-shadow: 0 4px 0 rgba(124, 92, 196, 0.15);
  transition: transform 0.12s, border-color 0.12s, background 0.12s;
}
.opt .bead {
  flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  color: white; font-weight: 900; font-size: 20px;
}
.opt:nth-child(1) .bead { background: #ff8fb8; }
.opt:nth-child(2) .bead { background: #a78bfa; }
.opt:nth-child(3) .bead { background: #38bdf8; }
.opt:nth-child(4) .bead { background: #fbbf24; }
.opt:active { transform: scale(0.98); }
.opt.picked { border-color: var(--accent); background: #f6f0ff; transform: scale(1.02); }
.opt.picked .bead::after { content: ""; }

.q-foot { display: flex; justify-content: flex-end; margin-top: 22px; gap: 12px; }

/* ---------- spelling ---------- */
.spell { text-align: center; }
.spell .listen { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin: 6px 0 20px; }
.spell .listen .btn { font-size: 20px; padding: 14px 24px; }
.slots { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; min-height: 74px; margin-bottom: 22px; }
.slot {
  width: 56px; height: 66px; border-radius: 16px; background: white; display: grid; place-items: center;
  font-size: 38px; font-weight: 800; box-shadow: inset 0 -4px 0 rgba(124, 92, 196, 0.15);
}
.slot.empty { background: rgba(255, 255, 255, 0.5); }
.tiles { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 18px; }
.tile {
  appearance: none; border: 0; cursor: pointer; font: inherit; width: 72px; height: 72px; position: relative;
  background: none; color: #6b4600; font-size: 30px; font-weight: 900;
}
.tile::before {
  content: "★"; position: absolute; inset: 0; font-size: 84px; line-height: 72px; color: var(--gold);
  text-shadow: 0 4px 0 #e59e0b; z-index: -1; transition: transform 0.15s;
}
.tile span { position: relative; top: 4px; }
.tile:active::before { transform: scale(0.9); }
.tile.used { opacity: 0.18; pointer-events: none; }
.spell-tools { display: flex; gap: 12px; justify-content: center; }

/* ---------- celebrate ---------- */
.celebrate { align-items: center; justify-content: center; text-align: center; gap: 18px; }
.celebrate .icon { font-size: 120px; animation: pop 1s ease; }
.celebrate .stars { font-size: 34px; letter-spacing: 4px; }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.confetti i {
  position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

.flystar { position: fixed; z-index: 6; font-size: 40px; pointer-events: none; transition: all 0.8s cubic-bezier(.5,-0.4,.5,1); }

/* ---------- parent gate / misc ---------- */
.hold {
  position: relative; overflow: hidden; touch-action: none; -webkit-touch-callout: none;
}
.hold .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(255, 255, 255, 0.35); }
.note { color: var(--ink-soft); font-size: 15px; }
.center { text-align: center; }
.hidden { display: none !important; }

/* ---------- report ---------- */
.report { -webkit-user-select: text; user-select: text; gap: 18px; }
.report .card { padding: 22px; }
.report h2 { font-size: 26px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.kpi { background: white; border-radius: 20px; padding: 16px; box-shadow: var(--shadow); }
.kpi .v { font-size: 34px; font-weight: 900; }
.kpi .l { color: var(--ink-soft); font-size: 15px; }
.bar { height: 14px; border-radius: 999px; background: #eee6ff; overflow: hidden; margin-top: 8px; }
.bar b { display: block; height: 100%; background: linear-gradient(90deg, #ff8fb8, #a78bfa); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid #eee6ff; vertical-align: top; }
th { color: var(--ink-soft); font-weight: 700; }
td.ok { color: #059669; font-weight: 800; }
td.bad { color: #e11d48; font-weight: 800; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; background: #f1ebff; }
.report .zh { font-size: 16px; line-height: 1.7; }
.report ul { margin: 6px 0; padding-left: 22px; line-height: 1.7; }
