/* ============ 基础 ============ */
* { box-sizing: border-box; }

:root {
  --orange: #FF8A3D;
  --orange-deep: #F0731C;
  --brown: #6B441F;
  --brown-dark: #4A2E13;
  --cream: #FFF6E3;
  --wood: #B87B45;
  --wood-dark: #7A431D;
  --green: #7CBD4A;
  --green-dark: #3F5E28;
}

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

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: var(--brown-dark);
  background: #8CD6F2;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}

button {
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
  border: none;
  background: none;
  padding: 0;
  color: inherit;
}

img { -webkit-user-drag: none; }

/* ============ 背景场景 ============ */
.scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 42% at 50% 4%, rgba(255, 255, 255, .42), transparent 70%),
    linear-gradient(180deg, #82D2F2 0%, #A9E4F7 26%, #C9EFE6 42%, #C9EA9A 48%, #A8DD70 100%);
}

.sun-glow {
  position: absolute;
  top: -90px;
  right: -70px;
  width: 290px;
  height: 290px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 244, 178, .95) 0%, rgba(255, 232, 140, .45) 38%, rgba(255, 232, 140, 0) 70%);
}

.cloud {
  position: absolute;
  height: 22px;
  border-radius: 999px;
  background: #FFFDF8;
  opacity: .92;
  filter: blur(.2px);
  box-shadow: 0 8px 18px rgba(74, 140, 178, .12);
  animation: drift 30s ease-in-out infinite alternate;
}
.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  background: #FFFDF8;
  border-radius: 50%;
}
.cloud::before { width: 36px; height: 36px; left: 16px; top: -18px; }
.cloud::after { width: 24px; height: 24px; right: 18px; top: -12px; }

.cloud-a { width: 104px; left: 4%; top: 8%; }
.cloud-b { width: 84px; left: 34%; top: 20%; opacity: .72; animation-delay: -9s; }
.cloud-c { width: 64px; left: 30%; top: 24%; opacity: .62; animation-delay: -18s; }

.hills {
  position: absolute;
  left: -2%;
  right: -2%;
  top: 19%;
  width: 104%;
  height: 32%;
  z-index: 1;
}

.barn {
  position: absolute;
  z-index: 2;
  top: 8.5%;
  right: 2px;
  width: clamp(96px, 27vw, 136px);
  height: auto;
  filter: drop-shadow(0 8px 10px rgba(80, 50, 20, .16));
}

.fence {
  position: absolute;
  z-index: 3;
  left: -1%;
  top: 27.5%;
  width: 102%;
  height: 9%;
  opacity: .96;
}

.ground {
  position: absolute;
  z-index: 4;
  left: -6%;
  right: -6%;
  top: 36%;
  bottom: -6%;
  border-radius: 50% 50% 0 0 / 9% 9% 0 0;
  background: linear-gradient(180deg, #B6E37E 0%, #9CD662 12%, #8DCC58 48%, #7DBE4A 100%);
  box-shadow: inset 0 8px 22px rgba(255, 255, 255, .22);
}
.ground::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(ellipse 120px 26px at 14% 22%, rgba(255, 255, 255, .14), transparent 70%),
    radial-gradient(ellipse 150px 30px at 80% 38%, rgba(255, 255, 255, .12), transparent 70%),
    radial-gradient(ellipse 90px 22px at 44% 70%, rgba(52, 104, 22, .12), transparent 70%),
    radial-gradient(ellipse 150px 30px at 14% 88%, rgba(52, 104, 22, .10), transparent 70%);
}

.bush {
  position: absolute;
  z-index: 5;
  border-radius: 50% 50% 42% 42% / 62% 62% 38% 38%;
  filter: drop-shadow(0 10px 10px rgba(44, 86, 18, .18));
  background: radial-gradient(circle at 34% 28%, #8FD05A 0%, #74B640 55%, #609C33 100%);
}
.bush::before {
  content: "";
  position: absolute;
  left: 18%;
  top: -18%;
  width: 52%;
  height: 62%;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #9BD965, #6FAE3E 80%);
}
.bush-1 { width: 190px; height: 116px; left: -64px; bottom: 5%; }
.bush-2 { width: 176px; height: 108px; right: -66px; bottom: 1%; }
.bush-3 { width: 126px; height: 80px; left: -54px; bottom: 32%; opacity: .92; }
.bush-4 { width: 118px; height: 74px; right: -56px; bottom: 28%; opacity: .9; transform: scaleX(-1); }

.flower {
  position: absolute;
  z-index: 6;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: radial-gradient(circle, #FFD35E 0 27%, #FFFDF4 29% 100%);
  box-shadow:
    0 -6px 0 -2px #FFFDF4,
    0 6px 0 -2px #FFFDF4,
    -6px 0 0 -2px #FFFDF4,
    6px 0 0 -2px #FFFDF4;
  opacity: .92;
}
.f1 { left: 8%; bottom: 8%; transform: scale(.9); }
.f2 { right: 12%; bottom: 15%; transform: scale(1.1); }
.f3 { left: 22%; bottom: 26%; transform: scale(.7); opacity: .8; }
.f4 { right: 6%; bottom: 34%; transform: scale(.8); opacity: .82; }
.f5 { left: 45%; bottom: 6%; transform: scale(.65); opacity: .7; }
.f6 { right: 31%; bottom: 29%; transform: scale(.6); opacity: .65; }

.tuft {
  position: absolute;
  z-index: 6;
  color: #5F9E35;
  opacity: .72;
  width: 30px !important;
  height: 30px !important;
}
.t1 { left: 3%; bottom: 19%; transform: rotate(-8deg); }
.t2 { right: 4%; bottom: 27%; transform: rotate(9deg) scale(.85); }
.t3 { left: 30%; bottom: 11%; transform: scale(.7); opacity: .55; }
.t4 { right: 24%; bottom: 7%; transform: scale(.65); opacity: .5; }

.scene::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 8;
  background: radial-gradient(ellipse 74% 62% at 50% 42%, transparent 56%, rgba(46, 80, 20, .16) 100%);
}

/* ============ 游戏容器 ============ */
.game {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 520px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

/* 小羊装饰 */
.sheep {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  filter: drop-shadow(0 10px 7px rgba(44, 86, 18, .2));
}
.sheep img {
  display: block;
  width: 100%;
  height: auto;
  animation: bob 5.6s ease-in-out infinite;
}
.sheep-left { left: 1px; bottom: 104px; width: clamp(94px, 26vw, 126px); }
.sheep-right { right: 0; bottom: 97px; width: clamp(88px, 24vw, 118px); }
.sheep-right img { animation-delay: -2.6s; }

/* ============ 顶部 HUD ============ */
.hud {
  position: absolute;
  z-index: 10;
  top: calc(10px + env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: grid;
  grid-template-columns: 46px 1fr 46px;
  align-items: start;
  gap: 6px;
  pointer-events: none;
}
.hud > * { pointer-events: auto; }

.hud-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #6B4A2A;
  background: linear-gradient(180deg, #FFFDF6, #FBEBCF);
  border: 2px solid #E4C99C;
  box-shadow: 0 3px 0 #C9A26A, 0 6px 12px rgba(74, 48, 20, .2), inset 0 2px 0 rgba(255, 255, 255, .9);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.hud-btn .mp-icon { width: 23px; height: 23px; }
.hud-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #C9A26A, 0 3px 7px rgba(74, 48, 20, .18);
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.level-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 13px;
  border-radius: 999px;
  color: #FFF9EC;
  background: linear-gradient(180deg, #536279 0%, #3D4B5E 55%, #344153 100%);
  border: 2px solid rgba(255, 255, 255, .22);
  box-shadow: 0 3px 0 rgba(38, 47, 60, .55), 0 7px 14px rgba(38, 47, 60, .22), inset 0 1px 0 rgba(255, 255, 255, .25);
  cursor: pointer;
  transition: transform .12s ease;
  max-width: 100%;
}
.level-pill:active { transform: translateY(2px); }
.level-text {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 1.5px;
  white-space: nowrap;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .2);
}
.pill-dash {
  width: 14px;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 249, 236, .46);
  flex: none;
}
.pill-caret {
  width: 16px !important;
  height: 16px !important;
  color: rgba(255, 249, 236, .72);
  flex: none;
  margin-left: -3px;
}

.progress-track {
  width: 96px;
  height: 8px;
  border-radius: 99px;
  background: rgba(255, 252, 240, .52);
  box-shadow: inset 0 1px 2px rgba(78, 55, 25, .3), 0 0 0 1px rgba(255, 255, 255, .22), 0 1px 0 rgba(255, 255, 255, .4);
  overflow: hidden;
}
.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #FFC24D, #FF8A3D);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5);
  transition: width .3s ease;
}

/* ============ 牌桌 ============ */
.stage {
  position: relative;
  z-index: 3;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(88px + env(safe-area-inset-top)) 12px 4px;
}

.board {
  position: relative;
  width: 340px;
  height: 359px;
  flex: none;
}
.board::before {
  content: "";
  position: absolute;
  z-index: 0;
  left: 5%;
  right: 5%;
  bottom: 1%;
  height: 30%;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(48, 82, 20, .30) 0%, rgba(48, 82, 20, .13) 46%, rgba(48, 82, 20, 0) 72%);
  pointer-events: none;
}

.tile {
  position: absolute;
  z-index: 1;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1.5px solid #E0C497;
  border-radius: 14%;
  overflow: hidden;
  background: linear-gradient(180deg, #FFFDF7, #FBEFD7 60%, #F4E1BF);
  box-shadow:
    0 3px 0 #CDAC7A,
    0 6px 9px rgba(70, 45, 15, .26),
    inset 0 2px 0 rgba(255, 255, 255, .95);
  cursor: pointer;
  transform: rotate(var(--rot, 0deg));
  transition: filter .18s ease, transform .14s ease, opacity .16s ease;
  animation: deal .36s cubic-bezier(.2, .8, .3, 1.15) backwards;
  animation-delay: calc(var(--i, 0) * 5ms);
  will-change: transform;
}
.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(ellipse 100% 100% at 50% 50%, #000 84%, transparent 100%);
  mask-image: radial-gradient(ellipse 100% 100% at 50% 50%, #000 84%, transparent 100%);
}
.tile.covered {
  cursor: default;
  filter: brightness(.84) saturate(.88);
}
.tile.covered::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(46, 60, 18, .12);
  pointer-events: none;
}
.tile.picked {
  transform: rotate(var(--rot, 0deg)) scale(.38);
  opacity: 0;
  pointer-events: none;
}
.tile.uncovered { animation: popFree .32s ease; }
.tile.deny { animation: denyShake .3s ease; }

@keyframes denyShake {
  0%, 100% { transform: rotate(var(--rot, 0deg)) translateX(0); }
  25% { transform: rotate(var(--rot, 0deg)) translateX(-3px); }
  55% { transform: rotate(var(--rot, 0deg)) translateX(3px); }
  80% { transform: rotate(var(--rot, 0deg)) translateX(-2px); }
}

@media (hover: hover) {
  .tile:not(.covered):hover {
    transform: rotate(var(--rot, 0deg)) translateY(-2px);
    filter: brightness(1.04);
  }
}
.tile:not(.covered):active {
  transform: rotate(var(--rot, 0deg)) scale(.9);
  box-shadow: 0 1px 0 #CDAC7A, 0 3px 5px rgba(70, 45, 15, .24);
}

/* 提示气泡 */
.toast {
  position: absolute;
  left: 50%;
  bottom: 4px;
  z-index: 9;
  transform: translate(-50%, 8px);
  padding: 9px 15px;
  border-radius: 999px;
  background: rgba(56, 40, 18, .8);
  color: #FFF6E3;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .3px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 6px 16px rgba(20, 12, 4, .22);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.toast.show { animation: toastShow 3.8s ease forwards; }

/* ============ 底部槽位 ============ */
.foot {
  position: relative;
  z-index: 4;
  flex: none;
  padding: 0 14px calc(16px + env(safe-area-inset-bottom));
}

.tray {
  position: relative;
  padding: 9px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .18), rgba(255, 255, 255, 0) 40%),
    linear-gradient(180deg, #CB8C50 0%, #AE6934 55%, #96521F 100%);
  border: 2.5px solid #7A431D;
  box-shadow:
    0 6px 0 #673715,
    0 13px 22px rgba(56, 32, 10, .32),
    inset 0 2px 0 rgba(255, 220, 170, .5);
}
.tray::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 16px;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, .055) 0 2px, transparent 2px 27px);
  pointer-events: none;
}

.slots {
  position: relative;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.slot {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 9px;
  background: linear-gradient(180deg, #65391A, #7B4A23);
  border: 1.5px solid #542E12;
  box-shadow:
    inset 0 4px 7px rgba(32, 16, 4, .55),
    inset 0 -1px 0 rgba(255, 205, 145, .14);
}

.tray-tile {
  position: absolute;
  inset: 2px;
  border-radius: 7px;
  overflow: hidden;
  background: linear-gradient(180deg, #FFFDF6, #F8E8C9);
  box-shadow: 0 1.5px 0 #D3AE77, inset 0 1px 0 #FFF;
}
.tray-tile.new { animation: dropIn .2s ease both; }
.tray-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  -webkit-mask-image: radial-gradient(ellipse 100% 100% at 50% 50%, #000 82%, transparent 100%);
  mask-image: radial-gradient(ellipse 100% 100% at 50% 50%, #000 82%, transparent 100%);
}
.slot.match { animation: matchPop .34s ease forwards; }
.slot.filled::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 7px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .4);
  pointer-events: none;
}

.meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 9px;
  padding: 0 5px;
  font-size: 12.5px;
  font-weight: 700;
  color: #3F5E28;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .5);
}
.remain { white-space: nowrap; }
.rule { opacity: .78; white-space: nowrap; }

/* ============ 遮罩与选关 ============ */
.mask {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(38, 26, 12, .46);
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease, visibility .25s ease;
  backdrop-filter: blur(1.5px);
  -webkit-backdrop-filter: blur(1.5px);
}
.mask.open { opacity: 1; visibility: visible; }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 9px 18px calc(20px + env(safe-area-inset-bottom));
  border-radius: 26px 26px 0 0;
  border-top: 2px solid #E8CFA5;
  background: linear-gradient(180deg, #FFFAEF 0%, #FFF1D6 100%);
  box-shadow: 0 -14px 44px rgba(40, 24, 8, .32), inset 0 2px 0 #FFF;
  transform: translateY(103%);
  transition: transform .34s cubic-bezier(.2, .85, .25, 1);
  visibility: hidden;
}
.sheet.open { transform: translateY(0); visibility: visible; }

.sheet-grab {
  width: 42px;
  height: 5px;
  border-radius: 99px;
  background: #E2CFA9;
  margin: 0 auto 12px;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.sheet-head h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #5B3818;
}
.close-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #8A6A45;
  background: #FFF9EC;
  border: 1.5px solid #E6D0A8;
  box-shadow: 0 2px 0 #D8BE92;
  cursor: pointer;
}
.close-btn .mp-icon { width: 19px; height: 19px; }
.close-btn:active { transform: translateY(2px); box-shadow: 0 0 0 #D8BE92; }

.sheet-sub {
  margin: 5px 0 15px;
  font-size: 12.5px;
  font-weight: 600;
  color: #A08356;
}

.levels {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.lv {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 70px;
  padding: 8px 4px 7px;
  border-radius: 16px;
  border: 1.5px solid #EBD8B4;
  background: linear-gradient(180deg, #FFFDF7, #F8EACD);
  box-shadow: 0 3px 0 #DCC095, inset 0 1px 0 #FFF;
  color: #6B441F;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.lv:active { transform: translateY(2px); box-shadow: 0 1px 0 #DCC095, inset 0 1px 0 #FFF; }
.lv-num { font-size: 21px; font-weight: 900; line-height: 1.05; letter-spacing: .5px; }
.lv-tag { font-size: 10px; font-weight: 700; color: #B2966B; letter-spacing: .5px; }
.lv .mp-icon { width: 15px; height: 15px; color: #B7A382; }

.lv.current {
  background: linear-gradient(180deg, #FFB35F, #FF8A3D 60%, #F67720);
  border-color: #F9A65C;
  color: #FFFDF4;
  box-shadow: 0 3px 0 #D4681A, 0 7px 14px rgba(255, 138, 61, .34), inset 0 2px 0 rgba(255, 255, 255, .45);
}
.lv.current:active { box-shadow: 0 1px 0 #D4681A, 0 4px 8px rgba(255, 138, 61, .3); }
.lv.current .lv-tag { color: rgba(255, 253, 244, .9); }
.lv.done .lv-tag { color: #74A846; }
.lv.locked {
  background: linear-gradient(180deg, #F0E6D1, #E4D7BC);
  border-color: #DCCBAB;
  color: #B4A17F;
  box-shadow: 0 3px 0 #CDBD9F, inset 0 1px 0 rgba(255, 255, 255, .6);
}
.lv.locked .lv-tag { color: #B4A17F; }
.lv.locked:active { transform: none; box-shadow: 0 3px 0 #CDBD9F; }

/* ============ 结算弹层 ============ */
.result-mask {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(34, 25, 13, .52);
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease, visibility .25s ease;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.result-mask.open { opacity: 1; visibility: visible; }

.result-card {
  position: relative;
  width: min(86vw, 352px);
  padding: 16px 22px 20px;
  border-radius: 28px;
  border: 3px solid #E5C795;
  background: linear-gradient(180deg, #FFFBF1 0%, #FFF2D9 100%);
  box-shadow: 0 20px 44px rgba(40, 24, 8, .38), inset 0 2px 0 #FFF;
  text-align: center;
  overflow: hidden;
  transform: scale(.84) translateY(14px);
  transition: transform .34s cubic-bezier(.2, .9, .3, 1.18);
}
.result-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 196, 100, .16), transparent 34%),
    radial-gradient(circle at 84% 8%, rgba(126, 190, 78, .14), transparent 30%);
  pointer-events: none;
}
.result-mask.open .result-card { transform: none; }

.mascot {
  position: relative;
  width: 116px;
  height: 116px;
  margin: 2px auto 8px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid #FFFDF7;
  background: radial-gradient(circle at 50% 28%, #D8F2FB 0%, #C2EA9A 58%, #9AD66A 100%);
  box-shadow: 0 6px 14px rgba(70, 50, 20, .22), inset 0 0 0 3px rgba(255, 255, 255, .5);
}
.mascot-shadow {
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 10px;
  height: 13px;
  border-radius: 50%;
  background: rgba(64, 104, 30, .22);
}
.mascot img {
  position: absolute;
  left: 50%;
  bottom: -2px;
  width: 97%;
  transform: translateX(-50%);
}

.result-title {
  position: relative;
  margin: 2px 0 4px;
  font-size: 27px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #5A3717;
}
.result-title.fail { color: #8A4B2A; }
.result-text {
  position: relative;
  margin: 0 auto 16px;
  max-width: 272px;
  font-size: 13.5px;
  line-height: 1.6;
  font-weight: 600;
  color: #96744E;
}

.result-actions { position: relative; }

.btn-primary {
  display: block;
  width: 100%;
  min-height: 53px;
  border-radius: 16px;
  background: linear-gradient(180deg, #FFC257 0%, #FF9A3F 48%, #FB7E25 100%);
  color: #5A2E08;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 1.5px;
  border: 2px solid rgba(255, 255, 255, .45);
  box-shadow:
    0 5px 0 #C85C14,
    0 11px 20px rgba(220, 110, 20, .3),
    inset 0 2px 0 rgba(255, 255, 255, .55);
  cursor: pointer;
  transition: transform .1s ease, box-shadow .1s ease;
}
.btn-primary:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #C85C14, 0 4px 8px rgba(220, 110, 20, .28);
}
.btn-primary:focus-visible,
.btn-ghost:focus-visible,
.lv:focus-visible,
.hud-btn:focus-visible,
.level-pill:focus-visible {
  outline: 3px solid rgba(255, 179, 95, .9);
  outline-offset: 2px;
}

.btn-ghost {
  display: block;
  margin: 9px auto 0;
  padding: 8px 16px;
  color: #8A6A45;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .5px;
  cursor: pointer;
}

.confetti {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}
.confetti i {
  position: absolute;
  top: -14px;
  left: var(--x);
  width: 8px;
  height: 12px;
  border-radius: 2px;
  background: var(--c);
  animation: confettiFall 1.7s ease-in forwards;
  animation-delay: var(--d);
  opacity: 0;
}

/* ============ 动画 ============ */
@keyframes drift {
  from { transform: translateX(-8px); }
  to { transform: translateX(14px); }
}
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-4px) rotate(1deg); }
}
@keyframes deal {
  from { opacity: 0; transform: translateY(-26px) scale(.62) rotate(var(--rot, 0deg)); }
  to { opacity: 1; transform: translateY(0) scale(1) rotate(var(--rot, 0deg)); }
}
@keyframes popFree {
  0% { filter: brightness(.76); }
  55% { transform: rotate(var(--rot, 0deg)) scale(1.06); }
  100% { filter: none; }
}
@keyframes dropIn {
  0% { transform: translateY(-10px) scale(1.16); opacity: .3; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes matchPop {
  0% { transform: scale(1); }
  38% { transform: scale(1.16); }
  100% { transform: scale(.18); opacity: 0; }
}
@keyframes toastShow {
  0% { opacity: 0; transform: translate(-50%, 10px); }
  12% { opacity: 1; transform: translate(-50%, 0); }
  76% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -7px); }
}
@keyframes confettiFall {
  0% { opacity: 1; transform: translate3d(0, -12px, 0) rotate(0deg); }
  100% { opacity: 0; transform: translate3d(var(--dx), 360px, 0) rotate(600deg); }
}

/* ============ 适配 ============ */
@media (max-height: 670px) {
  .hud { top: calc(8px + env(safe-area-inset-top)); }
  .hud-btn { width: 42px; height: 42px; }
  .hud-btn .mp-icon { width: 21px; height: 21px; }
  .hud { grid-template-columns: 42px 1fr 42px; }
  .level-pill { height: 37px; }
  .level-text { font-size: 15px; }
  .stage { padding-top: calc(74px + env(safe-area-inset-top)); }
  .tray { padding: 7px; border-radius: 15px; }
  .slots { gap: 3px; }
  .foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .meta { margin-top: 6px; font-size: 11.5px; }
  .sheep-left { width: 88px; bottom: 92px; }
  .sheep-right { width: 84px; bottom: 86px; }
  .toast { bottom: 0; font-size: 11.5px; padding: 8px 12px; }
  .result-card { padding: 12px 20px 16px; }
  .mascot { width: 96px; height: 96px; }
  .result-title { font-size: 24px; }
  .btn-primary { min-height: 48px; font-size: 17px; }
}
@media (max-height: 580px) {
  .rule { display: none; }
  .sheep-left, .sheep-right { display: none; }
  .stage { padding-top: calc(66px + env(safe-area-inset-top)); }
  .toast { display: none; }
  .barn { width: 74px; }
}
@media (min-width: 620px) {
  .game { max-width: 500px; }
  .stage { padding-left: 20px; padding-right: 20px; }
  .foot { padding-left: 22px; padding-right: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .01s !important; }
}
