:root {
  --orange: #FF8A3D;
  --orange-deep: #E56B18;
  --orange-light: #FFC45A;
  --cream: #FFF4DA;
  --wood: #8A4F16;
  --wood-dark: #5A2E0A;
  --brown: #6B3A12;
  --ink: #4A2A0C;
  --green: #6DB23C;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  display: flex;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 12%, rgba(255, 244, 198, .55) 0%, rgba(255, 244, 198, 0) 36%),
    radial-gradient(circle at 50% 38%, #A9D96C 0%, #6FAE42 42%, #3F7028 100%);
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

button {
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

button:focus-visible {
  outline: 3px solid #FFF7D8;
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.app {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  isolation: isolate;
  background: #8FD6F5;
  box-shadow: 0 0 70px rgba(20, 44, 8, .35);
}

/* ---------- 农场场景 ---------- */
.scene {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: linear-gradient(180deg, #65C4EE 0%, #8FD9F6 28%, #C6EEFD 48%, #E6F8FF 54%, #9DD567 54.1%, #75B944 74%, #5DA02F 100%);
}

.sky {
  position: absolute;
  inset: 0 0 auto 0;
  height: 60%;
  background: linear-gradient(180deg, rgba(75, 185, 235, .35) 0%, rgba(255, 255, 255, 0) 70%);
}

.sun {
  position: absolute;
  top: calc(var(--safe-top) + 4%);
  right: 7%;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: radial-gradient(circle, #FFF8BE 0 24%, #FFEB84 34%, rgba(255, 226, 96, .38) 48%, rgba(255, 221, 80, 0) 70%);
  animation: sunPulse 6s ease-in-out infinite;
}

.cloud {
  position: absolute;
  height: 24px;
  width: 92px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .82);
  filter: blur(.8px);
  box-shadow: 0 8px 18px rgba(90, 170, 210, .08);
  animation: cloudDrift 22s ease-in-out infinite alternate;
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: inherit;
}

.cloud::before {
  width: 38px;
  height: 38px;
  left: 14px;
  top: -18px;
}

.cloud::after {
  width: 28px;
  height: 28px;
  right: 15px;
  top: -13px;
}

.cloud-a {
  top: 12%;
  left: 5%;
  transform: scale(.86);
  animation-delay: -3s;
}

.cloud-b {
  top: 22%;
  right: 2%;
  transform: scale(1.14);
  opacity: .62;
  animation-delay: -9s;
}

.cloud-c {
  top: 33%;
  left: 28%;
  transform: scale(.62);
  opacity: .5;
  animation-delay: -14s;
}

.hill {
  position: absolute;
  left: -14%;
  right: -14%;
  pointer-events: none;
}

.hill-far {
  z-index: 1;
  bottom: 31%;
  height: 24%;
  border-radius: 50% 50% 0 0;
  background:
    radial-gradient(ellipse at 26% 25%, rgba(255, 255, 255, .16) 0%, rgba(255, 255, 255, 0) 38%),
    linear-gradient(180deg, #B8E57A 0%, #98D25E 100%);
}

.hill-mid {
  z-index: 4;
  bottom: 17%;
  height: 30%;
  border-radius: 48% 48% 0 0;
  background:
    radial-gradient(ellipse at 74% 18%, rgba(255, 255, 255, .14) 0%, rgba(255, 255, 255, 0) 35%),
    linear-gradient(180deg, #8ECD56 0%, #6FB43A 100%);
}

.hill-near {
  z-index: 5;
  bottom: 0;
  height: 38%;
  border-radius: 42% 42% 0 0;
  background:
    radial-gradient(ellipse at 22% 4%, rgba(255, 255, 255, .13) 0%, rgba(255, 255, 255, 0) 42%),
    linear-gradient(180deg, #7DC247 0%, #5E9F2F 100%);
}

.bg-art {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.bg-barn {
  left: -56px;
  top: 19%;
  width: 194px;
  opacity: .76;
  filter: saturate(.98) brightness(1.02) blur(.2px);
  transform: rotate(-2deg);
  -webkit-mask-image: radial-gradient(ellipse 64% 58% at 51% 54%, #000 42%, rgba(0, 0, 0, .4) 66%, transparent 82%);
  mask-image: radial-gradient(ellipse 64% 58% at 51% 54%, #000 42%, rgba(0, 0, 0, .4) 66%, transparent 82%);
}

.bg-windmill {
  right: -68px;
  top: 16%;
  width: 216px;
  opacity: .76;
  filter: saturate(.98) brightness(1.02) blur(.2px);
  transform: rotate(1.5deg);
  -webkit-mask-image: radial-gradient(ellipse 62% 58% at 48% 52%, #000 42%, rgba(0, 0, 0, .4) 66%, transparent 82%);
  mask-image: radial-gradient(ellipse 62% 58% at 48% 52%, #000 42%, rgba(0, 0, 0, .4) 66%, transparent 82%);
}

.fence {
  position: absolute;
  z-index: 3;
  left: -5%;
  right: -5%;
  bottom: 47%;
  height: 36px;
  opacity: .36;
  background:
    linear-gradient(180deg, transparent 0 7px, rgba(178, 121, 62, .95) 7px 12px, transparent 12px 22px, rgba(166, 109, 51, .95) 22px 27px, transparent 27px),
    repeating-linear-gradient(90deg, transparent 0 44px, rgba(160, 100, 44, .95) 44px 54px, transparent 54px 86px);
  filter: blur(.2px);
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 18%, #000 82%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0%, #000 18%, #000 82%, transparent 100%);
}

.grass-texture {
  position: absolute;
  z-index: 6;
  left: 0;
  right: 0;
  bottom: 0;
  height: 42%;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 12% 62%, rgba(255, 232, 116, .9) 0 2.5px, rgba(255, 232, 116, 0) 3.5px),
    radial-gradient(circle at 24% 84%, rgba(255, 255, 255, .55) 0 2px, rgba(255, 255, 255, 0) 3px),
    radial-gradient(circle at 81% 72%, rgba(255, 228, 108, .8) 0 2.5px, rgba(255, 228, 108, 0) 3.5px),
    radial-gradient(circle at 91% 46%, rgba(255, 255, 255, .42) 0 2px, rgba(255, 255, 255, 0) 3px),
    repeating-linear-gradient(102deg, rgba(255, 255, 255, 0) 0 19px, rgba(255, 255, 255, .035) 19px 20px, rgba(255, 255, 255, 0) 20px 38px);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 30%, #000 100%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 30%, #000 100%);
}

/* ---------- 顶部信息 ---------- */
.hud {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 12px) 16px 0;
}

.level-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  min-width: 88px;
  padding: 6px 15px 7px;
  border: 2px solid #6B3A0F;
  border-radius: 16px;
  background: linear-gradient(180deg, #C48336 0%, #9A5A1C 55%, #7C430F 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 229, 176, .48),
    inset 0 -3px 0 rgba(68, 32, 2, .28),
    0 4px 0 #5A2E0A,
    0 8px 12px rgba(49, 25, 3, .28);
  color: #FFF3D4;
  text-shadow: 0 2px 0 rgba(76, 35, 4, .46);
  font-weight: 900;
  letter-spacing: .05em;
}

.level-chip b {
  font-size: 25px;
  line-height: 1;
  color: #FFD763;
  margin: 0 2px;
  text-shadow: 0 2px 0 #7A3D09, 0 0 12px rgba(255, 208, 90, .35);
}

.level-label {
  font-size: 12px;
  opacity: .95;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.score-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 76px;
  padding: 5px 12px 5px 9px;
  border: 2px solid #E07A1D;
  border-radius: 999px;
  background: linear-gradient(180deg, #FFD36B 0%, #FFAD3C 58%, #FF922F 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .62),
    inset 0 -3px 0 rgba(198, 98, 15, .22),
    0 4px 0 #C46A17,
    0 8px 12px rgba(84, 42, 0, .24);
  color: #5B2D00;
  font-weight: 900;
}

.score-chip .mp-icon {
  width: 19px;
  height: 19px;
  color: #FFF9D8;
  filter: drop-shadow(0 1px 0 rgba(160, 80, 0, .45));
}

.score-chip b {
  font-size: 17px;
  line-height: 1;
  letter-spacing: .01em;
}

.score-chip.bump b {
  animation: scoreBump .32s ease;
}

.sound-btn {
  position: relative;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 2px solid #6B3A0F;
  border-radius: 50%;
  background: linear-gradient(180deg, #FFF5D8 0%, #F3D89F 100%);
  box-shadow:
    inset 0 2px 0 #FFFDF4,
    inset 0 -3px 0 rgba(146, 95, 34, .24),
    0 3px 0 #8D541B,
    0 6px 10px rgba(55, 30, 4, .22);
  color: #8A4F16;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease;
}

.sound-btn:active {
  transform: translateY(3px);
  box-shadow: inset 0 2px 0 #FFFDF4, inset 0 -2px 0 rgba(146, 95, 34, .24), 0 0 0 #8D541B;
}

.sound-btn .mp-icon {
  position: absolute;
  inset: 7px;
  width: 20px;
  height: 20px;
}

.sound-btn .sound-off {
  display: none;
}

.sound-btn.muted .sound-on {
  display: none;
}

.sound-btn.muted .sound-off {
  display: inline-block;
}

.progress-row {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 20px 2px;
}

.progress-track {
  flex: 1;
  height: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .38);
  border-radius: 999px;
  background: rgba(66, 38, 12, .3);
  box-shadow: inset 0 2px 4px rgba(35, 17, 2, .38), 0 1px 0 rgba(255, 255, 255, .18);
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #FFE07A 0%, #FFBD45 40%, #FF8A3D 100%);
  box-shadow: 0 0 9px rgba(255, 196, 90, .7);
  transition: width .38s cubic-bezier(.3, .8, .3, 1);
}

.progress-text {
  flex: 0 0 auto;
  min-width: 62px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 248, 230, .62);
  color: #563512;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .02em;
  text-align: center;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .5);
}

/* ---------- 游戏区 ---------- */
.stage {
  position: relative;
  z-index: 5;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  padding: 0 14px calc(var(--safe-bottom) + 12px);
}

.board-area {
  position: relative;
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 2px 0 4px;
}

.board-shadow {
  position: absolute;
  z-index: 0;
  bottom: 6%;
  left: 14%;
  right: 14%;
  height: 30px;
  border-radius: 50%;
  background: rgba(49, 27, 5, .24);
  filter: blur(15px);
  pointer-events: none;
}

.board {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  width: 320px;
  height: 320px;
  touch-action: manipulation;
}

.board::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: -7%;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(255, 247, 216, .18) 0%, rgba(255, 244, 202, .08) 46%, rgba(255, 244, 202, 0) 70%);
  pointer-events: none;
}

.tile {
  position: absolute;
  z-index: 1;
  display: block;
  padding: 0;
  border: 0;
  border-radius: 18%;
  background: transparent;
  cursor: pointer;
  transform-origin: 50% 55%;
  transition: transform .11s ease, filter .16s ease, opacity .2s ease;
  will-change: transform;
}

.tile img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 18%;
  pointer-events: none;
  filter: drop-shadow(0 5px 0 #A56428) drop-shadow(0 10px 8px rgba(52, 28, 6, .32));
  transition: filter .16s ease, transform .11s ease;
}

.tile.free img {
  filter: drop-shadow(0 5px 0 #A56428) drop-shadow(0 11px 9px rgba(52, 28, 6, .34));
}

.tile.covered {
  cursor: default;
}

.tile.covered img {
  filter: brightness(.56) saturate(.72) drop-shadow(0 4px 0 rgba(92, 56, 20, .45)) drop-shadow(0 7px 5px rgba(30, 16, 2, .2));
}

.tile.free:active img {
  transform: translateY(3px) scale(.95);
  filter: brightness(1.04) drop-shadow(0 2px 0 #A56428) drop-shadow(0 4px 5px rgba(52, 28, 6, .3));
}

.tile.enter {
  animation: tileIn .34s cubic-bezier(.2, 1.45, .45, 1) backwards;
  animation-delay: var(--d, 0ms);
}

.tile.gone {
  opacity: 0;
  transform: scale(.35) rotate(6deg);
  pointer-events: none;
  transition: transform .24s ease, opacity .22s ease;
}

.tile.shake {
  animation: tileShake .3s ease;
}

.tile.shuffling img {
  transform: scale(.72) rotate(9deg);
  opacity: .42;
}

.tile.hint::before {
  content: "";
  position: absolute;
  z-index: 3;
  inset: -4px;
  border: 3px solid #FFE16E;
  border-radius: 24%;
  box-shadow: 0 0 16px rgba(255, 201, 60, .95), inset 0 0 8px rgba(255, 240, 170, .55);
  animation: hintRing .65s ease-in-out infinite alternate;
  pointer-events: none;
}

.slot.hint {
  box-shadow:
    0 0 0 2px #FFE16E,
    0 0 16px rgba(255, 201, 60, .9),
    inset 0 3px 7px rgba(0, 0, 0, .6);
}

/* ---------- 牛槽 ---------- */
.tray-area {
  position: relative;
  z-index: 6;
  flex: 0 0 auto;
  padding-top: 3px;
}

.tray-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 7px 5px;
  color: #4C2B0B;
  font-size: 11.5px;
  font-weight: 900;
  letter-spacing: .08em;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .48);
}

.tray-head b {
  color: #6B3A12;
  font-size: 11px;
  letter-spacing: .04em;
}

.tray {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  padding: 8px;
  border: 2px solid #552B08;
  border-radius: 18px;
  background:
    repeating-linear-gradient(92deg, rgba(255, 255, 255, .045) 0 3px, rgba(255, 255, 255, 0) 3px 12px),
    linear-gradient(180deg, #A46A34 0%, #885122 50%, #6E3C14 100%);
  box-shadow:
    inset 0 3px 0 rgba(255, 220, 160, .38),
    inset 0 -5px 10px rgba(38, 17, 1, .46),
    0 5px 0 #4B2608,
    0 11px 16px rgba(42, 20, 2, .3);
}

.slot {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  border-radius: 10px;
  background: linear-gradient(180deg, #4E2A0E 0%, #633714 60%, #74431C 100%);
  box-shadow:
    inset 0 3px 7px rgba(0, 0, 0, .6),
    inset 0 -1px 0 rgba(255, 200, 120, .2),
    0 1px 0 rgba(255, 224, 170, .14);
}

.slot.filled {
  background: transparent;
  box-shadow: none;
}

.slot-tile {
  position: absolute;
  inset: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: slotIn .2s cubic-bezier(.2, 1.4, .45, 1) both;
}

.slot-tile img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  filter: drop-shadow(0 2px 2px rgba(33, 17, 2, .35));
}

.slot.matched {
  z-index: 2;
  box-shadow:
    0 0 0 2px #FFD65A,
    0 0 18px rgba(255, 205, 80, .8),
    inset 0 0 8px rgba(255, 235, 160, .5);
}

.slot.matched .slot-tile {
  animation: matchPop .34s cubic-bezier(.3, 1.3, .5, 1) both;
}

/* ---------- 操作 ---------- */
.actions {
  position: relative;
  z-index: 6;
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding-top: 10px;
}

.action-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
  min-width: 0;
  min-height: 49px;
  padding: 5px 3px 4px;
  border: 2px solid #E0781D;
  border-radius: 13px;
  background: linear-gradient(180deg, #FFD36B 0%, #FFAD3C 55%, #FF922F 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .65),
    inset 0 -3px 0 rgba(198, 98, 15, .2),
    0 4px 0 #CF6C16,
    0 8px 12px rgba(80, 38, 0, .22);
  color: #5B2D00;
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: .03em;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease;
}

.action-btn:active {
  transform: translateY(3px);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .55), 0 1px 0 #CF6C16, 0 3px 5px rgba(80, 38, 0, .18);
}

.action-btn .mp-icon {
  width: 19px;
  height: 19px;
}

.tip-line {
  flex: 0 0 auto;
  padding-top: 5px;
  color: #472B11;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  line-height: 1.3;
  text-align: center;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .5);
}

/* ---------- 特效 ---------- */
.fx {
  position: absolute;
  z-index: 40;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.fly-tile {
  position: fixed;
  z-index: 60;
  margin: 0;
  border-radius: 16%;
  pointer-events: none;
  filter: drop-shadow(0 8px 10px rgba(45, 23, 3, .35));
  will-change: transform;
}

.score-pop {
  position: absolute;
  z-index: 61;
  transform: translate(-50%, -50%);
  color: #FFE16E;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: .02em;
  text-shadow:
    0 2px 0 #B85B0E,
    0 0 12px rgba(255, 160, 40, .9),
    0 4px 10px rgba(84, 38, 0, .45);
  animation: scorePop .85s cubic-bezier(.2, .8, .3, 1) forwards;
  pointer-events: none;
}

/* ---------- 结算 ---------- */
.overlay {
  position: absolute;
  z-index: 80;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px 24px calc(var(--safe-bottom) + 26px);
  background: rgba(38, 22, 7, .5);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  overflow: hidden;
}

.dialog {
  position: relative;
  z-index: 2;
  width: min(100%, 336px);
  padding: 40px 20px 18px;
  border: 3px solid #E4BE7A;
  border-radius: 26px;
  background:
    radial-gradient(circle at 50% 0%, #FFFDF2 0%, rgba(255, 253, 242, 0) 55%),
    linear-gradient(180deg, #FFF9EA 0%, #FBEBCB 100%);
  box-shadow:
    inset 0 3px 0 #FFFEF8,
    inset 0 -4px 0 rgba(190, 145, 76, .18),
    0 18px 44px rgba(20, 10, 0, .48),
    0 0 0 8px rgba(255, 248, 224, .1);
  text-align: center;
  animation: dialogIn .38s cubic-bezier(.18, 1.32, .38, 1) both;
}

.dialog::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 8px;
  border: 1px dashed rgba(196, 151, 83, .38);
  border-radius: 19px;
  pointer-events: none;
}

.dialog-cow {
  position: absolute;
  top: -74px;
  left: 50%;
  width: 116px;
  height: 116px;
  margin-left: -58px;
  border-radius: 22%;
  filter: drop-shadow(0 9px 10px rgba(88, 48, 9, .3));
  animation: cowFloat 2.4s ease-in-out infinite;
}

.brand {
  margin-top: 2px;
  color: #B27A35;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .42em;
  text-indent: .42em;
}

.dialog h2 {
  margin: 3px 0 5px;
  color: #6B3A12;
  font-size: 26px;
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: .02em;
  text-shadow: 0 2px 0 #FFE9B8;
}

.dialog p {
  margin: 0 0 14px;
  color: #96744C;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.5;
}

.ov-score {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 9px;
  margin: 0 0 5px;
  padding: 8px 12px;
  border: 1px solid #EAD3A6;
  border-radius: 14px;
  background: rgba(255, 255, 255, .62);
  color: #90704A;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .04em;
}

.ov-score b {
  color: #FF8A3D;
  font-size: 27px;
  line-height: 1;
  text-shadow: 0 1px 0 #FFF;
}

.ov-best {
  margin-bottom: 15px;
  color: #AE8D62;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .03em;
}

.primary-btn {
  width: 100%;
  min-height: 48px;
  padding: 11px 16px;
  border: 2px solid #E0781D;
  border-radius: 16px;
  background: linear-gradient(180deg, #FFD36B 0%, #FFAD3C 55%, #FF922F 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, .65),
    0 5px 0 #CF6C16,
    0 9px 14px rgba(160, 70, 0, .22);
  color: #5B2D00;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: .06em;
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease;
}

.primary-btn:active {
  transform: translateY(3px);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .5), 0 2px 0 #CF6C16;
}

.ghost-btn {
  width: 100%;
  min-height: 40px;
  margin-top: 8px;
  padding: 8px;
  border: 0;
  background: transparent;
  color: #9A774C;
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: .04em;
  cursor: pointer;
}

.ghost-btn:active {
  opacity: .62;
}

.overlay.lose .confetti {
  display: none;
}

.overlay.lose .dialog-cow {
  filter: grayscale(.32) brightness(.98) drop-shadow(0 9px 10px rgba(88, 48, 9, .26));
  animation: none;
  transform: rotate(-5deg);
}

.confetti {
  position: absolute;
  z-index: 1;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -22px;
  left: var(--x, 50%);
  width: var(--w, 8px);
  height: var(--h, 13px);
  border-radius: 2px;
  background: var(--c, #FFD45A);
  opacity: .92;
  transform: rotate(var(--r, 0deg));
  animation: confettiFall var(--d, 2.6s) linear var(--delay, 0s) infinite;
}

/* ---------- 动画 ---------- */
@keyframes sunPulse {
  0%, 100% { transform: scale(1); opacity: .95; }
  50% { transform: scale(1.06); opacity: 1; }
}

@keyframes cloudDrift {
  from { margin-left: -8px; }
  to { margin-left: 14px; }
}

@keyframes tileIn {
  0% { opacity: 0; transform: scale(.55) translateY(14px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes tileShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px) rotate(-2deg); }
  40% { transform: translateX(4px) rotate(2deg); }
  60% { transform: translateX(-3px) rotate(-1deg); }
  80% { transform: translateX(3px) rotate(1deg); }
}

@keyframes hintRing {
  from { opacity: .55; transform: scale(.96); }
  to { opacity: 1; transform: scale(1.04); }
}

@keyframes scoreBump {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.28); }
}

@keyframes slotIn {
  0% { opacity: 0; transform: scale(.55); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes matchPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.18) translateY(-4px); }
  100% { transform: scale(0) rotate(16deg); opacity: 0; }
}

@keyframes scorePop {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.6); }
  25% { opacity: 1; transform: translate(-50%, -60%) scale(1.12); }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(1); }
}

@keyframes dialogIn {
  0% { opacity: 0; transform: translateY(18px) scale(.9); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes cowFloat {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-6px) rotate(2deg); }
}

@keyframes confettiFall {
  0% { transform: translate3d(0, -20px, 0) rotate(var(--r, 0deg)); opacity: 0; }
  8% { opacity: .95; }
  100% { transform: translate3d(var(--sway, 18px), 110vh, 0) rotate(calc(var(--r, 0deg) + 420deg)); opacity: .8; }
}

@media (max-height: 700px) {
  .hud { padding-top: calc(var(--safe-top) + 8px); }
  .progress-row { padding-top: 6px; }
  .actions { padding-top: 7px; }
  .tray-head { padding-bottom: 3px; }
  .tip-line { font-size: 9.5px; padding-top: 3px; }
}

@media (max-height: 620px) {
  .level-chip { padding: 4px 12px 5px; }
  .level-chip b { font-size: 21px; }
  .score-chip { padding: 4px 10px 4px 8px; }
  .score-chip b { font-size: 15px; }
  .sound-btn { width: 34px; height: 34px; }
  .sound-btn .mp-icon { inset: 6px; width: 18px; height: 18px; }
  .progress-row { padding-top: 5px; }
  .progress-track { height: 6px; }
  .board-area { padding-bottom: 0; }
  .tray { padding: 6px; gap: 3px; }
  .tray-area { padding-top: 0; }
  .actions { padding-top: 5px; gap: 5px; }
  .action-btn { min-height: 42px; font-size: 9.5px; padding: 4px 2px 3px; }
  .action-btn .mp-icon { width: 17px; height: 17px; }
  .tip-line { display: none; }
}

@media (max-height: 620px) {
  .overlay { padding-top: 54px; padding-bottom: calc(var(--safe-bottom) + 12px); }
  .dialog { padding: 32px 16px 12px; }
  .dialog-cow { width: 94px; height: 94px; top: -60px; margin-left: -47px; }
  .dialog h2 { font-size: 22px; }
  .dialog p { margin-bottom: 10px; font-size: 12px; }
  .ov-score { padding: 6px 10px; }
  .ov-score b { font-size: 23px; }
  .ov-best { margin-bottom: 10px; }
  .primary-btn { min-height: 44px; font-size: 15px; }
  .ghost-btn { min-height: 32px; margin-top: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

/* 首页追加榜单：保持原游戏一屏尺寸，向下滚动查看。 */
.app { overflow-y: auto; overflow-x: hidden; }
.hud, .progress-row { flex-shrink: 0; }
.stage { flex: 1 0 auto; min-height: calc(100dvh - 110px); }
.leaderboard { position: relative; z-index: 6; flex-shrink: 0; margin: 8px 14px calc(20px + var(--safe-bottom)); padding: 18px 14px; border: 2px solid #E5AD62; border-radius: 20px; background: #FFF4DA; color: var(--ink); }
.leaderboard h2 { margin: 0 0 6px; font-size: 21px; }
.leaderboard-note, .leaderboard-status { margin: 0 0 14px; font-size: 12px; color: #896342; line-height: 1.6; }
.leaderboard-list { padding: 0; margin: 0; list-style: none; }
.leaderboard-row { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 62px; padding: 10px 8px; border: 0; border-bottom: 1px solid #EFDABA; background: transparent; text-align: left; color: inherit; font: inherit; border-radius: 10px; }
button.leaderboard-row { cursor: pointer; }
button.leaderboard-row:active, button.leaderboard-row:focus-visible { background: #FFE0B7; }
.leaderboard-rank { flex: 0 0 30px; text-align: center; font-weight: 800; color: #C76420; font-size: 15px; }
.leaderboard-avatar { width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%; object-fit: cover; background: #FFE3B5; }
.leaderboard-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.leaderboard-score { flex-shrink: 0; font-size: 15px; font-weight: 800; }
.leaderboard-score small { font-size: 11px; font-weight: 400; margin-left: 3px; }
.leaderboard-self { margin-top: 14px; border: 2px solid var(--orange); border-radius: 12px; background: #FFE5C7; }
.leaderboard-retry { min-height: 44px; padding: 8px 20px; border: 0; border-radius: 10px; color: #542D10; background: var(--orange); font-weight: 700; }
