/* ===================================================
   ui.css —— 按钮、弹窗、地图、剧情、结算、勋章、错题本
   =================================================== */

/* ---------------- 按钮 ---------------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: var(--border-w) solid var(--ink);
  border-radius: 20px;
  font-family: var(--font);
  font-weight: 900;
  font-size: 19px;
  letter-spacing: 1px;
  color: #fff;
  padding: 12px 26px;
  cursor: pointer;
  background: var(--blue);
  box-shadow: 0 6px 0 var(--blue-d), 0 10px 16px rgba(54, 48, 77, 0.2);
  transition: transform 0.07s ease, box-shadow 0.07s ease, filter 0.15s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); }
.btn:active {
  transform: translateY(5px);
  box-shadow: 0 1px 0 var(--blue-d), 0 2px 6px rgba(54, 48, 77, 0.18);
}
.btn:disabled {
  filter: grayscale(0.7) opacity(0.6);
  cursor: not-allowed;
  transform: none;
}

.btn-lg { font-size: 22px; padding: 15px 34px; border-radius: 24px; }
.btn-mini { font-size: 15px; padding: 8px 16px; border-radius: 14px; border-width: 3px; }
.btn-crab   { background: var(--crab);   box-shadow: 0 6px 0 var(--crab-d),   0 10px 16px rgba(54, 48, 77, 0.2); }
.btn-crab:active { box-shadow: 0 1px 0 var(--crab-d); }
.btn-sun    { background: var(--sun);    color: var(--ink); box-shadow: 0 6px 0 var(--sun-d),    0 10px 16px rgba(54, 48, 77, 0.2); }
.btn-sun:active { box-shadow: 0 1px 0 var(--sun-d); }
.btn-purple { background: var(--purple); box-shadow: 0 6px 0 var(--purple-d), 0 10px 16px rgba(54, 48, 77, 0.2); }
.btn-purple:active { box-shadow: 0 1px 0 var(--purple-d); }
.btn-mint   { background: var(--mint);   color: var(--ink); box-shadow: 0 6px 0 #2fae90, 0 10px 16px rgba(54, 48, 77, 0.2); }
.btn-ghost  {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 5px 0 rgba(54, 48, 77, 0.35), 0 8px 14px rgba(54, 48, 77, 0.14);
}
.btn-ghost:active { box-shadow: 0 1px 0 rgba(54, 48, 77, 0.35); }

.btn-link {
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 800;
  color: var(--purple-d);
  text-decoration: underline;
  cursor: pointer;
  padding: 4px 6px;
}
.btn-link:hover { color: var(--crab); }

/* 弹窗按钮支持纵向排列 */
.btn-col { flex-direction: column; }

/* ---------------- 关卡地图 ---------------- */
#screen-map { z-index: 1; }
.map-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 4px 20px;
  display: flex;
  justify-content: center;
}
.map-path {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
  padding: 18px 0;
  width: min(560px, 100%);
}
.map-line {
  position: absolute;
  left: 50%;
  top: 40px;
  bottom: 40px;
  width: 10px;
  margin-left: -5px;
  border-radius: 999px;
  background: repeating-linear-gradient(
    180deg,
    rgba(54, 48, 77, 0.22) 0 14px,
    transparent 14px 28px
  );
  z-index: 0;
}

.lv-node {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 460px;
  padding: 14px 18px;
  border: var(--border-w) solid var(--ink);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
  text-align: left;
  font-family: var(--font);
  color: var(--ink);
}
.lv-node:nth-child(even) { transform: translateX(-26px); }
.lv-node:nth-child(odd)  { transform: translateX(26px); }
.lv-node:hover { box-shadow: 0 14px 0 rgba(54, 48, 77, 0.16), 0 22px 34px rgba(54, 48, 77, 0.22); }
.lv-node:nth-child(even):hover { transform: translateX(-26px) translateY(-4px); }
.lv-node:nth-child(odd):hover  { transform: translateX(26px) translateY(-4px); }

.lv-node.locked {
  filter: grayscale(0.85);
  opacity: 0.68;
  cursor: not-allowed;
}
.lv-node.locked::after {
  content: "🔒 先通过上一关";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.9);
  padding: 3px 8px;
  border-radius: 999px;
}
.lv-node.cleared { background: linear-gradient(180deg, #fffdf0, #fff3cf); }

.lv-node .node-icon {
  flex: 0 0 auto;
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  font-size: 34px;
  border-radius: 18px;
  border: 3px solid var(--ink);
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.08);
}
.lv-node .node-main { flex: 1 1 auto; min-width: 0; }
.lv-node .node-step {
  display: inline-block;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #fff;
  background: var(--ink);
  border-radius: 999px;
  padding: 2px 10px;
  margin-bottom: 4px;
}
.lv-node .node-name {
  font-size: 19px;
  font-weight: 900;
  line-height: 1.25;
}
.lv-node .node-sub {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-top: 2px;
}
.lv-node .node-stars {
  flex: 0 0 auto;
  font-size: 17px;
  letter-spacing: 1px;
}
.lv-node.pulse { animation: nodePulse 1.4s ease-in-out infinite; }
@keyframes nodePulse {
  0%, 100% { box-shadow: var(--shadow-card); }
  50% { box-shadow: 0 12px 0 rgba(54,48,77,.13), 0 0 0 10px rgba(255, 217, 61, 0.45), 0 18px 34px rgba(54, 48, 77, 0.2); }
}

/* ---------------- 剧情播放 ---------------- */
#screen-story { justify-content: flex-end; padding: 0; z-index: 3; }
.story-stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.story-bg {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 30%, rgba(255,255,255,.75), rgba(180, 230, 255, 0.5) 55%, rgba(150, 220, 255, 0.75));
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
/* 插画淡入换场 */
.story-bg.swap { animation: storyBgIn 0.5s ease both; }
@keyframes storyBgIn {
  from { opacity: 0.2; transform: scale(1.04); }
  to   { opacity: 1; transform: scale(1); }
}

/* 漂浮的小气泡 */
.story-bubbles {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.story-bubbles.show { opacity: 1; }
.story-bubbles .bub {
  position: absolute;
  bottom: -14%;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.9);
  background: radial-gradient(circle at 32% 26%,
    rgba(255, 255, 255, 0.96) 0%,
    rgba(200, 240, 255, 0.46) 42%,
    rgba(150, 215, 255, 0.18) 68%,
    rgba(150, 215, 255, 0.05) 100%);
  box-shadow: inset -3px -4px 8px rgba(150, 210, 255, 0.45), 0 0 10px rgba(255, 255, 255, 0.35);
  animation: bubbleRise 7s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  will-change: transform, opacity;
}
@keyframes bubbleRise {
  0%   { transform: translate3d(0, 0, 0) scale(0.5); opacity: 0; }
  10%  { opacity: 0.95; }
  45%  { transform: translate3d(var(--sway, 14px), calc(var(--rise, 90vh) * -0.42), 0) scale(0.95); }
  75%  { opacity: 0.85; }
  100% { transform: translate3d(calc(var(--sway, 14px) * -0.6), calc(var(--rise, 90vh) * -1), 0) scale(1.15); opacity: 0; }
}

/* 池水变浅：水位下降，露出滩涂 */
.story-shallow {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.8s ease;
}
.story-shallow.show { opacity: 1; }

/* 剩下的那层浅水：更薄更透亮 */
.sh-tint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 24%;
  background: linear-gradient(180deg,
    rgba(214, 250, 255, 0) 0%,
    rgba(216, 251, 255, 0.3) 55%,
    rgba(230, 253, 255, 0.42) 100%);
}
/* 退水后露出的整片滩涂：盖住原来的水面和倒影，水面就“退”下去了 */
.sh-bed {
  position: absolute;
  left: -2%;
  right: -2%;
  bottom: 19.6%;
  height: 15%;
  background: linear-gradient(180deg,
    rgba(214, 180, 126, 0.34) 0%,
    rgba(205, 168, 112, 0.66) 44%,
    rgba(191, 152, 96, 0.78) 100%);
  filter: blur(6px);
}
/* 岸边新淤出来的泥滩 */
.sh-bar {
  position: absolute;
  border-radius: 50%;
  filter: blur(7px);
}
.sh-bar.b1 {
  left: -6%;
  bottom: 11%;
  width: 48%;
  height: 18%;
  transform: rotate(-3deg);
  background: radial-gradient(ellipse at 42% 60%,
    rgba(208, 170, 112, 0.88) 0%,
    rgba(199, 161, 105, 0.58) 55%,
    rgba(196, 158, 104, 0) 100%);
}
.sh-bar.b2 {
  left: 42%;
  bottom: 8%;
  width: 30%;
  height: 12%;
  transform: rotate(2deg);
  background: radial-gradient(ellipse at 50% 60%,
    rgba(206, 168, 110, 0.66) 0%,
    rgba(198, 160, 104, 0) 100%);
}
/* 下降后的新水面线 */
.sh-line {
  position: absolute;
  left: -2%;
  right: 2%;
  bottom: 19.2%;
  height: 4px;
  border-radius: 50%;
  transform: rotate(-0.9deg);
  background: linear-gradient(90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.9) 10%,
    rgba(235, 252, 255, 0.72) 55%,
    rgba(255, 255, 255, 0) 100%);
  box-shadow: 0 -4px 10px rgba(150, 226, 255, 0.6);
  filter: blur(1.4px);
}
/* 露出的河床上散着几颗小石子 */
.sh-pebbles {
  position: absolute;
  width: 8px;
  height: 6px;
  border-radius: 50%;
  background: rgba(182, 145, 92, 0.85);
  box-shadow:
    26px -6px 0 rgba(166, 130, 80, 0.85),
    58px 4px 0 rgba(190, 152, 98, 0.8),
    96px -10px 0 rgba(172, 136, 86, 0.8),
    132px 2px 0 rgba(184, 146, 92, 0.75),
    164px -8px 0 rgba(168, 132, 82, 0.7);
  filter: blur(0.4px);
}
.sh-pebbles.p1 { left: 12%; bottom: 26%; }
.sh-pebbles.p2 { left: 34%; bottom: 23%; opacity: 0.8; transform: rotate(6deg) scale(0.8); }
/* 水浅了，涟漪一圈圈小下去 */
.sh-ripple {
  position: absolute;
  width: 60px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(160, 230, 255, 0.5);
  animation: shRipple 3.4s ease-out infinite;
}
.sh-ripple.r1 { left: 12%; bottom: 12%; }
.sh-ripple.r2 { left: 25%; bottom: 6%; animation-delay: 1.7s; }
@keyframes shRipple {
  0%   { transform: scale(0.3); opacity: 0; }
  30%  { opacity: 0.9; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* 鼓声响起：小动物们跟着节奏跳舞 */
.story-dance {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.story-dance.show { opacity: 1; }
.story-dance span {
  position: absolute;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.9);
  overflow: hidden;
  box-shadow: 0 8px 18px rgba(20, 24, 46, 0.35);
  opacity: 0;
}
.story-dance.show span { opacity: 1; }
.dn-lion {
  left: 42%;
  bottom: 22%;
  width: min(13vw, 128px);
  height: min(13vw, 128px);
  animation: danceBob 0.8s ease-in-out infinite;
}
.dn-turtle {
  left: 61%;
  bottom: 20%;
  width: min(11vw, 108px);
  height: min(11vw, 108px);
  animation: danceBob 0.8s ease-in-out 0.22s infinite;
}
.dn-bird {
  left: 76%;
  bottom: 28%;
  width: min(9vw, 88px);
  height: min(9vw, 88px);
  animation: danceHop 0.8s ease-in-out 0.44s infinite;
}
@keyframes danceBob {
  0%, 100% { transform: translateY(0) rotate(-5deg) scale(1); }
  50%      { transform: translateY(-14px) rotate(5deg) scale(1.06); }
}
@keyframes danceHop {
  0%, 100% { transform: translateY(0) rotate(-9deg); }
  50%      { transform: translateY(-18px) rotate(9deg); }
}

/* 深坑：小乌龟掉进坑里爬不上来，小螃蟹急忙爬过来 */
.story-pit {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.story-pit.show { opacity: 1; }
.pt-crab {
  position: absolute;
  left: 10%;
  bottom: 21%;
  width: min(9vw, 88px);
  height: min(9vw, 88px);
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.94);
  overflow: hidden;
  opacity: 0;
}
.story-pit.show .pt-crab {
  opacity: 1;
  animation: ptRush 1.6s ease-in-out infinite;
}
@keyframes ptRush {
  0%, 100% { transform: translate(0, 0) rotate(-6deg); }
  50%      { transform: translate(14px, -8px) rotate(6deg); }
}
.pt-hole {
  position: absolute;
  left: 40%;
  bottom: 17%;
  width: min(28vw, 300px);
  height: 118px;
  border-radius: 50%;
  overflow: hidden;
  opacity: 0;
  background: radial-gradient(ellipse at 50% 42%, #4a3550 0%, #2e2136 55%, #1c1425 100%);
  box-shadow: inset 0 14px 22px rgba(0, 0, 0, 0.55);
}
.story-pit.show .pt-hole { opacity: 1; }
.pt-turtle {
  position: absolute;
  left: 12%;
  bottom: 8px;
  width: 42%;
  height: 84px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.85);
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  animation: ptClimb 2.6s ease-in-out infinite;
}
/* 小螃蟹旁边的一捆绳子 */
.pt-rope {
  position: absolute;
  left: 21%;
  bottom: 20%;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid #a8713d;
  background: repeating-radial-gradient(circle, #e7b876 0 5px, #c98f4e 5px 10px);
  box-shadow: 0 5px 10px rgba(54, 48, 77, 0.25);
  opacity: 0;
}
.story-pit.show.rope .pt-rope { opacity: 1; }
.pt-rope i {
  position: absolute;
  right: -13px;
  top: 46%;
  width: 26px;
  height: 8px;
  border-radius: 6px;
  background: #c98f4e;
  transform: rotate(18deg);
}
  0%, 100% { transform: translateY(0) rotate(-10deg); }
  40%      { transform: translateY(-20px) rotate(8deg); }
}
.story-meadow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.story-meadow.show { opacity: 1; }
.md-crab {
  position: absolute;
  left: 7%;
  bottom: 21%;
  width: min(9vw, 88px);
  height: min(9vw, 88px);
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.94);
  overflow: hidden;
  box-shadow: 0 6px 14px rgba(54, 48, 77, 0.24);
  opacity: 0;
}
.story-meadow.show .md-crab {
  opacity: 1;
  animation: mdCrawl 2.2s ease-in-out infinite;
}
@keyframes mdCrawl {
  0%, 100% { transform: translate(0, 0) rotate(-6deg); }
  50%      { transform: translate(16px, -9px) rotate(5deg); }
}

/* 一滩水：狮子低头照的那面“镜子” */
.md-puddle {
  position: absolute;
  left: 33%;
  bottom: 18%;
  width: min(29vw, 310px);
  height: 96px;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(158, 214, 235, 0.85), rgba(120, 186, 214, 0.95));
  box-shadow: 0 0 0 5px rgba(206, 235, 219, 0.55), 0 6px 14px rgba(60, 100, 90, 0.18);
  opacity: 0;
}
.story-meadow.show .md-puddle { opacity: 1; }
/* 水里的倒影：狮子上下颠倒、发虚，随着水波轻轻晃 */
.md-reflect {
  position: absolute;
  left: 14%;
  border-radius: 50%;
  overflow: hidden;
  top: 2px;
  width: 52%;
  height: 132%;
  transform: scaleY(-1);
  filter: blur(1px) saturate(0.85) brightness(0.98);
  opacity: 0.62;
  animation: mdMirror 3.6s ease-in-out infinite;
}
@keyframes mdMirror {
  0%, 100% { transform: scaleY(-1) translateX(0); opacity: 0.6; }
  50%      { transform: scaleY(-1) translateX(5px); opacity: 0.72; }
}
.md-ripple {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 40%;
  height: 60%;
  margin: -30% 0 0 -20%;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.75);
  animation: mdRipple 3.2s ease-out infinite;
}
.md-ripple.r2 { animation-delay: 1.6s; }
@keyframes mdRipple {
  0%   { transform: scale(0.4); opacity: 0; }
  35%  { opacity: 0.75; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* 照水的狮子：蓬头散发、愁眉苦脸，低头看着水面叹口气 */
.md-lion {
  position: absolute;
  left: 53%;
  bottom: 17%;
  width: min(23vw, 224px);
  height: min(23vw, 224px);
  border-radius: 50%;
  border: 5px solid rgba(255, 255, 255, 0.94);
  overflow: hidden;
  box-shadow: 0 10px 22px rgba(54, 48, 77, 0.24);
  opacity: 0;
}
.story-meadow.show .md-lion {
  opacity: 1;
  animation: mdSigh 4.2s ease-in-out infinite;
}
/* 低头凑到水边照自己：整体往水潭那边倾 */
@keyframes mdSigh {
  0%, 100% { transform: translateY(2px) rotate(-11deg); }
  50%      { transform: translateY(-2px) rotate(-7deg); }
}

/* 池塘边的小泥洞：小螃蟹和小青蟹的家 */
.story-burrow {
  --bs-from: 0.86;
  --bs-to: 1;
  position: absolute;
  left: 4.5%;
  bottom: 25%;
  z-index: 1;
  width: 200px;
  height: 152px;
  transform-origin: left bottom;
  pointer-events: none;
  opacity: 0;
  transform: translateY(18px) scale(var(--bs-from));
  transition: opacity 0.45s ease, transform 0.55s cubic-bezier(0.22, 1.4, 0.5, 1);
}
.story-burrow.show {
  opacity: 1;
  transform: translateY(0) scale(var(--bs-to));
}

/* 洞口的草坡，让小泥洞落在岸边而不是浮在水上 */
.burrow-ground {
  position: absolute;
  left: -8%;
  right: -8%;
  bottom: -4px;
  height: 54px;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 42%, #a9e37f 0%, #79cc60 55%, rgba(110, 195, 90, 0) 100%);
}
/* 土堆 */
.burrow-mound {
  position: absolute;
  left: 7%;
  right: 7%;
  bottom: 4px;
  height: 92px;
  border-radius: 50% 50% 34% 34% / 78% 78% 22% 22%;
  background: radial-gradient(ellipse at 50% 14%, #e2b57c 0%, #bf8c53 48%, #8f6335 100%);
  box-shadow: 0 8px 0 rgba(96, 64, 32, 0.22), inset 0 -8px 12px rgba(88, 57, 26, 0.4),
    inset 0 7px 10px rgba(255, 238, 205, 0.5);
}
/* 洞口 */
.burrow-hole {
  position: absolute;
  left: 50%;
  bottom: 16px;
  width: 88px;
  height: 62px;
  margin-left: -44px;
  border-radius: 50% 50% 44% 44% / 62% 62% 38% 38%;
  background: radial-gradient(ellipse at 50% 26%, #4a2d14 0%, #2a1809 58%, #150c03 100%);
  box-shadow: 0 5px 0 rgba(255, 236, 200, 0.35), inset 0 10px 16px rgba(0, 0, 0, 0.8);
  overflow: hidden;
}
/* 住在洞里的小螃蟹和小青蟹 */
.burrow-crab {
  position: absolute;
  bottom: -2px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.92);
  overflow: hidden;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
  animation: peekBob 2.6s ease-in-out infinite;
}
.burrow-crab.crab-a { left: 0; }
.burrow-crab.crab-b { right: 0; animation-delay: 1.3s; }
@keyframes peekBob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}
/* 洞口小草 */
.burrow-grass {
  position: absolute;
  bottom: 8px;
  width: 11px;
  height: 30px;
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  background: linear-gradient(180deg, #9ceb7d, #4fae44);
  transform-origin: bottom center;
}
.burrow-grass.g1 { left: 0; transform: rotate(-14deg); }
.burrow-grass.g2 { right: -2px; height: 24px; transform: rotate(12deg); }
/* 小木牌 */
.burrow-sign {
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translateX(-50%) rotate(-3deg);
  padding: 3px 10px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #fff8e2;
  background: linear-gradient(180deg, #c48f56, #9a6a37);
  border: 2px solid #5f3f1f;
  border-radius: 8px;
  white-space: nowrap;
  box-shadow: 0 3px 0 rgba(70, 45, 20, 0.35);
}
.burrow-sign::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -15px;
  width: 5px;
  height: 16px;
  margin-left: -2.5px;
  border-radius: 2px;
  background: linear-gradient(180deg, #a8763f, #7d5227);
}
/* 小青蟹爬出洞口，和小螃蟹挥手道别 */
.burrow-crab { transition: opacity 0.35s ease, left 0.5s ease, margin-left 0.5s ease; }
.story-burrow.bye .burrow-crab.crab-b { opacity: 0; }
/* 小青蟹走了：洞里只剩小螃蟹，独自待在正中 */
.story-burrow.alone .burrow-crab.crab-b { opacity: 0; }
/* 鼓声那一段：洞里只有小螃蟹，小青蟹还没回来 */
.story-burrow.nofriend .burrow-crab.crab-b { opacity: 0; }
.story-burrow.alone .burrow-crab.crab-a { left: 50%; margin-left: -22px; }
.story-burrow.nofriend .burrow-crab.crab-b { opacity: 0; }
.story-burrow.out .burrow-hole .burrow-crab.crab-a { opacity: 0; }
/* 爬出洞口、站在土堆上抬头看的小螃蟹 */
.burrow-out-crab {
  position: absolute;
  left: 128px;
  bottom: 4px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.92);
  overflow: hidden;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 0.35s ease;
  z-index: 2;
}
.story-burrow.out .burrow-out-crab {
  opacity: 1;
  animation: outLook 3.4s ease-in-out infinite;
}

/* 一个人待在池塘：小螃蟹发灰、低头叹气、眼角一滴泪 */
.story-burrow.sad .burrow-crab.crab-a {
  filter: saturate(0.4) brightness(0.92);
  animation: sadBob 4.4s ease-in-out infinite;
}
.story-burrow.sad .burrow-crab.crab-a::after {
  content: "";
  position: absolute;
  left: 62%;
  top: 48%;
  width: 7px;
  height: 11px;
  border-radius: 50% 50% 50% 50% / 66% 66% 34% 34%;
  background: linear-gradient(180deg, #d8f4ff, #66bdf2);
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.85);
  animation: tearDrop 2.9s ease-in infinite;
}

/* 天上乱飞的小纸鸟：转着圈儿乱飞乱撞，好像在生气又好像在哭 */
.story-bird {
  position: absolute;
  left: 60%;
  top: 24%;
  opacity: 0;
  transition: opacity 0.5s ease;
  width: 88px;
  height: 88px;
}
.story-bird.show {
  opacity: 1;
  animation: birdFlit 2.6s ease-in-out infinite;
}
.sb-body {
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  overflow: hidden;
  animation: birdSpin 1.4s ease-in-out infinite alternate;
}
/* 放大一点，让纸鸟在天空里看得清 */
.sb-body > img { transform: scale(1.3); }
@keyframes sadBob {
  0%, 100% { transform: translateY(1px) rotate(-4deg); }
  50%      { transform: translateY(4px) rotate(-1deg); }
}
@keyframes tearDrop {
  0%   { opacity: 0; transform: translateY(-7px) scale(0.5); }
  22%  { opacity: 1; transform: translateY(0) scale(1); }
  68%  { opacity: 0.95; transform: translateY(11px) scale(0.92); }
  100% { opacity: 0; transform: translateY(19px) scale(0.65); }
}
@keyframes birdFlit {
  0%, 100% { transform: translate(0, 0) rotate(-8deg); }
  50%      { transform: translate(12px, -20px) rotate(10deg); }
}
@keyframes outLook {
  0%, 100% { transform: translateY(0) rotate(6deg); }
  50%      { transform: translateY(-5px) rotate(-4deg); }
}
@keyframes birdSpin {
  0%   { transform: rotate(-16deg) }
  100% { transform: rotate(18deg) }
}
.story-farewell {
  position: absolute;
  right: -16px;
  bottom: 16px;
  width: 56px;
  height: 56px;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transform: translate(-14px, 10px) scale(0.7);
  transition: opacity 0.45s ease, transform 0.6s cubic-bezier(0.22, 1.5, 0.5, 1);
}
.story-farewell.show {
  opacity: 1;
  transform: translate(0, 0) scale(1);
}
.fw-shadow {
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 46px;
  height: 10px;
  margin-left: -23px;
  border-radius: 50%;
  background: rgba(76, 68, 40, 0.28);
  filter: blur(3px);
}
.fw-crab {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.94);
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(60, 48, 30, 0.4);
  transform-origin: 40% 100%;
  animation: fwWave 1.7s ease-in-out infinite;
}
@keyframes fwWave {
  0%, 100% { transform: rotate(-7deg) translateY(0); }
  25%      { transform: rotate(3deg) translateY(-5px); }
  55%      { transform: rotate(9deg) translateY(-1px); }
  80%      { transform: rotate(1deg) translateY(-4px); }
}
/* 挥动的手臂线条 */
.fw-arc {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 3px solid rgba(255, 255, 255, 0.95);
  border-color: transparent transparent rgba(255, 255, 255, 0.95) transparent;
  border-radius: 50%;
  filter: drop-shadow(0 1px 2px rgba(96, 156, 196, 0.5));
  opacity: 0;
  animation: fwArc 1.7s ease-out infinite;
}
.fw-arc.a1 { top: -4px; left: -14px; }
.fw-arc.a2 { top: 8px; left: -22px; width: 28px; height: 28px; animation-delay: 0.45s; }
@keyframes fwArc {
  0%   { opacity: 0; transform: rotate(35deg) scale(0.5); }
  35%  { opacity: 0.95; }
  100% { opacity: 0; transform: rotate(35deg) scale(1.2); }
}

@media (max-height: 620px) {
  .story-burrow { --bs-from: 0.66; --bs-to: 0.78; bottom: 27%; }
}
@media (max-height: 520px) {
  .story-burrow { --bs-from: 0.52; --bs-to: 0.62; bottom: 33%; }
}
.story-scene-icon {
  font-size: clamp(120px, 26vw, 260px);
  opacity: 0.9;
  filter: drop-shadow(0 16px 24px rgba(60, 90, 140, 0.28));
  animation: sceneFloat 4s ease-in-out infinite;
}
@keyframes sceneFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-18px) scale(1.04); }
}

.story-panel {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin: 0 18px 22px;
  padding: 20px 22px 22px;
  border: var(--border-w) solid var(--ink);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  animation: panelIn 0.3s cubic-bezier(0.22, 1.4, 0.5, 1) both;
}
@keyframes panelIn {
  from { transform: translateY(28px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.story-avatar {
  flex: 0 0 auto;
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  font-size: 42px;
  border-radius: 22px;
  border: 3px solid var(--ink);
  background: linear-gradient(180deg, #ffe9a8, #ffd93d);
  box-shadow: inset 0 -6px 0 rgba(0,0,0,.08);
  animation: avatarPop 0.4s ease both;
}
@keyframes avatarPop {
  0% { transform: scale(0.6) rotate(-12deg); }
  70% { transform: scale(1.1) rotate(6deg); }
  100% { transform: scale(1) rotate(0); }
}
.story-right { flex: 1 1 auto; min-width: 0; }
.story-name {
  display: inline-block;
  font-size: 14px;
  font-weight: 900;
  color: #fff;
  background: var(--purple);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 2px 12px;
  margin-bottom: 8px;
}
.story-text {
  margin: 0;
  font-size: clamp(17px, 2.4vw, 22px);
  font-weight: 700;
  line-height: 1.75;
  color: var(--ink);
  min-height: 60px;
  max-height: 34vh;
  overflow-y: auto;
}
.story-next {
  position: absolute;
  right: 20px;
  bottom: 14px;
  font-size: 18px;
  color: var(--crab);
  animation: nextBounce 1s ease-in-out infinite;
}
@keyframes nextBounce {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  50% { transform: translateY(6px); opacity: 1; }
}
.story-skip {
  position: absolute;
  right: 26px;
  top: 18px;
  z-index: 3;
  background: rgba(255,255,255,.85);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 14px;
}

/* ---------------- 答题 ---------------- */
#screen-quiz { z-index: 4; align-items: center; justify-content: center; }
.quiz-wrap {
  width: min(760px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.quiz-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 900;
  color: #fff;
  -webkit-text-stroke: 1.5px var(--ink);
  paint-order: stroke fill;
}
.quiz-dots { display: flex; gap: 7px; }
.quiz-dots i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: #fff;
  display: block;
}
.quiz-dots i.done { background: var(--mint); }
.quiz-dots i.wrong { background: var(--crab); }
.quiz-dots i.now { background: var(--sun); transform: scale(1.25); }

.quiz-card {
  border: var(--border-w) solid var(--ink);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-card);
  padding: 22px 22px 20px;
  overflow-y: auto;
}
.quiz-card.shake { animation: shake 0.4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-9px) rotate(-1deg); }
  75% { transform: translateX(9px) rotate(1deg); }
}
.quiz-tag {
  display: inline-block;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #fff;
  background: var(--blue);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 3px 14px;
  margin-bottom: 12px;
}
.quiz-tag.t2 { background: var(--pink); }
.quiz-tag.t3 { background: var(--purple); }

.quiz-q {
  margin: 0 0 16px;
  font-size: clamp(18px, 2.6vw, 23px);
  font-weight: 900;
  line-height: 1.6;
}
.quiz-options { display: flex; flex-direction: column; gap: 11px; }
.opt {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 16px;
  border: 3px solid var(--ink);
  border-radius: var(--radius-s);
  background: #f7f6ff;
  font-family: var(--font);
  font-size: clamp(16px, 2.2vw, 19px);
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  box-shadow: 0 5px 0 rgba(54, 48, 77, 0.22);
  transition: transform 0.08s, background 0.15s, box-shadow 0.08s;
}
.opt:hover { background: #eef4ff; }
.opt:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(54,48,77,.22); }
.opt .opt-key {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: #fff;
  font-weight: 900;
  font-size: 16px;
}
.opt.correct { background: #d8ffe7; border-color: #1f9c58; box-shadow: 0 5px 0 #1f9c58; }
.opt.correct .opt-key { background: var(--mint); }
.opt.wrong { background: #ffe2e2; border-color: #d63b3b; box-shadow: 0 5px 0 #d63b3b; }
.opt.wrong .opt-key { background: var(--crab); color: #fff; }
.opt:disabled { cursor: default; }

.quiz-feedback {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-s);
  border: 3px solid var(--ink);
  background: #fffbe6;
  animation: panelIn 0.25s ease both;
}
.quiz-feedback.ok { background: #e6fff1; }
.quiz-feedback.no { background: #ffefef; }
.fb-icon { font-size: 30px; line-height: 1; }
.fb-text strong { display: block; font-size: 17px; font-weight: 900; margin-bottom: 4px; }
.fb-text p { margin: 0; font-size: 15px; font-weight: 700; line-height: 1.6; color: var(--ink-soft); }
.quiz-next { align-self: center; margin-top: 16px; }

/* ---------------- 结算 ---------------- */
#screen-result { align-items: center; justify-content: center; z-index: 4; }
.result-wrap {
  width: min(600px, 100%);
  text-align: center;
  padding: 26px 26px 24px;
  border: var(--border-w) solid var(--ink);
  border-radius: 30px;
  background: #fff;
  box-shadow: var(--shadow-card);
  animation: panelIn 0.35s cubic-bezier(0.22, 1.4, 0.5, 1) both;
  overflow-y: auto;
  max-height: 100%;
}
.result-stars { font-size: 40px; letter-spacing: 8px; margin-bottom: 4px; }
.result-stars span { display: inline-block; animation: starPop 0.5s cubic-bezier(0.22, 1.6, 0.4, 1) both; }
@keyframes starPop {
  0% { transform: scale(0) rotate(-90deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.medal-big {
  width: 132px;
  height: 132px;
  margin: 6px auto 10px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 5px solid var(--ink);
  background: radial-gradient(circle at 34% 28%, #fff6c9, #ffd93d 55%, #f2a900);
  box-shadow: 0 8px 0 rgba(54, 48, 77, 0.25), 0 0 0 12px rgba(255, 217, 61, 0.28);
  animation: medalIn 0.7s cubic-bezier(0.22, 1.6, 0.4, 1) both;
}
@keyframes medalIn {
  0% { transform: scale(0.2) rotate(-180deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.medal-icon {
  width: 108px;
  height: 108px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  overflow: hidden;
  font-size: 66px;
}
@keyframes medalSpin {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(6deg); }
}
.result-title { margin: 0; font-size: clamp(24px, 4vw, 32px); font-weight: 900; }
.result-medal-name {
  margin: 6px 0 0;
  font-size: 17px;
  font-weight: 900;
  color: var(--purple-d);
}
.result-desc {
  margin: 8px 0 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.7;
  color: var(--ink-soft);
}
.result-score {
  display: flex;
  justify-content: center;
  gap: 26px;
  margin: 16px 0 4px;
  font-size: 15px;
  font-weight: 800;
  color: var(--ink-soft);
}
.result-score b { color: var(--crab); font-size: 20px; }
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 18px;
}

/* ---------------- 勋章墙 ---------------- */
.medal-grid {
  flex: 1 1 auto;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
  padding: 6px 4px 16px;
  align-content: start;
}
.medal-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 18px 14px;
  border: var(--border-w) solid var(--ink);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-card);
  animation: panelIn 0.3s ease both;
}
.medal-card.locked { filter: grayscale(1); opacity: 0.55; }
.medal-card .mc-icon {
  width: 84px;
  height: 84px;
  display: grid;
  place-items: center;
  font-size: 42px;
  border-radius: 50%;
  border: 4px solid var(--ink);
  background: radial-gradient(circle at 34% 28%, #fff6c9, #ffd93d 60%, #f2a900);
  margin-bottom: 10px;
}
.medal-card.final .mc-icon {
  background: radial-gradient(circle at 34% 28%, #ffe8ff, #d78bff 55%, #9b5bff);
}
.medal-card .mc-name { font-size: 17px; font-weight: 900; }
.medal-card .mc-desc { font-size: 13px; font-weight: 700; color: var(--ink-soft); margin-top: 5px; line-height: 1.5; }
.medal-card .mc-time { font-size: 12px; font-weight: 700; color: var(--mint); margin-top: 8px; }

/* ---------------- 错题本 ---------------- */
.wrong-list {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px 4px 20px;
}
.wrong-item {
  border: var(--border-w) solid var(--ink);
  border-radius: var(--radius);
  background: #fff;
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
  animation: panelIn 0.3s ease both;
}
.wrong-item .wi-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.wrong-item .wi-lv {
  font-size: 12px;
  font-weight: 900;
  color: #fff;
  background: var(--purple);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 2px 10px;
}
.wrong-item .wi-type { font-size: 12px; font-weight: 800; color: var(--ink-soft); }
.wrong-item .wi-q { font-size: 17px; font-weight: 900; line-height: 1.6; margin: 0 0 10px; }
.wrong-item .wi-row { font-size: 15px; font-weight: 700; margin: 6px 0; display: flex; gap: 8px; align-items: flex-start; }
.wrong-item .wi-row .tag {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 8px;
  border: 2px solid var(--ink);
}
.tag-bad { background: #ffe2e2; }
.tag-good { background: #d8ffe7; }
.wrong-item .wi-tip {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fffbe6;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
  line-height: 1.6;
}
.empty-hint {
  text-align: center;
  padding: 50px 20px;
  font-size: 17px;
  font-weight: 800;
  color: var(--ink-soft);
}
.empty-hint .big { display: block; font-size: 62px; margin-bottom: 12px; }

/* ---------------- 结局 ---------------- */
#screen-ending { padding: 0; z-index: 5; }
.ending-stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(180deg, #ffd0a3 0%, #ffb3c8 42%, #ffd7ea 70%, #c9f7d4 100%);
}
.ending-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}
/* 前景压暗，让标题和按钮看得清 */
.ending-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16) 0%, rgba(54, 48, 77, 0.06) 45%, rgba(54, 48, 77, 0.3) 100%);
}
.ending-sky .sun { position: absolute; top: 8%; left: 12%; font-size: 76px; animation: sunRise 3s ease-out both; }
@keyframes sunRise {
  from { transform: translateY(120px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.ending-ground {
  position: absolute;
  left: -10%;
  right: -10%;
  bottom: -60px;
  height: 40%;
  border-radius: 50% 50% 0 0;
  background: linear-gradient(180deg, #9ceb9c, #4fc46a 60%, #35a352);
  box-shadow: inset 0 8px 0 rgba(255, 255, 255, 0.4);
}
.ending-crab-left {
  position: absolute;
  bottom: 15%;
  left: 20%;
  z-index: 2;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: 5px solid #fff;
  overflow: hidden;
  box-shadow: 0 12px 22px rgba(54, 48, 77, 0.28);
  animation: crabWalkRight 3.6s cubic-bezier(0.4, 0, 0.5, 1) 0.5s both;
}
@keyframes crabWalkRight {
  0% { transform: translateX(-160px) scale(0.9) rotate(-6deg); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateX(0) scale(1) rotate(0); }
}
.ending-crab-right {
  position: absolute;
  bottom: 15%;
  right: 20%;
  z-index: 2;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: 5px solid #fff;
  overflow: hidden;
  box-shadow: 0 12px 22px rgba(54, 48, 77, 0.28);
  animation: crabWalkLeft 3.6s cubic-bezier(0.4, 0, 0.5, 1) 0.5s both;
}
@keyframes crabWalkLeft {
  0% { transform: translateX(160px) scale(0.9) rotate(6deg); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateX(0) scale(1) rotate(0); }
}
.ending-hearts {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}
.ending-hearts span {
  position: absolute;
  bottom: 30%;
  left: 50%;
  font-size: 34px;
  animation: heartUp 2.6s ease-out both;
}
@keyframes heartUp {
  0% { transform: translate(-50%, 0) scale(0.3); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), -320px) scale(1.2) rotate(var(--rot)); opacity: 0; }
}
.ending-title {
  position: absolute;
  top: 12%;
  left: 0;
  right: 0;
  z-index: 4;
  text-align: center;
  padding: 0 20px;
  animation: panelIn 0.6s 2.4s ease both;
}
.ending-title h2 {
  margin: 0;
  font-size: clamp(30px, 6vw, 54px);
  font-weight: 900;
  color: #fff;
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 8px 0 rgba(255, 95, 95, 0.75);
}
.ending-title p {
  margin: 12px 0 0;
  font-size: clamp(16px, 2.6vw, 22px);
  font-weight: 800;
  color: #fff;
  -webkit-text-stroke: 1.5px var(--ink);
  paint-order: stroke fill;
}
.ending-actions {
  position: absolute;
  bottom: 5%;
  left: 0;
  right: 0;
  z-index: 4;
  display: flex;
  gap: 14px;
  justify-content: center;
  animation: panelIn 0.5s 3s ease both;
}

/* ---------------- 星星点亮状态 ---------------- */
.node-stars .ico,
.result-stars .ico { color: #d9d6e8; }
.node-stars .star.on .ico,
.result-stars .on .ico {
  color: var(--sun);
  filter: drop-shadow(0 2px 0 rgba(226, 171, 0, 0.55));
}
