/* ==========================================================================
   小学英语闯关 · Web 端样式
   目标：平板/手机横竖屏都能用，按钮足够大，配色明快但不刺眼
   ========================================================================== */

:root {
  --bg1: #eef3ff;
  --bg2: #f8f0ff;
  --card: #ffffff;
  --primary: #5b7cfa;
  --primary-d: #4361e0;
  --primary-l: #eaefff;
  --ok: #2fbf71;
  --ok-l: #e4f8ed;
  --no: #ff8a3d;
  --no-l: #fff0e4;
  --gold: #ffc53d;
  --text: #1f2937;
  --muted: #7a8496;
  --line: #e6eaf3;
  --radius: 18px;
  --shadow: 0 6px 24px rgba(46, 64, 120, .08);
  --shadow-s: 0 2px 10px rgba(46, 64, 120, .06);
}

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

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, var(--bg1) 0%, var(--bg2) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  font-size: inherit;
}

.view {
  display: none;
  min-height: 100vh;
  padding: 18px 16px calc(28px + env(safe-area-inset-bottom));
  max-width: 820px;
  margin: 0 auto;
}
.view.on {
  display: block;
  animation: fade .22s ease;
}
@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------- 通用 ------------------------------- */

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 22px;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 600;
  transition: transform .12s, box-shadow .12s, background .15s;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 18px rgba(91, 124, 250, .32);
}
.btn-primary:hover { background: var(--primary-d); }
.btn-ghost {
  background: var(--primary-l);
  color: var(--primary-d);
}
.btn-line {
  background: #fff;
  color: var(--text);
  box-shadow: inset 0 0 0 1.5px var(--line);
}
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.muted { color: var(--muted); }

/* ------------------------------- 登录 ------------------------------- */

.login-wrap {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100vh - 60px);
  gap: 22px;
}
.brand { text-align: center; }
.brand .logo { font-size: 56px; line-height: 1; }
.brand h1 {
  margin: 12px 0 6px;
  font-size: 27px;
  letter-spacing: .5px;
}
.brand p { margin: 0; color: var(--muted); font-size: 14px; }

.login-card { padding: 22px; }
.login-card label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}
.login-card input {
  width: 100%;
  height: 56px;
  padding: 0 16px;
  font-size: 19px;
  font-family: inherit;
  color: var(--text);
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #fbfcff;
  outline: none;
  transition: border-color .15s, background .15s;
}
.login-card input:focus {
  border-color: var(--primary);
  background: #fff;
}
.login-card .btn { margin-top: 16px; }

.profiles {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}
.profiles:empty { display: none; }
.profile-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 15px 9px 10px;
  background: #f6f8ff;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  box-shadow: inset 0 0 0 1.5px var(--line);
  transition: background .15s, box-shadow .15s;
}
.profile-chip:hover { background: var(--primary-l); box-shadow: inset 0 0 0 1.5px var(--primary); }
.profile-chip .av {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
}

.tip {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
}

/* ------------------------------- 顶栏 ------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.topbar h2 {
  margin: 0;
  font-size: 20px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.icon-btn {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 19px;
  background: #fff;
  box-shadow: var(--shadow-s);
  flex-shrink: 0;
}
.icon-btn:active { transform: scale(.94); }

.stars-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 13px;
  background: #fff8e4;
  color: #b47b00;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ------------------------------- 首页 ------------------------------- */

.home-hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #5b7cfa 0%, #7b5bfa 100%);
  color: #fff;
  border-radius: 22px;
  padding: 22px;
  box-shadow: 0 10px 28px rgba(91, 124, 250, .3);
}
.home-hero::after {
  content: "";
  position: absolute;
  right: -40px; top: -40px;
  width: 180px; height: 180px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
}
.home-hero .hi { font-size: 14px; opacity: .88; }
.home-hero .who {
  font-size: 25px;
  font-weight: 700;
  margin: 4px 0 14px;
}
.progress-track {
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .28);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: #fff;
  transition: width .5s cubic-bezier(.2, .8, .2, 1);
}
.home-hero .pmeta {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-top: 8px;
  opacity: .92;
}

.sect-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 22px 2px 12px;
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
}
.sect-title .line { flex: 1; height: 1px; background: var(--line); }

.action-list { display: grid; gap: 12px; }

.action-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: #fff;
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  transition: transform .12s, box-shadow .12s;
}
.action-card:active { transform: scale(.985); }
.action-card .ic {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-size: 24px;
  flex-shrink: 0;
  background: var(--primary-l);
}
.action-card .ic.g { background: var(--ok-l); }
.action-card .ic.o { background: var(--no-l); }
.action-card .ic.y { background: #fff6e0; }
.action-card .body { flex: 1; min-width: 0; }
.action-card .t { display: block; font-size: 16px; font-weight: 700; }
.action-card .d { display: block; font-size: 13px; color: var(--muted); margin-top: 3px; }
.action-card .arrow { color: #c3cada; font-size: 20px; flex-shrink: 0; }

@media (min-width: 640px) {
  .action-list { grid-template-columns: 1fr 1fr; }
}

.badge-dot {
  display: inline-block;
  min-width: 20px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--no);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  margin-left: 6px;
  vertical-align: 1px;
}

/* ------------------------------- 地图 ------------------------------- */

.map-head {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.map-head .big { font-size: 30px; }
.map-head .txt { flex: 1; }
.map-head .n { font-size: 16px; font-weight: 700; }
.map-head .s { font-size: 13px; color: var(--muted); margin-top: 3px; }

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 10px;
}
.level-cell {
  position: relative;
  min-height: 76px;
  border-radius: 15px;
  background: #fff;
  box-shadow: var(--shadow-s);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 6px;
  transition: transform .12s;
}
.level-cell:active { transform: scale(.94); }
.level-cell .no {
  font-size: 21px;
  font-weight: 800;
  color: var(--primary-d);
  line-height: 1.05;
}
.level-cell .nm {
  font-size: 9px;
  color: var(--muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1;
}
.level-cell .st {
  font-size: 10px;
  letter-spacing: -0.5px;
  color: var(--gold);
  line-height: 1;
}
.level-cell.locked {
  background: #f2f4f9;
  box-shadow: none;
}
.level-cell.locked .no { color: #c3cada; }
.level-cell.locked::after {
  content: "🔒";
  position: absolute;
  top: 5px;
  right: 6px;
  font-size: 10px;
  line-height: 1;
}
.level-cell.locked .st { display: none; }
.level-cell.passed { box-shadow: inset 0 0 0 2px #d0e9dd, var(--shadow-s); }
.level-cell.boss {
  background: linear-gradient(135deg, #fff4e0, #ffe7cc);
}
.level-cell.boss .no { color: #b47b00; }
.level-cell .st.empty-star { color: #ccd4e4; }

/* ------------------------------- 答题 ------------------------------- */

.play-view {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  max-width: 820px;
  margin: 0 auto;
  padding: 14px 16px calc(24px + env(safe-area-inset-bottom));
}
.play-view.on { display: flex; }

.play-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.play-head .quit {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: #fff;
  display: grid; place-items: center;
  font-size: 17px;
  color: var(--muted);
  box-shadow: var(--shadow-s);
  flex-shrink: 0;
}
.dots {
  flex: 1;
  display: flex;
  gap: 4px;
}
.dot {
  flex: 1;
  height: 7px;
  border-radius: 999px;
  background: #dfe5f2;
  transition: background .25s;
}
.dot.done { background: var(--ok); }
.dot.err { background: var(--no); }
.dot.now { background: var(--primary); }

.combo {
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 800;
  color: var(--no);
  min-width: 42px;
  text-align: right;
  transition: transform .15s;
}
.combo.pop { transform: scale(1.35); }

.q-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
  padding: 8px 0;
}

.q-prompt {
  text-align: center;
  font-size: 15px;
  color: var(--muted);
  font-weight: 600;
}

.q-big {
  text-align: center;
  font-size: 42px;
  font-weight: 800;
  letter-spacing: .5px;
  line-height: 1.2;
  word-break: break-word;
  animation: pop .25s ease;
}
.q-big.cn { font-size: 34px; }
@keyframes pop {
  from { transform: scale(.9); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.ipa {
  text-align: center;
  font-size: 16px;
  color: var(--muted);
  margin-top: -12px;
}

.speaker {
  width: 118px; height: 118px;
  border-radius: 50%;
  margin: 0 auto;
  display: grid;
  place-items: center;
  font-size: 48px;
  background: linear-gradient(135deg, #5b7cfa, #7b5bfa);
  color: #fff;
  box-shadow: 0 10px 26px rgba(91, 124, 250, .34);
  transition: transform .12s;
}
.speaker:active { transform: scale(.93); }
.speaker.playing { animation: ring .7s ease infinite; }
@keyframes ring {
  0%, 100% { box-shadow: 0 10px 26px rgba(91, 124, 250, .34); }
  50% { box-shadow: 0 10px 26px rgba(91, 124, 250, .34), 0 0 0 14px rgba(91, 124, 250, .12); }
}

.opts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
}
@media (max-width: 340px) {
  .opts { grid-template-columns: 1fr; }
}
.opt {
  min-height: 62px;
  padding: 11px 14px;
  border-radius: 15px;
  background: #fff;
  box-shadow: var(--shadow-s), inset 0 0 0 2px transparent;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  transition: transform .1s, box-shadow .15s, background .15s;
}
.opt:active { transform: scale(.975); }
.opt .k {
  width: 27px; height: 27px;
  border-radius: 9px;
  background: #f2f5fc;
  color: var(--muted);
  display: grid; place-items: center;
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.opt .tx { flex: 1; min-width: 0; word-break: break-word; }
.opt.right {
  background: var(--ok-l);
  box-shadow: inset 0 0 0 2px var(--ok);
}
.opt.right .k { background: var(--ok); color: #fff; }
.opt.wrong {
  background: var(--no-l);
  box-shadow: inset 0 0 0 2px var(--no);
  animation: shake .32s;
}
.opt.wrong .k { background: var(--no); color: #fff; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
.opt[disabled] { pointer-events: none; }
.opts.dim .opt:not(.right):not(.wrong) { opacity: .45; }

/* 拼写 */
.spell-board {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 58px;
  align-items: center;
}
.slot {
  width: 40px; height: 52px;
  border-radius: 11px;
  background: #fff;
  box-shadow: inset 0 0 0 2px var(--line);
  display: grid; place-items: center;
  font-size: 24px;
  font-weight: 800;
  text-transform: lowercase;
}
.slot.filled {
  box-shadow: inset 0 0 0 2px var(--primary);
  background: var(--primary-l);
  color: var(--primary-d);
}
.slot.ok { box-shadow: inset 0 0 0 2px var(--ok); background: var(--ok-l); color: #17864d; }
.slot.bad { box-shadow: inset 0 0 0 2px var(--no); background: var(--no-l); color: #b35a12; }

.letters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 9px;
  margin-top: 6px;
}
.letter {
  width: 54px; height: 54px;
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-s);
  font-size: 22px;
  font-weight: 800;
  text-transform: lowercase;
  color: var(--primary-d);
  transition: transform .1s, opacity .15s;
}
.letter:active { transform: scale(.9); }
.letter.used { opacity: .25; pointer-events: none; }

.spell-tools {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 4px;
}
.spell-tools button {
  padding: 10px 18px;
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow-s);
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
}

/* 答题结果条 */
.verdict {
  text-align: center;
  font-size: 17px;
  font-weight: 800;
  min-height: 26px;
  color: var(--ok);
}
.verdict.bad { color: var(--no); }

/* ------------------------------- 结算 ------------------------------- */

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(23, 32, 56, .45);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 90;
  backdrop-filter: blur(3px);
}
.sheet.on { display: flex; }
.sheet-body {
  width: 100%;
  max-width: 620px;
  background: #fff;
  border-radius: 26px 26px 0 0;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: up .3s cubic-bezier(.2, .9, .25, 1);
}
/* 内容区独立滚动，按钮区固定在底部 —— 错题多的时候按钮不会被滚走 */
.sheet-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 26px 20px 6px;
}
@keyframes up {
  from { transform: translateY(100%); }
  to { transform: none; }
}

.medal { text-align: center; }
.medal .big { font-size: 54px; line-height: 1; }
.medal .ttl {
  font-size: 22px;
  font-weight: 800;
  margin: 8px 0 2px;
}
.medal .sub { font-size: 14px; color: var(--muted); }

.star-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 16px 0 6px;
  font-size: 40px;
  line-height: 1;
}
.star-row span {
  color: #e3e8f2;
  display: inline-block;
  animation: starIn .4s backwards;
}
.star-row span.on { color: var(--gold); }
.star-row span:nth-child(1) { animation-delay: .1s; }
.star-row span:nth-child(2) { animation-delay: .28s; }
.star-row span:nth-child(3) { animation-delay: .46s; }
@keyframes starIn {
  from { transform: scale(0) rotate(-40deg); opacity: 0; }
  60% { transform: scale(1.25) rotate(8deg); }
  to { transform: none; opacity: 1; }
}

.stat-row {
  display: flex;
  justify-content: space-around;
  padding: 16px 0;
  margin: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.stat-row .it { text-align: center; }
.stat-row .v { font-size: 21px; font-weight: 800; }
.stat-row .l { font-size: 12px; color: var(--muted); margin-top: 3px; }

.wrong-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  margin: 16px 0 10px;
}
.wrong-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 13px;
  background: #fbfcff;
  box-shadow: inset 0 0 0 1.5px var(--line);
  margin-bottom: 8px;
}
.wrong-item .w {
  font-size: 17px;
  font-weight: 700;
  color: var(--no);
}
.wrong-item .c { font-size: 13px; color: var(--muted); }
.wrong-item .spk {
  margin-left: auto;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: #fff;
  display: grid; place-items: center;
  box-shadow: var(--shadow-s);
  font-size: 15px;
  flex-shrink: 0;
}

.sheet-actions {
  display: grid;
  gap: 10px;
  flex-shrink: 0;
  background: #fff;
  padding: 12px 20px calc(18px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.sheet-actions .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* 矮屏（iPhone SE 这类 568~640 高度的机器）压缩垂直间距，否则四个选项会顶出屏幕 */
@media (max-height: 660px) {
  .play-view { padding-top: 10px; }
  .play-head { margin-bottom: 10px; }
  .q-stage { gap: 12px; padding: 0; }
  .q-prompt { font-size: 14px; }
  .q-big { font-size: 34px; }
  .q-big.cn { font-size: 26px; }
  .speaker { width: 86px; height: 86px; font-size: 34px; }
  .opts { gap: 9px; }
  .opt { min-height: 54px; padding: 9px 12px; font-size: 15px; }
  .slot { width: 36px; height: 46px; font-size: 21px; }
  .letter { width: 48px; height: 48px; font-size: 20px; }
}

/* ------------------------------- 选择册 ------------------------------- */

.book-list { display: grid; gap: 10px; }
.book-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-s);
  text-align: left;
  width: 100%;
}
.book-item.cur { box-shadow: inset 0 0 0 2px var(--primary); }
.book-item .g {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--primary-l);
  color: var(--primary-d);
  display: grid; place-items: center;
  font-size: 16px;
  font-weight: 800;
  flex-shrink: 0;
}
.book-item .t { display: block; font-size: 15px; font-weight: 700; }
.book-item .s { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
.book-item .ck { color: var(--primary); font-size: 18px; }

/* ------------------------------- 提示 ------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 80px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(31, 41, 55, .94);
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  z-index: 200;
  max-width: 80vw;
  text-align: center;
}
.toast.on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.empty {
  text-align: center;
  padding: 50px 20px;
  color: var(--muted);
}
.empty .e { font-size: 44px; }
.empty .t { margin-top: 10px; font-size: 15px; }

.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-page {
  display: grid;
  place-items: center;
  min-height: 60vh;
  gap: 14px;
}
.loading-page .t { color: var(--muted); font-size: 14px; }

/* 桌面端放宽 */
@media (min-width: 700px) {
  .view { padding: 30px 24px 40px; }
  .level-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .q-big { font-size: 50px; }
  .sheet-body { border-radius: 26px; margin-bottom: 24px; }
}
