/* 贪吃蛇 · 可爱果子乐园 —— 竖向铺满的游戏界面 */
:root {
  --orange: #FF8A3D;
  --orange-deep: #F2701C;
  --orange-light: #FFB05E;
  --cream: #FFF4E3;
  --cream-deep: #FFE6C8;
  --ink: #5B3A22;
  --ink-soft: #9A6B4A;
  --line: #FFE1BC;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #FFDDBB;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  -webkit-font-smoothing: antialiased;
}

.game {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  overflow: hidden;
  background:
    radial-gradient(120% 78% at 18% 0%, #FFFBF3 0%, rgba(255, 251, 243, 0) 56%),
    radial-gradient(96% 66% at 102% 12%, #FFE1BE 0%, rgba(255, 225, 190, 0) 62%),
    linear-gradient(180deg, #FFF4E4 0%, #FFE8CF 46%, #FFD3AD 100%);
}

/* 背景柔光色块 */
.bg-blob {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.55;
  filter: blur(2px);
}
.blob-a {
  width: 68vw;
  height: 68vw;
  max-width: 380px;
  max-height: 380px;
  left: -26vw;
  top: -16vh;
  background: radial-gradient(circle at 50% 50%, rgba(255, 214, 170, 0.95), rgba(255, 230, 200, 0) 70%);
}
.blob-b {
  width: 52vw;
  height: 52vw;
  max-width: 300px;
  max-height: 300px;
  right: -20vw;
  top: 30vh;
  background: radial-gradient(circle at 50% 50%, rgba(255, 197, 141, 0.75), rgba(255, 226, 194, 0) 72%);
}
.blob-c {
  width: 62vw;
  height: 62vw;
  max-width: 340px;
  max-height: 340px;
  left: 6vw;
  bottom: -12vh;
  background: radial-gradient(circle at 50% 50%, rgba(255, 190, 133, 0.6), rgba(255, 224, 190, 0) 72%);
}

#board {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: block;
}

/* ---------- 顶部 HUD（悬浮，不是标题栏） ---------- */
.hud {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(12px + var(--safe-top)) 16px 0;
  pointer-events: none;
}
.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}
.pill {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 44px;
  padding: 0 15px 0 12px;
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.82);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 6px 18px rgba(206, 120, 52, 0.16), inset 0 1px 0 #fff;
  font-size: 18px;
  font-weight: 800;
  color: #7A4A26;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.pill .mp-icon {
  width: 21px;
  height: 21px;
  color: #F5A623;
  margin-top: -2px;
}
.pill-score { padding: 0 15px 0 12px; }
#curScore { display: inline-block; min-width: 12px; text-align: left; }
#curScore.pop { animation: scorePop 0.32s ease; }

.apple-mark {
  position: relative;
  width: 19px;
  height: 18px;
  border-radius: 50% 50% 46% 46% / 48% 48% 54% 54%;
  background: radial-gradient(circle at 34% 28%, #FF9282, #FF5749 58%, #EE3B33 100%);
  box-shadow: inset -2px -3px 5px rgba(160, 18, 18, 0.28), 0 1px 2px rgba(200, 50, 30, 0.2);
  flex: none;
}
.apple-mark::before {
  content: "";
  position: absolute;
  left: 8px;
  top: -4px;
  width: 2.5px;
  height: 6px;
  border-radius: 2px;
  background: #8C5A34;
  transform: rotate(14deg);
}
.apple-leaf {
  position: absolute;
  right: -1px;
  top: -3px;
  width: 8px;
  height: 6px;
  border-radius: 50% 0 50% 0;
  background: #6FC44E;
  transform: rotate(-18deg);
}

.round-btn {
  width: 44px;
  height: 44px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  background: rgba(255, 253, 248, 0.82);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: 0 6px 18px rgba(206, 120, 52, 0.16), inset 0 1px 0 #fff;
  color: #B06C3C;
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease, background 0.15s ease;
}
.round-btn .mp-icon { width: 22px; height: 22px; }
.round-btn:active { transform: scale(0.9); background: rgba(255, 240, 224, 0.95); }
.round-btn[hidden] { display: none; }

/* ---------- 屏幕层 ---------- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0 20px calc(24px + var(--safe-bottom));
}
.screen[hidden] { display: none !important; }

.start-screen {
  justify-content: flex-end;
  pointer-events: none;
}
.start-screen::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 52%;
  background: linear-gradient(180deg, rgba(255, 238, 216, 0) 0%, rgba(255, 234, 209, 0.72) 42%, rgba(255, 225, 195, 0.95) 100%);
  pointer-events: none;
}
.start-bottom {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding-bottom: 2px;
  pointer-events: none;
}
.start-bottom > * { pointer-events: auto; }

/* 开始按钮 */
.btn-play {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: min(344px, 86vw);
  height: 66px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  overflow: hidden;
  background: linear-gradient(180deg, #FFB565 0%, #FF923F 44%, #FF7A1E 100%);
  color: #fff;
  font-family: inherit;
  font-size: 23px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-shadow: 0 2px 3px rgba(190, 78, 0, 0.28);
  box-shadow:
    0 16px 30px -8px rgba(236, 110, 26, 0.62),
    0 4px 0 0 #E8701B,
    inset 0 2px 0 rgba(255, 255, 255, 0.5),
    inset 0 -8px 14px rgba(190, 80, 0, 0.2);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  animation: btnIn 0.48s cubic-bezier(0.22, 1.25, 0.4, 1) both;
}
.btn-play:active {
  transform: translateY(3px) scale(0.985);
  box-shadow:
    0 7px 16px -6px rgba(236, 110, 26, 0.55),
    0 1px 0 0 #E8701B,
    inset 0 2px 0 rgba(255, 255, 255, 0.4),
    inset 0 -6px 12px rgba(190, 80, 0, 0.22);
}
.btn-gloss {
  position: absolute;
  left: 13%;
  right: 13%;
  top: 6px;
  height: 20px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0));
  pointer-events: none;
}
.btn-play-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.24);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
  flex: none;
}
.btn-play-icon .mp-icon {
  width: 25px;
  height: 25px;
  color: #fff;
  margin-left: 2px;
}

/* 提示气泡 */
.hint-bubble {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 16px 8px 9px;
  border-radius: 999px;
  background: linear-gradient(180deg, #FFFDF8, #FFF0DA);
  border: 1.5px solid #FFE3C2;
  box-shadow: 0 6px 16px rgba(206, 120, 52, 0.13), inset 0 1px 0 #fff;
  font-size: 14px;
  font-weight: 700;
  color: #A5673A;
  letter-spacing: 0.01em;
}
.mini-face {
  position: relative;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: linear-gradient(180deg, #FFB166, #FF8E37);
  box-shadow: inset 0 -2px 3px rgba(180, 80, 0, 0.18), 0 2px 4px rgba(220, 120, 40, 0.2);
  flex: none;
}
.mini-eye {
  position: absolute;
  top: 8px;
  left: 6.5px;
  width: 5px;
  height: 6px;
  border-radius: 50%;
  background: #5B3A22;
}
.mini-eye.right { left: 15.5px; }
.mini-mouth {
  position: absolute;
  left: 10px;
  top: 15px;
  width: 7px;
  height: 4px;
  border-radius: 0 0 7px 7px;
  background: #5B3A22;
  opacity: 0.85;
}

.swipe-tip {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: #B07A50;
  opacity: 0.92;
}
.swipe-tip .mp-icon { width: 16px; height: 16px; color: #C98A57; }

/* ---------- 结束 / 暂停 卡片 ---------- */
.pause-screen,
.over-screen {
  z-index: 9;
  justify-content: center;
  padding-top: calc(70px + var(--safe-top));
  padding-bottom: calc(20px + var(--safe-bottom));
  background: rgba(112, 62, 26, 0.22);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.card {
  position: relative;
  width: 100%;
  max-width: 356px;
  margin: 0 auto;
  padding: 24px 22px 20px;
  border-radius: 30px;
  background: linear-gradient(180deg, #FFFDF9 0%, #FFF6E9 100%);
  border: 1.5px solid #FFE8CC;
  box-shadow:
    0 26px 60px -14px rgba(160, 88, 30, 0.45),
    inset 0 1px 0 #fff;
  text-align: center;
  animation: cardIn 0.34s cubic-bezier(0.22, 1.2, 0.4, 1) both;
}
.card::after {
  content: "";
  position: absolute;
  left: 22px;
  right: 22px;
  top: 7px;
  height: 1px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 2px;
}
.card h2 {
  margin: 6px 0 4px;
  font-size: 23px;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: #5B3A22;
}
.card-sub {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: #A67A56;
}
.card-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(180deg, #FFE7CB, #FFD5AB);
  box-shadow: inset 0 1px 0 #fff, 0 6px 14px rgba(206, 120, 52, 0.18);
  color: #E88934;
}
.card-icon .mp-icon { width: 28px; height: 28px; }

.card-actions {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 18px;
}

.btn-main {
  width: 100%;
  height: 54px;
  border: 0;
  border-radius: 18px;
  cursor: pointer;
  background: linear-gradient(180deg, #FFB060 0%, #FF8D38 55%, #FF7A1E 100%);
  color: #fff;
  font-family: inherit;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-shadow: 0 1px 2px rgba(190, 78, 0, 0.28);
  box-shadow:
    0 10px 20px -8px rgba(236, 110, 26, 0.6),
    0 3px 0 0 #E8701B,
    inset 0 2px 0 rgba(255, 255, 255, 0.45);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn-main:active {
  transform: translateY(2px) scale(0.99);
  box-shadow: 0 4px 10px -6px rgba(236, 110, 26, 0.5), 0 1px 0 0 #E8701B, inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.btn-ghost {
  width: 100%;
  height: 44px;
  border: 1.5px solid #FFE0BE;
  border-radius: 16px;
  background: rgba(255, 249, 240, 0.9);
  color: #A86A38;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease;
}
.btn-ghost:active { transform: scale(0.98); background: #FFF1DF; }

/* 结束卡 */
.over-card { padding-top: 28px; }
.over-face {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: linear-gradient(180deg, #FFC27E 0%, #FF9C43 100%);
  box-shadow:
    inset 0 -4px 8px rgba(175, 80, 0, 0.16),
    inset 0 3px 0 rgba(255, 255, 255, 0.4),
    0 8px 18px rgba(235, 130, 50, 0.32);
}
.over-eye {
  position: absolute;
  top: 23px;
  left: 19px;
  width: 10px;
  height: 13px;
  border-radius: 50%;
  background: #5B3A22;
}
.over-eye.right { left: 43px; }
.over-eye::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 2.5px;
  width: 3.2px;
  height: 3.2px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
}
.over-mouth {
  position: absolute;
  left: 25px;
  top: 47px;
  width: 22px;
  height: 10px;
  border-top: 2.6px solid #5B3A22;
  border-radius: 12px 12px 0 0;
  opacity: 0.9;
}

.record-badge {
  position: absolute;
  top: -13px;
  right: 20px;
  padding: 5px 13px;
  border-radius: 999px;
  background: linear-gradient(180deg, #FFE7C3, #FFD29A);
  border: 1px solid #FFC183;
  color: #C9600F;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  transform: rotate(5deg);
  box-shadow: 0 5px 12px rgba(206, 120, 52, 0.25);
}
.record-badge[hidden] { display: none; }

.score-grid {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.score-cell {
  flex: 1;
  padding: 11px 8px 10px;
  border-radius: 18px;
  background: linear-gradient(180deg, #FFF8EE, #FFEFD9);
  border: 1px solid #FFE3C4;
  box-shadow: inset 0 1px 0 #fff;
}
.score-cell span {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  color: #B0855F;
  letter-spacing: 0.04em;
}
.score-cell strong {
  display: block;
  margin-top: 2px;
  font-size: 30px;
  line-height: 1.1;
  font-weight: 800;
  color: #FF8A3D;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.8);
}
.score-cell.best strong { color: #F5A623; }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(18px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes btnIn {
  from { opacity: 0; transform: translateY(16px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes scorePop {
  0% { transform: scale(1); }
  45% { transform: scale(1.4); color: #F2701C; }
  100% { transform: scale(1); }
}

/* 桌面端不出现滚动条 */
@media (min-width: 620px) {
  body { background: #F7C79B; }
  .game { box-shadow: 0 0 0 1px rgba(214, 130, 60, 0.12); }
}
