* { box-sizing: border-box; }

[hidden] { display: none !important; }

:root {
  --orange: #FF8A3D;
  --orange-deep: #E86A1E;
  --orange-dark: #C95716;
  --brown: #6F3A12;
  --brown-mid: #8C4D1D;
  --brown-soft: #A96B33;
  --cream: #FFF7E8;
  --cream-deep: #F7E3BF;
  --cream-edge: #E7C392;
  --gold: #FFC93C;
  --red: #E8452C;
  --green: #6FB13F;
  --ink-shadow: 0 3px 0 rgba(120, 60, 18, .22);
  --panel-shadow: 0 8px 0 rgba(150, 82, 28, .22), 0 18px 30px rgba(74, 34, 8, .28);
}

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

body {
  position: relative;
  overflow: hidden;
  overscroll-behavior: none;
  background: #E7A25F;
  color: var(--brown);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ---------- 厨房背景：直接使用 gpt-image 成品图 ----------
   手机是竖屏，取成品图左侧「窗户 + 水槽 + 台面」这一块放大铺满，
   避开成品图里画好的棋盘，避免和真实棋盘叠影。 */
.kitchen-bg {
  position: fixed;
  inset: 0;
  background-image: url("images/gen/gptimg_1795326169_look.png");
  background-repeat: no-repeat;
  background-size: auto 192%;
  background-position: 0% 32%;
  filter: blur(.9px) saturate(1.06) brightness(1.03);
  z-index: 0;
}

.kitchen-veil {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(115% 72% at 50% 34%, rgba(255, 244, 218, .04) 0%, rgba(255, 205, 148, .10) 48%, rgba(84, 38, 8, .38) 100%),
    linear-gradient(180deg, rgba(255, 236, 203, .36) 0%, rgba(255, 177, 98, .08) 34%, rgba(104, 52, 16, .12) 64%, rgba(76, 34, 8, .44) 100%);
}

/* ---------- 主容器 ---------- */
.game {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 470px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top)) 14px calc(10px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(6px, 1.2vh, 12px);
}

/* ---------- 顶部 HUD ---------- */
.hud {
  display: grid;
  grid-template-columns: minmax(94px, 1fr) 1.55fr 46px;
  gap: 8px;
  align-items: stretch;
  animation: dropIn .5s cubic-bezier(.2, .9, .3, 1.2) both;
}

.hud-pill,
.progress-card,
.pause-btn {
  border: 2px solid var(--brown-mid);
  background: linear-gradient(180deg, #FFF9EC 0%, #F8E5C3 100%);
  box-shadow: 0 4px 0 rgba(150, 82, 28, .55), 0 8px 16px rgba(80, 36, 8, .24), inset 0 1px 0 #FFFDF6;
}

.timer-pill {
  border-radius: 15px;
  height: 50px;
  padding: 0 9px 0 8px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.timer-disc {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 34% 28%, #FFFFFF 0%, #EAF4FF 48%, #BBD8F7 100%);
  border: 1.5px solid #7E9FC6;
  box-shadow: inset 0 1px 0 #fff, 0 1px 2px rgba(50, 70, 100, .18);
}

.timer-disc .mp-icon {
  width: 20px;
  height: 20px;
  color: #2F72C8;
}

.timer-text {
  font-size: clamp(19px, 5.6vw, 23px);
  font-weight: 900;
  letter-spacing: .4px;
  color: #6B3410;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .8);
  white-space: nowrap;
}

.timer-pill.urgent {
  border-color: #B8321E;
  background: linear-gradient(180deg, #FFF3E6 0%, #FFD9C9 100%);
  animation: urgentPulse .9s ease-in-out infinite;
}

.timer-pill.urgent .timer-text { color: #D3361D; }
.timer-pill.urgent .timer-disc .mp-icon { color: #D3361D; }

.progress-card {
  border-radius: 15px;
  height: 50px;
  padding: 6px 10px 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-width: 0;
}

.hud-stars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 17px;
}

.hud-star {
  width: 17px;
  height: 17px;
  color: #D8B27C;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, .85));
  transition: color .25s ease, transform .25s ease;
}

.hud-star.lit {
  color: var(--gold);
  transform: scale(1.1);
  filter: drop-shadow(0 0 4px rgba(255, 196, 50, .75));
}

.progress-track {
  position: relative;
  width: 100%;
  height: 10px;
  border-radius: 8px;
  background: #DFC096;
  box-shadow: inset 0 2px 4px rgba(118, 66, 24, .35), 0 1px 0 rgba(255, 255, 255, .75);
  overflow: hidden;
}

.progress-fill {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #FFD34D 0%, #FF9F35 56%, #FF7A22 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .65);
  transition: width .35s cubic-bezier(.2, .8, .3, 1);
}

.pause-btn {
  width: 46px;
  height: 46px;
  align-self: center;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #FFF8E9;
  background: linear-gradient(180deg, #FFB04E 0%, #FF8A3D 48%, #ED6C1F 100%);
  box-shadow: 0 4px 0 #B95316, 0 8px 16px rgba(80, 36, 8, .3), inset 0 2px 0 rgba(255, 255, 255, .55);
  transition: transform .1s ease, box-shadow .1s ease;
}

.pause-btn .mp-icon {
  width: 24px;
  height: 24px;
  filter: drop-shadow(0 1px 0 rgba(130, 58, 10, .35));
}

.pause-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #B95316, 0 3px 8px rgba(80, 36, 8, .26), inset 0 2px 0 rgba(255, 255, 255, .4);
}

/* ---------- 棋盘 ---------- */
.board-frame {
  position: relative;
  width: min(100%, calc(100dvh - 208px));
  max-width: 440px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  padding: clamp(8px, 2.2vw, 11px);
  border: 2px solid #8F4F1C;
  border-radius: clamp(20px, 6vw, 28px);
  background:
    linear-gradient(145deg, #FBD79F 0%, #EFB269 32%, #DA9149 66%, #C77B36 100%);
  box-shadow:
    0 10px 0 rgba(139, 74, 25, .55),
    0 20px 34px rgba(72, 32, 6, .36),
    inset 0 2px 0 rgba(255, 247, 224, .85),
    inset 0 -5px 0 rgba(119, 61, 20, .22);
  animation: boardIn .55s cubic-bezier(.18, .9, .28, 1.12) both;
}

.board-frame::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: inherit;
  pointer-events: none;
  opacity: .22;
  background:
    repeating-linear-gradient(93deg, transparent 0 17px, rgba(116, 58, 17, .35) 17px 18px, transparent 18px 37px),
    repeating-linear-gradient(2deg, transparent 0 23px, rgba(255, 250, 235, .5) 23px 24px, transparent 24px 47px);
  mix-blend-mode: soft-light;
}

.board-grid {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: clamp(3px, 1vw, 6px);
  padding: clamp(4px, 1.4vw, 7px);
  border-radius: clamp(14px, 4vw, 20px);
  background:
    linear-gradient(180deg, #FCEFD6 0%, #F7E0B9 55%, #F0D0A0 100%);
  box-shadow:
    inset 0 3px 8px rgba(132, 73, 27, .26),
    inset 0 -2px 0 rgba(255, 255, 255, .7),
    0 1px 0 rgba(255, 250, 235, .6);
}

/* 棋子：脸即为 gpt-image 成品图里裁出的食材 */
.tile {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border-radius: 18%;
  background: #FBF0DB;
  overflow: hidden;
  box-shadow: 0 2px 0 rgba(151, 92, 38, .36), 0 4px 8px rgba(105, 56, 17, .2);
  transition: transform .13s ease, box-shadow .13s ease, opacity .2s ease, filter .13s ease, visibility .2s;
  animation: tileIn .34s cubic-bezier(.2, .9, .3, 1.2) both;
  animation-delay: calc(var(--i, 0) * 9ms);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7), inset 0 0 0 1px rgba(255, 250, 235, .28);
  pointer-events: none;
}

.tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  pointer-events: none;
  -webkit-user-drag: none;
}

.tile:focus { outline: none; }
.tile:focus-visible {
  outline: 3px solid #FFD15C;
  outline-offset: 2px;
}

.tile:active {
  transform: scale(.92);
  box-shadow: 0 1px 0 rgba(151, 92, 38, .4), 0 2px 4px rgba(105, 56, 17, .18);
}

.tile.selected {
  transform: translateY(-2px) scale(1.06);
  z-index: 4;
  box-shadow: 0 0 0 3px #FFD15C, 0 0 0 5px rgba(255, 251, 235, .95), 0 8px 14px rgba(120, 58, 16, .35);
  animation: selectedPulse .9s ease-in-out infinite;
}

.tile.selected::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: 2;
  box-shadow: inset 0 0 14px rgba(255, 207, 92, .9);
  pointer-events: none;
}

.tile.wrong {
  animation: shake .34s ease both;
  box-shadow: 0 0 0 3px #E8603E, 0 4px 10px rgba(120, 40, 15, .35);
}

.tile.hint {
  z-index: 3;
  animation: hintGlow .72s ease-in-out 3;
}

.tile.matched {
  transform: scale(1.24) rotate(2deg);
  opacity: 0;
  filter: brightness(1.25) saturate(1.2);
  box-shadow: 0 0 0 4px rgba(255, 220, 120, .9), 0 0 22px rgba(255, 162, 52, .9);
  animation: none;
  z-index: 5;
}

.tile.empty {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  animation: none;
}

.board-grid.shuffling .tile {
  transform: rotateY(86deg) scale(.86);
  opacity: .36;
}

.board-grid.shuffling .tile.selected,
.board-grid.shuffling .tile.hint {
  animation: none;
}

/* 连线层 */
.link-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 6;
  pointer-events: none;
  overflow: visible;
}

.link-halo {
  fill: none;
  stroke: #FFF9E8;
  stroke-width: 8.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .95;
}

.link-line {
  fill: none;
  stroke: #FF6F21;
  stroke-width: 4.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 4px rgba(255, 186, 72, .95));
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: drawLink .17s linear forwards;
}

.link-dot {
  fill: #FFF6DD;
  stroke: #FF6F21;
  stroke-width: 2.4;
}

/* 飘分 */
.float-layer {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  overflow: hidden;
  border-radius: inherit;
}

.float-score {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 3px 9px;
  border-radius: 999px;
  font-size: clamp(12px, 3.4vw, 15px);
  font-weight: 900;
  color: #FFF9E9;
  white-space: nowrap;
  background: linear-gradient(180deg, #FF9F3C, #EC631A);
  border: 1.5px solid #9B4A12;
  box-shadow: 0 3px 8px rgba(100, 44, 8, .35), inset 0 1px 0 rgba(255, 255, 255, .5);
  animation: floatScore .9s cubic-bezier(.15, .8, .3, 1) forwards;
}

.float-score .x {
  margin-left: 3px;
  font-size: .82em;
  color: #FFF1B8;
}

/* ---------- 底部工具 ---------- */
.toolbar {
  display: flex;
  align-items: stretch;
  gap: 8px;
  animation: riseIn .5s .08s cubic-bezier(.2, .9, .3, 1.2) both;
}

.score-card {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: 58px;
  padding: 7px 12px 7px 14px;
  border-radius: 18px;
  border: 2px solid var(--brown-mid);
  background: linear-gradient(180deg, #FFF9EC 0%, #F6E2BF 100%);
  box-shadow: 0 4px 0 rgba(150, 82, 28, .55), 0 8px 16px rgba(80, 36, 8, .24), inset 0 1px 0 #FFFDF6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  overflow: hidden;
}

.score-left {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.score-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
  color: #A36B34;
  white-space: nowrap;
}

.score-card strong {
  font-size: clamp(23px, 6.6vw, 28px);
  line-height: 1;
  font-weight: 900;
  color: #6B3410;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .8);
  transition: transform .12s ease;
}

.score-card strong.bump { animation: scoreBump .26s ease; }

.combo-chip.pop { animation: comboPop .28s cubic-bezier(.2, 1.4, .4, 1) both; }

.combo-chip {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  color: #FFF9E8;
  background: linear-gradient(180deg, #FFA63E, #EE641A);
  border: 1.5px solid #97460F;
  box-shadow: 0 2px 0 rgba(130, 58, 12, .3);
  white-space: nowrap;
  animation: comboPop .28s cubic-bezier(.2, 1.4, .4, 1) both;
}

.best-chip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px 3px 6px;
  border-radius: 999px;
  background: rgba(255, 250, 235, .9);
  border: 1.5px solid #E2C08B;
  box-shadow: inset 0 1px 0 #FFFDF6;
}

.best-chip .mp-icon {
  width: 14px;
  height: 14px;
  color: #E0A21D;
}

.best-chip span {
  font-size: 10px;
  font-weight: 800;
  color: #A36B34;
  white-space: nowrap;
}

.best-chip b {
  font-size: 12px;
  line-height: 1;
  font-weight: 900;
  color: #6B3410;
  font-variant-numeric: tabular-nums;
}

.tool-btn {
  position: relative;
  flex: 0 0 58px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 2px solid #8F4F1C;
  color: #7B3E12;
  background: linear-gradient(180deg, #FFD874 0%, #FFB14C 48%, #F08B31 100%);
  box-shadow: 0 4px 0 #B65A19, 0 8px 14px rgba(80, 36, 8, .28), inset 0 2px 0 rgba(255, 255, 255, .65);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  transition: transform .1s ease, box-shadow .1s ease, opacity .2s ease, filter .2s ease;
}

.tool-btn .mp-icon {
  width: 23px;
  height: 23px;
  color: #7A3D10;
  filter: drop-shadow(0 1px 0 rgba(255, 250, 230, .7));
}

.tool-btn > span {
  font-size: 10px;
  line-height: 1.1;
  font-weight: 900;
  color: #7A3D10;
  text-shadow: 0 1px 0 rgba(255, 250, 230, .55);
}

.tool-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #B65A19, 0 3px 7px rgba(80, 36, 8, .24), inset 0 2px 0 rgba(255, 255, 255, .45);
}

.tool-btn.used,
.tool-btn:disabled {
  opacity: .52;
  filter: grayscale(.28);
}

.tool-badge {
  position: absolute;
  top: -5px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 11px;
  border: 2px solid #FFF3DC;
  background: linear-gradient(180deg, #F35A3C, #D93621);
  color: #fff;
  font-size: 12px;
  line-height: 18px;
  font-weight: 900;
  text-align: center;
  box-shadow: 0 2px 4px rgba(110, 34, 8, .35);
}

/* ---------- 提示条 ---------- */
.toast {
  position: fixed;
  z-index: 40;
  left: 50%;
  top: calc(72px + env(safe-area-inset-top));
  transform: translate(-50%, -8px) scale(.96);
  max-width: calc(100% - 40px);
  padding: 8px 15px;
  border-radius: 999px;
  border: 1.5px solid rgba(120, 62, 21, .55);
  background: rgba(255, 248, 232, .96);
  color: #743B12;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .02em;
  white-space: normal;
  text-align: center;
  line-height: 1.35;
  box-shadow: 0 6px 18px rgba(72, 32, 6, .28);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

/* ---------- 结算 / 暂停 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  padding: 22px;
  display: grid;
  place-items: center;
  background: radial-gradient(90% 70% at 50% 40%, rgba(92, 45, 12, .32), rgba(55, 24, 4, .66));
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  opacity: 0;
  transition: opacity .22s ease;
}

.overlay.show { opacity: 1; }
.overlay[hidden] { display: none; }

.result-card {
  position: relative;
  width: min(100%, 344px);
  padding: 26px 20px 20px;
  border-radius: 28px;
  border: 3px solid #8A4A18;
  background:
    radial-gradient(120% 70% at 50% 0%, #FFFDF4 0%, transparent 58%),
    linear-gradient(180deg, #FFF8E8 0%, #F9E4BE 62%, #F3D4A1 100%);
  box-shadow:
    0 10px 0 rgba(126, 63, 18, .5),
    0 30px 60px rgba(44, 18, 2, .52),
    inset 0 2px 0 #FFFDF5;
  text-align: center;
  overflow: hidden;
  transform: translateY(16px) scale(.94);
  transition: transform .28s cubic-bezier(.16, .95, .3, 1.15);
}

.overlay.show .result-card { transform: translateY(0) scale(1); }

.result-card::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 22px;
  border: 1.5px dashed rgba(178, 118, 58, .36);
  pointer-events: none;
}

.result-emblem {
  position: relative;
  width: 62px;
  height: 62px;
  margin: 0 auto 8px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #FFF9E8;
  background: linear-gradient(180deg, #FFB24E, #F07827);
  border: 2.5px solid #8A4A18;
  box-shadow: 0 5px 0 #B65A19, 0 10px 18px rgba(90, 40, 8, .3), inset 0 2px 0 rgba(255, 255, 255, .55);
}

.result-emblem .mp-icon {
  width: 32px;
  height: 32px;
  filter: drop-shadow(0 1px 0 rgba(130, 58, 10, .3));
}

.result-emblem.lose {
  background: linear-gradient(180deg, #C9B8A2, #9C815F);
  color: #FFF6E8;
}

.result-emblem.pause-emblem {
  background: linear-gradient(180deg, #8FC7F0, #4A91D0);
  box-shadow: 0 5px 0 #2D6EA6, 0 10px 18px rgba(30, 70, 110, .28), inset 0 2px 0 rgba(255, 255, 255, .5);
}

.result-kicker {
  margin: 0;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .22em;
  color: #B07A3D;
  text-transform: uppercase;
}

.result-card h2 {
  margin: 3px 0 4px;
  font-size: clamp(25px, 7.4vw, 31px);
  line-height: 1.16;
  font-weight: 900;
  letter-spacing: .02em;
  color: #6B3410;
  text-shadow: 0 2px 0 rgba(255, 255, 255, .75);
}

.result-stars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  margin: 4px 0 8px;
}

.result-star {
  width: 34px;
  height: 34px;
  color: #D8B27C;
  transform: scale(.8);
  opacity: .6;
  transition: color .2s ease;
}

.result-star.lit {
  color: var(--gold);
  opacity: 1;
  animation: starPop .48s cubic-bezier(.2, 1.5, .4, 1) both;
  filter: drop-shadow(0 0 7px rgba(255, 196, 50, .8));
}

.result-stars .result-star:nth-child(2) { animation-delay: .1s; }
.result-stars .result-star:nth-child(3) { animation-delay: .2s; }

.result-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 10px 0 6px;
}

.stat-box {
  padding: 8px 8px 7px;
  border-radius: 14px;
  background: rgba(255, 250, 236, .78);
  border: 1.5px solid #E4C392;
  box-shadow: inset 0 1px 0 #FFFDF6;
}

.stat-box span {
  display: block;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .1em;
  color: #A36B34;
}

.stat-box b {
  display: block;
  margin-top: 1px;
  font-size: 21px;
  line-height: 1.1;
  font-weight: 900;
  color: #6B3410;
  font-variant-numeric: tabular-nums;
}

.result-best {
  min-height: 17px;
  margin: 4px 0 12px;
  font-size: 12px;
  font-weight: 800;
  color: #A36B34;
}

.result-best.new-best {
  color: #D9531E;
  animation: bestFlash 1s ease-in-out infinite;
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 16px;
  border: 2px solid #8A4A18;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: .04em;
  transition: transform .1s ease, box-shadow .1s ease, filter .1s ease;
}

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

.btn.primary {
  color: #FFF9E8;
  background: linear-gradient(180deg, #FFB24E 0%, #FF8A3D 50%, #EE681C 100%);
  box-shadow: 0 4px 0 #B65A19, 0 9px 16px rgba(90, 40, 8, .28), inset 0 2px 0 rgba(255, 255, 255, .5);
  text-shadow: 0 1px 0 rgba(130, 58, 10, .35);
}

.btn.ghost {
  color: #7A3D10;
  background: linear-gradient(180deg, #FFF8E7, #F4DDB8);
  box-shadow: 0 4px 0 rgba(160, 96, 40, .5), inset 0 1px 0 #FFFDF5;
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(150, 82, 28, .55), inset 0 2px 0 rgba(255, 255, 255, .4);
}

.pause-card { max-width: 330px; }

.pause-sub {
  margin: 8px 0 18px;
  font-size: 13px;
  line-height: 1.5;
  font-weight: 600;
  color: #936331;
}

/* 彩带 */
.confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  border-radius: inherit;
}

.confetti span {
  position: absolute;
  top: -12%;
  left: var(--x);
  width: var(--w);
  height: var(--h);
  border-radius: 2px;
  background: var(--c);
  opacity: .95;
  transform: rotate(var(--r));
  animation: confettiFall var(--t) cubic-bezier(.25, .6, .4, 1) var(--d) both;
}

/* ---------- 动画 ---------- */
@keyframes dropIn {
  from { opacity: 0; transform: translateY(-18px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes boardIn {
  from { opacity: 0; transform: translateY(18px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes tileIn {
  from { opacity: 0; transform: scale(.6) rotate(-4deg); }
  to { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes selectedPulse {
  0%, 100% { transform: translateY(-2px) scale(1.06); }
  50% { transform: translateY(-2px) scale(1.1); }
}

@keyframes hintGlow {
  0%, 100% { box-shadow: 0 0 0 2px rgba(255, 215, 92, .4), 0 4px 8px rgba(105, 56, 17, .2); }
  50% { box-shadow: 0 0 0 4px #FFE36E, 0 0 20px rgba(255, 193, 59, .95), 0 4px 8px rgba(105, 56, 17, .2); }
}

@keyframes shake {
  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 drawLink {
  to { stroke-dashoffset: 0; }
}

@keyframes floatScore {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(.7); }
  18% { opacity: 1; transform: translate(-50%, -60%) scale(1.06); }
  100% { opacity: 0; transform: translate(-50%, -155%) scale(1); }
}

@keyframes scoreBump {
  0%, 100% { transform: scale(1); }
  45% { transform: scale(1.18); color: #D9531E; }
}

@keyframes comboPop {
  from { opacity: 0; transform: scale(.6); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes urgentPulse {
  0%, 100% { box-shadow: 0 4px 0 rgba(150, 82, 28, .55), 0 8px 16px rgba(80, 36, 8, .24), inset 0 1px 0 #FFFDF6; }
  50% { box-shadow: 0 0 0 3px rgba(255, 90, 56, .32), 0 4px 0 rgba(150, 82, 28, .55), 0 8px 16px rgba(80, 36, 8, .24); }
}

@keyframes starPop {
  0% { opacity: .3; transform: scale(.5) rotate(-18deg); }
  60% { opacity: 1; transform: scale(1.2) rotate(6deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes bestFlash {
  0%, 100% { opacity: 1; }
  50% { opacity: .55; }
}

@keyframes confettiFall {
  0% { opacity: 0; transform: translate3d(0, -20px, 0) rotate(var(--r)); }
  12% { opacity: 1; }
  100% { opacity: 0; transform: translate3d(var(--sx), 360px, 0) rotate(calc(var(--r) + 520deg)); }
}

/* ---------- 桌面/平板浏览：背景转为柔和的环境光，避免成品图里的棋盘穿帮 ---------- */
@media (min-width: 620px) {
  .kitchen-bg {
    background-size: cover;
    background-position: center 46%;
    filter: blur(16px) saturate(1.12) brightness(.8);
    transform: scale(1.08);
  }
  .kitchen-veil {
    background:
      radial-gradient(52% 66% at 50% 48%, rgba(255, 243, 218, .10) 0%, rgba(88, 42, 12, .18) 62%, rgba(48, 19, 2, .5) 100%),
      linear-gradient(180deg, rgba(70, 32, 8, .22), rgba(48, 19, 2, .34));
  }
}

/* ---------- 小屏与横屏兼容 ---------- */
@media (max-width: 360px) {
  .hud { grid-template-columns: minmax(88px, 1.15fr) 1.3fr 44px; gap: 6px; }
  .timer-pill { padding: 0 6px; gap: 4px; }
  .timer-disc { width: 24px; height: 24px; flex-basis: 24px; }
  .timer-disc .mp-icon { width: 17px; height: 17px; }
  .timer-text { font-size: 17px; }
  .pause-btn { width: 44px; height: 44px; }
  .best-chip { display: none; }
}

@media (max-width: 350px) {
  .score-label { display: none; }
  .score-card { padding: 6px 9px; }
  .score-card strong { font-size: 22px; }
  .combo-chip { font-size: 10px; padding: 2px 6px; }
}

@media (max-height: 640px) {
  .game { gap: 7px; padding-top: calc(6px + env(safe-area-inset-top)); padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
  .hud-pill, .progress-card { height: 46px; }
  .pause-btn { height: 46px; }
  .board-frame { width: min(100%, calc(100dvh - 178px)); }
  .score-card { height: 52px; }
  .tool-btn { flex-basis: 52px; width: 52px; height: 52px; }
  .tool-btn .mp-icon { width: 21px; height: 21px; }
  .tool-btn > span { font-size: 9px; }
}

@media (max-height: 560px) {
  .hud { grid-template-columns: minmax(88px, 1fr) 1.4fr 42px; gap: 6px; }
  .pause-btn { width: 42px; }
  .timer-pill { padding: 0 6px; gap: 5px; }
  .timer-disc { width: 24px; height: 24px; flex-basis: 24px; }
  .timer-disc .mp-icon { width: 17px; height: 17px; }
  .board-frame { width: min(100%, calc(100dvh - 164px)); }
  .score-card { height: 48px; padding: 5px 9px 5px 11px; }
  .tool-btn { flex-basis: 48px; width: 48px; height: 48px; }
  .score-card strong { font-size: 21px; }
}

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