:root {
  --bg: #070b16;
  --panel: rgba(16, 22, 42, 0.78);
  --line: rgba(125, 211, 252, 0.18);
  --text: #e8eefc;
  --muted: #93a0c2;
  --cyan: #3ddcff;
  --gold: #ffb020;
  --ok: #3dff9a;
  --bad: #ff5c7a;
  --lp: #e879f9;
  --lr: #fb923c;
  --lm: #facc15;
  --li: #4ade80;
  --th: #94a3b8;
  --ri: #38bdf8;
  --rm: #818cf8;
  --rr: #f472b6;
  --rp: #c084fc;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

#stars {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  height: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 24px 16px;
}

.screen { display: none; height: 100%; position: relative; }
.screen.active { display: flex; flex-direction: column; gap: 16px; }
[hidden] { display: none !important; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(180deg, #1c2a4d, #10182d);
  border: 1px solid var(--line);
  box-shadow: 0 0 18px rgba(61, 220, 255, 0.25);
}
.brand strong { display: block; font-size: 18px; }
.brand small { color: var(--cyan); letter-spacing: 0.18em; font-size: 10px; }

.top-stats { display: flex; align-items: center; gap: 10px; color: var(--gold); font-weight: 700; }
.top-stats span {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 176, 32, 0.08);
  border: 1px solid rgba(255, 176, 32, 0.2);
}

.icon-btn, .text-btn, .primary-btn, .ghost-btn, .mode-card, .level-node, .chip {
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.icon-btn {
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
}
.icon-btn.off { opacity: 0.4; }
.text-btn {
  border: 0;
  background: transparent;
  color: var(--cyan);
  padding: 8px 0;
}
.primary-btn, .ghost-btn {
  border-radius: 14px;
  padding: 12px 22px;
  border: 1px solid transparent;
}
.primary-btn {
  background: linear-gradient(180deg, #4ae6ff, #1aa8c8);
  color: #06212a;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(61, 220, 255, 0.28);
}
.ghost-btn {
  background: transparent;
  border-color: var(--line);
}

.hero { display: flex; align-items: center; gap: 28px; }
.mascot {
  flex: 0 0 auto;
  filter: drop-shadow(0 0 16px rgba(61, 220, 255, 0.35));
}
.eyebrow { color: var(--cyan); letter-spacing: 0.12em; margin: 0 0 8px; font-size: 13px; }
.hero h1 { margin: 0; font-size: 40px; line-height: 1.2; letter-spacing: 0.02em; }
.lead { color: var(--muted); max-width: 620px; line-height: 1.7; }

.mode-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.mode-card {
  text-align: left;
  padding: 18px 16px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  min-height: 196px;
  transition: transform .18s ease, border-color .18s ease;
}
.mode-card:hover { transform: translateY(-4px); border-color: rgba(61, 220, 255, 0.5); }
.mode-card.featured { border-color: rgba(255, 176, 32, 0.45); background: linear-gradient(180deg, rgba(255,176,32,0.08), var(--panel)); }
.mode-ico { font-size: 28px; }
.mode-card h2 { margin: 10px 0 6px; font-size: 20px; }
.mode-card p { margin: 0; color: var(--muted); line-height: 1.55; font-size: 13px; }
.mode-card b { display: inline-block; margin-top: 12px; color: var(--gold); font-size: 12px; }
.chinese-card {
  grid-column: span 2;
  min-height: auto;
  display: flex;
  align-items: flex-start;
  gap: 18px;
}
.chinese-card .mode-ico {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: rgba(255, 176, 32, 0.12);
  color: var(--gold);
  font-weight: 900;
}
.chinese-card h2 { margin-top: 0; }
.chinese-card p { max-width: 780px; }

.home-foot { color: var(--muted); font-size: 12px; line-height: 1.6; }
.parent-note { color: #b7c2e0; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.screen-title { margin: 0; font-size: 22px; }
.tutorial-panel { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 24px; }
.steps { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.steps li {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid transparent;
  background: rgba(255,255,255,0.03);
  color: var(--muted);
}
.steps li.on { border-color: rgba(61, 220, 255, 0.4); color: var(--text); background: rgba(61, 220, 255, 0.08); }
.steps b { display: block; margin-bottom: 4px; }
.steps p { margin: 0; line-height: 1.6; }
.tutorial-play { display: flex; flex-direction: column; justify-content: center; gap: 16px; }
.hint-line { margin: 0; color: var(--muted); }
.hint-line kbd {
  display: inline-grid; place-items: center;
  min-width: 28px; height: 28px; padding: 0 6px;
  border-radius: 6px;
  background: #11182b;
  border: 1px solid var(--line);
  font-family: Orbitron, sans-serif;
}
.tut-targets { display: flex; gap: 16px; }
.tut-key {
  width: 88px; height: 88px;
  display: grid; place-items: center;
  border-radius: 18px;
  font: 800 36px Orbitron, sans-serif;
  background: #10182d;
  border: 2px solid var(--line);
}
.tut-key.done { border-color: var(--ok); color: var(--ok); box-shadow: 0 0 20px rgba(61, 255, 154, 0.25); }
.tut-key.now { border-color: var(--cyan); box-shadow: 0 0 22px rgba(61, 220, 255, 0.35); }
.tut-status { margin: 0; color: var(--gold); font-weight: 700; }

.map-intro { margin: 0; color: var(--muted); }
.map-heading {
  grid-column: 1 / -1;
  margin: 10px 0 0;
  font-size: 15px;
  letter-spacing: 0.08em;
  color: var(--cyan);
}
.word-meaning {
  margin: 0;
  color: var(--gold);
  font-size: 20px;
  letter-spacing: 0.12em;
}
.level-map {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  overflow: auto;
  padding-bottom: 8px;
}
.level-node {
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 14px 12px;
  text-align: left;
  min-height: 118px;
}
.level-node:disabled { opacity: 0.36; cursor: not-allowed; filter: grayscale(0.35); }
.level-node .lv { color: var(--cyan); font-size: 12px; letter-spacing: 0.08em; }
.level-node h3 { margin: 6px 0 4px; font-size: 16px; }
.level-node p { margin: 0; color: var(--muted); font-size: 12px; }
.level-node .stars { color: var(--gold); margin-top: 8px; letter-spacing: 2px; }

.setup-panel { max-width: 640px; margin: 20px auto 0; display: grid; gap: 16px; }
.setup-panel p { margin: 0; color: var(--muted); line-height: 1.6; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  padding: 8px 14px;
}
.chip.on { border-color: var(--cyan); background: rgba(61, 220, 255, 0.12); color: var(--cyan); }
.check { color: var(--muted); display: flex; align-items: center; gap: 8px; }

.play-top { align-items: flex-start; }
.play-meta p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.hud { display: flex; gap: 8px; }
.hud span {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
  font-size: 13px;
}

.stage { position: relative; flex: 1; min-height: 180px; }
.target-area, .sky { height: 100%; }
.target-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.finger-tip {
  margin: 0;
  color: var(--cyan);
  letter-spacing: 0.16em;
  font-size: 14px;
}
.big-letter {
  font: 800 108px/1 Orbitron, "Arial Black", Impact, ui-sans-serif, sans-serif;
  letter-spacing: 0.04em;
  text-shadow: 0 0 28px rgba(61, 220, 255, 0.35);
  min-height: 108px;
}
.big-letter.ok { color: var(--ok); }
.big-letter.bad { color: var(--bad); animation: shake .28s ease; }
.word-line { margin: 0; font-size: 28px; letter-spacing: 0.18em; }
.word-line .done { color: var(--ok); }
.word-line .now { color: var(--cyan); border-bottom: 3px solid var(--cyan); }
.meter {
  width: 220px; height: 6px;
  border-radius: 99px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}
.meter i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--gold), var(--bad));
}

.sky { position: relative; overflow: hidden; border-radius: 18px; border: 1px dashed var(--line); }
.meteor {
  position: absolute;
  width: 56px; height: 56px;
  display: grid; place-items: center;
  border-radius: 16px;
  font: 800 24px ui-monospace, Menlo, Consolas, "Courier New", monospace;
  background: #121a31;
  border: 2px solid var(--cyan);
  box-shadow: 0 0 16px rgba(61, 220, 255, 0.25);
  transform: translate(-50%, 0);
}

.ready-mask {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  place-items: center;
  text-align: center;
  background: rgba(7, 11, 22, 0.72);
  border: 1px solid var(--line);
  border-radius: 20px;
  backdrop-filter: blur(8px);
}
.ready-mask.show { display: grid; }
.ready-mask p { color: var(--muted); }
.ready-mask b { font-size: 28px; color: var(--gold); }

.kb-wrap { display: grid; gap: 6px; justify-content: center; user-select: none; }
.kb-row { display: flex; gap: 6px; justify-content: center; }
.key {
  --c: #64748b;
  min-width: 46px; height: 44px;
  padding: 0 6px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: color-mix(in srgb, var(--c) 16%, #0e1426);
  border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  color: #f4f7ff;
  font: 700 13px ui-monospace, Menlo, Consolas, "Courier New", monospace;
  transition: transform .08s ease, box-shadow .12s ease, background .12s ease;
}
.key.wide { min-width: 74px; }
.key.space { min-width: 280px; }
.key.dim {
  opacity: 1;
  background: #12182b;
  border-color: #2a3450;
  color: #9aa6c2;
}
.key.target {
  transform: translateY(-2px);
  background: color-mix(in srgb, var(--c) 40%, #10203a);
  box-shadow: 0 0 0 2px var(--c), 0 0 22px color-mix(in srgb, var(--c) 55%, transparent);
}
.key.hit { border-color: var(--ok); box-shadow: 0 0 16px rgba(61, 255, 154, 0.35); }
.key.miss { border-color: var(--bad); box-shadow: 0 0 16px rgba(255, 92, 122, 0.35); }
.key.home::after {
  content: "";
  width: 10px; height: 2px;
  margin-top: 2px;
  background: currentColor;
  opacity: 0.7;
  border-radius: 2px;
}

.coach {
  margin: 0;
  text-align: center;
  color: var(--muted);
  min-height: 24px;
}

.cn-area {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 4px 0;
}
.cn-meta { margin: 0; color: var(--gold); font-size: 13px; letter-spacing: 0.08em; }
.passage {
  font-size: 28px;
  line-height: 1.75;
  letter-spacing: 0.04em;
  padding: 12px 4px;
  max-height: 34vh;
  overflow: auto;
}
.passage span { border-radius: 4px; }
.passage .ok { color: var(--ok); }
.passage .bad { color: var(--bad); background: rgba(255, 92, 122, 0.14); }
.passage .now { box-shadow: inset 0 -3px 0 var(--cyan); }
#cn-input {
  width: 100%;
  resize: none;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #0d1426;
  color: var(--text);
  font: 500 20px/1.6 "PingFang SC", "Microsoft YaHei", sans-serif;
  padding: 14px 16px;
}
#cn-input:focus { outline: 2px solid rgba(61, 220, 255, 0.45); }
.cn-actions { display: flex; align-items: center; gap: 14px; }
.cn-actions p { margin: 0; color: var(--muted); font-size: 13px; }

.result-panel { max-width: 520px; margin: auto; text-align: center; }
.result-kicker { color: var(--cyan); letter-spacing: 0.14em; }
.result-panel h1 { margin: 0 0 8px; font-size: 36px; }
.stars-big { font-size: 36px; color: var(--gold); letter-spacing: 6px; }
.record-banner {
  margin: 10px 0 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 176, 32, 0.14);
  color: var(--gold);
  font-weight: 800;
}
.record-banner.near {
  background: rgba(61, 220, 255, 0.12);
  color: var(--cyan);
}
.best-line { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.level-node .best { color: var(--gold); font-size: 12px; margin-top: 6px; }
.stat-list {
  list-style: none; padding: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin: 20px 0;
}
.stat-list li {
  background: rgba(255,255,255,0.04);
  border-radius: 12px;
  padding: 10px;
}
.stat-list span { display: block; color: var(--muted); font-size: 12px; }
.stat-list b { font-size: 22px; }
.result-msg { color: var(--muted); min-height: 24px; }
.result-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

@keyframes shake {
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

@media (max-width: 980px) {
  body { overflow: auto; }
  #app { height: auto; min-height: 100%; }
  .mode-grid, .level-map, .tutorial-panel { grid-template-columns: 1fr 1fr; }
  .chinese-card { grid-column: 1 / -1; }
  .hero h1 { font-size: 28px; }
  .big-letter { font-size: 80px; }
  .passage { font-size: 22px; }
  .key { min-width: 34px; height: 36px; font-size: 11px; }
  .key.space { min-width: 180px; }
}

@media (max-width: 720px) {
  .mode-grid, .level-map, .tutorial-panel, .hero { grid-template-columns: 1fr; display: block; }
  .home-foot { padding-bottom: 24px; }
}
