:root {
  --ink: #2c2650;
  --muted: #6c6790;
  --paper: #fffaf3;
  --card: #ffffff;
  --line: rgba(44, 38, 80, 0.1);
  --math: #ff8a3d;
  --cn: #ff5d7a;
  --en: #2bb7ff;
  --ot: #8a6bff;
  --good: #19c37d;
  --bad: #ff5d5d;
  --sun: #ffd36b;
  --shadow: 0 12px 30px rgba(80, 50, 120, 0.12);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Trebuchet MS", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 211, 107, 0.55), transparent 28%),
    radial-gradient(circle at 90% 0%, rgba(43, 183, 255, 0.28), transparent 26%),
    radial-gradient(circle at 80% 100%, rgba(138, 107, 255, 0.18), transparent 30%),
    linear-gradient(180deg, #eef7ff 0%, #fff6e8 100%);
  min-height: 100dvh;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
a { color: inherit; text-decoration: none; }
button, .choice, .planet, .game-card, .grade-btn {
  font: inherit;
  cursor: pointer;
}
.wrap {
  width: min(1080px, calc(100% - 24px));
  margin: 0 auto;
  padding: 18px 0 32px;
}
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 22px;
}
.mascot {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: linear-gradient(180deg, #fff 0%, #ffe38a 100%);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  font-size: 26px;
}
.sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.stars {
  background: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  box-shadow: var(--shadow);
  font-weight: 800;
}
.icon-btn, .grade-btn, .nav-btn, .big-btn, .choice {
  border: 3px solid #2c2650;
  background: #fff;
  border-radius: 16px;
  box-shadow: 3px 3px 0 #2c2650;
}
.icon-btn { padding: 8px 12px; font-weight: 800; }
.grade-bar, .game-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 16px;
}
.grade-btn { padding: 8px 12px; background: #fff; }
.grade-btn.on, .nav-btn.on {
  background: var(--sun);
}
.hero {
  background: rgba(255,255,255,0.72);
  border: 3px solid #2c2650;
  border-radius: 28px;
  padding: 28px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.hero h1 { margin: 0 0 8px; font-size: 36px; }
.hero p { margin: 0; color: var(--muted); font-size: 16px; line-height: 1.7; }
.planets, .games {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.planet, .game-card {
  display: block;
  border: 3px solid #2c2650;
  border-radius: 28px;
  padding: 22px;
  background: #fff;
  box-shadow: 6px 6px 0 #2c2650;
  min-height: 150px;
  transition: transform 0.15s ease;
}
.planet:hover, .game-card:hover, .big-btn:hover, .choice:hover { transform: translate(-2px, -2px); }
.planet.math { background: linear-gradient(180deg, #ffe4c8, #fff); }
.planet.cn { background: linear-gradient(180deg, #ffd5de, #fff); }
.planet.en { background: linear-gradient(180deg, #d6f1ff, #fff); }
.planet.ot { background: linear-gradient(180deg, #e6ddff, #fff); }
.planet .emoji, .game-card .emoji { font-size: 34px; }
.planet h2, .game-card h2 { margin: 8px 0 6px; font-size: 24px; }
.planet p, .game-card p { margin: 0; color: var(--muted); }
.stage {
  background: #fff;
  border: 3px solid #2c2650;
  border-radius: 28px;
  min-height: 420px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.progress {
  height: 12px;
  background: #efeaf8;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 14px;
}
.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #8a6bff, #2bb7ff);
  width: 0;
}
.hud-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 10px;
}
.prompt {
  font-size: 34px;
  font-weight: 800;
  text-align: center;
  margin: 18px 0;
  line-height: 1.4;
  word-break: break-word;
}
.hint { text-align: center; color: var(--muted); margin-bottom: 12px; }
.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.choice {
  padding: 16px 12px;
  font-size: 22px;
  font-weight: 800;
  background: #fffdf7;
}
.choice.good { background: #c9f7df; }
.choice.bad { background: #ffd5d5; }
.big-btn {
  padding: 12px 18px;
  font-weight: 800;
  background: var(--sun);
}
.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 16px; }
.summary { text-align: center; padding: 18px 8px; }
.summary h2 { font-size: 32px; margin: 0 0 8px; }
.cards-grid, .simon-grid, .sudoku, .maze {
  display: grid;
  gap: 8px;
  margin: 12px auto;
  width: min(100%, 460px);
}
.cards-grid.g4 { grid-template-columns: repeat(4, 1fr); }
.cards-grid.g6 { grid-template-columns: repeat(4, 1fr); }
.mem {
  aspect-ratio: 1;
  border: 3px solid #2c2650;
  border-radius: 16px;
  background: #7aa7ff;
  color: #7aa7ff;
  font-size: 28px;
  box-shadow: 3px 3px 0 #2c2650;
  display: grid;
  place-items: center;
}
.mem.open, .mem.done { background: #fff; color: var(--ink); }
.mem.done { background: #c9f7df; }
.simon-grid { grid-template-columns: 1fr 1fr; width: min(100%, 360px); }
.simon-pad {
  height: 120px;
  border-radius: 24px;
  border: 3px solid #2c2650;
  box-shadow: 3px 3px 0 #2c2650;
  opacity: 0.72;
}
.simon-pad.lit { opacity: 1; filter: brightness(1.2); }
.sudoku { grid-template-columns: repeat(4, 1fr); width: min(100%, 360px); }
.sudoku input, .cell-btn {
  aspect-ratio: 1;
  border: 3px solid #2c2650;
  border-radius: 12px;
  text-align: center;
  font-size: 24px;
  font-weight: 800;
  width: 100%;
}
.maze { grid-template-columns: repeat(9, 1fr); width: min(100%, 420px); }
.mz {
  aspect-ratio: 1;
  border-radius: 6px;
  background: #efeaf8;
}
.mz.wall { background: #2c2650; }
.mz.player { background: #ffd36b; }
.mz.goal { background: #19c37d; }
.spell-box {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 12px 0 18px;
  flex-wrap: wrap;
}
.letter {
  min-width: 46px;
  height: 50px;
  border: 3px dashed #2c2650;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 800;
  background: #fff;
}
.footer {
  text-align: center;
  color: var(--muted);
  margin-top: 18px;
  font-size: 13px;
}
@media (max-width: 720px) {
  .planets, .games, .choices { grid-template-columns: 1fr; }
  .hero h1 { font-size: 28px; }
  .prompt { font-size: 26px; }
  .top { align-items: flex-start; flex-direction: column; }
}
.nav-btn { padding: 8px 14px; font-weight: 800; background: #fff; }

/* ============================================================ HUD 附加信息 */

.hud-extra { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip {
  position: relative;
  overflow: hidden;
  background: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  box-shadow: var(--shadow);
  font-weight: 800;
  font-size: 14px;
  border: 0;
  color: var(--ink);
  line-height: 1.2;
  white-space: nowrap;
}
.chip-level i {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, #8a6bff, #2bb7ff);
  transition: width 0.35s ease;
}
.chip-streak { background: linear-gradient(180deg, #fff0d6, #fff); }
.chip-pet { cursor: pointer; font-size: 17px; }
.chip-pet:hover { transform: translateY(-1px); }

/* ============================================================ 首页游戏大厅 */

.hero-daily {
  margin-top: 16px;
  background: rgba(255, 255, 255, 0.85);
  border: 2px dashed rgba(44, 38, 80, 0.25);
  border-radius: 18px;
  padding: 12px 14px;
}
.hero-daily-row { display: flex; align-items: center; gap: 10px; }
.hero-daily-label { font-weight: 800; font-size: 14px; white-space: nowrap; }
.hero-daily-bar {
  flex: 1;
  height: 10px;
  background: #efeaf8;
  border-radius: 999px;
  overflow: hidden;
  min-width: 60px;
}
.hero-daily-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #19c37d, #7ee2b8);
  transition: width 0.4s ease;
}
.hero-daily-sub { color: var(--muted); font-size: 13px; margin-top: 8px; line-height: 1.6; }

.section-title {
  font-size: 19px;
  font-weight: 800;
  margin: 26px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::before {
  content: "";
  width: 6px;
  height: 20px;
  border-radius: 999px;
  background: linear-gradient(180deg, #8a6bff, #2bb7ff);
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 14px;
  margin: 0 0 18px;
}
.dash-card {
  background: #fff;
  border: 3px solid #2c2650;
  border-radius: 24px;
  padding: 16px;
  box-shadow: 6px 6px 0 #2c2650;
}
.dash-card.wide { grid-column: 1 / -1; }
.dash-head {
  font-weight: 800;
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.dash-count { color: var(--ink); }
.dash-level { font-size: 34px; font-weight: 900; line-height: 1.1; margin-bottom: 8px; }
.dash-sub { color: var(--muted); font-size: 13px; line-height: 1.6; margin-top: 8px; }
.dash-sub.done-tip { color: var(--good); font-weight: 800; }
.pet-card { background: linear-gradient(180deg, #fff3dd, #fff); }
.dash-pet { font-size: 46px; line-height: 1; margin: 4px 0 6px; }

.bar { height: 10px; background: #efeaf8; border-radius: 999px; overflow: hidden; }
.bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #8a6bff, #2bb7ff);
  transition: width 0.4s ease;
}
.quest { margin-bottom: 10px; }
.quest-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
}
.quest.done .quest-top { color: var(--good); }
.quest.done .bar > span { background: linear-gradient(90deg, #19c37d, #7ee2b8); }

.mini-btn {
  margin-top: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 3px solid #2c2650;
  border-radius: 14px;
  background: var(--sun);
  font-weight: 800;
  box-shadow: 3px 3px 0 #2c2650;
  cursor: pointer;
}
.mini-btn:disabled { background: #f1eef9; color: var(--muted); box-shadow: 3px 3px 0 #c9c3dd; cursor: not-allowed; }

.badge-wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 10px;
  margin-top: 6px;
}
.badge {
  text-align: center;
  padding: 10px 6px;
  border-radius: 16px;
  background: #f7f4ff;
  border: 2px dashed rgba(44, 38, 80, 0.2);
}
.badge.owned { background: linear-gradient(180deg, #fff6d9, #fff); border: 2px solid var(--sun); }
.badge-icon { font-size: 26px; line-height: 1.2; filter: grayscale(1); opacity: 0.45; }
.badge.owned .badge-icon { filter: none; opacity: 1; }
.badge-name { font-size: 11px; font-weight: 800; margin-top: 4px; color: var(--muted); }
.badge.owned .badge-name { color: var(--ink); }

/* ============================================================ 答题界面增强 */

.xp-line {
  height: 5px;
  background: #efeaf8;
  border-radius: 999px;
  overflow: hidden;
  margin: -8px 0 12px;
}
.xp-line > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #ffd36b, #ff8a3d);
  transition: width 0.4s ease;
}
.hud-combo { color: var(--muted); }
.hud-combo.hot { color: #ff5d3d; animation: comboPulse 0.7s ease-in-out infinite; }
@keyframes comboPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

.choice { min-height: 58px; }
.choice:disabled { cursor: default; opacity: 0.85; }
.choice.bad { opacity: 0.6; }

.retry-tip {
  display: none;
  text-align: center;
  font-weight: 800;
  margin-top: 14px;
  padding: 12px;
  border-radius: 16px;
  line-height: 1.6;
}
.retry-tip.on { display: block; background: #fff5e0; color: #a05a00; animation: tipIn 0.25s ease; }
.retry-tip.on.bad { background: #ffe9e9; color: #b02020; }
.retry-hint { font-weight: 600; font-size: 14px; opacity: 0.85; }
@keyframes tipIn { from { transform: translateY(-6px); opacity: 0; } }

.shake { animation: shakeX 0.42s ease; }
@keyframes shakeX {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}

/* ============================================================ 结算页 */

.sum-emoji { font-size: 54px; line-height: 1; margin-bottom: 6px; animation: popIn 0.4s ease; }
.sum-stars { display: flex; justify-content: center; gap: 10px; margin: 14px 0; }
.sum-star { font-size: 40px; color: #ddd7ea; }
.sum-star.on { color: var(--sun); text-shadow: 0 3px 0 #e0a800; }
.sum-star.pop { animation: starPop 0.5s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes starPop {
  0% { transform: scale(0.2) rotate(-40deg); opacity: 0; }
  70% { transform: scale(1.35) rotate(8deg); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes popIn { from { transform: scale(0.5); opacity: 0; } }

.sum-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 16px 0;
}
.sum-grid > div {
  background: #f7f4ff;
  border-radius: 16px;
  padding: 12px 6px;
}
.sum-grid b { display: block; font-size: 22px; }
.sum-grid span { color: var(--muted); font-size: 12px; }
.record-tip {
  font-weight: 800;
  color: #b06a00;
  background: #fff5d6;
  border-radius: 999px;
  padding: 8px 14px;
  display: inline-block;
  margin-bottom: 4px;
}
.big-btn.ghost { background: #fff; }

/* ============================================================ 星宠 */

.pet-big { font-size: 72px; text-align: center; line-height: 1; animation: popIn 0.4s ease; }
.pet-name { text-align: center; font-weight: 800; margin: 10px 0 12px; }
.pet-tip { color: var(--muted); font-size: 14px; line-height: 1.7; text-align: center; margin: 10px 0 0; }

/* ============================================================ 弹窗与提示 */

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(30, 24, 60, 0.5);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 9000;
  animation: fadeIn 0.2s ease;
}
.modal-card {
  background: #fff;
  border: 3px solid #2c2650;
  border-radius: 26px;
  box-shadow: 8px 8px 0 #2c2650;
  padding: 22px;
  width: min(420px, 100%);
  max-height: 86dvh;
  overflow: auto;
  animation: popIn 0.28s cubic-bezier(0.2, 1.5, 0.4, 1);
}
.modal-icon { font-size: 46px; text-align: center; line-height: 1; }
.modal-card h3 { text-align: center; margin: 10px 0 14px; font-size: 22px; }
.modal-body { color: var(--ink); }
@keyframes fadeIn { from { opacity: 0; } }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 24px);
  background: #2c2650;
  color: #fff;
  font-weight: 800;
  padding: 12px 20px;
  border-radius: 999px;
  box-shadow: 0 10px 26px rgba(44, 38, 80, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 9500;
  max-width: calc(100% - 32px);
  text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.warn { background: #a8541f; }

/* ============================================================ 粒子特效 */

.fx-layer { position: fixed; z-index: 9800; pointer-events: none; }
.fx-bit {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  animation: fxFly 0.9s cubic-bezier(0.2, 0.7, 0.4, 1) forwards;
}
@keyframes fxFly {
  to {
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.35) rotate(260deg);
    opacity: 0;
  }
}
.fx-float {
  position: fixed;
  transform: translate(-50%, -50%);
  font-weight: 900;
  font-size: 22px;
  color: var(--good);
  text-shadow: 0 2px 0 #fff, 0 0 12px #fff;
  pointer-events: none;
  z-index: 9850;
  white-space: nowrap;
  animation: fxFloat 1s ease-out forwards;
}
.fx-float.hot { color: #ff5d3d; font-size: 27px; }
.fx-float.calm { color: #2bb7ff; font-size: 19px; }
@keyframes fxFloat {
  to { transform: translate(-50%, -140%) scale(1.25); opacity: 0; }
}

/* ============================================================ 冒险模式 */

.mission-intro { text-align: center; padding: 12px 4px; }
.pet-large { font-size: 76px; line-height: 1; animation: floaty 2.4s ease-in-out infinite; }
.mission-intro h2 { font-size: 28px; margin: 12px 0 10px; }
.story {
  color: var(--muted);
  line-height: 1.85;
  max-width: 560px;
  margin: 0 auto 18px;
  background: #f7f4ff;
  border-radius: 18px;
  padding: 14px 16px;
}
@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-9px); }
}
.bridge { display: flex; justify-content: center; gap: 6px; margin: 12px 0; flex-wrap: wrap; }
.bridge-step {
  width: 30px;
  height: 12px;
  border-radius: 999px;
  background: #e4ddf5;
}
.bridge-step.on { background: linear-gradient(90deg, #ffd36b, #ff8a3d); }
.energy-row { display: flex; justify-content: center; gap: 8px; font-size: 24px; margin: 6px 0 12px; }
.energy-row .lost { filter: grayscale(1); opacity: 0.35; }
.nav-btn.adv-btn { background: linear-gradient(180deg, #ffe4c8, #fff); }
.nav-btn.adv-btn.on { background: var(--sun); }
.adventure-card {
  background: linear-gradient(180deg, #fff3cf, #fff);
}
.adventure-card .emoji {
  font-size: 38px;
}
.collection-block { margin-bottom: 18px; }
.collection-block:last-of-type { margin-bottom: 0; }

/* ============================================================ 移动端与触屏 */

@media (max-width: 720px) {
  .planets, .games, .choices { grid-template-columns: 1fr; }
  .dash-grid { grid-template-columns: 1fr; }
  .sum-grid { grid-template-columns: repeat(2, 1fr); }
  .hero h1 { font-size: 28px; }
  .prompt { font-size: 26px; }
  .top { align-items: flex-start; flex-direction: column; }
  .tools { width: 100%; justify-content: flex-start; }
  .hud-extra { order: 3; width: 100%; }
  .stage { padding: 14px; border-radius: 22px; }
  .sum-star { font-size: 32px; }
}

/* 横屏时压缩纵向空间，保证题目和选项都在首屏 */
@media (orientation: landscape) and (max-height: 520px) {
  .wrap { padding-top: 8px; }
  .top { margin-bottom: 8px; }
  .hero, .dash-grid { display: none; }
  .stage { min-height: 0; padding: 12px; }
  .prompt { font-size: 22px; margin: 8px 0; }
  .choice { min-height: 46px; padding: 10px; font-size: 18px; }
  .choices { grid-template-columns: repeat(4, 1fr); }
  .pet-large { font-size: 48px; }
}

/* 触屏设备不依赖 hover */
@media (hover: none) {
  .planet:hover, .game-card:hover, .big-btn:hover, .choice:hover { transform: none; }
  .choice:active, .big-btn:active, .mini-btn:active, .icon-btn:active, .grade-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 #2c2650;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fx-bit, .fx-float, .shake, .sum-star.pop, .hud-combo.hot, .pet-large, .sum-emoji, .modal-card {
    animation: none !important;
  }
}
