*,
*::before,
*::after { box-sizing: border-box; }

:root {
  --orange: #FF8A3D;
  --brown: #6B3A1C;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--brown);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

[hidden] { display: none !important; }

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

.app {
  position: relative;
  width: 100%;
  max-width: 520px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: #FFE3B8;
}

.scene {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.scene-wall {
  position: absolute;
  inset: 0;
  background: radial-gradient(100% 55% at 50% 0%, #FFF9E9 0%, #FFEECB 48%, #F8BE78 100%);
}

.scene-counter {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 22%;
  background: linear-gradient(180deg, #F0A85A, #C46B28);
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  flex-direction: column;
  padding: calc(14px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
}

.screen.active { display: flex; }

.home-top, .game-hud {
  display: flex;
  align-items: center;
  gap: 10px;
}

.best-chip, .hud-score, .hud-time {
  background: rgba(255, 248, 234, .92);
  border: 1.5px solid rgba(196, 120, 50, .28);
  border-radius: 18px;
  box-shadow: 0 4px 10px rgba(150, 75, 20, .1);
}

.best-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 42px;
  padding: 0 12px 0 8px;
}

.best-ico {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
}

.best-label { font-size: 13px; color: #9A6A3A; }
.best-chip b, .hud-score b { font-size: 18px; color: #D9651A; }

.icon-btn {
  width: 44px;
  height: 44px;
  margin-left: auto;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 248, 234, .92);
  border: 1.5px solid rgba(196, 120, 50, .28);
  color: #B05A17;
}

.hud-home { margin-left: 0; }

.home-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.logo-plate {
  width: min(82vw, 320px);
  padding: 22px 16px 18px;
  border-radius: 28px;
  border: 4px solid #C4510F;
  background: linear-gradient(180deg, #FFC061, #F3761C);
  box-shadow: 0 10px 0 #A63E09;
  text-align: center;
}

.logo-line1, .logo-line2 {
  display: block;
  color: #FFF8EA;
  font-weight: 900;
  text-shadow: 0 3px 0 #C4510F;
}

.logo-line1 { font-size: 28px; letter-spacing: .2em; }
.logo-line2 { margin-top: 4px; font-size: 42px; }

.tagline, .howto, .end-sub {
  margin: 14px 0 0;
  font-size: 15px;
  color: #8A4B1E;
  text-align: center;
}

.start-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: min(78vw, 300px);
  height: 64px;
  margin-top: 18px;
  border-radius: 32px;
  background: linear-gradient(180deg, #FFD05E, #FF7A1A);
  border: 2px solid #D96110;
  box-shadow: 0 7px 0 #BF4C0A;
  color: #fff;
  font-size: 22px;
  font-weight: 900;
}

.start-btn:active { transform: translateY(4px); box-shadow: 0 3px 0 #BF4C0A; }

.home-meta, .end-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
  font-size: 13px;
  color: #8A4B1E;
}

.meta-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #C98A3A;
}

.home-bottom { padding-bottom: 8px; }

.game-hud { margin-bottom: 10px; }
.hud-score {
  min-width: 92px;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
}
.hud-score span, .time-top { font-size: 12px; color: #9A6A3A; }
.hud-time { flex: 1; padding: 6px 10px; }
.time-top { display: flex; align-items: center; gap: 6px; }
.time-top b { font-size: 16px; color: #6B3A1C; }
.combo-chip {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 99px;
  background: #FFE3B8;
  color: #B4490F;
  font-size: 12px;
}
.combo-chip.hot { background: #FF8A3D; color: #fff; }
.time-track {
  height: 8px;
  margin-top: 6px;
  border-radius: 99px;
  background: #F3D2A4;
  overflow: hidden;
}
.time-fill {
  display: block;
  height: 100%;
  width: 100%;
  background: #FF8A3D;
}
.time-track.urgent .time-fill { background: #E8503A; }

.board-area { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.board-wrap { position: relative; flex: 1; min-height: 0; }
.board {
  height: 100%;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 6px;
}
.tile {
  border-radius: 12px;
  background: #FFF8EA;
  border: 2px solid #F0C48A;
  display: grid;
  place-items: center;
  min-height: 0;
  box-shadow: 0 3px 0 rgba(180, 90, 20, .12);
}
.tile .food { width: 78%; height: 78%; }
.tile.selected { border-color: #FF8A3D; background: #FFE7C4; transform: scale(.96); }
.tile.hint { border-color: #58B84A; background: #F3FFE8; }
.tile.gone { opacity: 0; transform: scale(.6); transition: .2s ease; }
.tile.shake { animation: shake .25s linear; }
@keyframes shake {
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}
.path-layer, .float-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.rice-pop {
  position: absolute;
  transform: translate(-50%, -10px);
  color: #D9651A;
  font-weight: 900;
  font-size: 16px;
  animation: rise .7s ease forwards;
}
@keyframes rise {
  to { transform: translate(-50%, -36px); opacity: 0; }
}
.game-tip {
  margin: 8px 0;
  text-align: center;
  font-size: 14px;
  color: #8A4B1E;
}
.game-tip.warn { color: #C2412D; }
.game-tools { display: flex; gap: 10px; }
.tool-btn {
  flex: 1;
  height: 52px;
  border-radius: 16px;
  background: #FFF8EA;
  border: 1.5px solid rgba(196, 120, 50, .3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 16px;
  font-weight: 800;
}
.tool-btn b {
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  background: #FF8A3D;
  color: #fff;
  font-size: 13px;
  line-height: 22px;
}
.tool-btn:disabled { opacity: .45; }

.end {
  align-items: center;
  justify-content: center;
}
.end-card {
  width: min(88vw, 360px);
  padding: 22px 18px 16px;
  border-radius: 24px;
  background: #FFF8EA;
  border: 2px solid #F0C48A;
  text-align: center;
}
.end-kicker { margin: 0; color: #C47A2A; font-size: 14px; }
.end-title { margin: 6px 0 0; font-size: 30px; }
.end-score-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}
.end-score-row b { font-size: 36px; color: #D9651A; }
.end-score-row.soft b { font-size: 20px; }
.end-record {
  font-style: normal;
  color: #fff;
  background: #FF8A3D;
  border-radius: 99px;
  padding: 2px 8px;
  font-size: 12px;
}
.text-btn {
  margin-top: 8px;
  height: 40px;
  color: #8A4B1E;
  font-size: 15px;
}
.toast {
  position: absolute;
  left: 50%;
  top: 22%;
  z-index: 8;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(107, 58, 28, .9);
  color: #fff;
  opacity: 0;
  pointer-events: none;
}
.toast.show { opacity: 1; }
.modal {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  background: rgba(80, 40, 10, .35);
}
.modal-card {
  width: min(80vw, 300px);
  padding: 18px;
  border-radius: 18px;
  background: #FFF8EA;
  text-align: center;
}
.modal-actions { display: flex; gap: 10px; }
.modal-actions button {
  flex: 1;
  height: 44px;
  border-radius: 12px;
  background: #FF8A3D;
  color: #fff;
  font-weight: 800;
}
#modal-cancel { background: #F3D2A4; color: #6B3A1C; }
.score.pop { transform: scale(1.08); }
.mp-icon { width: 20px; height: 20px; }
