/* ============ 疯狂蜜蜂 · Crazy Bees ============ */
*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  /* 明亮放松的奶油蜂蜜色：不压抑、也不是蓝色渐变，像午后花园 */
  --sky-1: #FFF8EA;
  --sky-2: #FDEFCE;
  --sky-3: #F6DFB6;
  --bg-outer: #EFDCB8;
  --wood-1: #F2B95C;
  --wood-2: #E09A38;
  --wood-3: #C97E22;
  --deck: #C1793A;
  --deck-d: #A86327;
  --cream: #FFF8E9;
  --ink: #4A2C16;
  --ink-soft: #7A5230;
  --gold: #FFC53D;
  --font: ui-rounded, "SF Pro Rounded", "Hiragino Sans GB", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

html, body {
  margin: 0; padding: 0; height: 100%;
  touch-action: manipulation;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg-outer);
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  user-select: none; -webkit-user-select: none;
}
body { display: grid; place-items: center; background: radial-gradient(120% 120% at 50% 0%, #FFF7E6 0%, #E9D2AB 72%); }

#app {
  position: relative;
  min-width: 0;
  width: min(100vw, 460px);
  height: 100vh;
  height: 100dvh;
  max-height: 960px;
  overflow: hidden;
  isolation: isolate;
}
@media (min-width: 500px) {
  #app { border-radius: 30px; box-shadow: 0 30px 70px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.08); }
}

/* ================= 启动画面 ================= */
.splash {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center;
  overflow: hidden;
  background:
    radial-gradient(85% 46% at 50% -6%, #FFFDF4 0%, #FFF2DA 52%, #F6E1BC 100%);
}
.splash-sky {
  position: absolute; inset: 0;
  background:
    radial-gradient(62% 34% at 50% 2%, rgba(255,255,255,.72), rgba(255,255,255,0) 72%),
    radial-gradient(40% 20% at 50% 24%, rgba(255,222,150,.20), rgba(255,222,150,0) 78%);
  pointer-events: none;
}
.scloud {
  position: absolute; width: 110px; height: 34px; border-radius: 40px;
  background: rgba(255,255,255,.78);
  filter: blur(.6px);
  box-shadow: 0 6px 18px rgba(190,150,90,.10);
}
.scloud::before, .scloud::after { content: ''; position: absolute; border-radius: 50%; background: rgba(255,255,255,.78); }
.scloud::before { width: 48px; height: 48px; left: 14px; top: -24px; }
.scloud::after { width: 32px; height: 32px; right: 16px; top: -15px; }
.scloud.c1 { left: -34px; top: 120px; transform: scale(.8); animation: drift 26s ease-in-out infinite; }
.scloud.c2 { right: -40px; top: 208px; transform: scale(.62); opacity: .55; animation: drift 32s ease-in-out infinite reverse; }
.scloud.c3 { left: 18px; top: 320px; transform: scale(.45); opacity: .4; animation: drift 38s ease-in-out infinite; }
@keyframes drift { 0%,100% { margin-left: 0 } 50% { margin-left: 22px } }

.splash-inner {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 100%; height: 100%;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 24px calc(env(safe-area-inset-bottom, 0px) + 14px);
  text-align: center;
}
.splash-kicker {
  font-size: 11.5px; font-weight: 800; letter-spacing: 2.4px;
  color: #9A7440;
  padding: 5px 13px; border-radius: 999px;
  background: rgba(255,255,255,.68);
  box-shadow: inset 0 0 0 1px rgba(214,178,116,.55), 0 2px 8px rgba(170,130,70,.10);
}
.splash-title {
  margin: 14px 0 0;
  display: flex; justify-content: center;
  font-size: clamp(38px, 13.2vw, 58px);
  font-weight: 900;
  letter-spacing: -1px;
  line-height: 1;
}
.splash-title span {
  display: inline-block;
  -webkit-text-stroke: 4.2px #45280D;
  paint-order: stroke fill;
  color: #FFD24A;
  text-shadow: 0 5px 0 #45280D, 0 10px 18px rgba(60,35,5,.35);
}
.splash-title .t1 { transform: rotate(-7deg) translateY(3px); color: #FFD24A; }
.splash-title .t2 { transform: rotate(4deg) translateY(-4px); color: #FFC02E; }
.splash-title .t3 { transform: rotate(-3deg) translateY(2px); color: #FFDE72; }
.splash-title .t4 { transform: rotate(7deg) translateY(-3px); color: #FFC02E; }
.splash-title span + span { margin-left: 0; }

.splash-en {
  margin-top: 9px;
  font-size: 13px; font-weight: 900; letter-spacing: 5px;
  color: #B07E34;
  opacity: .92;
}
.splash-art { width: min(80vw, 322px); margin: 0 auto; }
.splash-art svg {
  width: 100%; height: auto; display: block;
  filter: drop-shadow(0 12px 20px rgba(70,40,10,.22));
  animation: artFloat 4.6s ease-in-out infinite;
}
@keyframes artFloat { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-7px) } }

.btn-start {
  position: relative;
  margin-top: 14px;
  width: min(72%, 280px); height: 62px;
  border: 0; border-radius: 999px;
  font-family: inherit; font-size: 21px; font-weight: 900; letter-spacing: 3px;
  color: #4A2A06;
  background: linear-gradient(180deg, #FFE587 0%, #FFC02E 52%, #F5A209 100%);
  box-shadow: 0 0 0 4px #fff, 0 8px 0 #B86E06, 0 16px 26px rgba(120,70,10,.32), inset 0 2px 0 rgba(255,255,255,.7);
  cursor: pointer;
  transition: transform .1s ease, box-shadow .1s ease;
  animation: btnPulse 2.2s ease-in-out infinite;
}
.btn-start span { position: relative; top: -1px; text-shadow: 0 2px 0 rgba(255,255,255,.45); }
.btn-start:active { transform: translateY(5px); box-shadow: 0 0 0 4px #fff, 0 3px 0 #B86E06, 0 8px 14px rgba(120,70,10,.3), inset 0 2px 0 rgba(255,255,255,.7); }
@keyframes btnPulse {
  0%,100% { box-shadow: 0 0 0 4px #fff, 0 8px 0 #B86E06, 0 16px 26px rgba(120,70,10,.32), inset 0 2px 0 rgba(255,255,255,.7), 0 0 0 0 rgba(255,193,46,.55); }
  55% { box-shadow: 0 0 0 4px #fff, 0 8px 0 #B86E06, 0 16px 26px rgba(120,70,10,.32), inset 0 2px 0 rgba(255,255,255,.7), 0 0 0 12px rgba(255,193,46,0); }
}
.btn-ghost {
  margin-top: 12px;
  border: 0; background: none;
  font-family: inherit; font-size: 13.5px; font-weight: 800;
  color: #A9793C;
  padding: 8px 16px; border-radius: 999px;
  text-decoration: underline; text-underline-offset: 4px;
  cursor: pointer;
}
.splash-tip {
  margin-top: 16px; padding-top: 0;
  font-size: 11.5px; font-weight: 700; line-height: 1.6;
  color: #8C6A3E; opacity: .9;
}

/* 底部柔和浅绿草地：明亮、放松，不再是暗压抑的山丘 */
.splash::after {
  content: '';
  position: absolute; left: -12%; right: -12%; bottom: -46px; height: 130px;
  background: radial-gradient(70% 110% at 50% 0%, #DCECB6 0%, #BFD894 62%, #A6C877 100%);
  border-radius: 50% 50% 0 0 / 54px 54px 0 0;
  box-shadow: inset 0 6px 0 rgba(255,255,255,.38);
  z-index: 1;
}
.splash-inner { z-index: 2; }

/* ================= 主界面 ================= */
.screen {
  position: absolute; inset: 0; min-width: 0;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--sky-1) 0%, var(--sky-2) 32%, var(--sky-3) 100%);
  overflow: hidden;
}
.screen[hidden] { display: none; }
.sky-glow {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(72% 30% at 50% 0%, rgba(255,255,255,.58), rgba(255,255,255,0) 72%),
    radial-gradient(44% 20% at 50% 12%, rgba(255,214,130,.20), rgba(255,214,130,0) 78%);
}

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: relative; z-index: 6;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 7px) 14px 0;
  flex: 0 0 auto;
}
.icon-btn {
  position: relative;
  width: 38px; height: 38px; border-radius: 50%;
  border: 0; padding: 0;
  display: grid; place-items: center;
  color: #6B4A28;
  background: rgba(255,255,255,.94);
  box-shadow: 0 2px 0 rgba(200,165,115,.42), 0 4px 12px rgba(150,115,65,.16),
              inset 0 0 0 1.5px rgba(214,180,125,.50);
  backdrop-filter: blur(6px);
  cursor: pointer;
  transition: transform .12s ease, background .15s;
}
.icon-btn:active { transform: scale(.9); background: #FFFFFF; }
.icon-btn.off { color: #A08C78; }
.icon-btn.off::after {
  content: ''; position: absolute; width: 22px; height: 2.4px; border-radius: 2px;
  background: #A08C78; transform: rotate(-45deg);
}
.level-chip {
  margin-right: auto;
  padding: 6px 15px;
  cursor: default;
  font-size: 13px; font-weight: 800; letter-spacing: .6px;
  color: #6A431F;
  background: linear-gradient(180deg, #FFF3D8, #F6DCA9);
  border-radius: 999px;
  box-shadow: inset 0 0 0 1.5px rgba(190,140,70,.45), 0 2px 0 rgba(190,140,70,.22),
              0 3px 10px rgba(150,110,60,.14);
  cursor: pointer;
  transition: transform .1s;
}
.level-chip.static:active { transform: none; }
.level-chip b { font-size: 14.5px; color: #4A2C12; margin-left: 2px; }

/* ---------------- 蜂巢 ---------------- */
.hive-wrap {
  /* 上提 7px：放大到 1.2× 后让圆底与画框顶边留出呼吸空间，不再压住第一排格子 */
  position: absolute; left: 50%; top: calc(env(safe-area-inset-top, 0px) - 13px);
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center;
  pointer-events: none;
  z-index: 7;
}
.hive { position: relative; filter: drop-shadow(0 7px 10px rgba(150,95,25,.28)); animation: hiveBob 4.4s ease-in-out infinite; }
.hive svg { width: 104px; height: 122px; display: block; }   /* 1.2× */

/* 常态：轻轻上下浮动 + 左右摇曳，像挂在枝头 */
@keyframes hiveBob {
  0%,100% { transform: translateY(0) rotate(-1.2deg); }
  50%     { transform: translateY(-5px) rotate(1.6deg); }
}
/* 巢口呼吸光 / 叶子轻摆 / 小蜜蜂绕飞 —— 让蜂巢一直「活着」 */
.hive svg .hive-glow { transform-box: fill-box; transform-origin: center; animation: hiveGlow 2.6s ease-in-out infinite; }
@keyframes hiveGlow { 0%,100% { opacity: .38; transform: scale(.86); } 50% { opacity: .88; transform: scale(1.18); } }
.hive svg .hive-leaf-l, .hive svg .hive-leaf-r { transform-box: fill-box; transform-origin: center; }
.hive svg .hive-leaf-l { animation: leafSwayL 3.4s ease-in-out infinite; }
.hive svg .hive-leaf-r { animation: leafSwayR 3.9s ease-in-out infinite; }
@keyframes leafSwayL { 0%,100% { transform: rotate(-28deg); } 50% { transform: rotate(-17deg); } }
@keyframes leafSwayR { 0%,100% { transform: rotate(26deg); } 50% { transform: rotate(15deg); } }
.hive svg .hive-bee { transform-box: fill-box; transform-origin: center; animation: beeOrbit 3.1s ease-in-out infinite; }
.hive svg .hive-bee.b2 { animation-duration: 3.9s; animation-delay: -1.4s; }
@keyframes beeOrbit {
  0%,100% { transform: translate(0,0) rotate(0deg); }
  25%     { transform: translate(7px,-7px) rotate(9deg); }
  50%     { transform: translate(0,-13px) rotate(0deg); }
  75%     { transform: translate(-7px,-7px) rotate(-9deg); }
}

/* 蜜蜂进巢：弹性放大 + 摆一下 + 发光，比原来「抖一下」生动 */
.hive.hit { animation: hiveHit .5s cubic-bezier(.34,1.5,.5,1); }
@keyframes hiveHit {
  0%   { transform: scale(1) rotate(0deg);     filter: drop-shadow(0 7px 10px rgba(150,95,25,.28)) brightness(1); }
  32%  { transform: scale(1.19) rotate(-8deg); filter: drop-shadow(0 0 22px rgba(255,205,70,.95)) brightness(1.22); }
  64%  { transform: scale(.96) rotate(4deg);   filter: drop-shadow(0 0 14px rgba(255,215,90,.7)) brightness(1.08); }
  100% { transform: scale(1) rotate(0deg);     filter: drop-shadow(0 7px 10px rgba(150,95,25,.28)) brightness(1); }
}
/* 进巢瞬间从巢口扩散出去的金色光环 */
.hive-ring {
  position: absolute; left: 50%; top: 62%;
  width: 76px; height: 76px; border-radius: 50%;
  border: 3px solid rgba(255,203,74,.9);
  box-shadow: 0 0 20px rgba(255,203,74,.7), inset 0 0 14px rgba(255,231,150,.6);
  opacity: 0; pointer-events: none;
  transform: translate(-50%,-50%) scale(.45);
}
.hive.burst .hive-ring { animation: hiveRing .52s ease-out; }
@keyframes hiveRing {
  0%   { opacity: .9; transform: translate(-50%,-50%) scale(.45); }
  100% { opacity: 0;  transform: translate(-50%,-50%) scale(2.15); }
}

.combo {
  position: absolute; right: 10px; top: 10px; z-index: 5;
  margin: 0;
  max-width: calc(100% - 24px);
  display: flex; align-items: baseline; gap: 4px;
  transform-origin: right top;
  padding: 3px 11px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,240,190,.96), rgba(255,205,90,.96));
  box-shadow: inset 0 0 0 1.5px rgba(190,120,20,.55), 0 3px 8px rgba(140,80,10,.25);
  opacity: 0; transform: translateY(-6px) scale(.85);
  transition: opacity .18s, transform .18s;
}
.combo.show { opacity: 1; transform: translateY(0) scale(1); }
.combo b { font-variant-numeric: tabular-nums; }
.combo span { font-size: 9.5px; font-weight: 800; color: #8A5210; letter-spacing: .5px; }
.combo b { font-size: 15px; font-weight: 900; color: #B4370B; text-shadow: 0 1px 0 rgba(255,255,255,.6); letter-spacing: -.3px; }
.combo.hot b { animation: comboPop .28s ease-out; display: inline-block; }
@keyframes comboPop { 0% { transform: scale(1.24) } 100% { transform: scale(1) } }

/* ---------------- 画框 ---------------- */
.board-wrap {
  position: relative; z-index: 2;
  flex: 0 0 auto;
  /* 竖版画布 4:5，宽度驱动：约当前尺寸的 1.2 倍（297×371 → 356×445）
     再用 vh 兜住，小屏由媒体查询继续收，永远不会把下方料槽挤出屏幕 */
  width: min(92vw, 356px, 46vh);
  aspect-ratio: 4 / 5;
  height: auto;
  align-self: center;      /* 防止 flex 交叉轴拉伸把宽度撑满 */
  margin: 62px auto 6px;   /* 顶部留白 = 整体下移，与放大后的蜂巢拉开距离 */
  display: grid; place-items: center;
}
.board-wrap::before {
  content: ''; position: absolute;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: var(--board-w, 300px); height: var(--board-h, 240px);
  border-radius: 16px;
  background: linear-gradient(180deg, #FFD97A, #EDA93F);
  box-shadow: 0 0 0 2px #B9752A, 0 6px 0 -1px #A9621E, 0 14px 24px rgba(90,55,15,.22),
              inset 0 2px 0 rgba(255,255,255,.6);
  transition: box-shadow .3s;
}
.board-wrap.done::before {
  animation: frameWin 1s ease-out;
}
@keyframes frameWin {
  0% { box-shadow: 0 0 0 2px #B9752A, 0 6px 0 -1px #A9621E, 0 14px 24px rgba(90,55,15,.22), inset 0 2px 0 rgba(255,255,255,.6); }
  40% { box-shadow: 0 0 0 6px rgba(255,215,90,.7), 0 6px 0 -1px #A9621E, 0 0 46px rgba(255,196,60,.95), inset 0 2px 0 rgba(255,255,255,.9); }
  100% { box-shadow: 0 0 0 2px #B9752A, 0 6px 0 -1px #A9621E, 0 14px 24px rgba(90,55,15,.22), inset 0 2px 0 rgba(255,255,255,.6); }
}
#board {
  display: block;
  /* 绝对定位 + 居中：canvas 不再参与撑开容器，画框严格由 aspect-ratio 决定 */
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
  border-radius: 13px;
  touch-action: none;
}
/* 全屏特效层：蜜蜂 / 碎屑覆盖画框、槽位与蜂巢，pointer-events 不拦截点击 */
.fx-layer {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  z-index: 9;
  pointer-events: none;
}
.coach {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%) scale(.94);
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(255,252,243,.96);
  color: #7A5230;
  font-size: 11.5px; font-weight: 800; letter-spacing: .2px;
  white-space: nowrap;
  box-shadow: 0 3px 0 rgba(190,145,80,.3), 0 8px 16px rgba(120,80,30,.14);
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 8;
}
.coach.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* ---------------- 第一关教学 ---------------- */
.tutorial { position: absolute; inset: 0; z-index: 28; pointer-events: none; }
.tutorial[hidden] { display: none !important; }
.tut-ring {
  position: absolute; border: 3px solid rgba(255,255,255,.96);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(255,190,60,.55), 0 0 22px rgba(255,190,60,.65);
  animation: tutPulse 1.1s ease-in-out infinite;
}
@keyframes tutPulse {
  0%,100% { transform: scale(1); opacity: .95; }
  50%     { transform: scale(1.09); opacity: .62; }
}
.tut-finger {
  position: absolute; font-size: 30px; line-height: 1;
  transform-origin: 50% 12%;
  animation: tutTap 1s ease-in-out infinite;
  filter: drop-shadow(0 2px 3px rgba(80,45,10,.35));
}
@keyframes tutTap {
  0%,100% { transform: translateY(0) rotate(-12deg); }
  50%     { transform: translateY(-9px) rotate(-4deg); }
}
.tut-bubble {
  position: absolute; left: 50%; top: 29%;
  transform: translateX(-50%);
  width: min(84vw, 296px); padding: 12px 14px 10px;
  border-radius: 16px;
  background: rgba(255,250,235,.95);
  border: 2px solid #E8B44A;
  box-shadow: 0 8px 24px rgba(90,55,15,.26);
  text-align: center; color: #5A3A14;
}
.tut-bubble b { display: block; font-size: 15px; margin-bottom: 4px; color: #8A4E12; }
.tut-bubble span { display: block; font-size: 12px; line-height: 1.5; opacity: .88; }
#tut-skip {
  pointer-events: auto; margin-top: 9px; padding: 4px 13px;
  border: 0; border-radius: 999px;
  background: #F0D9A8; color: #7A4A1C;
  font-size: 11px; font-weight: 800; cursor: pointer;
}
/* ---------------- 槽位 ---------------- */
.slots {
  position: relative; z-index: 3;
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  gap: var(--slot-gap, 9px);
  /* 画框放大后槽位相应下移，留出更长的竖直升空通道 */
  margin: calc(var(--slot-h, 54px) + 10px) 16px 0;
  height: var(--slot-h, 54px);
}
.slot {
  position: relative;
  width: var(--slot-w, 54px); height: var(--slot-h, 54px);
  border-radius: 12px;
  background: linear-gradient(180deg, #FFFFFF, #F3E7D2);
  box-shadow: inset 0 2px 7px rgba(150,110,60,.3), inset 0 -2px 0 rgba(255,255,255,.9), 0 2px 0 rgba(180,130,70,.35);
  flex: 0 0 auto;
}
.slot::after {
  content: ''; position: absolute; inset: 5px;
  border-radius: 8px;
  border: 1.5px dashed rgba(180,140,90,.28);
}
.slot.filled::after { display: none; }
.slot .tile { position: absolute; inset: 0; }
/* 工单当前没有可达格：不消失，标出来等通路；点一下可退回托盘换颜色 */
.slot.waiting::before {
  content: '等通路';
  position: absolute; left: 50%; top: -15px;
  transform: translateX(-50%);
  padding: 1px 6px; border-radius: 999px;
  background: rgba(255,248,230,.94);
  color: #7A4A1C; font-size: 8px; font-weight: 800;
  white-space: nowrap; letter-spacing: .2px;
  box-shadow: 0 2px 5px rgba(80,45,10,.16);
  z-index: 6;
}
.slot.waiting .tile { animation: waitPulse 1.35s ease-in-out infinite; }
@keyframes waitPulse {
  0%,100% { filter: brightness(1) saturate(1); }
  50%     { filter: brightness(1.13) saturate(.78); }
}
.slot.pulse { animation: slotPulse .4s ease-out; }
@keyframes slotPulse {
  0% { box-shadow: inset 0 2px 7px rgba(150,110,60,.3), 0 0 0 0 rgba(255,200,60,.8); }
  100% { box-shadow: inset 0 2px 7px rgba(150,110,60,.3), 0 0 0 12px rgba(255,200,60,0); }
}
/* 数字每减少一次：整个槽位 + 槽内的色卡一起轻微缩放，给出「又搬走一块」的节拍反馈。
   槽位内缩、色卡相对鼓起，两者都有缩放但不会互相抵消。 */
.slot.count-pop { animation: slotCountPop .12s ease-out; }
.slot.pulse.count-pop { animation: slotPulse .4s ease-out, slotCountPop .12s ease-out; }
.slot .tile.count-pop { animation: tileCountPop .12s ease-out; }
@keyframes slotCountPop {
  0%,100% { transform: scale(1); }
  45%     { transform: scale(.94); }
}
@keyframes tileCountPop {
  0%,100% { transform: scale(1); }
  45%     { transform: scale(1.07); }
}

/* ---------------- 托盘（工单方块） ---------------- */
.tray-wrap {
  position: relative; z-index: 3;
  flex: 1 1 auto; min-height: 0;
  margin: 12px 16px 0;      /* v12：第二排下移后，把槽位下方腾出的空间让给托盘 */
  overflow: hidden;
}
/* 方块下方只用柔和的暗部表达「下面还压着很多」，不再拿一块木板硬压 */
.tray-wrap::after {
  content: ''; position: absolute;
  left: -16px; right: -16px;
  top: var(--tray-vis, 150px); bottom: 0;
  background: linear-gradient(180deg,
    rgba(120,85,40,0) 0%,
    rgba(120,85,40,.04) 34%,
    rgba(120,85,40,.13) 100%);
  pointer-events: none;
}
.tray {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: var(--tray-vis, 150px);
  overflow: hidden;
  /* v12：第一排到第二排拉开到 1.5 倍行距，第三排仍只露上半、下半柔和淡出。
     按 px 收尾而不是固定百分比，托盘高度随屏幕变化时淡出位置始终贴合第三排。 */
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 calc(100% - 15px), rgba(0,0,0,.58) calc(100% - 7px), transparent 100%);
  mask-image: linear-gradient(180deg, #000 0%, #000 calc(100% - 15px), rgba(0,0,0,.58) calc(100% - 7px), transparent 100%);
}

/* 单个方块（视频同款：圆角 + 白描边 + 底部厚度 + 大数字） */
.tile {
  position: absolute;
  left: 0; top: 0;
  border-radius: 11px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.34) 0%, rgba(255,255,255,.06) 38%, rgba(0,0,0,.14) 100%),
    var(--tc, #666);
  box-shadow:
    0 0 0 3px #FFFFFF,
    0 5px 0 var(--tcd, #333),
    0 9px 14px rgba(60,30,5,.22);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 rgba(0,0,0,.32), 0 0 3px rgba(0,0,0,.15);
  cursor: default;                 /* 默认不可点；只有 .live 才是可点的一层 */
  /* 排布位置放在自定义属性里：震动动画叠加偏移时不会把方块甩回左上角 */
  transform: translate(var(--tx, 0px), var(--ty, 0px));
  transition: transform .18s cubic-bezier(.3,1.4,.5,1), opacity .2s, filter .15s;
  will-change: transform;
  z-index: 2;
  padding-bottom: 3px;
}
/* 只有最上面一层可点：其余彻底屏蔽点击与任何点击效果 */
.tile.live { cursor: pointer; z-index: 3; }
.tile.locked { pointer-events: none; }
/* 从槽位退回托盘的卡片：单独淡入归位，浮在同列之上，其余卡片不重排抖动 */
.tile.returning { z-index: 5; }
.tile .num { line-height: 1; pointer-events: none; }
.tile.lite { color: #4A3216; text-shadow: 0 1px 0 rgba(255,255,255,.6); }
.tile::before {
  /* 顶部高光 */
  content: ''; position: absolute; left: 12%; right: 12%; top: 4%;
  height: 22%; border-radius: 8px 8px 40% 40%;
  background: rgba(255,255,255,.22);
  pointer-events: none;
}
/* 按压反馈只用亮度/阴影，不碰 transform（transform 由 JS 用于排布定位） */
.tile.live:active { filter: brightness(1.14); box-shadow: 0 0 0 3px #FFF, 0 2px 0 var(--tcd, #333), 0 3px 7px rgba(60,30,5,.24); }
.tile.lift { animation: tileLift .3s ease-out; }
@keyframes tileLift {
  0%   { transform: translate(var(--tx, 0px), var(--ty, 0px)) scale(1); }
  45%  { transform: translate(var(--tx, 0px), calc(var(--ty, 0px) - 9px)) scale(1.06); }
  100% { transform: translate(var(--tx, 0px), var(--ty, 0px)) scale(1); }
}
/* 槽位已满时点色块：原地左右震动 + 红色描边，明确告诉玩家「现在放不进去」 */
.tile.deny {
  z-index: 6;
  box-shadow:
    0 0 0 3px #FF6B57,
    0 5px 0 var(--tcd, #333),
    0 9px 14px rgba(60,30,5,.22);
  animation: tileDeny .42s cubic-bezier(.36,.07,.19,.97) both;
}
@keyframes tileDeny {
  0%,100% { transform: translate(var(--tx, 0px), var(--ty, 0px)) rotate(0deg); }
  16%     { transform: translate(calc(var(--tx, 0px) - 6px), var(--ty, 0px)) rotate(-5deg); }
  34%     { transform: translate(calc(var(--tx, 0px) + 6px), var(--ty, 0px)) rotate(5deg); }
  52%     { transform: translate(calc(var(--tx, 0px) - 4px), var(--ty, 0px)) rotate(-3deg); }
  70%     { transform: translate(calc(var(--tx, 0px) + 3px), var(--ty, 0px)) rotate(2deg); }
  86%     { transform: translate(calc(var(--tx, 0px) - 1px), var(--ty, 0px)) rotate(-1deg); }
}
.tile.working::after {
  /* 正在搬：一条进度边 */
  content: ''; position: absolute; left: 10%; right: 10%; bottom: -1px;
  height: 2.5px; border-radius: 3px;
  background: rgba(255,255,255,.5);
  transform-origin: left center;
  transform: scaleX(var(--p, 0));
  transition: transform .2s linear;
}

/* 飞向槽位的临时元素 */
.fly-tile {
  position: fixed; z-index: 60; pointer-events: none;
  border-radius: 11px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.34) 0%, rgba(255,255,255,.06) 38%, rgba(0,0,0,.14) 100%),
    var(--tc, #666);
  box-shadow: 0 0 0 3px #FFF, 0 5px 0 var(--tcd, #333), 0 12px 20px rgba(60,30,5,.3);
  color: #fff; font-weight: 900; display: grid; place-items: center;
  text-shadow: 0 2px 0 rgba(0,0,0,.32);
  font-variant-numeric: tabular-nums;
}

/* ---------------- 工具栏 ---------------- */
.toolbar {
  position: relative; z-index: 5;
  flex: 0 0 auto;
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px 12px calc(env(safe-area-inset-bottom, 0px) + 9px);
  background: linear-gradient(180deg, rgba(120,72,32,0) 0%, rgba(120,72,32,.18) 30%, rgba(90,50,15,.42) 100%);
}
.tool {
  position: relative;
  border: 0; padding: 5px 2px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: rgba(255,255,255,.14);
  border-radius: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: transform .1s, background .15s;
  box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.22);
}
.tool:active { transform: scale(.94); background: rgba(255,255,255,.28); }
.tool-ico { font-size: 19px; line-height: 1; filter: drop-shadow(0 2px 2px rgba(0,0,0,.2)); }
.tool-txt { font-size: 9.5px; font-weight: 800; color: #FFF6E4; text-shadow: 0 1px 2px rgba(60,30,5,.5); letter-spacing: .2px; }
.tool.active { background: rgba(255,208,80,.5); box-shadow: inset 0 0 0 2px #FFD24A, 0 0 14px rgba(255,210,74,.55); }
.tool.active .tool-txt { color: #4A3208; text-shadow: none; }
.tool.disabled { opacity: .38; pointer-events: none; }
.badge {
  position: absolute; right: 4px; top: 2px;
  min-width: 15px; height: 15px; padding: 0 3px;
  border-radius: 999px;
  background: #E8452F; color: #fff;
  font-size: 9.5px; font-weight: 900; font-style: normal;
  display: grid; place-items: center;
  box-shadow: 0 1px 0 rgba(0,0,0,.25), inset 0 0 0 1.5px rgba(255,255,255,.55);
}
.badge.empty { display: none; }

/* ---------------- 弹窗 ---------------- */
.modal {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(30,16,4,.52);
  backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none;
  transition: opacity .22s;
}
.modal.open { opacity: 1; pointer-events: auto; }
.modal[hidden] { display: none !important; }   /* 选择关卡入口已隐藏 */
.sheet {
  width: 100%; max-width: 340px;
  max-height: 84%;
  overflow-y: auto;
  padding: 20px 18px 18px;
  border-radius: 24px;
  background: linear-gradient(180deg, #FFFDF6, #FDF1DA);
  box-shadow: 0 0 0 3px rgba(255,255,255,.55), 0 20px 44px rgba(40,20,0,.42);
  transform: translateY(14px) scale(.96);
  transition: transform .26s cubic-bezier(.2,1.3,.4,1);
}
.modal.open .sheet { transform: translateY(0) scale(1); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-head h2 { margin: 0; font-size: 19px; font-weight: 900; color: #6A431F; letter-spacing: .5px; }
.close {
  width: 30px; height: 30px; border-radius: 50%; border: 0;
  background: rgba(190,150,100,.2); color: #8A6238;
  font-size: 14px; font-weight: 900; cursor: pointer;
}

/* 失败弹窗 */
.fail-sheet { text-align: center; position: relative; overflow: hidden; }
.fail-sheet::before {
  content: ''; position: absolute; inset: -40px -40px auto; height: 170px;
  background: radial-gradient(50% 50% at 50% 50%, rgba(120,150,190,.28), rgba(120,150,190,0) 70%);
  pointer-events: none;
}
.fail-badge { width: 92px; height: 92px; margin: 2px auto 6px; }
.fail-badge svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 5px 8px rgba(70,45,15,.2)); }
.fail-sheet h2 {
  margin: 2px 0 8px; font-size: 24px; font-weight: 900; letter-spacing: 2px;
  color: #7A5A8C;
  text-shadow: 0 2px 0 #fff, 0 4px 0 rgba(120,90,140,.2);
}
.fail-msg { margin: 0 0 10px; font-size: 12.5px; line-height: 1.7; color: #6A4C2A; font-weight: 700; }
.fail-tip {
  margin: 0 0 14px; padding: 9px 11px; border-radius: 12px;
  background: rgba(255,214,110,.3);
  box-shadow: inset 0 0 0 1.5px rgba(200,150,50,.3);
  font-size: 11.5px; line-height: 1.6; color: #7A5230; font-weight: 700;
}

/* 结算 */
.win-sheet { text-align: center; position: relative; overflow: hidden; }
.win-sheet h2 {
  margin: 4px 0 8px;
  font-size: 25px; font-weight: 900; letter-spacing: 2px;
  color: #E8720C;
  text-shadow: 0 2px 0 #fff, 0 4px 0 rgba(200,120,20,.28);
}
.win-burst {
  position: absolute; inset: -40px -40px auto;
  height: 160px;
  background: radial-gradient(50% 50% at 50% 50%, rgba(255,206,80,.55), rgba(255,206,80,0) 70%);
  pointer-events: none;
}
.stars { display: flex; justify-content: center; gap: 10px; margin: 6px 0 14px; }
.stars i {
  width: 34px; height: 34px; display: block;
  background: rgba(190,150,100,.22);
  clip-path: polygon(50% 0%, 62% 35%, 98% 36%, 69% 58%, 79% 95%, 50% 72%, 21% 95%, 31% 58%, 2% 36%, 38% 35%);
}
.stars i.on { background: linear-gradient(180deg, #FFE070, #FFAE18); filter: drop-shadow(0 2px 4px rgba(220,150,20,.5)); animation: starIn .45s ease-out backwards; }
.stars i.on:nth-child(2) { animation-delay: .12s; }
.stars i.on:nth-child(3) { animation-delay: .24s; }
@keyframes starIn { 0% { transform: scale(0) rotate(-40deg) } 100% { transform: scale(1) rotate(0) } }

.win-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; margin-bottom: 14px;
}
.win-stats div {
  padding: 9px 4px;
  border-radius: 13px;
  background: rgba(235,205,160,.32);
  box-shadow: inset 0 0 0 1.5px rgba(200,160,110,.28);
}
.win-stats span { display: block; font-size: 9.5px; font-weight: 800; color: #9A7448; letter-spacing: .4px; }
.win-stats b { display: block; margin-top: 2px; font-size: 17px; font-weight: 900; color: #6A431F; }
.win-art { position: relative; margin: 0 auto 16px; width: 132px; }
.win-art canvas { width: 132px; height: 132px; display: block; border-radius: 14px; box-shadow: 0 4px 14px rgba(120,80,20,.22); background: #2E2634; }
.win-art span {
  position: absolute; left: 50%; bottom: -9px; transform: translateX(-50%);
  padding: 2px 10px; border-radius: 999px;
  background: #6A431F; color: #FFEBB8;
  font-size: 9.5px; font-weight: 800; letter-spacing: 1px; white-space: nowrap;
}
.sheet-btns { display: grid; grid-template-columns: 1fr 1.25fr; gap: 9px; }
.btn {
  border: 0; border-radius: 14px; padding: 13px 8px;
  font-family: inherit; font-size: 14.5px; font-weight: 900; letter-spacing: 1px;
  cursor: pointer; transition: transform .1s;
}
.btn:active { transform: translateY(2px); }
.btn.primary {
  color: #4A2A06;
  background: linear-gradient(180deg, #FFE587, #FFC02E 55%, #F5A209);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.6), 0 4px 0 #B86E06;
}
.btn.ghost {
  color: #7A5230;
  background: rgba(200,170,130,.26);
  box-shadow: inset 0 0 0 1.5px rgba(180,140,90,.4), 0 4px 0 rgba(180,140,90,.28);
}
.btn.wide { width: 100%; margin-top: 14px; }

/* 关卡列表 */
.level-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.level-card {
  position: relative;
  padding: 9px; border-radius: 16px; border: 0;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(210,175,125,.5), 0 4px 10px rgba(140,95,30,.14);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  font-family: inherit;
  transition: transform .1s;
}
.level-card:active { transform: scale(.96); }
.level-card canvas { width: 100%; aspect-ratio: 1/1; border-radius: 10px; background: #2E2634; display: block; }
.level-card .nm { font-size: 12px; font-weight: 800; color: #6A431F; }
.level-card .st { display: flex; gap: 2px; }
.level-card .st i {
  width: 9px; height: 9px; display: block;
  background: rgba(190,150,100,.28);
  clip-path: polygon(50% 0%, 62% 35%, 98% 36%, 69% 58%, 79% 95%, 50% 72%, 21% 95%, 31% 58%, 2% 36%, 38% 35%);
}
.level-card .st i.on { background: #FFB01F; }
.level-card.locked { opacity: .62; }
.level-card.locked canvas { filter: grayscale(.7) brightness(.6); }
.level-card .lock {
  position: absolute; left: 9px; right: 9px; top: 9px;
  aspect-ratio: 1/1;
  display: grid; place-items: center;
  font-size: 22px; color: rgba(255,255,255,.9);
  text-shadow: 0 2px 6px rgba(0,0,0,.5);
}

/* 帮助 */
.help-list { margin: 0; padding-left: 18px; }
.help-list li {
  font-size: 12.5px; line-height: 1.75; color: #6A4C2A;
  margin-bottom: 6px;
}
.help-list b { color: #B4630C; }

/* Toast */
.toast {
  position: absolute; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 56px);
  transform: translate(-50%, -8px);
  padding: 9px 18px; border-radius: 999px;
  background: rgba(58,32,10,.9);
  color: #FFF3D6; font-size: 12.5px; font-weight: 800; letter-spacing: .4px;
  pointer-events: none; opacity: 0;
  transition: opacity .2s, transform .2s;
  z-index: 70; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 成就 / 道具 ---------------- */
.ach-dot {
  position: absolute; right: -1px; top: -1px;
  width: 9px; height: 9px; border-radius: 50%;
  background: #E8452F; box-shadow: 0 0 0 2px #FFF;
}
.ach-dot[hidden] { display: none; }
.badge.zero { background: #9C8B74; }
.tool.out .tool-ico { filter: grayscale(.75); opacity: .68; }
.tool.out .tool-txt { color: #E7D5B7; }

.ach-sheet { max-width: 360px; }
.ach-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.ach-summary div {
  padding: 9px 4px; border-radius: 13px; text-align: center;
  background: rgba(235,205,160,.34);
  box-shadow: inset 0 0 0 1.5px rgba(200,160,110,.3);
}
.ach-summary span { display: block; font-size: 9.5px; font-weight: 800; color: #9A7448; }
.ach-summary b { display: block; margin-top: 2px; font-size: 18px; font-weight: 900; color: #6A431F; }
.ach-list { display: flex; flex-direction: column; gap: 8px; }
.ach-card {
  display: grid; grid-template-columns: 38px 1fr auto; gap: 9px; align-items: center;
  padding: 9px 10px; border-radius: 14px;
  background: rgba(255,255,255,.72);
  box-shadow: inset 0 0 0 1.5px rgba(210,175,125,.5);
}
.ach-card.done { background: linear-gradient(180deg,#FFF6D8,#FFE9B0); box-shadow: inset 0 0 0 1.5px rgba(225,170,60,.7); }
.ach-ico {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center; font-size: 20px;
  background: rgba(190,150,100,.18);
}
.ach-card.done .ach-ico { background: rgba(255,193,46,.5); }
.ach-name { font-size: 12.5px; font-weight: 900; color: #6A431F; }
.ach-desc { font-size: 10.5px; font-weight: 700; color: #9A7448; line-height: 1.4; margin-top: 1px; }
.ach-bar { height: 5px; border-radius: 5px; background: rgba(190,150,100,.22); margin-top: 5px; overflow: hidden; }
.ach-bar i { display: block; height: 100%; border-radius: 5px; background: linear-gradient(90deg,#FFC02E,#F08A0A); }
.ach-reward { font-size: 10px; font-weight: 900; color: #B4630C; white-space: nowrap; text-align: right; line-height: 1.5; }
.ach-card.done .ach-reward { color: #3E8B34; }
.ach-foot { margin: 12px 2px 0; font-size: 10.5px; line-height: 1.6; color: #9A7448; font-weight: 700; }

.ach-pop {
  position: absolute; z-index: 80;
  left: 50%; top: calc(env(safe-area-inset-top, 0px) + 12px);
  transform: translate(-50%, -120%);
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px 9px 10px; border-radius: 999px;
  background: linear-gradient(180deg,#FFF3C9,#FFD973);
  box-shadow: 0 0 0 2px #fff, 0 8px 22px rgba(90,55,10,.32);
  opacity: 0; pointer-events: none;
  transition: transform .38s cubic-bezier(.2,1.3,.4,1), opacity .3s;
  white-space: nowrap;
}
.ach-pop.show { transform: translate(-50%, 0); opacity: 1; }
.ach-pop-ico { font-size: 23px; line-height: 1; }
.ach-pop-txt b { display: block; font-size: 12.5px; font-weight: 900; color: #6A431F; }
.ach-pop-txt small { display: block; font-size: 10px; font-weight: 800; color: #A8782F; }

.win-ach {
  margin: -6px 0 12px; padding: 8px 10px; border-radius: 12px;
  background: rgba(255,214,110,.38);
  box-shadow: inset 0 0 0 1.5px rgba(200,150,50,.34);
  font-size: 11.5px; font-weight: 800; color: #8A5A16; line-height: 1.6;
}
.win-ach[hidden] { display: none; }

/* ---------------- 小屏适配 ---------------- */
@media (max-height: 730px) {
  /* 蜂巢常态有 ±5px 浮动：小屏再上提 6px，任何动画相位都不压住画框第一排 */
  .hive-wrap { top: calc(env(safe-area-inset-top, 0px) - 19px); }
  .coach { top: 42%; }
  .coach::after { display: none; }
  .board-wrap { margin-top: 34px; width: min(84vw, 292px, 37vh); }
  .slots { margin-top: 34px; }
  .tray-wrap { margin-top: 16px; }
  .hive svg { width: 90px; height: 105px; }
  .combo { top: 5px; right: 5px; }
  .toolbar { padding-top: 5px; }
  .tool-ico { font-size: 17px; }
  .splash-art { width: min(58vw, 210px); }
  .splash-title { margin-top: 8px; }
  .btn-start { height: 54px; font-size: 19px; margin-top: 8px; }
  .splash-tip { padding-top: 6px; }
}
@media (max-height: 640px) {
  .splash-art { display: none; }
  .hive svg { width: 83px; height: 97px; }
  .board-wrap { margin-top: 24px; width: min(78vw, 250px, 34vh); }
  .slots { margin-top: 26px; }
  .tray-wrap { margin-top: 12px; }
  .topbar { padding-top: calc(env(safe-area-inset-top, 0px) + 4px); }
}
