/* ============================================================
   厨房连连看 · 卡通厨房风
   主色 #FF8A3D / 木质暖色 / 奶油卡片
   ============================================================ */

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

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

body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #F7C393;
  color: #5B3417;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  -webkit-user-select: none;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

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

input { font-family: inherit; }

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.app {
  position: relative;
  width: 100%;
  max-width: 560px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  isolation: isolate;
}

/* ---------------- 背景：卡通厨房 ---------------- */

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

.bg-wall {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(85% 52% at 52% 0%, #FFF7EA 0%, #FFE4C1 46%, #FFCE9C 100%),
    linear-gradient(180deg, #FFE6C8, #F7BE8B);
}

.bg-wall::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, rgba(185, 116, 56, 0.055) 0 2px, transparent 2px 48px);
}

.bg-window {
  position: absolute;
  top: 4%;
  right: -15%;
  width: 62%;
  height: 37%;
  border: 6px solid #F5D6AC;
  border-radius: 48% 48% 16px 16px / 40% 40% 10px 10px;
  background: linear-gradient(165deg, #FFFDF0 0%, #FFF1CE 52%, #FFDFA6 100%);
  box-shadow:
    inset 0 0 28px rgba(255, 205, 130, 0.8),
    0 10px 24px rgba(150, 88, 34, 0.16);
  overflow: hidden;
}

.win-glow {
  position: absolute;
  top: -22%;
  left: 18%;
  width: 58%;
  height: 82%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95) 0%, rgba(255, 244, 205, 0.55) 45%, rgba(255, 230, 170, 0) 70%);
}

.win-bar {
  position: absolute;
  background: #F4D6AE;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

.win-bar--v { top: 0; bottom: 0; left: 47%; width: 6px; }
.win-bar--h { left: 0; right: 0; top: 54%; height: 6px; }

.bg-shelf {
  position: absolute;
  left: -6%;
  top: 22%;
  width: 54%;
  filter: drop-shadow(0 8px 8px rgba(140, 80, 30, 0.12));
}

.jars {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  padding: 0 0 0 22px;
}

.jar {
  position: relative;
  display: block;
  width: 24px;
  height: 38px;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-radius: 5px 5px 8px 8px;
  background: linear-gradient(180deg, rgba(255, 198, 120, 0.55), rgba(214, 132, 55, 0.62));
  box-shadow: inset -4px 0 0 rgba(255, 255, 255, 0.25);
}

.jar::before {
  content: "";
  position: absolute;
  left: -2px;
  right: -2px;
  top: -5px;
  height: 7px;
  border-radius: 3px;
  background: #B47B44;
}

.jar span {
  position: absolute;
  left: 4px;
  right: 4px;
  top: 46%;
  height: 8px;
  border-radius: 2px;
  background: rgba(255, 248, 226, 0.75);
}

.jar--1 { width: 20px; height: 34px; }
.jar--2 { width: 28px; height: 44px; }
.jar--3 { width: 22px; height: 30px; background: linear-gradient(180deg, rgba(255, 224, 170, 0.7), rgba(226, 164, 86, 0.65)); }

.shelf-board {
  height: 12px;
  margin-top: 2px;
  border-radius: 5px;
  background: linear-gradient(180deg, #D79A5B, #A96530);
  box-shadow: 0 5px 10px rgba(130, 72, 24, 0.25), inset 0 2px 0 rgba(255, 255, 255, 0.35);
}

.hangers {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding: 3px 0 0 34px;
}

.hang {
  position: relative;
  display: block;
  width: 5px;
  height: 44px;
  border-radius: 3px;
  background: linear-gradient(90deg, #CDD7DD, #93A2AB);
}

.hang::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -12px;
  width: 5px;
  height: 16px;
  transform: translateX(-50%);
  border-radius: 3px;
  background: #9CABB4;
}

.hang::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -9px;
  width: 18px;
  height: 14px;
  transform: translateX(-50%);
  border-radius: 3px 3px 9px 9px;
  background: linear-gradient(180deg, #E0E8EC, #AEBDC6);
}

.hang--2 { height: 54px; }
.hang--2::after { width: 13px; height: 21px; border-radius: 50% 50% 6px 6px; }
.hang--3 { height: 36px; }
.hang--3::after { width: 23px; height: 11px; }

.bg-plant {
  position: absolute;
  right: 5%;
  bottom: 12%;
  width: 92px;
  height: 126px;
  opacity: 0.95;
}

.leaf {
  position: absolute;
  display: block;
  width: 40px;
  height: 26px;
  border-radius: 50% 8% 50% 8%;
  background: linear-gradient(135deg, #86C86A, #4C9A3F);
  transform-origin: 80% 100%;
  box-shadow: inset -3px -3px 0 rgba(255, 255, 255, 0.16);
}

.leaf--1 { left: 30px; bottom: 52px; transform: rotate(-38deg); }
.leaf--2 { left: 10px; bottom: 40px; transform: rotate(-12deg) scale(0.85); }
.leaf--3 { left: 46px; bottom: 46px; transform: rotate(-72deg) scale(0.9); }
.leaf--4 { left: 26px; bottom: 62px; transform: rotate(-96deg) scale(0.7); }

.bg-plant .pot {
  position: absolute;
  left: 20px;
  bottom: 0;
  width: 58px;
  height: 48px;
  border-radius: 6px 6px 18px 18px;
  background: linear-gradient(180deg, #E9A76B, #C47B3F);
  box-shadow: inset -8px 0 0 rgba(120, 62, 20, 0.14), 0 6px 12px rgba(120, 64, 20, 0.18);
}

.bg-plant .pot::before {
  content: "";
  position: absolute;
  left: -4px;
  right: -4px;
  top: -7px;
  height: 12px;
  border-radius: 5px;
  background: linear-gradient(180deg, #F2B77D, #D08A4B);
}

.bg-counter {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 15%;
  background:
    repeating-linear-gradient(90deg, rgba(150, 88, 38, 0.07) 0 2px, transparent 2px 54px),
    linear-gradient(180deg, #F0C290, #DE9F5E);
  box-shadow: inset 0 7px 0 #C98A4D, inset 0 10px 0 rgba(255, 255, 255, 0.25);
}

.bg-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 76% at 50% 42%, rgba(255, 255, 255, 0) 40%, rgba(158, 92, 34, 0.17) 100%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0) 22%);
}

/* ---------------- 通用屏幕 ---------------- */

.screen {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  flex-direction: column;
}

.screen.is-active {
  display: flex;
  animation: screenIn 0.3s ease both;
}

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

/* ---------------- 开始页 ---------------- */

.screen--start {
  padding: calc(11px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom));
  justify-content: space-between;
  overflow-y: auto;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex: none;
  position: relative;
  z-index: 2;
}

.player-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 4px 14px 4px 4px;
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.88);
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 0 rgba(203, 142, 84, 0.35), 0 8px 16px rgba(140, 80, 28, 0.14);
  transition: transform 0.12s ease;
}

.player-chip:active { transform: translateY(2px) scale(0.985); }

.avatar {
  position: relative;
  display: block;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(180deg, #FFE8CB, #FFC98F);
  border: 2px solid #fff;
  box-shadow: 0 2px 5px rgba(170, 104, 40, 0.2);
}

.avatar svg, .avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.player-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
  min-width: 0;
}

.player-name {
  max-width: 132px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 14px;
  font-weight: 800;
  color: #5B3417;
}

.player-best {
  margin-top: 2px;
  font-size: 10px;
  font-weight: 600;
  color: #A4713D;
  letter-spacing: 0.02em;
}

.player-best b { color: #E96F1B; font-weight: 900; }

.hud-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 40px;
  padding: 0 11px 0 8px;
  border-radius: 13px;
  background: rgba(255, 250, 240, 0.9);
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 3px 0 rgba(203, 142, 84, 0.38);
  color: #7A4A20;
  font-size: 12px;
  font-weight: 800;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.hud-btn .mp-icon { width: 17px; height: 17px; }
.hud-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(203, 142, 84, 0.38); }

.hero {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2.4vh, 20px);
  padding: 14px 0 10px;
  position: relative;
  z-index: 1;
}

.logo {
  position: relative;
  width: min(292px, 78vw);
  margin-top: 24px;
}

.logo-hat {
  position: absolute;
  top: -40px;
  left: 50%;
  width: 92px;
  height: auto;
  transform: translateX(-50%) rotate(-4deg);
  filter: drop-shadow(0 4px 5px rgba(140, 80, 24, 0.22));
  z-index: 2;
}

.logo-plank {
  position: relative;
  padding: 13px 18px 15px;
  border-radius: 16px;
  background: linear-gradient(180deg, #E2A162 0%, #C07C3F 52%, #9C5926 100%);
  border: 3px solid #F6C68E;
  box-shadow:
    0 7px 0 #7E4518,
    0 14px 20px rgba(110, 58, 16, 0.28),
    inset 0 2px 0 rgba(255, 255, 255, 0.4);
  text-align: center;
  overflow: hidden;
}

.logo-plank::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(0deg, rgba(112, 58, 18, 0.1) 0 2px, transparent 2px 13px),
    radial-gradient(80% 60% at 30% 10%, rgba(255, 255, 255, 0.25), transparent 70%);
  pointer-events: none;
}

.logo-top,
.logo-main {
  position: relative;
  display: block;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-indent: 0.14em;
}

.logo-top {
  font-size: 19px;
  color: #FFEBC5;
  text-shadow: 0 2px 0 #8A4A12;
  margin-bottom: 1px;
}

.logo-main {
  font-size: clamp(36px, 11.4vw, 47px);
  line-height: 1.04;
  color: #FFD84D;
  -webkit-text-stroke: 2px #8A4A12;
  text-shadow:
    0 3px 0 #B9650F,
    0 6px 0 #7E4210,
    0 10px 14px rgba(60, 28, 4, 0.38);
}

.logo-spatula {
  position: absolute;
  right: -26px;
  top: -8px;
  width: 46px;
  height: auto;
  transform: rotate(17deg);
  filter: drop-shadow(0 4px 4px rgba(110, 58, 16, 0.28));
  z-index: 3;
}

.demo-board {
  width: min(304px, 80vw);
  filter: drop-shadow(0 12px 16px rgba(120, 64, 20, 0.26));
  transform: rotate(-1.1deg);
}

.demo-frame {
  padding: 7px;
  border-radius: 19px;
  background: linear-gradient(180deg, #D99355 0%, #B06C32 60%, #8E4E1E 100%);
  border: 3px solid #F2BC80;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.4),
    inset 0 -4px 0 rgba(90, 45, 10, 0.28);
}

.demo-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  padding: 6px;
  border-radius: 12px;
  background: linear-gradient(180deg, #FFF8E8, #FFE8C6);
  box-shadow: inset 0 3px 7px rgba(150, 92, 32, 0.18);
}

.demo-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  background: linear-gradient(180deg, #FFFDF7, #FFF0D6);
  border: 1px solid #F6DFBC;
  box-shadow: 0 3px 0 #E4C39B, inset 0 1px 0 #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.demo-tile .food {
  width: 84%;
  height: 84%;
  filter: drop-shadow(0 2px 1px rgba(120, 60, 20, 0.16));
}

.demo-tile.is-bob { animation: bob 2.6s ease-in-out infinite; }
.demo-tile.is-bob:nth-child(3n) { animation-delay: 0.35s; }
.demo-tile.is-bob:nth-child(4n) { animation-delay: 0.7s; }

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  45% { transform: translateY(-3px) rotate(-1.2deg); }
  70% { transform: translateY(1px) rotate(0.8deg); }
}

.tagline {
  margin: 0;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.85);
  color: #8A5626;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: 0 2px 6px rgba(140, 80, 28, 0.1);
}

.tagline b { color: #E96F1B; }

.start-actions {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  position: relative;
  z-index: 2;
}

.btn-play {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: min(326px, 88vw);
  height: 62px;
  border-radius: 20px;
  background: linear-gradient(180deg, #FFB05C 0%, #FF8A3D 46%, #F26B14 100%);
  border: 3px solid #FFD2A3;
  box-shadow:
    0 7px 0 #C1550C,
    0 14px 22px rgba(190, 90, 14, 0.38),
    inset 0 3px 0 rgba(255, 255, 255, 0.45),
    inset 0 -6px 10px rgba(160, 66, 6, 0.22);
  color: #FFFDF6;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-shadow: 0 2px 0 #C4570C, 0 3px 8px rgba(120, 50, 4, 0.35);
  transition: transform 0.09s ease, box-shadow 0.09s ease;
  overflow: hidden;
}

.btn-play::before {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  top: 5px;
  height: 38%;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.btn-play:active {
  transform: translateY(5px);
  box-shadow:
    0 2px 0 #C1550C,
    0 5px 12px rgba(190, 90, 14, 0.3),
    inset 0 3px 0 rgba(255, 255, 255, 0.4);
}

.play-tri {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 12px 0 12px 19px;
  border-color: transparent transparent transparent #FFFDF6;
  filter: drop-shadow(0 2px 0 rgba(160, 66, 6, 0.55));
}

.btn-play--sm {
  width: 100%;
  height: 54px;
  font-size: 20px;
  border-radius: 17px;
  margin-top: 4px;
}

.btn-play--sm .play-tri { border-width: 10px 0 10px 16px; }

.start-note {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  color: #95602D;
  letter-spacing: 0.02em;
}

/* ---------------- 游戏中 ---------------- */

.screen--game {
  padding: calc(8px + env(safe-area-inset-top)) 12px calc(9px + env(safe-area-inset-bottom));
  gap: 7px;
  overflow: hidden;
}

.hud {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 46px;
}

.hud .hud-btn {
  height: 36px;
  padding: 0 9px 0 7px;
  border-radius: 12px;
  font-size: 11px;
}

.hud-score,
.hud-combo {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-width: 66px;
  height: 40px;
  padding: 3px 10px;
  border-radius: 12px;
  background: rgba(255, 251, 242, 0.92);
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 3px 0 rgba(203, 142, 84, 0.34);
  line-height: 1.05;
}

.hud-combo { min-width: 56px; }

.hud-label {
  font-size: 9px;
  font-weight: 700;
  color: #A9794A;
  letter-spacing: 0.06em;
}

.hud-score strong {
  font-size: 18px;
  font-weight: 900;
  color: #E96F1B;
  font-variant-numeric: tabular-nums;
}

.hud-combo strong {
  font-size: 15px;
  font-weight: 900;
  color: #A9773E;
  font-variant-numeric: tabular-nums;
}

.hud-combo.is-hot strong { color: #FF7A1A; }
.hud-combo.is-hot { animation: comboPop 0.3s ease; }

@keyframes comboPop {
  0% { transform: scale(1); }
  45% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.hud-timer {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 3px;
  height: 40px;
  padding: 0 10px 0 7px;
  border-radius: 12px;
  background: rgba(255, 251, 242, 0.92);
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 3px 0 rgba(203, 142, 84, 0.34);
  color: #7A4A20;
  font-size: 14px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.hud-timer .mp-icon { width: 17px; height: 17px; color: #FF8A3D; }

.hud-timer.is-urgent {
  color: #E4302A;
  animation: urgent 0.9s ease-in-out infinite;
}

@keyframes urgent {
  0%, 100% { box-shadow: 0 3px 0 rgba(203, 142, 84, 0.34); }
  50% { box-shadow: 0 3px 0 rgba(203, 142, 84, 0.34), 0 0 0 3px rgba(228, 48, 42, 0.22); }
}

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

.board-frame {
  position: relative;
  padding: 7px;
  border-radius: 22px;
  background:
    repeating-linear-gradient(0deg, rgba(110, 58, 18, 0.08) 0 2px, transparent 2px 15px),
    linear-gradient(160deg, #E3A162 0%, #C27E42 48%, #A25D28 100%);
  border: 3px solid #F4C28D;
  box-shadow:
    0 12px 24px rgba(112, 58, 16, 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.42),
    inset 0 -5px 0 rgba(92, 46, 10, 0.26);
}

.board {
  position: relative;
  padding: 6px;
  border-radius: 13px;
  background: linear-gradient(180deg, #FFF8E8 0%, #FFEACB 100%);
  box-shadow: inset 0 3px 8px rgba(150, 92, 32, 0.18);
}

.board-inner {
  position: relative;
  display: grid;
  gap: var(--gap, 4px);
  grid-template-columns: repeat(var(--cols, 5), var(--tile, 52px));
  grid-template-rows: repeat(var(--rows, 10), var(--tile, 52px));
}

.path-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 6;
}

.tile {
  position: relative;
  width: var(--tile, 52px);
  height: var(--tile, 52px);
  padding: 0;
  background: none;
  border: 0;
  border-radius: 11px;
  display: block;
  cursor: pointer;
  touch-action: manipulation;
  outline: none;
  animation: tileIn 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.25) both;
}

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

.tile-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: linear-gradient(180deg, #FFFEF9 0%, #FFF2DC 100%);
  border: 1px solid #F4DDBB;
  box-shadow:
    0 3px 0 #E4C399,
    0 5px 8px rgba(140, 80, 24, 0.13),
    inset 0 1px 0 #fff;
  transition: transform 0.1s ease, box-shadow 0.13s ease, background 0.13s ease;
  will-change: transform;
}

.tile .food {
  display: block;
  width: 84%;
  height: 84%;
  filter: drop-shadow(0 2px 1px rgba(120, 60, 20, 0.18));
  pointer-events: none;
}

.tile:active .tile-face { transform: scale(0.92); }

.tile:focus-visible .tile-face {
  box-shadow: 0 0 0 3px #4FBBD3, 0 3px 0 #E4C399, inset 0 1px 0 #fff;
}

.tile.is-selected .tile-face {
  background: linear-gradient(180deg, #FFF6DE, #FFE2B2);
  border-color: #FFB067;
  box-shadow:
    0 0 0 2.5px #FF8A3D,
    0 0 16px rgba(255, 138, 61, 0.55),
    0 3px 0 #D9A268,
    inset 0 1px 0 #fff;
  transform: scale(0.94);
}

.tile.is-selected .food { animation: pick 0.9s ease-in-out infinite; }

@keyframes pick {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.06) rotate(-2deg); }
}

.tile.is-hint .tile-face {
  animation: hintPulse 0.5s ease-in-out 3;
  border-color: #FFC93C;
}

@keyframes hintPulse {
  0%, 100% { box-shadow: 0 3px 0 #E4C399, 0 0 0 0 rgba(255, 201, 60, 0.7); }
  50% { box-shadow: 0 3px 0 #E4C399, 0 0 0 5px rgba(255, 201, 60, 0.55), 0 0 18px rgba(255, 180, 40, 0.6); }
}

.tile.is-shake .tile-face { animation: shake 0.3s ease; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px) rotate(-2deg); }
  45% { transform: translateX(4px) rotate(2deg); }
  70% { transform: translateX(-2px); }
}

.tile.is-gone { pointer-events: none; }

.tile.is-gone .tile-face {
  animation: tileOut 0.3s ease forwards;
}

@keyframes tileOut {
  0% { transform: scale(0.94); opacity: 1; }
  42% { transform: scale(1.12) rotate(4deg); opacity: 1; box-shadow: 0 0 22px rgba(255, 200, 90, 0.9); }
  100% { transform: scale(0.15) rotate(-14deg); opacity: 0; }
}

.tile.is-empty .tile-face { display: none; }

.tile.is-shuffling .tile-face { animation: shuffleFlip 0.32s ease; }

@keyframes shuffleFlip {
  0% { transform: rotateY(0deg) scale(1); }
  50% { transform: rotateY(72deg) scale(0.88); }
  100% { transform: rotateY(0deg) scale(1); }
}

.float-layer,
.combo-burst {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 8;
}

.float-gain {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 20px;
  font-weight: 900;
  color: #FFF9E6;
  text-shadow: 0 2px 0 #E96F1B, 0 4px 10px rgba(150, 70, 8, 0.55);
  animation: gainUp 0.85s ease-out forwards;
  white-space: nowrap;
}

@keyframes gainUp {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(0.6); }
  25% { opacity: 1; transform: translate(-50%, -60%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -190%) scale(0.95); }
}

.combo-burst {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 900;
  color: #FFF6D8;
  text-shadow: 0 3px 0 #E96F1B, 0 6px 14px rgba(140, 60, 4, 0.5);
  opacity: 0;
}

.combo-burst.is-show { animation: comboBurst 1s ease-out forwards; }

@keyframes comboBurst {
  0% { opacity: 0; transform: scale(0.5) rotate(-6deg); }
  22% { opacity: 1; transform: scale(1.12) rotate(2deg); }
  70% { opacity: 1; transform: scale(1) rotate(0deg); }
  100% { opacity: 0; transform: scale(1.06) translateY(-18px); }
}

.game-foot {
  flex: none;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
}

.tool-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 44px;
  padding: 0 8px;
  border-radius: 13px;
  background: rgba(255, 251, 242, 0.94);
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 3px 0 rgba(203, 142, 84, 0.36);
  color: #7A4A20;
  font-size: 11px;
  font-weight: 800;
  transition: transform 0.1s ease, box-shadow 0.1s ease, opacity 0.15s ease;
}

.tool-btn .mp-icon { width: 17px; height: 17px; color: #E96F1B; }

.tool-btn em {
  font-style: normal;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 7px;
  background: #FF8A3D;
  color: #fff;
  font-size: 9px;
  font-weight: 900;
  line-height: 15px;
  text-align: center;
}

.tool-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(203, 142, 84, 0.36); }
.tool-btn.is-disabled { opacity: 0.45; }

.progress {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 2px;
}

.progress-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 9px;
  font-weight: 700;
  color: #90602F;
  letter-spacing: 0.05em;
}

.progress-top b {
  font-size: 10px;
  color: #E96F1B;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 247, 232, 0.85);
  box-shadow: inset 0 1px 3px rgba(140, 80, 24, 0.22);
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #FFC24B, #FF8A3D 70%, #F26B14);
  box-shadow: 0 0 8px rgba(255, 160, 60, 0.6);
  transition: width 0.25s ease;
}

/* ---------------- 结束页 ---------------- */

.screen--result {
  z-index: 20;
  align-items: center;
  justify-content: center;
  padding: calc(16px + env(safe-area-inset-top)) 18px calc(16px + env(safe-area-inset-bottom));
  background:
    radial-gradient(90% 60% at 50% 18%, rgba(255, 196, 110, 0.42), rgba(92, 44, 10, 0.62) 100%);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  overflow-y: auto;
}

.result-card {
  position: relative;
  width: 100%;
  max-width: 354px;
  margin-top: 26px;
  padding: 44px 18px 18px;
  border-radius: 26px;
  background: linear-gradient(180deg, #FFFDF6 0%, #FFF2DA 100%);
  border: 3px solid #F6C98C;
  box-shadow:
    0 18px 40px rgba(74, 36, 6, 0.42),
    inset 0 2px 0 #fff,
    inset 0 -6px 0 rgba(216, 160, 90, 0.18);
  text-align: center;
  animation: cardIn 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.15) both;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(24px) scale(0.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.result-hat {
  position: absolute;
  top: -37px;
  left: 50%;
  width: 88px;
  transform: translateX(-50%) rotate(-4deg);
  filter: drop-shadow(0 5px 6px rgba(100, 50, 10, 0.25));
}

.result-hat svg { display: block; width: 100%; height: auto; }

.result-title {
  margin: 3px 0 4px;
  font-size: 25px;
  font-weight: 900;
  color: #7E4318;
  letter-spacing: 0.03em;
  text-shadow: 0 2px 0 #fff;
}

.result-sub {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: #A4713D;
}

.stars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 40px;
  margin-bottom: 4px;
}

.star {
  width: 32px;
  height: 32px;
  fill: #EFE3CE;
  stroke: #DCC8A8;
  stroke-width: 1;
  transform: scale(0.96);
  transition: transform 0.2s ease;
}

.star--mid { width: 38px; height: 38px; margin-top: -6px; }

.star.lit {
  fill: #FFC53D;
  stroke: #E79B12;
  filter: drop-shadow(0 3px 3px rgba(220, 140, 20, 0.35));
  animation: starIn 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.4) both;
}

@keyframes starIn {
  from { transform: scale(0.2) rotate(-30deg); }
  to { transform: scale(1) rotate(0deg); }
}

.result-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 8px 0 10px;
}

.result-score span {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: #A9794A;
}

.result-score strong {
  font-size: 46px;
  line-height: 1;
  font-weight: 900;
  color: #FF8A3D;
  font-variant-numeric: tabular-nums;
  -webkit-text-stroke: 1.5px #D9620E;
  text-shadow: 0 4px 0 #FFD9A6, 0 7px 12px rgba(180, 90, 10, 0.25);
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 8px;
  border-radius: 14px;
  background: rgba(255, 246, 230, 0.9);
  border: 1px solid #F2DCBC;
}

.result-stats div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 2px;
  border-radius: 9px;
}

.result-stats div + div { border-left: 1px dashed #E8CFAA; }

.result-stats span { font-size: 10px; font-weight: 700; color: #A9794A; }

.result-stats b {
  font-size: 15px;
  font-weight: 900;
  color: #6E3E18;
  font-variant-numeric: tabular-nums;
}

.best-row {
  margin: 9px 0 4px;
  font-size: 11px;
  font-weight: 600;
  color: #A4713D;
}

.best-row b { color: #E96F1B; font-weight: 900; }

.btn-ghost {
  display: block;
  width: 100%;
  height: 42px;
  margin-top: 7px;
  border-radius: 13px;
  border: 2px solid #EAD2B1;
  background: rgba(255, 252, 245, 0.8);
  color: #8A5A2C;
  font-size: 14px;
  font-weight: 800;
  transition: transform 0.1s ease;
}

.btn-ghost:active { transform: translateY(2px); }

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

.confetti i {
  position: absolute;
  top: -18px;
  width: 8px;
  height: 13px;
  border-radius: 2px;
  opacity: 0;
  animation: confettiFall 2.4s ease-in forwards;
}

@keyframes confettiFall {
  0% { opacity: 0; transform: translateY(-20px) rotate(0deg); }
  12% { opacity: 1; }
  100% { opacity: 0; transform: translateY(105vh) rotate(540deg); }
}

/* ---------------- 弹层 ---------------- */

.dim {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(74, 36, 6, 0.45);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: fadeIn 0.2s ease both;
}

.dim[hidden] { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.sheet[hidden] { display: none; }

.sheet-card {
  width: 100%;
  max-width: 560px;
  max-height: 92%;
  overflow-y: auto;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0;
  background: linear-gradient(180deg, #FFFDF7 0%, #FFF2DC 100%);
  border-top: 3px solid #F6C98C;
  box-shadow: 0 -12px 32px rgba(74, 36, 6, 0.3);
  animation: sheetUp 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.05) both;
}

.sheet-card--small { padding-bottom: calc(22px + env(safe-area-inset-bottom)); }

@keyframes sheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.sheet-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 900;
  color: #6E3E18;
  letter-spacing: 0.01em;
}

.sheet-close {
  width: auto;
  height: 32px;
  flex: none;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: #FFF4E1;
  border: 1px solid #F2DCBC;
  color: #A4713D;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.sheet-close:active { transform: translateY(1px); }

.rule-list {
  list-style: none;
  margin: 4px 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.rule-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 250, 240, 0.85);
  border: 1px solid #F5E3C8;
}

.rule-num {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  background: linear-gradient(180deg, #FFB05C, #F26B14);
  color: #fff;
  font-style: normal;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 2px 0 #C1550C;
}

.rule-list b {
  display: block;
  font-size: 13px;
  font-weight: 900;
  color: #6E3E18;
  margin-bottom: 2px;
}

.rule-list span {
  display: block;
  font-size: 11.5px;
  line-height: 1.5;
  color: #9A6C43;
}

.sheet-ok {
  display: block;
  width: 100%;
  height: 50px;
  border-radius: 15px;
  background: linear-gradient(180deg, #FFB05C, #F26B14);
  border: 2px solid #FFD2A3;
  box-shadow: 0 5px 0 #C1550C, inset 0 2px 0 rgba(255, 255, 255, 0.4);
  color: #FFFDF6;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-shadow: 0 2px 0 #C4570C;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.sheet-ok:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #C1550C, inset 0 2px 0 rgba(255, 255, 255, 0.4);
}

.name-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 6px 0 4px;
}

.name-field span {
  font-size: 11px;
  font-weight: 800;
  color: #A9794A;
  letter-spacing: 0.08em;
}

.name-field input {
  height: 50px;
  padding: 0 14px;
  border-radius: 14px;
  border: 2px solid #EFD7B6;
  background: #FFFDF8;
  color: #5B3417;
  font-size: 16px;
  font-weight: 700;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}

.name-field input:focus { border-color: #FF9E55; box-shadow: 0 0 0 3px rgba(255, 138, 61, 0.18); }

.name-tip {
  margin: 6px 0 14px;
  font-size: 10.5px;
  color: #A4713D;
}

.quit-tip {
  margin: 2px 0 16px;
  font-size: 12.5px;
  line-height: 1.6;
  color: #9A6C43;
}

/* ---------------- 轻提示 ---------------- */

.toast {
  position: absolute;
  left: 50%;
  bottom: 22%;
  z-index: 60;
  transform: translate(-50%, 10px);
  max-width: 86%;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(76, 41, 12, 0.92);
  border: 1px solid rgba(255, 220, 170, 0.3);
  box-shadow: 0 8px 20px rgba(50, 24, 4, 0.35);
  color: #FFF4DE;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

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

/* ---------------- 适配 ---------------- */

@media (max-height: 700px) {
  .hero { gap: 9px; padding: 8px 0 6px; }
  .logo { width: min(250px, 72vw); margin-top: 18px; }
  .logo-hat { width: 76px; top: -33px; }
  .logo-main { font-size: clamp(32px, 10vw, 40px); }
  .logo-top { font-size: 17px; }
  .demo-board { width: min(258px, 72vw); }
  .demo-frame { padding: 5px; border-radius: 16px; }
  .demo-grid { padding: 5px; gap: 4px; }
  .tagline { font-size: 11px; padding: 5px 12px; }
  .btn-play { height: 56px; font-size: 22px; }
  .start-note { font-size: 10px; }
  .player-chip { min-height: 42px; }
  .avatar { width: 32px; height: 32px; }
  .player-name { font-size: 13px; }
}

@media (max-height: 600px) {
  .hero { justify-content: flex-start; overflow-y: auto; }
  .logo-hat { display: none; }
  .logo { margin-top: 4px; }
  .demo-board { width: 214px; }
  .tagline { display: none; }
  .game-foot { min-height: 42px; }
  .tool-btn { height: 40px; }
}

@media (max-height: 720px) {
  .screen--result {
    justify-content: flex-start;
    padding-top: calc(26px + env(safe-area-inset-top));
  }
  .result-card { margin-top: 24px; padding-top: 38px; }
  .result-score strong { font-size: 40px; }
  .result-title { font-size: 22px; }
  .stars { height: 34px; }
  .star { width: 28px; height: 28px; }
  .star--mid { width: 33px; height: 33px; }
}

@media (min-width: 430px) {
  .player-name { max-width: 180px; }
  .result-card { max-width: 380px; }
}

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