/* ============ 全局与防误触 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  height: 100%;
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  background: linear-gradient(160deg, #fff9ef 0%, #f0f9ff 55%, #eef7ff 100%);
  color: #3a4a5a;
  display: flex;
  flex-direction: column;
}
button { font-family: inherit; }
svg { pointer-events: none; }

/* ============ 顶栏 ============ */
#topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 2vmin;
  padding: 1vmin 2vmin;
  background: linear-gradient(90deg, #6ec6f2, #5bc0eb);
  color: #fff;
  height: 8.5vmin;
}
#page-title { flex: 1; text-align: center; font-size: 3.6vmin; font-weight: 800; letter-spacing: .3vmin; }
#back-btn, #home-btn {
  width: 6vmin; height: 6vmin; border-radius: 50%;
  border: none; background: rgba(255,255,255,.35); color: #fff;
  font-size: 4.4vmin; line-height: 1; display: flex; align-items: center; justify-content: center;
}
#view { flex: 1; min-height: 0; }

/* ============ 通用键 ============ */
.key {
  border: 3px solid transparent;
  border-radius: 2vmin;
  font-weight: 800;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .4vmin;
  padding: .6vmin;
  transition: transform .08s;
  background: #fff;
  box-shadow: 0 .4vmin 1vmin rgba(90,120,150,.16);
}
.key:active, .big-btn:active, .opt-btn:active, .nav-btn:active { transform: scale(.92); }
.k-main { font-size: 3.2vmin; line-height: 1.1; }
.k-sub { font-size: 1.5vmin; font-weight: 600; opacity: .75; }

.c-blue   { color: #4a90d9; border-color: #bcd9f7; background: #eaf4ff; }
.c-green  { color: #43a047; border-color: #bfe6c1; background: #ecf9ed; }
.c-yellow { color: #e08a00; border-color: #ffe3a6; background: #fff6e0; }
.c-pink   { color: #e0657f; border-color: #ffc3cf; background: #fff0f3; }
.c-purple { color: #7e68c8; border-color: #d8cdf4; background: #f3efff; }
.c-gray   { color: #6c7a89; border-color: #ccd5dd; background: #f2f5f8; }
.c-teal   { color: #2a9d8f; border-color: #b7e6e0; background: #e9f9f7; }
.c-orange { color: #e07b2a; border-color: #f7d2ae; background: #fdf1e4; }
.c-blue2  { color: #3f7fd6; border-color: #c3dcff; background: #eef5ff; }

.c-blue.active   { background: #4a90d9; color: #fff; border-color: #4a90d9; }
.c-green.active  { background: #43a047; color: #fff; border-color: #43a047; }
.c-yellow.active { background: #f2b02a; color: #fff; border-color: #f2b02a; }
.c-pink.active   { background: #f48fb1; color: #fff; border-color: #f48fb1; }

.c-white { background: #fff; color: #3a4a5a; border-color: #e5edf5; }

.big-btn {
  border: none; border-radius: 2vmin; font-size: 3.8vmin; font-weight: 800;
  padding: 2vmin 5vmin; color: #fff; cursor: pointer;
  box-shadow: 0 .6vmin 1.4vmin rgba(90,120,150,.25);
}
.big-btn.c-green { background: #66bb6a; }
.big-btn.c-yellow { background: #f6b93b; }
.big-btn.c-pink { background: #f48fb1; }
.big-btn.c-blue { background: #5bc0eb; }
.big-btn.c-gray { background: #9aa7b5; }
.big-btn.c-purple { background: #9c8fd6; }
.big-btn[disabled] { opacity: .45; pointer-events: none; }

.mode-tabs { display: flex; align-items: center; gap: 1.4vmin; padding: .4vmin 1.6vmin 1.2vmin; }
.tab {
  font-size: 3.2vmin; font-weight: 800; padding: 1.2vmin 4vmin;
  border-radius: 999px; border: 3px solid #b9c7d6; background: #fff; color: #5a6b7d; cursor: pointer;
}
.tab.on { background: #5bc0eb; border-color: #5bc0eb; color: #fff; }
.star-box { margin-left: auto; font-size: 3.6vmin; font-weight: 800; color: #f2b02a; }

.zone-title { font-size: 2.8vmin; font-weight: 800; padding: .8vmin 1.4vmin; }

/* ============ 主页 ============ */
.home-grid {
  height: 100%; display: grid; gap: 1.8vmin; padding: 1.8vmin;
  grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
}
.home-card {
  border: none; border-radius: 2.6vmin; color: #fff; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.2vmin;
  box-shadow: 0 1vmin 2.4vmin rgba(90,120,150,.22);
  transition: transform .08s;
}
.home-card:active { transform: scale(.96); }
.home-card.c-blue { background: linear-gradient(150deg, #6ec6f2, #4a90d9); }
.home-card.c-green { background: linear-gradient(150deg, #8fd694, #43a047); }
.home-card.c-pink { background: linear-gradient(150deg, #ffb3c1, #f48fb1); }
.home-card.c-yellow { background: linear-gradient(150deg, #ffd97a, #f2b02a); }
.home-card.c-purple { background: linear-gradient(150deg, #c7b8f0, #9c8fd6); }
.home-card.c-teal { background: linear-gradient(150deg, #7fd8cc, #2a9d8f); }
.home-card.c-orange { background: linear-gradient(150deg, #ffc08a, #e07b2a); }
.home-card.c-blue2 { background: linear-gradient(150deg, #8fb8f5, #3f7fd6); }
.home-card.c-gray { background: linear-gradient(150deg, #c3cdd6, #8493a3); }
.hc-icon { width: 11vmin; height: 11vmin; }
.hc-icon svg { width: 100%; height: 100%; }
.hc-title { font-size: 4.4vmin; font-weight: 800; letter-spacing: .2vmin; }
.hc-sub { font-size: 2.3vmin; opacity: .88; }

/* ============ 点读乐园 ============ */
.read-grid {
  height: 100%; display: grid; gap: 1.2vmin; padding: 1.2vmin;
  grid-template-columns: 1.1fr .92fr 1.1fr;
  grid-template-rows: 1fr 1fr .92fr;
  grid-template-areas: "sm screen ym" "sm screen ym" "zt zt zt";
}
.zone { display: flex; flex-direction: column; border-radius: 2.4vmin; padding: 1vmin 1.4vmin; background: #ffffffcc; box-shadow: 0 .8vmin 2vmin rgba(90,120,150,.12); }
.zone-sm { grid-area: sm; }
.screen-zone { grid-area: screen; align-items: center; }
.zone-ym { grid-area: ym; }
.zone-zt { grid-area: zt; }
.keys { display: grid; gap: .8vmin; flex: 1; }
.sm-keys { grid-template-columns: repeat(6, 1fr); grid-template-rows: repeat(4, 1fr); }
.ym-keys { grid-template-columns: repeat(6, 1fr); grid-template-rows: repeat(4, 1fr); }
.tone-row { grid-template-columns: repeat(4, 1fr); flex: 0 0 auto; height: 10.5vmin; margin-top: 1vmin; }
.zt-keys { grid-template-columns: repeat(16, 1fr); }
.zt-keys .k-main { font-size: 4.6vmin; }
.tone-row .k-main { font-size: 4.2vmin; }

.lines-box { position: relative; flex: 1; width: 86%; margin-top: 2vmin; }
.line { position: absolute; left: 0; right: 0; height: .35vmin; background: #c9d6e3; border-radius: 1vmin; }
.line.l1 { top: 24%; } .line.l2 { top: 50%; } .line.l3 { top: 76%; }
.screen-big {
  position: absolute; top: 4%; width: 100%; text-align: center;
  font-size: 11vmin; font-weight: 800; color: #4a90d9;
}
.screen-big.pop { animation: pop .22s ease; }
@keyframes pop { 0% { transform: scale(.4); opacity: .2; } 100% { transform: scale(1); opacity: 1; } }
.screen-sub { position: absolute; top: 78%; width: 100%; text-align: center; font-size: 3vmin; color: #8a97a5; font-weight: 700; }
.screen-hint { font-size: 2.8vmin; color: #8a97a5; font-weight: 700; padding-bottom: 2vmin; }

/* ============ 自由拼读 ============ */
.spell-wrap { height: 100%; display: flex; flex-direction: column; }
.spell-grid { flex: 1; min-height: 0; display: grid; grid-template-rows: 1fr auto; gap: 1.2vmin; padding: 0 1.2vmin 1.2vmin; }
.spell-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1.6vmin; border-radius: 2.4vmin; box-shadow: 0 .8vmin 2vmin rgba(90,120,150,.12);
}
.slot-row { display: flex; gap: 2vmin; }
.slot {
  width: 20vmin; height: 14vmin; border-radius: 2vmin; background: #f2f6fa;
  border: .5vmin dashed #b9c7d6; display: flex; align-items: center; justify-content: center;
  font-size: 6vmin; font-weight: 800; color: #4a90d9;
}
.slot:empty { color: #c3cdd6; }
.spell-result { font-size: 8.5vmin; font-weight: 800; color: #8a97a5; min-height: 10vmin; }
.spell-result.good { color: #43a047; animation: pop .3s ease; }
.spell-screen .tone-row { height: 9vmin; }
.spell-screen .tone-row .k-main { font-size: 3.6vmin; }
.spell-btns { display: flex; gap: 2vmin; }
.spell-keys { display: grid; gap: 1vmin; grid-template-columns: auto 1fr; align-items: center; }
.row-title { font-size: 2.4vmin; font-weight: 800; color: #8a97a5; padding-right: 1vmin; text-align: center; }
.spell-keys .row-sm { display: grid; grid-template-columns: repeat(23, 1fr); height: 11vmin; gap: .7vmin; }
.spell-keys .row-jm { display: grid; grid-template-columns: repeat(3, 1fr); height: 11vmin; gap: .7vmin; }
.spell-keys .row-ym { display: grid; grid-template-columns: repeat(24, 1fr); height: 11vmin; gap: .7vmin; }
.spell-keys .key .k-main { font-size: 4vmin; }
.game-target-label { font-size: 3.2vmin; color: #8a97a5; font-weight: 700; }
.game-target { font-size: 14vmin; font-weight: 800; color: #f2b02a; }
.game-progress { display: flex; gap: 1.4vmin; }
.game-progress .dot { width: 3vmin; height: 3vmin; border-radius: 50%; background: #e3eaf1; }
.game-progress .dot.done { background: #66bb6a; }

/* ============ 声调练习 ============ */
.tone-wrap { height: 100%; display: flex; flex-direction: column; }
.tone-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: 1.15fr 1fr; gap: 1.2vmin; padding: 0 1.2vmin 1.2vmin; }
.tone-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2vmin; border-radius: 2.4vmin; box-shadow: 0 .8vmin 2vmin rgba(90,120,150,.12);
}
.tone-ym { font-size: 13vmin; font-weight: 800; color: #4a90d9; }
.tone-four { display: flex; align-items: center; gap: 3.4vmin; font-size: 7vmin; font-weight: 800; color: #f48fb1; }
.tone-four span { width: .5vmin; height: 5vmin; background: #e3eaf1; border-radius: 1vmin; }
.tone-side { display: flex; flex-direction: column; gap: 1.2vmin; }
.tone-side .tone-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.2vmin; height: 15vmin; margin: 0; }
.tone-side .row-ym { display: grid; grid-template-columns: repeat(6, 1fr); grid-auto-rows: 1fr; gap: .8vmin; flex: 1; }
.big-t .k-main { font-size: 5.4vmin; }
.quiz-score { font-size: 3vmin; color: #8a97a5; font-weight: 700; }

/* ============ 趣味测试 ============ */
.quiz-wrap { height: 100%; display: flex; flex-direction: column; padding: 1.6vmin; gap: 1.2vmin; }
.quiz-head { font-size: 3.2vmin; font-weight: 800; color: #5a6b7d; text-align: center; }
.quiz-main {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2.6vmin;
  background: #fff; border-radius: 2.4vmin; box-shadow: 0 .8vmin 2vmin rgba(90,120,150,.12);
}
.quiz-prompt { font-size: 3.8vmin; font-weight: 800; color: #8a97a5; }
.quiz-big { font-size: 10vmin; font-weight: 800; color: #4a90d9; }
.hear-btn { font-size: 4.2vmin; font-weight: 800; padding: 2vmin 6vmin; border-radius: 2vmin; border: none; color: #fff; cursor: pointer; }
.hear-btn.c-yellow { background: #f6b93b; }
.quiz-opts { display: flex; gap: 3vmin; flex-wrap: wrap; justify-content: center; }
.opt-btn {
  min-width: 22vmin; padding: 2.6vmin 4.5vmin; font-size: 5.4vmin; font-weight: 800;
  border-radius: 2vmin; border: .5vmin solid #8ec9f5; background: #fff; color: #4a90d9; cursor: pointer;
  transition: transform .08s;
}
.opt-btn.right { background: #8fd694; border-color: #43a047; color: #fff; }
.opt-btn.wrong { background: #ffb3c1; border-color: #e0657f; color: #fff; }

/* ============ 跟读 ============ */
.recite-wrap { height: 100%; display: flex; flex-direction: column; gap: 1.6vmin; padding: 1.6vmin; }
.recite-main {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2vmin;
  background: #fff; border-radius: 2.4vmin; box-shadow: 0 .8vmin 2vmin rgba(90,120,150,.12);
}
.recite-big { font-size: 14vmin; font-weight: 800; color: #4a90d9; }
.recite-sub { font-size: 5vmin; font-weight: 700; color: #f48fb1; }
.recite-hint { font-size: 3.2vmin; color: #8a97a5; font-weight: 700; }
.perm-warn { font-size: 2.8vmin; color: #e0657f; font-weight: 700; padding: 0 6vmin; text-align: center; }
.recite-btns { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1.4vmin; }
.recite-btns .big-btn { padding: 2vmin 1vmin; font-size: 3.4vmin; }
.rec-btn.recording { background: #e0657f; animation: pulse .9s ease infinite; }
@keyframes pulse { 50% { transform: scale(.94); opacity: .8; } }

/* ============ 古诗 ============ */
.poem-list { height: 100%; display: grid; grid-template-columns: repeat(5, 1fr); grid-template-rows: repeat(2, 1fr); gap: 1.6vmin; padding: 1.6vmin; }
.poem-card {
  border: none; border-radius: 2.4vmin; background: #fff; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.2vmin;
  box-shadow: 0 .8vmin 2vmin rgba(90,120,150,.14);
}
.pc-title { font-size: 4.8vmin; font-weight: 800; color: #4a90d9; }
.pc-author { font-size: 2.6vmin; color: #8a97a5; font-weight: 700; }
.pc-line { font-size: 3.2vmin; color: #5a6b7d; }
.poem-detail { height: 100%; display: flex; flex-direction: column; align-items: center; gap: 2vmin; padding: 2.4vmin; }
.poem-head { text-align: center; }
.pd-title { font-size: 5.6vmin; font-weight: 800; color: #4a90d9; }
.pd-author { font-size: 2.8vmin; color: #8a97a5; font-weight: 700; }
.poem-lines { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 1.6vmin; width: 82%; }
.poem-line {
  font-size: 5.2vmin; font-weight: 700; padding: 1.6vmin 3vmin; border-radius: 1.8vmin;
  background: #fff; border: none; color: #3a4a5a; cursor: pointer; text-align: left;
  box-shadow: 0 .4vmin 1vmin rgba(90,120,150,.1);
}
.poem-line.playing { background: #ffd97a; color: #7a4a00; transform: scale(1.02); }
.poem-btns { display: flex; gap: 2vmin; }

/* ============ 国学 ============ */
.gx-wrap { height: 100%; display: flex; flex-direction: column; }
.gx-lines { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2vmin; padding: 0 1.6vmin 1.2vmin; }
.gx-line {
  font-size: 4.2vmin; font-weight: 700; padding: 1.4vmin; border-radius: 1.8vmin;
  background: #fff; border: none; color: #3a4a5a; cursor: pointer;
  box-shadow: 0 .4vmin 1vmin rgba(90,120,150,.1);
}
.gx-line.playing { background: #ffd97a; color: #7a4a00; }
.gx-btns { display: flex; justify-content: center; padding-bottom: 1.6vmin; }

/* ============ 识字 ============ */
.zi-wrap { height: 100%; display: flex; flex-direction: column; gap: 1.4vmin; padding: 1.6vmin; }
.zi-card {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1vmin;
  border-radius: 2.4vmin; box-shadow: 0 .8vmin 2vmin rgba(90,120,150,.12);
}
.zi-char { font-size: 24vmin; font-weight: 800; line-height: 1.15; color: #3a4a5a; }
.zi-py { font-size: 7vmin; font-weight: 800; color: #4a90d9; }
.zi-ci { font-size: 6vmin; font-weight: 700; color: #8a97a5; margin: .4vmin 0 2vmin; }
.zi-btns { display: flex; gap: 2.4vmin; }
.zi-nav { display: grid; grid-template-columns: 1fr 1.3fr 1fr 1fr 1fr; gap: 1.2vmin; }
.nav-btn {
  border: none; border-radius: 2vmin; font-size: 3.4vmin; font-weight: 800; color: #fff; cursor: pointer;
  box-shadow: 0 .5vmin 1.2vmin rgba(90,120,150,.2);
}
.nav-btn.c-gray { background: #9aa7b5; }
.nav-btn.c-yellow { background: #f6b93b; }
.nav-btn.c-purple { background: #9c8fd6; }
.zi-progress { display: flex; align-items: center; justify-content: center; font-size: 3.4vmin; font-weight: 800; color: #5a6b7d; background: #fff; border-radius: 2vmin; }

/* ============ 结果页 / 设置 ============ */
.finish {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3vmin;
  border-radius: 2.4vmin; margin: 1.6vmin;
}
.finish-stars { font-size: 12vmin; color: #f2b02a; letter-spacing: 1.5vmin; }
.finish-text { font-size: 4.6vmin; font-weight: 800; }

.settings { height: 100%; padding: 1.6vmin; }
.set-card {
  height: 100%; border-radius: 2.4vmin; padding: 4vmin 6vmin;
  display: flex; flex-direction: column; gap: 3vmin;
  box-shadow: 0 .8vmin 2vmin rgba(90,120,150,.12);
}
.set-title { font-size: 4.6vmin; font-weight: 800; }
.set-row { display: flex; align-items: center; gap: 2.4vmin; }
.set-label { font-size: 3.4vmin; font-weight: 800; width: 12vmin; }
.set-info { font-size: 3vmin; color: #4a90d9; font-weight: 700; }
.set-tips { font-size: 3vmin; line-height: 1.9; color: #5a6b7d; }
#vol-slider { flex: 1; height: 1.4vmin; accent-color: #5bc0eb; }
#vol-val { font-size: 3.2vmin; font-weight: 800; width: 6vmin; text-align: center; }

/* ============ 竖屏提示 ============ */
@media (orientation: portrait) {
  body::after {
    content: '请把平板横过来使用';
    position: fixed; inset: 0; z-index: 999; background: #fff9ef;
    display: flex; align-items: center; justify-content: center;
    font-size: 5vmin; font-weight: 800; color: #4a90d9;
  }
}
