/* ============================================================
   词兽猎人 Word Beast Hunter — 视觉层
   ============================================================ */
:root {
  --ink: #f7f3ff;
  --muted: rgba(247, 243, 255, .6);
  --dim: rgba(247, 243, 255, .38);
  --gold: #ffd451;
  --gold-2: #ff9f43;
  --mint: #6ee7b7;
  --pink: #ff7a9c;
  --sky: #7cc6ff;
  --violet: #a78bfa;
  --panel: rgba(255, 255, 255, .065);
  --panel-2: rgba(255, 255, 255, .11);
  --line: rgba(255, 255, 255, .13);
  --radius: 18px;
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-en: "Arial Rounded MT Bold", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none;
}

body {
  background: #0b0718;
  color: var(--ink);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

button, textarea { font-family: inherit; }
button { cursor: pointer; border: 0; background: none; color: inherit; }

/* ---------------- 外框 ---------------- */
.game-shell {
  position: relative;
  width: 100%;
  max-width: 560px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: radial-gradient(120% 80% at 50% 0%, #3a2564 0%, #221440 45%, #150c2b 100%);
  box-shadow: 0 0 80px rgba(0, 0, 0, .6);
  isolation: isolate;
}

/* ---------------- 背景装饰 ---------------- */
.bg { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(38px);
  opacity: .5;
  animation: drift 16s ease-in-out infinite alternate;
}
.bg-orb.o1 { width: 240px; height: 240px; background: #6d3fff; top: -70px; left: -60px; }
.bg-orb.o2 { width: 200px; height: 200px; background: #ff4f8b; bottom: 8%; right: -70px; animation-delay: -5s; opacity: .35; }
.bg-orb.o3 { width: 180px; height: 180px; background: #24d3b0; bottom: 30%; left: -70px; animation-delay: -9s; opacity: .25; }

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(18px, 26px, 0) scale(1.12); }
}

.bg-stars {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(1.4px 1.4px at 12% 18%, rgba(255,255,255,.85), transparent),
    radial-gradient(1.6px 1.6px at 78% 12%, rgba(255,255,255,.7), transparent),
    radial-gradient(1.2px 1.2px at 34% 34%, rgba(255,255,255,.55), transparent),
    radial-gradient(1.8px 1.8px at 62% 44%, rgba(255,255,255,.5), transparent),
    radial-gradient(1.2px 1.2px at 88% 62%, rgba(255,255,255,.55), transparent),
    radial-gradient(1.4px 1.4px at 22% 68%, rgba(255,255,255,.4), transparent),
    radial-gradient(1.2px 1.2px at 52% 84%, rgba(255,255,255,.35), transparent),
    radial-gradient(1.6px 1.6px at 72% 90%, rgba(255,255,255,.3), transparent);
  animation: twinkle 5s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: .55; } to { opacity: 1; } }

.bg-hill {
  position: absolute; left: -10%; width: 120%; border-radius: 50% 50% 0 0;
  background: linear-gradient(180deg, rgba(120, 84, 255, .28), rgba(20, 10, 40, .1));
}
.bg-hill.h1 { bottom: -60px; height: 190px; }
.bg-hill.h2 { bottom: -110px; height: 210px; background: linear-gradient(180deg, rgba(76, 48, 180, .45), rgba(15, 8, 32, .2)); }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: relative; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  flex: 0 0 auto;
}

.icon-btn {
  width: 36px; height: 36px; flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 16px; line-height: 1;
  transition: transform .12s, background .2s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn.ghost { background: rgba(0, 0, 0, .22); }
.icon-btn.off { opacity: .45; }

.hero-chip {
  flex: 1 1 auto; min-width: 0;
  display: flex; align-items: center; gap: 7px;
}
.hero-rank { font-size: 20px; line-height: 1; }
.hero-meta { display: flex; flex-direction: column; min-width: 0; }
.hero-meta b { font-size: 13px; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-meta small {
  display: flex; align-items: center; gap: 3px;
  font-size: 10px; color: var(--muted); font-weight: 600;
}
.star-mini {
  width: 9px; height: 9px; display: inline-block;
  background: var(--gold);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

.wallet {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 10px 6px 8px;
  border-radius: 999px;
  background: rgba(255, 212, 81, .13);
  border: 1px solid rgba(255, 212, 81, .3);
  font-size: 14px; font-weight: 800; color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.coin-ico {
  width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #fff6c9, #ffd451 45%, #e0952a);
  box-shadow: inset 0 -2px 3px rgba(160, 100, 0, .5);
}

/* ---------------- 舞台 / 屏幕 ---------------- */
.stage { position: relative; z-index: 4; flex: 1 1 auto; min-height: 0; }

.screen {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  padding: 4px 16px 18px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.screen.active { display: flex; animation: screenIn .26s ease-out both; }

@keyframes screenIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.screen-head { padding: 6px 2px 12px; flex: 0 0 auto; }
.screen-head h2 { margin: 0 0 4px; font-size: 22px; letter-spacing: .02em; }
.screen-head p { margin: 0; font-size: 12px; color: var(--muted); }

/* ---------------- 首页 ---------------- */
#screen-home { justify-content: center; gap: 4px; }

.home-hero {
  position: relative;
  flex: 1 1 auto;
  min-height: 210px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}

.title-wrap { position: relative; z-index: 2; text-align: center; margin-top: 6px; }

.game-title {
  margin: 0;
  display: flex; gap: 2px; justify-content: center;
  font-size: clamp(38px, 12.5vw, 54px);
  font-weight: 900;
  letter-spacing: .04em;
  line-height: 1.05;
}
.game-title span {
  background: linear-gradient(170deg, #fff8d6 8%, #ffd451 42%, #ff9f43 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 rgba(120, 50, 0, .45)) drop-shadow(0 8px 18px rgba(255, 160, 60, .35));
  animation: titleBob 3.4s ease-in-out infinite;
}
.game-title span:nth-child(2) { animation-delay: .12s; }
.game-title span:nth-child(3) { animation-delay: .24s; }
.game-title span:nth-child(4) { animation-delay: .36s; }
@keyframes titleBob { 0%, 100% { transform: translateY(0) rotate(-1.5deg); } 50% { transform: translateY(-5px) rotate(1.5deg); } }

.game-sub {
  margin: 6px 0 0;
  font-family: var(--font-en);
  font-size: 10px; font-weight: 700;
  letter-spacing: .34em;
  color: rgba(255, 255, 255, .5);
  text-indent: .34em;
}

.home-monster {
  position: relative; z-index: 1;
  margin-top: -6px;
  display: grid; place-items: center;
  filter: drop-shadow(0 18px 26px rgba(0, 0, 0, .45));
}
.home-monster svg { width: min(46vw, 200px); height: auto; }

.home-stats {
  position: absolute;
  left: 0; right: 0; bottom: 2px;
  display: flex; align-items: center; justify-content: center;
  gap: 9px;
  font-size: 11px; font-weight: 600;
  color: var(--muted);
  letter-spacing: .02em;
}
.home-stats span { display: flex; align-items: baseline; gap: 3px; }
.home-stats b { font-size: 14px; color: var(--gold); font-family: var(--font-en); }
.home-stats i { width: 3px; height: 3px; border-radius: 50%; background: rgba(255, 255, 255, .22); }

.howto {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 10px;
  margin: 4px 0 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.howto .step {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; line-height: 1.25; font-weight: 700;
}
.howto .step i {
  flex: 0 0 auto;
  width: 19px; height: 19px; border-radius: 50%;
  display: grid; place-items: center;
  font-style: normal; font-size: 11px; font-weight: 800;
  background: rgba(255, 212, 81, .18);
  color: var(--gold);
  border: 1px solid rgba(255, 212, 81, .35);
}
.howto .step small { display: block; font-weight: 500; font-size: 10px; color: var(--muted); }
.howto .arrow { color: rgba(255, 255, 255, .25); font-size: 12px; }

.home-actions { flex: 0 0 auto; display: flex; flex-direction: column; gap: 9px; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 14px 16px;
  border-radius: 15px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 15px; font-weight: 800;
  letter-spacing: .02em;
  transition: transform .12s, filter .2s, background .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; }

.btn-primary {
  background: linear-gradient(135deg, #ffe27a, #ffd451 38%, #ff9f43);
  color: #40270a;
  border: 0;
  box-shadow: 0 10px 28px rgba(255, 160, 60, .38), inset 0 1px 0 rgba(255, 255, 255, .6);
}
.btn-primary small { font-weight: 700; font-size: 11px; opacity: .7; }

.btn-lg { flex-direction: column; padding: 16px; font-size: 20px; gap: 2px; border-radius: 18px; }

.btn-row { display: flex; gap: 9px; }
.btn-row .btn { flex: 1; }

.home-foot { margin: 12px 0 0; text-align: center; font-size: 11px; color: var(--dim); }

.link-btn {
  color: var(--sky); font-size: inherit; font-weight: 700;
  padding: 2px; text-decoration: underline; text-underline-offset: 3px;
}

/* ---------------- 关卡地图 ---------------- */
.level-list { display: flex; flex-direction: column; gap: 9px; }

.level-card {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 12px;
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(255, 255, 255, .1), rgba(255, 255, 255, .04));
  border: 1px solid var(--line);
  text-align: left;
  transition: transform .12s, border-color .2s, box-shadow .2s;
}
.level-card:active { transform: scale(.985); }
.level-card.locked { opacity: .45; filter: grayscale(.7); }
.level-card.next {
  border-color: rgba(255, 212, 81, .55);
  box-shadow: 0 0 0 1px rgba(255, 212, 81, .18), 0 8px 24px rgba(255, 170, 60, .16);
}
.level-card.done { border-color: rgba(110, 231, 183, .3); }

.lv-emoji {
  flex: 0 0 auto;
  width: 46px; height: 46px; border-radius: 14px;
  display: grid; place-items: center;
  font-size: 22px;
  background: rgba(0, 0, 0, .25);
  border: 1px solid rgba(255, 255, 255, .08);
}
.lv-body { flex: 1 1 auto; min-width: 0; }
.lv-body b { display: block; font-size: 15px; letter-spacing: .01em; }
.lv-body small { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lv-right { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.lv-stars { display: flex; gap: 1px; font-size: 12px; letter-spacing: -1px; }
.lv-stars i { font-style: normal; color: rgba(255, 255, 255, .18); }
.lv-stars i.on { color: var(--gold); text-shadow: 0 0 8px rgba(255, 212, 81, .6); }
.lv-mons { font-size: 10px; color: var(--muted); }
.lv-lock { font-size: 16px; opacity: .8; }

.map-foot {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 9px;
  margin: 16px 2px 4px;
  font-size: 11px; color: var(--muted);
}
.prog-track { flex: 1; height: 7px; border-radius: 999px; background: rgba(0, 0, 0, .32); overflow: hidden; }
.prog-track i { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, #6ee7b7, #7cc6ff); transition: width .5s ease; }
.map-foot b { color: var(--ink); font-variant-numeric: tabular-nums; }

.review-slot { flex: 0 0 auto; }
.review-card {
  width: 100%;
  display: flex; align-items: center; gap: 11px;
  padding: 12px;
  margin-bottom: 9px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(255, 122, 156, .18), rgba(167, 139, 250, .14));
  border: 1px dashed rgba(255, 122, 156, .5);
  text-align: left;
}
.review-card:active { transform: scale(.985); }
.review-card .lv-emoji { background: rgba(0, 0, 0, .2); }
.review-card b { display: block; font-size: 14px; }
.review-card small { font-size: 11px; color: var(--muted); }

/* ---------------- 战斗 ---------------- */
#screen-battle { padding: 0; overflow: hidden; }

.battle-head {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px 2px;
}
.mon-title { flex: 1 1 auto; display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.mon-title b { font-size: 15px; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mon-title span {
  flex: 0 0 auto;
  font-size: 9px; font-weight: 800;
  padding: 2px 6px; border-radius: 999px;
  background: rgba(255, 122, 156, .2);
  color: #ffb3c6;
  border: 1px solid rgba(255, 122, 156, .35);
}

.combo-box {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 3px;
  font-size: 13px; font-weight: 800; color: var(--gold);
  opacity: .35;
  transition: opacity .2s, transform .2s;
}
.combo-box.hot { opacity: 1; transform: scale(1.05); }
.combo-box i { font-style: normal; font-size: 13px; }

.arena {
  position: relative;
  flex: 1 1 auto;
  min-height: 150px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 4px 16px 0;
  overflow: hidden;
}
.arena.shake { animation: shakeHard .42s cubic-bezier(.36, .07, .19, .97); }
@keyframes shakeHard {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 1px, 0); }
  30%, 50%, 70% { transform: translate3d(-7px, -2px, 0); }
  40%, 60% { transform: translate3d(7px, 2px, 0); }
}

.arena-glow {
  position: absolute;
  width: 70%; height: 62%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(167, 139, 250, .3), transparent 68%);
  filter: blur(18px);
  pointer-events: none;
}

.arena-deco { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.arena-deco span {
  position: absolute;
  font-family: var(--font-en);
  font-weight: 800;
  color: rgba(255, 255, 255, .07);
  text-shadow: 0 0 18px rgba(167, 139, 250, .25);
  animation: floatLetter 8s ease-in-out infinite;
}
@keyframes floatLetter {
  0%, 100% { transform: translateY(0) rotate(-7deg); }
  50% { transform: translateY(-16px) rotate(7deg); }
}

.monster-wrap { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; }

.monster-art { display: grid; place-items: center; animation: bob 3.2s ease-in-out infinite; }
.monster-art svg {
  width: min(50vw, 200px);
  height: auto;
  display: block;
  filter: drop-shadow(0 14px 20px rgba(0, 0, 0, .45));
}
@keyframes bob {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-7px) scale(1.015); }
}

.monster-art.hit { animation: monHit .42s ease-out; }
@keyframes monHit {
  0% { transform: translateX(0) scale(1); filter: brightness(3) saturate(.4); }
  25% { transform: translateX(-12px) scale(.96); }
  55% { transform: translateX(9px) scale(1.02); filter: brightness(1.6); }
  100% { transform: translateX(0) scale(1); filter: none; }
}
.monster-art.enrage svg { animation: enrage .5s ease-in-out 3; }
@keyframes enrage {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07) rotate(-2deg); filter: drop-shadow(0 0 16px rgba(255, 90, 90, .8)); }
}
.monster-art.dead { animation: monDead .9s ease-in forwards; }
@keyframes monDead {
  0% { transform: scale(1) rotate(0); opacity: 1; filter: brightness(2); }
  35% { transform: scale(1.12) rotate(-6deg); opacity: 1; }
  100% { transform: scale(.5) rotate(24deg) translateY(40px); opacity: 0; filter: grayscale(1) blur(4px); }
}

.hpbar {
  position: relative;
  width: 180px; height: 17px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .42);
  border: 1px solid rgba(255, 255, 255, .16);
  overflow: hidden;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, .5);
}
.hpbar i {
  display: block; height: 100%; width: 100%;
  transform-origin: left center;
  transition: transform .38s cubic-bezier(.2, .8, .3, 1), background .3s;
  background: linear-gradient(90deg, #ff4d6d, #ff9a6b);
}
.hpbar.mon i { background: linear-gradient(90deg, #ff4d6d, #ffb46b); }
.hpbar.me i { background: linear-gradient(90deg, #43d6a4, #7cc6ff); }
.hpbar.me i.low { background: linear-gradient(90deg, #ff4d6d, #ff8a5b); }
.hpbar span {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 800; letter-spacing: .03em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .9);
}

.speech {
  position: absolute;
  top: 6px; left: 50%;
  transform: translateX(-50%) translateY(-6px);
  max-width: 82%;
  padding: 6px 11px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .94);
  color: #2a1a3e;
  font-size: 11.5px; font-weight: 700; line-height: 1.35;
  text-align: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
}
.speech::after {
  content: ''; position: absolute; bottom: -5px; left: 50%; margin-left: -5px;
  border: 5px solid transparent; border-top-color: rgba(255, 255, 255, .94); border-bottom: 0;
}
.speech.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 玩家条 */
.player-strip {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 9px;
  padding: 8px 14px 2px;
}
.hero-figure {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  font-size: 21px;
  border-radius: 12px;
  background: linear-gradient(160deg, rgba(124, 198, 255, .3), rgba(167, 139, 250, .2));
  border: 1px solid rgba(124, 198, 255, .35);
  transition: transform .12s;
}
.hero-figure.attack { animation: heroAtk .5s ease-out; }
.hero-figure svg { width: 27px; height: 27px; display: block; }
.hero-figure.hurt { animation: heroHurt .3s ease-out; }

/* 战场上的玩家（词书精灵） */
.hero-art {
  position: absolute;
  left: 6%;
  bottom: 2%;
  width: 66px; height: 66px;
  display: grid; place-items: center;
  animation: bob 4.2s ease-in-out infinite;
  filter: drop-shadow(0 10px 16px rgba(0, 0, 0, .45));
  z-index: 3;
}
.hero-art::after {
  content: '';
  position: absolute;
  inset: 12% 6% -8% 6%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124, 198, 255, .45), transparent 68%);
  filter: blur(8px);
  z-index: -1;
}
.hero-art svg { width: 100%; height: 100%; }
.hero-art.attack { animation: heroAtk .5s ease-out; }
.hero-art.hurt { animation: heroHurt .34s ease-out; }

@keyframes heroAtk {
  0%, 100% { transform: translateY(0) scale(1); }
  35% { transform: translate(10px, -14px) scale(1.14); }
}
@keyframes heroHurt {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px) rotate(-9deg); filter: hue-rotate(-40deg) brightness(1.5); }
  75% { transform: translateX(7px) rotate(9deg); }
}

.bars { flex: 1 1 auto; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.bars .hpbar { width: 100%; height: 15px; }

.energybar {
  position: relative;
  height: 13px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .42);
  border: 1px solid rgba(255, 255, 255, .14);
  overflow: hidden;
}
.energybar i {
  display: block; height: 100%; width: 100%;
  transform: scaleX(0); transform-origin: left center;
  transition: transform .32s cubic-bezier(.2, .8, .3, 1);
  background: linear-gradient(90deg, #a78bfa, #7cc6ff 55%, #ffe27a);
  box-shadow: 0 0 12px rgba(167, 139, 250, .7);
}
.energybar.full i { background: linear-gradient(90deg, #ffe27a, #ffd451, #ff9f43); animation: energyPulse .8s ease-in-out infinite; }
@keyframes energyPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.55); }
}
.energybar span {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 800; letter-spacing: .04em;
  color: rgba(255, 255, 255, .92);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .8);
}
.energy-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(0, 0, 0, .35); left: 50%; }
.energy-tick.t2 { left: 33.3%; }

/* 题目 */
.quiz {
  flex: 0 0 auto;
  padding: 8px 14px 0;
}
.quiz-meta {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 10px; font-weight: 700;
  color: var(--muted);
  margin-bottom: 3px;
}
.qtype { color: var(--sky); letter-spacing: .04em; }
.qcount { font-variant-numeric: tabular-nums; }

.q-main {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 46px;
}
.q-word {
  font-family: var(--font-en);
  font-size: clamp(27px, 8.8vw, 36px);
  font-weight: 800;
  letter-spacing: .01em;
  text-align: center;
  line-height: 1.15;
  text-shadow: 0 3px 12px rgba(0, 0, 0, .5);
  word-break: break-word;
}
.q-word.zh { font-family: var(--font); font-size: clamp(22px, 7vw, 28px); }
.q-word .blank {
  display: inline-block;
  min-width: .6em;
  border-bottom: 3px solid var(--gold);
  color: var(--gold);
  margin: 0 1px;
}
.q-word .listen-ico { font-size: .9em; }

.speak-btn {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(124, 198, 255, .16);
  border: 1px solid rgba(124, 198, 255, .38);
  font-size: 15px;
  display: grid; place-items: center;
  transition: transform .12s, background .2s;
}
.speak-btn:active { transform: scale(.9); }
.speak-btn.hidden { visibility: hidden; }
.speak-btn.playing { animation: speakWave .6s ease-in-out infinite; }
@keyframes speakWave {
  0%, 100% { box-shadow: 0 0 0 0 rgba(124, 198, 255, .5); }
  50% { box-shadow: 0 0 0 7px rgba(124, 198, 255, 0); }
}

.timebar {
  height: 4px; border-radius: 999px;
  background: rgba(255, 255, 255, .1);
  overflow: hidden;
  margin: 4px 0 9px;
}
.timebar i {
  display: block; height: 100%; width: 100%;
  transform-origin: left center;
  background: linear-gradient(90deg, #6ee7b7, #7cc6ff);
  transition: transform .12s linear, background .3s;
}
.timebar i.warn { background: linear-gradient(90deg, #ffb46b, #ff4d6d); }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.options.one-col { grid-template-columns: 1fr; }

.opt {
  position: relative;
  min-height: 50px;
  padding: 10px 12px 10px 24px;
  border-radius: 13px;
  background: linear-gradient(170deg, rgba(255, 255, 255, .12), rgba(255, 255, 255, .06));
  border: 1px solid rgba(255, 255, 255, .16);
  font-size: 16px; font-weight: 800;
  line-height: 1.2;
  display: flex; align-items: center; justify-content: center;
  gap: 6px;
  transition: transform .1s, background .2s, border-color .2s, opacity .2s;
  word-break: break-word;
}
.opt.en { font-family: var(--font-en); letter-spacing: .01em; }
.opt .idx {
  position: absolute;
  left: 7px; top: 50%;
  transform: translateY(-50%);
  width: 13px; height: 13px;
  display: grid; place-items: center;
  border-radius: 4px;
  font-size: 8.5px; font-weight: 800;
  line-height: 1;
  color: rgba(255, 255, 255, .6);
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .12);
}
.opt.no-idx { padding: 10px 12px; }
.opt:active { transform: scale(.97); }
.opt.correct {
  background: linear-gradient(170deg, rgba(110, 231, 183, .42), rgba(67, 214, 164, .22));
  border-color: #6ee7b7;
  box-shadow: 0 0 0 1px rgba(110, 231, 183, .4), 0 6px 20px rgba(67, 214, 164, .3);
  animation: popOk .35s ease-out;
}
.opt.wrong {
  background: linear-gradient(170deg, rgba(255, 122, 156, .4), rgba(255, 77, 109, .2));
  border-color: #ff7a9c;
  animation: shakeX .4s ease-out;
}
.opt.dim { opacity: .35; }
@keyframes popOk { 0% { transform: scale(1); } 45% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes shakeX {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  60% { transform: translateX(6px); }
  80% { transform: translateX(-3px); }
}

.feedback {
  min-height: 26px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 12px; font-weight: 800;
  padding: 4px 0 0;
  opacity: 0;
  transition: opacity .2s;
}
.feedback.show { opacity: 1; }
.feedback.ok { color: var(--mint); }
.feedback.no { color: #ff9db4; }
.feedback small { font-weight: 600; color: var(--muted); font-size: 11px; }

/* 攻击按钮 */
.attack-dock {
  flex: 0 0 auto;
  padding: 6px 14px calc(10px + env(safe-area-inset-bottom));
}
.attack-btn {
  width: 100%;
  height: 52px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .06);
  border: 1px dashed rgba(255, 255, 255, .22);
  color: var(--dim);
  font-size: 15px; font-weight: 800;
  letter-spacing: .04em;
  transition: transform .12s, background .25s, color .25s, box-shadow .25s;
}
.attack-btn .atk-pct { font-size: 12px; opacity: .8; font-variant-numeric: tabular-nums; }
.attack-btn.ready {
  background: linear-gradient(135deg, #ffe27a, #ffd451 40%, #ff9f43);
  color: #3d2503;
  border: 0;
  box-shadow: 0 10px 30px rgba(255, 165, 60, .5), 0 0 0 3px rgba(255, 212, 81, .18);
  animation: atkPulse 1.05s ease-in-out infinite;
}
.attack-btn.ready .atk-pct { display: none; }
.attack-btn.ready:active { transform: scale(.97); }
@keyframes atkPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 10px 30px rgba(255, 165, 60, .45), 0 0 0 3px rgba(255, 212, 81, .14); }
  50% { transform: scale(1.018); box-shadow: 0 10px 40px rgba(255, 185, 70, .7), 0 0 0 8px rgba(255, 212, 81, .1); }
}
.attack-btn:disabled { cursor: default; }

/* ---- 战斗特效 ---- */
.fx-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

.beam {
  position: absolute;
  width: 30px;
  transform-origin: 50% 100%;
  background: linear-gradient(to top, rgba(255, 255, 255, 0) 0%, rgba(167, 139, 250, .85) 12%, #ffffff 55%, #ffe27a 100%);
  border-radius: 999px;
  filter: blur(2px) saturate(1.3);
  animation: beamUp .5s cubic-bezier(.2, .9, .3, 1) forwards;
  mix-blend-mode: screen;
  opacity: 0;
}
.beam.thick { width: 46px; }
@keyframes beamUp {
  0% { transform: rotate(var(--ang, 0deg)) scaleY(0) scaleX(.4); opacity: 0; }
  20% { opacity: 1; }
  55% { transform: rotate(var(--ang, 0deg)) scaleY(1) scaleX(1); opacity: 1; }
  100% { transform: rotate(var(--ang, 0deg)) scaleY(1) scaleX(.5); opacity: 0; }
}

.impact {
  position: absolute;
  left: 50%; top: 46%;
  width: 24px; height: 24px;
  margin: -12px 0 0 -12px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, #ffe27a 40%, rgba(255, 159, 67, 0) 70%);
  animation: impactBurst .55s ease-out forwards;
}
@keyframes impactBurst {
  0% { transform: scale(.2); opacity: 1; }
  55% { transform: scale(9); opacity: .85; }
  100% { transform: scale(14); opacity: 0; }
}

.ring {
  position: absolute;
  left: 50%; top: 46%;
  width: 40px; height: 40px;
  margin: -20px 0 0 -20px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, .9);
  animation: ringOut .6s ease-out forwards;
}
@keyframes ringOut {
  0% { transform: scale(.3); opacity: 1; }
  100% { transform: scale(5); opacity: 0; }
}

.dmg {
  position: absolute;
  left: 50%; top: 26%;
  transform: translateX(-50%);
  font-family: var(--font-en);
  font-size: 40px; font-weight: 900;
  color: #fff;
  letter-spacing: .01em;
  text-shadow:
    0 0 4px rgba(0, 0, 0, .9),
    2px 2px 0 rgba(96, 32, 0, .95), -2px 2px 0 rgba(96, 32, 0, .95),
    2px -2px 0 rgba(96, 32, 0, .95), -2px -2px 0 rgba(96, 32, 0, .95),
    0 5px 14px rgba(255, 170, 40, .8);
  animation: dmgFloat 1s cubic-bezier(.2, .8, .3, 1) forwards;
  white-space: nowrap;
}
.dmg.crit { font-size: 52px; color: #ffe27a; }
.dmg.crit::after {
  content: '暴击!';
  display: block;
  font-size: 12px;
  text-align: center;
  color: #ffd451;
  letter-spacing: .2em;
  margin-top: -4px;
  font-family: var(--font);
  text-shadow: 0 2px 6px rgba(0, 0, 0, .8);
}
@keyframes dmgFloat {
  0% { transform: translateX(-50%) scale(.4) translateY(0); opacity: 0; }
  25% { transform: translateX(-50%) scale(1.25) translateY(-12px); opacity: 1; }
  55% { transform: translateX(-50%) scale(1) translateY(-26px); opacity: 1; }
  100% { transform: translateX(-50%) scale(.9) translateY(-62px); opacity: 0; }
}

.pdot {
  position: absolute;
  left: 50%; top: 46%;
  width: 7px; height: 7px; border-radius: 50%;
  animation: pdotOut .7s ease-out forwards;
}
@keyframes pdotOut {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; }
}

.toast {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%) scale(.7);
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .72);
  border: 1px solid rgba(255, 212, 81, .5);
  color: var(--gold);
  font-size: 14px; font-weight: 800;
  letter-spacing: .06em;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.flash {
  position: fixed; inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 60;
  animation: flashOut .3s ease-out forwards;
}
@keyframes flashOut { 0% { opacity: .26; } 100% { opacity: 0; } }

/* ---------------- 结算 ---------------- */
#screen-result { justify-content: center; overflow-y: auto; }

.result-card {
  position: relative;
  padding: 22px 18px 18px;
  border-radius: 24px;
  background: linear-gradient(170deg, rgba(255, 255, 255, .13), rgba(255, 255, 255, .05));
  border: 1px solid var(--line);
  box-shadow: 0 22px 60px rgba(0, 0, 0, .45);
  text-align: center;
  animation: cardIn .4s cubic-bezier(.2, .9, .3, 1) both;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(18px) scale(.96); }
  to { opacity: 1; transform: none; }
}
.result-card.lose { border-color: rgba(255, 122, 156, .35); }

.result-badge {
  font-size: 44px;
  line-height: 1;
  animation: badgePop .6s cubic-bezier(.2, 1.6, .4, 1) both;
}
@keyframes badgePop {
  0% { transform: scale(0) rotate(-40deg); }
  100% { transform: scale(1) rotate(0); }
}

.result-card h2 {
  margin: 6px 0 4px;
  font-size: 26px;
  letter-spacing: .06em;
  background: linear-gradient(180deg, #fff, #ffd451);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.stars { display: flex; justify-content: center; gap: 6px; margin: 4px 0 8px; min-height: 30px; }
.stars i {
  font-style: normal; font-size: 26px;
  color: rgba(255, 255, 255, .15);
  transform: scale(.6);
}
.stars i.on {
  color: var(--gold);
  text-shadow: 0 0 18px rgba(255, 212, 81, .85);
  animation: starPop .5s cubic-bezier(.2, 1.6, .4, 1) both;
}
.stars i.on:nth-child(2) { animation-delay: .14s; }
.stars i.on:nth-child(3) { animation-delay: .28s; }
@keyframes starPop {
  0% { transform: scale(0) rotate(-60deg); }
  70% { transform: scale(1.35) rotate(8deg); }
  100% { transform: scale(1) rotate(0); }
}

.res-sub { margin: 0 0 14px; font-size: 12.5px; color: var(--muted); line-height: 1.5; }

.res-stats {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.res-stats div {
  padding: 9px 8px;
  border-radius: 13px;
  background: rgba(0, 0, 0, .25);
  border: 1px solid rgba(255, 255, 255, .07);
  display: flex; flex-direction: column; gap: 2px;
}
.res-stats span { font-size: 10px; color: var(--muted); }
.res-stats b { font-size: 17px; font-variant-numeric: tabular-nums; }
.res-stats b.gold { color: var(--gold); }

.res-words {
  max-height: 108px;
  overflow-y: auto;
  display: flex; flex-wrap: wrap; gap: 5px;
  justify-content: center;
  margin-bottom: 14px;
}
.res-words:empty { display: none; }
.word-chip {
  font-size: 10.5px; font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 122, 156, .15);
  border: 1px solid rgba(255, 122, 156, .3);
  color: #ffb3c6;
}
.res-label { width: 100%; font-size: 10px; color: var(--dim); margin-bottom: 2px; }

.res-actions { display: flex; gap: 9px; }
.res-actions .btn { flex: 1; }
.res-home { margin-top: 14px; font-size: 11px; color: var(--dim); text-decoration: none; }

/* ---------------- 商店 ---------------- */
.shop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

.shop-card {
  padding: 12px 11px;
  border-radius: 16px;
  background: linear-gradient(165deg, rgba(255, 255, 255, .1), rgba(255, 255, 255, .035));
  border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 7px;
  text-align: left;
  transition: transform .12s, border-color .2s;
}
.shop-card:active { transform: scale(.98); }
.shop-card.max { border-color: rgba(255, 212, 81, .45); }
.shop-ico {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 24px;
  background: rgba(0, 0, 0, .28);
  border: 1px solid rgba(255, 255, 255, .08);
}
.shop-name { font-size: 13.5px; font-weight: 800; }
.shop-desc { font-size: 10px; color: var(--muted); line-height: 1.35; min-height: 26px; }
.pips { display: flex; gap: 3px; }
.pips i {
  flex: 1; height: 4px; border-radius: 999px;
  background: rgba(255, 255, 255, .12);
}
.pips i.on { background: linear-gradient(90deg, #ffd451, #ff9f43); box-shadow: 0 0 8px rgba(255, 180, 60, .6); }
.shop-effect { font-size: 10.5px; font-weight: 700; color: var(--mint); }
.buy-btn {
  margin-top: auto;
  width: 100%;
  padding: 8px 6px;
  border-radius: 10px;
  background: rgba(255, 212, 81, .16);
  border: 1px solid rgba(255, 212, 81, .35);
  color: var(--gold);
  font-size: 11.5px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.buy-btn:active { transform: scale(.97); }
.buy-btn.no { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .12); color: var(--dim); }
.buy-btn.done { background: rgba(110, 231, 183, .14); border-color: rgba(110, 231, 183, .3); color: var(--mint); }
.shop-foot { margin: 14px 2px 4px; font-size: 10.5px; color: var(--dim); line-height: 1.5; }

/* ---------------- 词库 ---------------- */
.import-box {
  padding: 12px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  margin-bottom: 12px;
}
.import-box textarea {
  width: 100%;
  height: 96px;
  padding: 10px;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(0, 0, 0, .32);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.55;
  resize: vertical;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}
.import-box textarea::placeholder { color: rgba(255, 255, 255, .28); }
.import-box textarea:focus { border-color: rgba(124, 198, 255, .6); }
.import-actions { display: flex; gap: 8px; margin-top: 8px; }
.import-actions .btn { flex: 1; padding: 11px; font-size: 13px; }
.import-msg { margin: 8px 0 0; font-size: 11px; color: var(--mint); min-height: 14px; line-height: 1.4; }
.import-msg.err { color: #ff9db4; }

.word-extra { margin-bottom: 10px; }
.word-extra .review-card { margin-bottom: 0; }

.chapter-words { display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; }
.wgroup {
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  overflow: hidden;
}
.wgroup summary {
  padding: 11px 12px;
  list-style: none;
  font-size: 13px; font-weight: 800;
  cursor: pointer; list-style: none;
  display: flex; align-items: center; gap: 8px;
}
.wgroup summary::-webkit-details-marker { display: none; }
.wgroup summary::marker { content: ''; }
.wgroup summary::after { content: '▾'; margin-left: 6px; opacity: .5; font-size: 11px; transition: transform .2s; }
.wgroup[open] summary::after { transform: rotate(180deg); }
.wgroup summary .wg-emoji { flex: 0 0 auto; font-size: 14px; }
.wgroup summary .wg-name {
  flex: 1 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wgroup summary .cnt { flex: 0 0 auto; margin-left: 4px; font-size: 10px; color: var(--muted); font-weight: 600; }
.wlist { padding: 0 12px 10px; display: flex; flex-wrap: wrap; gap: 5px; }
.wlist span {
  font-size: 10.5px;
  padding: 3px 7px;
  border-radius: 7px;
  background: rgba(0, 0, 0, .22);
  color: rgba(255, 255, 255, .78);
  border: 1px solid rgba(255, 255, 255, .06);
}
.wlist span b { color: var(--sky); font-family: var(--font-en); margin-right: 3px; }

/* ---------------- 弹窗 ---------------- */
.modal {
  position: fixed; inset: 0;
  z-index: 50;
  display: grid; place-items: center;
  padding: 24px;
  background: rgba(8, 4, 18, .72);
  backdrop-filter: blur(4px);
  animation: fadeIn .2s ease-out;
}
.modal[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  width: 100%; max-width: 320px;
  padding: 18px;
  border-radius: 18px;
  background: linear-gradient(170deg, #33245c, #221741);
  border: 1px solid rgba(255, 255, 255, .16);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
  text-align: center;
  animation: cardIn .28s cubic-bezier(.2, .9, .3, 1) both;
}
.modal-card h3 { margin: 0 0 8px; font-size: 17px; }
.modal-card p { margin: 0 0 16px; font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.modal-actions { display: flex; gap: 9px; }
.modal-actions .btn { flex: 1; padding: 11px; font-size: 13.5px; }

/* ---------------- 小屏适配 ---------------- */
@media (max-height: 700px) {
  .howto { padding: 7px; margin-bottom: 8px; }
  .home-monster svg { width: min(38vw, 158px); }
  .game-title { font-size: clamp(32px, 10.5vw, 44px); }
  .q-word { font-size: clamp(21px, 6.8vw, 27px); }
  .quiz { padding-top: 4px; }
  .opt { min-height: 44px; font-size: 15px; }
  .attack-btn { height: 46px; }
  .arena { min-height: 118px; padding-bottom: 46px; }
  .home-stats { display: none; }
  .monster-art svg { width: min(38vw, 150px); }
  .hero-art { width: 54px; height: 54px; }
  .speech { font-size: 10.5px; padding: 4px 9px; }
}

@media (max-height: 600px) {
  .monster-art svg { width: min(30vw, 112px); }
  .hero-art { width: 46px; height: 46px; }
  .hpbar { width: 158px; height: 15px; }
  .quiz-meta { margin-bottom: 1px; }
  .q-main { min-height: 38px; }
  .feedback { min-height: 18px; font-size: 11px; }
  .attack-btn { height: 42px; font-size: 14px; }
  .arena { min-height: 104px; padding-bottom: 40px; }
}

@media (max-height: 600px) {
  .home-monster { display: none; }
  .quiz { padding-top: 4px; }
}

@media (min-width: 640px) {
  body { display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 50% 30%, #1b1133, #08040f 70%); }
  .game-shell {
    height: min(920px, 100dvh);
    border-radius: 26px;
    box-shadow: 0 30px 90px rgba(0, 0, 0, .75), 0 0 0 1px rgba(255, 255, 255, .06);
  }
}
