/* ==========================================================
   厨房连连看 2 — 卡通厨房主题
   ========================================================== */
:root {
  --orange: #FF8A3D;
  --orange-deep: #E8621A;
  --orange-dark: #B84B0C;
  --cream: #FFF8E8;
  --cream-2: #FFEFD2;
  --brown: #5A3318;
  --brown-2: #8A5A35;
  --yellow: #FFC531;
  --red: #F0553D;
  --green: #6FBF4C;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", -apple-system, BlinkMacSystemFont, sans-serif;
}

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

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

body {
  font-family: var(--font);
  color: var(--brown);
  background: #F6AA63;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font-family: var(--font);
  border: 0;
  padding: 0;
  cursor: pointer;
  color: inherit;
  background: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:focus-visible { outline: 3px solid rgba(255, 255, 255, .9); outline-offset: 2px; }

/* ---------- 厨房背景 ---------- */
.scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(110% 80% at 78% 4%, rgba(255, 252, 230, .95) 0%, rgba(255, 252, 230, 0) 46%),
    linear-gradient(180deg, #FFE9C8 0%, #FFD9A8 30%, #FFC78D 60%, #F6AA63 100%);
}

.scene-tiles {
  position: absolute;
  left: -2px;
  right: -2px;
  top: 0;
  height: 64%;
  background-image:
    linear-gradient(rgba(255, 255, 255, .34) 1.5px, transparent 1.5px),
    linear-gradient(90deg, rgba(255, 255, 255, .34) 1.5px, transparent 1.5px);
  background-size: 46px 46px;
  opacity: .52;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, .6) 58%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 0%, rgba(0, 0, 0, .6) 58%, transparent 100%);
}

.scene-window {
  position: absolute;
  left: -24px;
  top: 7%;
  width: 150px;
  height: 186px;
  border: 8px solid #FFF4E1;
  border-radius: 18px;
  background: linear-gradient(180deg, #8FD4FF 0%, #D9F2FF 64%, #FFF2D8 65%, #FFE9C4 100%);
  box-shadow: 0 12px 0 rgba(160, 90, 40, .1), 0 20px 34px rgba(150, 80, 20, .12), inset 0 0 20px rgba(255, 255, 255, .65);
  transform: rotate(-1.5deg);
  opacity: .92;
}
.win-sun {
  position: absolute;
  right: 22px;
  top: 18px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, #FFF5A8, #FFD34E 68%, #FFB322);
  box-shadow: 0 0 18px rgba(255, 211, 78, .75);
}
.win-cloud {
  position: absolute;
  height: 16px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .9);
}
.win-cloud::before, .win-cloud::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: inherit;
}
.win-cloud-a { left: 14px; top: 66px; width: 52px; }
.win-cloud-a::before { width: 22px; height: 22px; left: 8px; top: -10px; }
.win-cloud-a::after { width: 16px; height: 16px; left: 28px; top: -6px; }
.win-cloud-b { right: 10px; top: 108px; width: 44px; opacity: .7; }
.win-cloud-b::before { width: 18px; height: 18px; left: 6px; top: -8px; }
.win-bar { position: absolute; background: #FFF4E1; box-shadow: 0 0 0 1px rgba(190, 130, 70, .12); }
.win-bar-v { left: 50%; top: 0; bottom: 0; width: 7px; transform: translateX(-50%); }
.win-bar-h { left: 0; right: 0; top: 58%; height: 7px; }

.scene-shelf {
  position: absolute;
  right: -22px;
  top: 9%;
  width: 176px;
  height: 132px;
  opacity: .9;
}
.shelf-board {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 13px;
  border-radius: 6px;
  background: linear-gradient(180deg, #D28A4A, #A85A22);
  box-shadow: 0 5px 0 rgba(120, 60, 20, .16);
}
.jar {
  position: absolute;
  bottom: 11px;
  border-radius: 8px 8px 10px 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .68), rgba(255, 255, 255, .18));
  border: 2px solid rgba(255, 255, 255, .75);
  box-shadow: inset -4px 0 8px rgba(255, 255, 255, .4), 0 6px 10px rgba(120, 60, 20, .12);
}
.jar-lid {
  position: absolute;
  left: -3px;
  right: -3px;
  top: -9px;
  height: 11px;
  border-radius: 4px;
  background: linear-gradient(180deg, #F0A24F, #C96D25);
}
.jar-fill {
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: 3px;
  height: 48%;
  border-radius: 4px 4px 7px 7px;
  background: linear-gradient(180deg, rgba(255, 168, 60, .95), rgba(227, 111, 20, .95));
}
.jar-a { right: 100px; width: 34px; height: 50px; }
.jar-b { right: 58px; width: 36px; height: 62px; }
.jar-b .jar-fill { background: linear-gradient(180deg, rgba(255, 205, 74, .95), rgba(238, 158, 20, .95)); }
.jar-c { right: 16px; width: 32px; height: 44px; }
.jar-c .jar-fill { background: linear-gradient(180deg, rgba(134, 190, 84, .95), rgba(80, 140, 52, .95)); }

.scene-hang {
  position: absolute;
  right: 4%;
  top: 27%;
  width: 132px;
  height: auto;
  opacity: .72;
  filter: drop-shadow(0 4px 4px rgba(120, 60, 20, .12));
}

.scene-counter {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 21%;
  min-height: 120px;
  background: linear-gradient(180deg, #E8A05D 0%, #D5843F 26%, #C16F2E 62%, #B15F24 100%);
  box-shadow: 0 -10px 24px rgba(140, 70, 20, .14);
}
.counter-top {
  height: 13px;
  background: linear-gradient(180deg, #FFF3D9, #F3C892 70%, #E0A45E);
  box-shadow: 0 4px 8px rgba(110, 55, 15, .18);
}
.counter-front {
  position: absolute;
  inset: 13px 0 0 0;
  background:
    linear-gradient(90deg, transparent 0 12%, rgba(120, 60, 20, .12) 12% 12.6%, transparent 12.6% 49.7%, rgba(120, 60, 20, .12) 49.7% 50.3%, transparent 50.3% 87.4%, rgba(120, 60, 20, .12) 87.4% 88%, transparent 88%),
    repeating-linear-gradient(180deg, rgba(255, 255, 255, .05) 0 2px, transparent 2px 26px);
}
.counter-knob {
  position: absolute;
  bottom: 22%;
  width: 26px;
  height: 7px;
  border-radius: 99px;
  background: linear-gradient(180deg, #FFD79A, #D89951);
  box-shadow: 0 2px 3px rgba(90, 40, 10, .25);
}
.knob-a { left: 24%; }
.knob-b { right: 24%; }
.veg-basket {
  position: absolute;
  left: -8px;
  bottom: 28px;
  width: 148px;
  opacity: .95;
  filter: drop-shadow(0 6px 8px rgba(100, 45, 10, .16));
}

.scene-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 84% at 50% 18%, rgba(255, 255, 255, 0) 42%, rgba(150, 75, 15, .15) 100%),
    linear-gradient(180deg, rgba(255, 255, 255, .06), transparent 30%);
}

.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- 通用 ---------- */
.app { position: relative; z-index: 2; height: 100vh; height: 100dvh; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .26s ease, visibility .26s;
}
.screen.is-active { opacity: 1; visibility: visible; pointer-events: auto; }

.path-layer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 40;
  pointer-events: none;
  overflow: visible;
}

.round-btn {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #FFFDF7, #FFEAC7);
  border: 1.5px solid rgba(255, 255, 255, .95);
  box-shadow: 0 3px 0 #D59C5C, 0 7px 14px rgba(120, 55, 10, .2);
  color: #8A4A1D;
  transition: transform .08s, box-shadow .08s;
}
.round-btn:active { transform: translateY(2px) scale(.96); box-shadow: 0 1px 0 #D59C5C; }
.round-btn .mp-icon { width: 22px; height: 22px; }
.sound-btn .ico-off { display: none; }
.sound-btn.is-muted .ico-on { display: none; }
.sound-btn.is-muted .ico-off { display: block; }

.mp-icon { flex: 0 0 auto; }

/* ---------- 开始页 ---------- */
.screen-home {
  padding: calc(var(--safe-top) + 12px) 16px calc(var(--safe-bottom) + 16px);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.screen-home::-webkit-scrollbar { display: none; }

.home-top {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex: 0 0 auto;
}

.best-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 42px;
  padding: 4px 15px 4px 5px;
  border-radius: 999px;
  background: rgba(255, 249, 235, .86);
  border: 1.5px solid rgba(255, 255, 255, .9);
  box-shadow: 0 3px 0 rgba(200, 135, 65, .28), 0 8px 16px rgba(120, 55, 10, .14);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.coin {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #A85E00;
  background: radial-gradient(circle at 35% 30%, #FFF3A8, #FFD34E 55%, #F2A81A 100%);
  border: 2px solid #FFF6D0;
  box-shadow: inset 0 -2px 0 rgba(180, 110, 0, .22), 0 2px 4px rgba(160, 90, 10, .2);
}
.coin .mp-icon { width: 17px; height: 17px; }
.best-label { font-size: 11px; color: #A27147; letter-spacing: .04em; }
.best-chip b { font-size: 18px; color: #E8621A; font-weight: 900; font-variant-numeric: tabular-nums; }

.logo-wrap {
  position: relative;
  width: 100%;
  max-width: 430px;
  margin: clamp(10px, 3.5vh, 30px) auto 0;
  padding-top: 26px;
  flex: 0 0 auto;
  z-index: 1;
}
.logo-glow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 116%;
  height: 120%;
  transform: translate(-50%, -48%);
  background: radial-gradient(closest-side, rgba(255, 240, 170, .62), rgba(255, 220, 120, 0));
  pointer-events: none;
}
.logo-board {
  position: relative;
  padding: 15px 8px 18px;
  border-radius: 36px;
  background:
    repeating-linear-gradient(102deg, rgba(255, 255, 255, .045) 0 3px, transparent 3px 13px),
    linear-gradient(145deg, #C97A3C 0%, #9A4E1B 48%, #A95B24 100%);
  border: 4px solid #FFD79A;
  box-shadow:
    0 9px 0 #6C310D,
    0 22px 40px rgba(95, 42, 5, .38),
    inset 0 2px 0 rgba(255, 255, 255, .42),
    inset 0 -12px 24px rgba(80, 30, 0, .28);
  transform: rotate(-2deg);
  text-align: center;
  overflow: hidden;
}
.logo-board::after {
  content: "";
  position: absolute;
  left: 7%;
  right: 7%;
  top: 5px;
  height: 2px;
  border-radius: 99px;
  background: rgba(255, 240, 210, .38);
}
.logo-line {
  position: relative;
  z-index: 2;
  display: block;
  font-weight: 900;
  line-height: .96;
  letter-spacing: .03em;
  -webkit-text-stroke: 3px #6B2C08;
  paint-order: stroke fill;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
.logo-line-top {
  font-size: clamp(50px, 16vw, 78px);
  color: #FFC531;
  text-shadow:
    0 5px 0 #F17412,
    0 10px 0 #A63E08,
    0 16px 20px rgba(50, 18, 0, .4);
  transform: rotate(-1.5deg);
}
.logo-line-bottom {
  margin-top: 2px;
  font-size: clamp(42px, 13.6vw, 68px);
  color: #FFF9EA;
  -webkit-text-stroke: 3.5px #7A330C;
  text-shadow:
    0 5px 0 #FF8A3D,
    0 10px 0 #B84B0C,
    0 16px 22px rgba(50, 18, 0, .38);
  transform: rotate(.6deg);
}
.logo-num {
  display: inline-block;
  margin-left: .04em;
  font-size: 1.18em;
  color: #FFC531;
  -webkit-text-stroke: 4px #7A330C;
  text-shadow:
    0 5px 0 #F17412,
    0 10px 0 #A63E08,
    0 14px 18px rgba(50, 18, 0, .3);
  transform: rotate(5deg) translateY(-2px);
}

.logo-hat {
  position: absolute;
  left: 50%;
  top: 0;
  width: clamp(76px, 22vw, 98px);
  transform: translateX(-50%) rotate(-7deg);
  z-index: 3;
  filter: drop-shadow(0 6px 8px rgba(90, 40, 5, .28));
}
.logo-utensil {
  position: absolute;
  width: clamp(36px, 10vw, 48px);
  z-index: 1;
  filter: drop-shadow(0 6px 6px rgba(90, 40, 5, .24));
}
.utensil-left { left: -4px; top: 18%; transform: rotate(-20deg); }
.utensil-right { right: -5px; top: 18%; transform: rotate(18deg); }

.logo-spark {
  position: absolute;
  z-index: 2;
  width: 13px;
  height: 13px;
  background: #FFE27A;
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation: twinkle 2.4s ease-in-out infinite;
}
.spark-a { left: 11%; top: 16%; }
.spark-b { right: 12%; top: 21%; width: 10px; height: 10px; animation-delay: .7s; }
.spark-c { right: 18%; bottom: 16%; width: 8px; height: 8px; animation-delay: 1.3s; }

.home-actions {
  width: 100%;
  max-width: 430px;
  margin: clamp(18px, 4vh, 34px) auto 0;
  display: flex;
  flex-direction: column;
  gap: 13px;
  flex: 0 0 auto;
}

.play-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  width: 100%;
  min-height: 76px;
  border-radius: 40px;
  overflow: hidden;
  color: #FFFFFF;
  font-size: clamp(23px, 6.6vw, 29px);
  font-weight: 900;
  letter-spacing: .08em;
  background: linear-gradient(180deg, #FFBE4D 0%, #FF8A3D 44%, #F0630F 100%);
  box-shadow:
    0 8px 0 #C24A0B,
    0 16px 26px rgba(160, 65, 5, .38),
    inset 0 2px 0 rgba(255, 255, 255, .7),
    inset 0 -5px 9px rgba(180, 60, 0, .22);
  transition: transform .08s ease, box-shadow .08s ease;
}
.play-btn::before {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  top: 5px;
  height: 38%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .38), rgba(255, 255, 255, 0));
  pointer-events: none;
}
.play-btn::after {
  content: "";
  position: absolute;
  top: -40%;
  left: -30%;
  width: 22%;
  height: 180%;
  transform: rotate(20deg);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, .25), rgba(255, 255, 255, 0));
  animation: shineSweep 3.8s ease-in-out infinite;
  pointer-events: none;
}
.play-btn > * { position: relative; z-index: 2; }
.play-btn:active { transform: translateY(5px); box-shadow: 0 3px 0 #C24A0B, 0 6px 10px rgba(160, 65, 5, .28); }
.play-tri {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .24);
  border: 1.5px solid rgba(255, 255, 255, .45);
}
.play-tri .mp-icon { width: 28px; height: 28px; color: #fff; filter: drop-shadow(0 2px 2px rgba(140, 50, 0, .25)); }

.mode-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mode-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 82px;
  padding: 10px 8px;
  border-radius: 20px;
  text-align: left;
  background: linear-gradient(165deg, rgba(255, 252, 242, .98), rgba(255, 236, 205, .98));
  border: 2px solid #F3D3A0;
  box-shadow: 0 4px 0 #D9A364, 0 10px 18px rgba(120, 55, 10, .16);
  transition: transform .1s, box-shadow .1s, border-color .15s;
}
.mode-card:active { transform: translateY(3px); box-shadow: 0 1px 0 #D9A364; }
.mode-card.is-active {
  border-color: var(--orange);
  box-shadow: 0 4px 0 #E8731F, 0 0 0 3px rgba(255, 138, 61, .2), 0 12px 20px rgba(160, 75, 15, .2);
}
.mode-ico {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 14px;
  display: grid;
  place-items: center;
  box-shadow: inset 0 -2px 0 rgba(150, 85, 10, .14);
}
.mode-ico .mp-icon { width: 24px; height: 24px; }
.mode-ico-yellow { background: linear-gradient(160deg, #FFEFB0, #FFD15C); color: #D98200; }
.mode-ico-red { background: linear-gradient(160deg, #FFD3C6, #FF9E82); color: #D94424; }
.mode-text { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.mode-text b { font-size: 15px; font-weight: 900; color: var(--brown); letter-spacing: .01em; white-space: nowrap; }
.mode-text small { font-size: 10.5px; color: #9C7147; white-space: nowrap; letter-spacing: .01em; }
.mode-check {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--orange);
  box-shadow: 0 2px 4px rgba(200, 80, 10, .3);
  opacity: 0;
  transform: scale(.4);
  transition: opacity .15s, transform .15s;
}
.mode-check .mp-icon { width: 12px; height: 12px; }
.mode-card.is-active .mode-check { opacity: 1; transform: scale(1); }

.home-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 1px 6px 4px;
  font-size: 12px;
  line-height: 1.5;
  color: #7D4E27;
  text-align: center;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .45);
}
.home-hint .mp-icon { width: 16px; height: 16px; color: #D88614; }

/* ---------- 游戏中 ---------- */
.screen-game {
  padding: calc(var(--safe-top) + 8px) 12px calc(var(--safe-bottom) + 8px);
  align-items: center;
  overflow: hidden;
}

.game-hud {
  width: 100%;
  max-width: 430px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.hud-pill {
  height: 46px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(255, 252, 242, .93);
  border: 1.5px solid rgba(255, 255, 255, .95);
  box-shadow: 0 3px 0 rgba(190, 120, 50, .45), 0 8px 16px rgba(120, 55, 10, .15);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  min-width: 0;
}
.score-pill { flex: 1; flex-direction: column; gap: 0; line-height: 1; }
.score-pill small { font-size: 9px; color: #A36A3B; letter-spacing: .18em; margin-bottom: 2px; }
.score-pill b { font-size: 21px; font-weight: 900; color: #E8621A; font-variant-numeric: tabular-nums; }
.score-pill.bump b { animation: scoreBump .3s ease; }
.time-pill { flex: 1.18; }
.time-pill .mp-icon { width: 19px; height: 19px; color: #E8822C; }
.time-pill b { font-size: 18px; font-weight: 900; color: var(--brown); font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.time-pill.is-low {
  background: linear-gradient(180deg, #FFF2EC, #FFD8CD);
  border-color: #FFB7A8;
  animation: lowPulse 1s ease-in-out infinite;
}
.time-pill.is-low .mp-icon, .time-pill.is-low b { color: #D83A26; }

.time-track {
  width: 100%;
  max-width: 430px;
  height: 9px;
  margin-top: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 245, 225, .62);
  box-shadow: inset 0 1px 3px rgba(120, 55, 10, .2);
  flex: 0 0 auto;
}
.time-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #FFD34E, #FF8A3D 60%, #F26A1B);
  box-shadow: 0 0 8px rgba(255, 160, 50, .55);
  transition: width .12s linear, background .2s;
}
.time-fill.is-low { background: linear-gradient(90deg, #FF9A6C, #F0553D 70%, #D83A26); animation: lowPulse 1s ease-in-out infinite; }

.board-area {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
}
.board-shell {
  position: relative;
  width: min(calc(100vw - 26px), 430px, calc((100vh - 232px) * var(--ratio, 1) + 24px));
  width: min(calc(100vw - 26px), 430px, calc((100dvh - 232px) * var(--ratio, 1) + 24px));
  padding: 9px;
  border-radius: 26px;
  background: linear-gradient(155deg, #FFF9EC 0%, #FFEBC8 55%, #F6D29A 100%);
  border: 3px solid #F7C47C;
  box-shadow:
    0 7px 0 #C97B39,
    0 18px 34px rgba(110, 50, 8, .32),
    inset 0 2px 0 #fff,
    inset 0 -4px 10px rgba(190, 120, 50, .16);
  z-index: 2;
}
.board-shell::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 22px;
  border: 1px dashed rgba(200, 130, 55, .32);
  pointer-events: none;
}
.board {
  position: relative;
  width: 100%;
  aspect-ratio: var(--ratio, 1);
  display: grid;
  grid-template-columns: repeat(var(--cols, 6), 1fr);
  border-radius: 18px;
  background:
    linear-gradient(160deg, rgba(255, 252, 244, .5), rgba(255, 232, 194, .38)),
    repeating-linear-gradient(45deg, rgba(190, 120, 50, .05) 0 2px, transparent 2px 12px);
  box-shadow: inset 0 2px 7px rgba(150, 80, 20, .13);
  overflow: hidden;
}
.cell {
  position: relative;
  padding: 2.2%;
  min-width: 0;
  min-height: 0;
}
.tile {
  position: absolute;
  inset: 2.2%;
  border-radius: clamp(8px, 2.4vw, 14px);
  background: linear-gradient(160deg, #FFFDF6 0%, #FFF2D9 62%, #FFE5BB 100%);
  border: 1px solid #F0D3A2;
  box-shadow:
    0 2px 0 #DDB878,
    inset 0 1px 0 #FFFFFF,
    inset 0 -2px 0 rgba(205, 150, 90, .16);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .1s ease, box-shadow .1s ease, border-color .1s ease;
  will-change: transform;
}
.tile::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: inherit;
  border-top: 1px solid rgba(255, 255, 255, .75);
  pointer-events: none;
}
.tile svg {
  width: 78%;
  height: 78%;
  pointer-events: none;
  filter: drop-shadow(0 2px 1px rgba(120, 60, 20, .14));
}
.tile.selected {
  border-color: var(--orange);
  background: linear-gradient(160deg, #FFFBEF 0%, #FFE7BE 62%, #FFD398 100%);
  box-shadow:
    0 0 0 3px rgba(255, 138, 61, .38),
    0 3px 0 #E4771F,
    0 6px 12px rgba(200, 90, 10, .3);
  transform: translateY(-2px) scale(.97);
  z-index: 3;
}
.tile.hinted {
  animation: hintPulse .55s ease-in-out infinite alternate;
  border-color: #FFC531;
  z-index: 2;
}
.tile.pop-in { animation: tileIn .28s ease both; }
.tile.matched {
  animation: tilePop .3s ease-in forwards;
  pointer-events: none;
  z-index: 4;
}
.tile.invalid { animation: shake .34s ease; }

.combo-badge {
  position: absolute;
  left: 50%;
  top: 2px;
  z-index: 15;
  transform: translate(-50%, -10px) scale(.7);
  opacity: 0;
  pointer-events: none;
  padding: 6px 14px;
  border-radius: 999px;
  border: 2px solid #FFF3D8;
  background: linear-gradient(180deg, #FFB13C, #FF7A1F);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: .04em;
  white-space: nowrap;
  box-shadow: 0 4px 0 #C24A0B, 0 10px 18px rgba(160, 65, 10, .3);
}
.combo-badge.show { animation: comboPop .85s ease both; }

.game-bottom {
  width: 100%;
  max-width: 430px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex: 0 0 auto;
  margin-top: 2px;
}
.tool-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 52px;
  padding: 0 11px 0 5px;
  border-radius: 18px;
  background: linear-gradient(160deg, #FFFDF7, #FFE9C6);
  border: 1.5px solid rgba(255, 255, 255, .95);
  box-shadow: 0 4px 0 #D59C5C, 0 8px 16px rgba(120, 55, 10, .16);
  color: #6E3D1A;
  font-size: 14px;
  font-weight: 800;
  transition: transform .08s, box-shadow .08s, opacity .2s;
}
.tool-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #D59C5C; }
.tool-ico {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 13px;
  box-shadow: inset 0 -2px 0 rgba(150, 85, 10, .12);
}
.tool-ico .mp-icon { width: 22px; height: 22px; }
.tool-yellow { background: linear-gradient(160deg, #FFF0B0, #FFD35C); color: #D98200; }
.tool-blue { background: linear-gradient(160deg, #DCEFFF, #A8D4FF); color: #2E7DC4; }
.tool-btn em {
  font-style: normal;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--orange);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  box-shadow: inset 0 -1px 0 rgba(150, 50, 0, .25);
}
.tool-btn.is-disabled { opacity: .42; filter: saturate(.5); }
.tool-label { display: inline; }
.pairs-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 38px;
  padding: 0 13px;
  border-radius: 999px;
  background: rgba(90, 48, 18, .84);
  color: #FFF3DE;
  font-size: 11px;
  letter-spacing: .04em;
  box-shadow: 0 4px 10px rgba(80, 35, 5, .25), inset 0 1px 0 rgba(255, 255, 255, .15);
}
.pairs-chip b { color: #FFD34E; font-size: 18px; font-weight: 900; font-variant-numeric: tabular-nums; }

.countdown {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(90, 45, 10, .14);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  pointer-events: none;
}
.countdown[hidden] { display: none; }
.countdown span {
  font-size: 120px;
  font-weight: 900;
  color: #FFF9EC;
  -webkit-text-stroke: 7px #FF8A3D;
  paint-order: stroke fill;
  text-shadow: 0 8px 0 #C24A0B, 0 18px 30px rgba(80, 32, 0, .35);
  animation: countPop .58s ease both;
}
.countdown span.is-go { font-size: 64px; -webkit-text-stroke: 6px #FF8A3D; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 96px);
  z-index: 70;
  transform: translate(-50%, 12px);
  opacity: 0;
  pointer-events: none;
  max-width: 82vw;
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(74, 40, 14, .93);
  color: #FFF5E4;
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
  box-shadow: 0 8px 20px rgba(60, 25, 0, .3);
  transition: opacity .22s, transform .22s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 结束页 ---------- */
.screen-result {
  padding: calc(var(--safe-top) + 18px) 16px calc(var(--safe-bottom) + 18px);
  align-items: center;
  justify-content: flex-start;
  overflow-y: auto;
  scrollbar-width: none;
}
.screen-result::-webkit-scrollbar { display: none; }
.result-card {
  position: relative;
  width: min(92vw, 410px);
  margin: auto;
  padding: 0 20px 20px;
  border-radius: 30px;
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(255, 247, 220, .95), rgba(255, 247, 220, 0) 60%),
    linear-gradient(170deg, #FFFDF6 0%, #FFF3DD 56%, #FFE9C8 100%);
  border: 3px solid #FFFFFF;
  box-shadow:
    0 8px 0 #D08A43,
    0 26px 50px rgba(100, 45, 8, .35),
    inset 0 2px 0 #fff;
  text-align: center;
  animation: resultIn .5s cubic-bezier(.16, .9, .3, 1.15) both;
}
.result-emblem {
  width: 88px;
  height: 88px;
  margin: -46px auto 6px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #A85E00;
  background: radial-gradient(circle at 36% 28%, #FFF7C0, #FFD34E 52%, #F0A311 100%);
  border: 4px solid #FFF8E0;
  box-shadow: 0 6px 0 #C9860E, 0 12px 22px rgba(150, 85, 10, .3), inset 0 -4px 8px rgba(180, 100, 0, .2);
}
.result-emblem .mp-icon { width: 46px; height: 46px; }
.result-emblem.is-lose {
  color: #7D4E27;
  background: radial-gradient(circle at 36% 28%, #FFF1D9, #FFD7A8 52%, #E8A158 100%);
  box-shadow: 0 6px 0 #B97432, 0 12px 22px rgba(150, 85, 10, .25), inset 0 -4px 8px rgba(160, 90, 20, .15);
}
.result-stars { display: flex; align-items: center; justify-content: center; gap: 5px; height: 30px; margin-bottom: 2px; }
.star-slot { width: 27px; height: 27px; color: #E4D6C2; transition: color .2s; }
.star-slot.on {
  color: #FFC531;
  filter: drop-shadow(0 2px 0 #D68F0F);
  animation: starPop .45s cubic-bezier(.2, 1.6, .4, 1) both;
}
.star-slot.on:nth-child(2) { animation-delay: .1s; }
.star-slot.on:nth-child(3) { animation-delay: .2s; }
.result-card h2 { margin: 2px 0 4px; font-size: 30px; line-height: 1.15; color: #5A3318; letter-spacing: .05em; text-shadow: 0 2px 0 #fff; }
.result-card > p { margin: 0 0 13px; font-size: 12.5px; color: #9C7147; }

.result-score {
  padding: 10px 12px 9px;
  border-radius: 18px;
  background: linear-gradient(180deg, #FFF1D5, #FFE1AE);
  border: 1.5px solid #F5D29A;
  box-shadow: inset 0 -2px 0 rgba(200, 140, 70, .18);
}
.result-score > span { display: block; font-size: 10.5px; letter-spacing: .18em; color: #A27147; }
.result-score > b {
  display: block;
  margin: 1px 0 0;
  font-size: 40px;
  line-height: 1.05;
  font-weight: 900;
  color: #E8621A;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 #fff;
}
.result-bonus { font-size: 11.5px; font-weight: 800; color: #3E9E45; letter-spacing: .02em; }
.result-bonus.is-muted { color: #A27147; }

.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0 14px; }
.result-grid > div {
  padding: 7px 8px;
  border-radius: 13px;
  background: rgba(255, 250, 238, .82);
  border: 1px solid rgba(240, 213, 170, .8);
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.result-grid span { font-size: 10px; color: #A27147; }
.result-grid b { font-size: 14px; color: #6E3D1A; font-weight: 900; font-variant-numeric: tabular-nums; }

.play-btn.small { min-height: 54px; font-size: 19px; border-radius: 28px; letter-spacing: .06em; }
.result-play { min-height: 58px; font-size: 20px; border-radius: 30px; gap: 8px; }
.result-play .play-tri { width: 36px; height: 36px; }
.result-play .play-tri .mp-icon { width: 23px; height: 23px; }

.ghost-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  height: 44px;
  margin-top: 8px;
  border-radius: 999px;
  background: rgba(255, 252, 244, .72);
  border: 1.5px solid #E9C89C;
  color: #8A5A35;
  font-size: 13.5px;
  font-weight: 800;
  transition: transform .08s, background .15s;
}
.ghost-btn:active { transform: scale(.98); background: rgba(255, 240, 210, .9); }
.ghost-btn .mp-icon { width: 18px; height: 18px; }

.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti span {
  position: absolute;
  top: -20px;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  opacity: 0;
  animation: confettiFall 2.6s linear forwards;
}

/* ---------- 暂停 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(72, 36, 8, .55);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}
.overlay[hidden] { display: none; }
.pause-card {
  width: min(88vw, 340px);
  padding: 24px 22px 20px;
  border-radius: 28px;
  background: linear-gradient(170deg, #FFFDF6, #FFEBC9);
  border: 3px solid #fff;
  box-shadow: 0 10px 0 #B97432, 0 24px 60px rgba(0, 0, 0, .4);
  text-align: center;
  animation: popIn .26s cubic-bezier(.2, 1.4, .5, 1) both;
}
.pause-icon {
  width: 68px;
  height: 68px;
  margin: 0 auto 10px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(160deg, #FFB13C, #F0630F);
  border: 3px solid #FFF3D8;
  box-shadow: 0 5px 0 #C24A0B, inset 0 2px 0 rgba(255, 255, 255, .45);
}
.pause-icon .mp-icon { width: 34px; height: 34px; }
.pause-card h2 { margin: 0 0 4px; font-size: 24px; color: #5A3318; }
.pause-card p { margin: 0 0 16px; font-size: 12.5px; color: #9C7147; }
.pause-card .play-btn { margin-bottom: 3px; }

.match-path { animation: pathFade .62s ease forwards; }

/* ---------- 浮字 ---------- */
.float-score {
  position: fixed;
  z-index: 80;
  transform: translate(-50%, -50%);
  pointer-events: none;
  font-size: 21px;
  font-weight: 900;
  color: #FFD34E;
  -webkit-text-stroke: 3px #B84B0C;
  paint-order: stroke fill;
  text-shadow: 0 3px 0 rgba(122, 51, 12, .5);
  animation: floatUp .9s ease-out forwards;
}

/* ---------- 动画 ---------- */
@keyframes pathFade {
  0% { opacity: 0; }
  12% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; }
}
@keyframes twinkle {
  0%, 100% { transform: scale(.7) rotate(0); opacity: .5; }
  50% { transform: scale(1.15) rotate(20deg); opacity: 1; }
}
@keyframes shineSweep {
  0%, 55% { left: -35%; opacity: 0; }
  62% { opacity: 1; }
  82%, 100% { left: 120%; opacity: 0; }
}
@keyframes tilePop {
  0% { transform: scale(1); opacity: 1; }
  42% { transform: scale(1.16) rotate(-2deg); opacity: 1; }
  100% { transform: scale(.28) rotate(10deg); opacity: 0; }
}
@keyframes tileIn {
  from { transform: scale(.55); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes hintPulse {
  from { box-shadow: 0 0 0 0 rgba(255, 197, 49, .78), 0 2px 0 #DDB878; transform: scale(1); }
  to { box-shadow: 0 0 0 7px rgba(255, 197, 49, 0), 0 2px 0 #DDB878; transform: scale(1.04); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px) rotate(-2deg); }
  50% { transform: translateX(4px) rotate(2deg); }
  75% { transform: translateX(-2px); }
}
@keyframes scoreBump {
  0% { transform: scale(1); }
  45% { transform: scale(1.25); }
  100% { transform: scale(1); }
}
@keyframes lowPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.09); }
}
@keyframes comboPop {
  0% { opacity: 0; transform: translate(-50%, 2px) scale(.55); }
  18% { opacity: 1; transform: translate(-50%, 0) scale(1.08); }
  30% { transform: translate(-50%, 0) scale(1); }
  72% { opacity: 1; transform: translate(-50%, -4px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -16px) scale(.94); }
}
@keyframes countPop {
  0% { opacity: 0; transform: scale(1.7); }
  22% { opacity: 1; transform: scale(1); }
  82% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(.92); }
}
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.7); }
  18% { opacity: 1; transform: translate(-50%, -60%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -190%) scale(1); }
}
@keyframes resultIn {
  from { opacity: 0; transform: translateY(26px) scale(.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(.88) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes starPop {
  from { opacity: 0; transform: scale(.4) rotate(-15deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}
@keyframes confettiFall {
  0% { opacity: 0; transform: translateY(-10px) rotate(0); }
  10% { opacity: 1; }
  100% { opacity: .85; transform: translateY(105vh) rotate(620deg); }
}

/* ---------- 适配 ---------- */
@media (max-height: 760px) {
  .screen-home { padding-top: calc(var(--safe-top) + 9px); }
  .logo-wrap { margin-top: 8px; padding-top: 22px; }
  .logo-board { padding: 11px 8px 14px; border-radius: 30px; }
  .home-actions { margin-top: 15px; gap: 11px; }
  .play-btn { min-height: 68px; }
  .mode-card { min-height: 74px; }
  .home-hint { font-size: 11.5px; }
  .scene-hang { opacity: .55; }
}
@media (max-height: 650px) {
  .logo-wrap { padding-top: 18px; }
  .logo-board { padding: 8px 6px 11px; }
  .logo-utensil { display: none; }
  .play-btn { min-height: 62px; border-radius: 32px; }
  .play-tri { width: 38px; height: 38px; }
  .mode-card { min-height: 68px; padding: 7px; }
  .mode-ico { width: 35px; height: 35px; border-radius: 12px; }
  .mode-text b { font-size: 14px; }
  .mode-text small { font-size: 10px; }
  .home-hint { display: none; }
  .home-actions { gap: 9px; }
  .game-hud { height: 44px; }
  .hud-pill { height: 42px; }
  .tool-btn { height: 48px; }
  .game-bottom { margin-top: 0; }
  .result-card { padding-bottom: 16px; }
  .result-score > b { font-size: 34px; }
}
@media (max-width: 350px) {
  .mode-text small { display: none; }
  .mode-card { min-height: 70px; }
  .tool-btn { padding-right: 7px; gap: 4px; }
  .tool-ico { width: 34px; height: 34px; }
  .tool-label { display: none; }
  .pairs-chip { padding: 0 9px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
