* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: #2b2f3a; overflow: hidden; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  user-select: none; -webkit-user-select: none;
}
button { font-family: inherit; cursor: pointer; border: none; }
.hidden { display: none !important; }

#app {
  position: relative; margin: 0 auto; width: 100%; max-width: 480px;
  height: 100vh; height: 100dvh; overflow: hidden; background: #d4d9ea;
}

/* ---------- 首页 ---------- */
.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px;
  background: linear-gradient(#9be15d, #5fc36b 55%, #4a9fd8);
}
.home-title {
  font-size: 64px; font-weight: 900; color: #ffd83b; letter-spacing: 4px;
  -webkit-text-stroke: 3px #7a4a00; text-shadow: 0 6px 0 #7a4a00;
}
.home-sub { color: #fff; font-size: 18px; font-weight: 700; text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.home-bears { display: flex; gap: 4px; margin: 10px 0 20px; }
.home-bears svg { width: 34px; height: 38px; animation: hop .9s ease-in-out infinite; }
@keyframes hop { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

.btn {
  padding: 12px 34px; border-radius: 18px; font-size: 20px; font-weight: 800; color: #fff;
  box-shadow: 0 5px 0 rgba(0,0,0,.25);
}
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.25); }
.btn.big { font-size: 26px; padding: 14px 54px; }
.btn.yellow { background: #ffb21e; border: 3px solid #8a4e00; text-shadow: 0 2px 0 #8a4e00; }
.btn.green { background: #42c76b; border: 3px solid #1d6b34; text-shadow: 0 2px 0 #1d6b34; }
.btn.blue { background: #3fa5f0; border: 3px solid #1b5c8f; text-shadow: 0 2px 0 #1b5c8f; }
.btn.gray { background: #9aa0ad; border: 3px solid #5d626d; }
.btn.ghost { background: rgba(255,255,255,.25); border: 2px solid #fff; font-size: 17px; }

/* ---------- 游戏布局 ---------- */
#game { position: absolute; inset: 0; display: flex; flex-direction: column; }
.scene { position: relative; flex: 0 0 auto; height: min(30vh, 230px); overflow: hidden; }
.grass { position: absolute; inset: 0 0 42% 0; background: #7fcf4a; }
.tree { position: absolute; width: 34px; height: 54px; }
.tree::before {
  content: ""; position: absolute; left: 0; top: 0; width: 34px; height: 40px; border-radius: 50% 50% 45% 45%;
  background: radial-gradient(circle at 35% 30%, #a6f78a, #5fd35a 60%, #3fae46);
}
.tree::after {
  content: ""; position: absolute; left: 14px; top: 38px; width: 6px; height: 16px; border-radius: 3px; background: #f0b43a;
}
.rock {
  position: absolute; width: 40px; height: 30px; border-radius: 40% 50% 30% 40%;
  background: linear-gradient(135deg, #e3fbff, #9fd8e6);
}
.road {
  position: absolute; left: 0; right: 0; bottom: 0; height: 42%;
  background: #5f6372; border-top: 6px solid #4b4e5a; border-bottom: 10px solid #c9cfe2;
}
.lane {
  position: absolute; left: 0; right: 0; top: 48%; height: 6px;
  background: repeating-linear-gradient(90deg, #fff 0 46px, transparent 46px 80px);
}
.stop-sign {
  position: absolute; right: 13%; bottom: -14px; width: 26px; height: 26px; border-radius: 50%;
  background: #cfe0f5; border: 3px solid #8fb0d8; display: flex; align-items: center; justify-content: center;
  font-size: 12px; z-index: 3;
}

.hud { position: absolute; inset: 0; pointer-events: none; z-index: 20; }
.hud > * { pointer-events: auto; position: absolute; }
.icon-btn {
  left: 12px; top: 12px; width: 44px; height: 44px; border-radius: 12px;
  background: rgba(255,255,255,.45); color: #333; font-size: 34px; line-height: 40px;
}
.level-text {
  left: 50%; top: 22px; transform: translateX(-50%); font-size: 26px; font-weight: 900; color: #ffd83b;
  -webkit-text-stroke: 1.5px #6b3d00; text-shadow: 0 3px 0 #6b3d00; white-space: nowrap;
}
.remain-text {
  right: 12px; top: 22px; font-size: 22px; font-weight: 900; color: #6bff3d;
  -webkit-text-stroke: 1.5px #1b3d10; text-shadow: 0 3px 0 #1b3d10;
}
.gear {
  right: 14px; top: 58px; width: 38px; height: 38px; border-radius: 50%; background: #ffb21e;
  color: #fff; font-size: 26px; line-height: 36px; border: 3px solid #a65c00;
}
.tips-btn {
  left: 6px; top: 62px; background: transparent; color: #fff; font-size: 13px; font-weight: 800;
  -webkit-text-stroke: .6px #333; display: flex; flex-direction: column; align-items: center;
}
.tips-btn span { font-size: 26px; -webkit-text-stroke: 0; }

/* ---------- 巴士 ---------- */
.bus { position: absolute; left: 0; bottom: 18%; width: var(--bw); height: calc(var(--bw) * .46); z-index: 4; }
.bus-body {
  position: absolute; left: 0; right: 0; top: 30%; bottom: 14%;
  background: var(--bc); border-radius: 10px 22px 10px 10px;
  box-shadow: inset 0 -7px 0 rgba(0,0,0,.18), inset 0 4px 0 rgba(255,255,255,.4), 0 2px 0 rgba(0,0,0,.25);
}
.bus.white .bus-body { box-shadow: inset 0 -7px 0 rgba(0,0,0,.12), 0 0 0 2px #b9bcc6; }
.bus-win { position: absolute; top: 18%; height: 30%; width: 13%; background: #2d3a4a; border-radius: 4px; opacity: .85; }
.bus-door { position: absolute; top: 18%; bottom: 8%; width: 16%; left: 42%; background: rgba(0,0,0,.35); border-radius: 4px; }
.bus-front { position: absolute; top: 14%; right: 3%; width: 9%; height: 50%; background: #2d3a4a; border-radius: 3px 10px 3px 3px; }
.bus-rail {
  position: absolute; left: 4%; right: 18%; top: 4%; height: 28%;
  border: 3px solid rgba(255,255,255,.85); border-bottom: none; border-radius: 4px 4px 0 0;
}
.wheel {
  position: absolute; bottom: 0; width: 17%; aspect-ratio: 1; border-radius: 50%;
  background: #333; border: 4px solid #e6e6e6; box-shadow: inset 0 0 0 4px #333, inset 0 0 0 9px #bbb;
}
.wheel.w1 { left: 12%; } .wheel.w2 { right: 14%; }
.bus-seats { position: absolute; left: 8%; right: 22%; top: -6%; height: 42%; display: flex; justify-content: space-around; }
.seat { position: relative; width: 22%; height: 100%; }
.seat::before {
  content: ""; position: absolute; left: 8%; right: 8%; bottom: 0; height: 70%;
  background: linear-gradient(#a5aab5, #7d8290); border-radius: 5px 5px 0 0;
}
.seat-bear { position: absolute; left: 0; bottom: 0; width: 100%; height: 110%; z-index: 2; }
.seat-bear svg { width: 100%; height: 100%; display: block; }

/* ---------- 站台 ---------- */
.station { flex: 0 0 auto; display: flex; justify-content: center; padding: 14px 0 8px; }
.slots { display: flex; gap: 3px; }
.slot {
  position: relative; width: var(--ss); height: calc(var(--ss) * 1.12); border-radius: 6px; background: #fff;
  box-shadow: 0 4px 0 #b3b9cb;
}
.slot.locked { background: #7d8290; box-shadow: 0 4px 0 #555a66; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.slot.locked::after { content: "＋"; color: #fff; font-size: calc(var(--ss) * .5); font-weight: 900; }
.slot.flash { animation: flash .5s 2; }
@keyframes flash { 50% { background: #ff7a7a; } }

/* ---------- 棋盘 ---------- */
.board-wrap { flex: 1 1 auto; display: flex; justify-content: center; align-items: flex-start; padding-top: 18px; min-height: 0; }
.board {
  background: #a1a8bb; padding: 0 6px 8px 6px; border-radius: 0 0 10px 10px;
  box-shadow: 0 6px 0 #868da0;
}
.tiles { display: grid; gap: 0; }
.tile { width: var(--cell); height: var(--cell); padding: 2px; }
.tile i { display: block; width: 100%; height: 100%; border-radius: 5px; background: #e4ebf6; box-shadow: inset 0 -3px 0 #c6cddd; }

/* ---------- 小熊 ---------- */
.layer { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
.bear {
  position: absolute; left: 0; top: 0; width: var(--bs); height: calc(var(--bs) * 1.1);
  transform-origin: 0 0; pointer-events: auto; cursor: pointer; will-change: transform;
}
.bear svg { width: 100%; height: 100%; display: block; transition: filter .2s; }
.bear.blocked svg { filter: brightness(.96); }
.bear.blocked { cursor: default; }
.bear .q {
  position: absolute; left: 0; right: 0; top: 40%; text-align: center; pointer-events: none;
  font-size: calc(var(--bs) * .44); font-weight: 900; line-height: 1; color: #fff; font-family: Arial, sans-serif;
  text-shadow: 0 0 2px #1d1e22, 0 2px 0 #1d1e22;
}
.bear.moving { pointer-events: none; }
.bear.moving svg { animation: bob .22s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8%); } }
.bear.shake svg { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-10%); } 75% { transform: translateX(10%); } }

/* ---------- 道具 ---------- */
.boosters {
  flex: 0 0 auto; display: flex; justify-content: space-around; padding: 12px 6px 16px;
  background: linear-gradient(#c3d3ea, #aec6e2);
}
.booster { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bbtn {
  display: flex; align-items: center; gap: 3px; padding: 9px 9px; border-radius: 14px;
  font-size: 15px; font-weight: 900; color: #fff; -webkit-text-stroke: .5px rgba(0,0,0,.4); white-space: nowrap;
  box-shadow: 0 4px 0 rgba(0,0,0,.25); border: 3px solid rgba(0,0,0,.35);
}
.bbtn b { font-size: 18px; }
.bbtn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.25); }
.bbtn:disabled { filter: grayscale(.9) brightness(.9); cursor: not-allowed; }
.bbtn.orange { background: #ff9d1e; }
.bbtn.cyan { background: #3cc9e6; }
.bbtn.purple { background: #b06ee8; }
.bcount { font-size: 18px; font-weight: 900; color: #4b5269; }

/* ---------- 提示 & 弹窗 ---------- */
.toast {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(.8); opacity: 0;
  background: rgba(0,0,0,.72); color: #fff; padding: 10px 20px; border-radius: 20px; font-size: 16px; font-weight: 700;
  transition: .2s; pointer-events: none; z-index: 50; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.modal { position: absolute; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 100; }
.panel {
  width: 84%; max-width: 360px; background: #fff7e4; border: 4px solid #8a4e00; border-radius: 22px; padding: 20px 18px;
  box-shadow: 0 8px 0 rgba(0,0,0,.3); animation: pop .25s;
}
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
.panel-title { text-align: center; font-size: 28px; font-weight: 900; color: #ff9d1e; -webkit-text-stroke: 1px #7a4a00; margin-bottom: 12px; }
.panel-body { color: #5a4630; font-size: 15px; line-height: 1.7; margin-bottom: 16px; }
.panel-body ol, .panel-body ul { padding-left: 20px; }
.panel-body .center { text-align: center; font-size: 18px; }
.panel-btns { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.panel-btns .btn { font-size: 18px; padding: 10px 16px; }
.switch-row { display: flex; justify-content: space-between; align-items: center; font-size: 17px; font-weight: 700; }
.stars { text-align: center; font-size: 40px; margin: 4px 0 8px; }
