:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --orange: #FF8A3D;
  --orange-deep: #EA6A18;
  --brown: #743412;
  --brown-soft: #9C5A28;
  --cream: #FFF8EC;
  --cream-2: #FFF0D6;
  --gold: #FFC93F;
  --line: #F1C48D;
  --shadow: rgba(139, 60, 8, 0.16);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 12%, rgba(255, 237, 208, 0.55), transparent 42%),
    linear-gradient(160deg, #F5A366 0%, #E98D4E 55%, #D97A3F 100%);
  color: var(--brown);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

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

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

.hidden { display: none !important; }

.app {
  position: relative;
  width: 100%;
  max-width: 520px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(120% 58% at 50% -4%, #FFF1D9 0%, #FFE3C0 28%, #FFD0A3 53%, #FFB97F 78%, #FFA968 100%);
  box-shadow: 0 0 90px rgba(108, 44, 6, 0.26);
}

@media (min-width: 560px) {
  .app { border-radius: 28px; }
}

/* ---------- 背景装饰 ---------- */
.bg-decor {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.sun {
  position: absolute;
  top: -130px;
  left: 50%;
  width: 420px;
  height: 420px;
  margin-left: -210px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 252, 230, 0.85) 0%, rgba(255, 241, 203, 0.45) 40%, transparent 68%);
}

.ray {
  position: absolute;
  top: -80px;
  left: 50%;
  width: 150px;
  height: 520px;
  margin-left: -75px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.4), transparent 76%);
  transform-origin: 50% 0;
  filter: blur(2px);
}

.ray-a { transform: rotate(27deg); opacity: 0.5; }
.ray-b { transform: rotate(-31deg); opacity: 0.4; }

.cloud {
  position: absolute;
  width: 116px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.26);
  filter: blur(1.5px);
  animation: cloudFloat 12s ease-in-out infinite;
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: inherit;
}

.cloud::before { width: 52px; height: 52px; left: 17px; top: -21px; }
.cloud::after { width: 38px; height: 38px; right: 14px; top: -14px; }

.cloud-a { top: 16%; left: -38px; opacity: 0.6; }
.cloud-b { top: 40%; right: -46px; width: 140px; opacity: 0.38; animation-delay: -4s; }
.cloud-c { bottom: 14%; left: -54px; width: 150px; opacity: 0.3; animation-delay: -7s; }

.bubble {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, rgba(255, 255, 255, 0.48), rgba(255, 255, 255, 0.06) 58%, transparent 70%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  animation: bubbleFloat 8s ease-in-out infinite;
}

.bubble-a { width: 26px; height: 26px; top: 26%; right: 9%; }
.bubble-b { width: 16px; height: 16px; top: 34%; left: 8%; animation-delay: -2.6s; }
.bubble-c { width: 34px; height: 34px; bottom: 20%; right: 12%; animation-delay: -5s; }

/* ---------- 页面 ---------- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.start-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(var(--safe-top) + 10px) 18px calc(var(--safe-bottom) + 14px);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.start-screen::-webkit-scrollbar { display: none; }

.start-bar {
  position: absolute;
  top: calc(var(--safe-top) + 12px);
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 4;
}

.round-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  color: #C25D1B;
  background: linear-gradient(180deg, rgba(255, 253, 246, 0.96), rgba(255, 240, 218, 0.93));
  border: 2px solid rgba(255, 255, 255, 0.78);
  box-shadow: 0 4px 0 rgba(160, 73, 17, 0.16), 0 7px 16px rgba(150, 64, 10, 0.16), inset 0 1px 0 #fff;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 0.09s ease, box-shadow 0.09s ease;
}

.round-btn .mp-icon { width: 22px; height: 22px; }
.round-btn:active { transform: translateY(3px) scale(0.94); box-shadow: 0 1px 0 rgba(160, 73, 17, 0.16); }

.logo-frame {
  width: min(89%, 400px);
  margin-top: 48px;
  border-radius: 24px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.4);
  background: #FDD0A2;
  box-shadow: 0 18px 28px -18px rgba(124, 48, 4, 0.58);
  animation: logoIn 0.55s cubic-bezier(0.2, 0.9, 0.25, 1.2) both;
}

.logo {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

.plaque {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding: 5px 18px 7px;
  border-radius: 999px;
  background: linear-gradient(180deg, #93441A 0%, #76300E 58%, #682708 100%);
  border: 3px solid #FFE0A3;
  box-shadow: 0 5px 0 #551F06, 0 11px 20px rgba(86, 31, 3, 0.28), inset 0 2px 0 rgba(255, 255, 255, 0.22);
  animation: logoIn 0.6s 0.06s cubic-bezier(0.2, 0.9, 0.25, 1.2) both;
}

.plaque-medal { width: 20px; height: 20px; color: #FFD166; }

.plaque-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 92px;
  line-height: 1;
}

.plaque-text span {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 3px;
  color: #FFD9A0;
  margin-bottom: 3px;
}

.plaque-text strong {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #FFD04E;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 #A45606, 0 0 14px rgba(255, 196, 45, 0.38);
}

.hero {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  min-height: 196px;
  margin-top: 2px;
  animation: heroIn 0.65s 0.14s cubic-bezier(0.2, 0.9, 0.25, 1.1) both;
}

#heroCanvas { display: block; width: 100%; height: 100%; }

.start-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  width: 100%;
  max-width: 380px;
  margin-top: auto;
  padding-top: 4px;
}

.cta {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 60px;
  padding: 0 22px;
  border-radius: 999px;
  color: #FFFDF7;
  font-size: 23px;
  font-weight: 900;
  letter-spacing: 2.5px;
  background: linear-gradient(180deg, #FFD154 0%, #FFA832 34%, #FF7D17 100%);
  border: 2px solid #FFE19B;
  box-shadow:
    0 7px 0 #C4530A,
    0 15px 26px rgba(157, 60, 6, 0.38),
    inset 0 3px 0 rgba(255, 255, 255, 0.55),
    inset 0 -6px 12px rgba(190, 72, 3, 0.2);
  text-shadow: 0 2px 0 rgba(160, 58, 0, 0.62), 0 4px 10px rgba(160, 58, 0, 0.24);
  transition: transform 0.09s ease, box-shadow 0.09s ease, filter 0.15s ease;
  overflow: hidden;
}

.cta::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 9%;
  right: 9%;
  height: 34%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.4), transparent);
  pointer-events: none;
}

.cta:active {
  transform: translateY(5px) scale(0.99);
  box-shadow: 0 2px 0 #C4530A, 0 6px 12px rgba(157, 60, 6, 0.3), inset 0 2px 0 rgba(255, 255, 255, 0.5);
}

.cta-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
  flex: 0 0 auto;
}

.cta-icon .mp-icon { width: 27px; height: 27px; color: #fff; }

.start-hint {
  margin: 0;
  padding: 0 6px;
  text-align: center;
  font-size: 11.5px;
  line-height: 1.5;
  font-weight: 600;
  color: #95531F;
  opacity: 0.82;
}

/* ---------- 游戏中 ---------- */
.game-screen { overflow: hidden; }

#gameCanvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
  -webkit-user-select: none;
  user-select: none;
}

.hud {
  position: absolute;
  top: calc(var(--safe-top) + 10px);
  left: 14px;
  right: 14px;
  z-index: 5;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.hud-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}

.hud button { pointer-events: auto; }

.hud-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.score-card {
  min-width: 106px;
  padding: 5px 14px 6px;
  border-radius: 18px;
  background: linear-gradient(180deg, #FFFDF6 0%, #FFF0D8 100%);
  border: 2px solid #FFD79C;
  box-shadow: 0 6px 14px rgba(144, 65, 10, 0.16), inset 0 1px 0 #fff;
}

.score-label {
  display: block;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 3px;
  color: #A65B22;
  line-height: 1.2;
}

.score-value {
  display: block;
  font-size: 26px;
  line-height: 1.1;
  font-weight: 900;
  color: #7B3512;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 0 #fff;
  transform-origin: 20% 60%;
}

.score-value.bump { animation: scoreBump 0.22s ease; }

.best-mini {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  color: #8D4A1E;
  background: rgba(255, 248, 235, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 2px 6px rgba(139, 60, 8, 0.1);
}

.best-mini b { font-weight: 900; color: #B95514; }

.next-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 58px;
  padding: 3px 0 2px;
  border-radius: 16px;
  background: linear-gradient(180deg, #FFFDF6 0%, #FFF0D8 100%);
  border: 2px solid #FFD79C;
  box-shadow: 0 5px 12px rgba(144, 65, 10, 0.14), inset 0 1px 0 #fff;
}

.next-card span {
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: #A65B22;
  line-height: 1.25;
}

#nextCanvas { display: block; width: 34px; height: 34px; }

.hud-btn { width: 38px; height: 38px; }
.hud-btn .mp-icon { width: 20px; height: 20px; }

.danger-tip {
  position: absolute;
  top: calc(var(--safe-top) + 96px);
  left: 50%;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 5px 12px 6px;
  border-radius: 999px;
  background: linear-gradient(180deg, #F04C38, #D82D17);
  border: 2px solid #FFB49F;
  color: #fff;
  font-size: 11.5px;
  font-weight: 900;
  letter-spacing: 0.5px;
  white-space: nowrap;
  box-shadow: 0 5px 14px rgba(180, 40, 10, 0.35);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.danger-tip .mp-icon { width: 16px; height: 16px; }
.danger-tip.show { opacity: 1; transform: translate(-50%, 0); animation: dangerPulse 0.9s ease-in-out infinite; }

.combo-badge {
  position: absolute;
  top: 42%;
  left: 50%;
  z-index: 6;
  transform: translate(-50%, -50%) scale(0.6);
  font-size: 34px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 1px;
  color: #FFE35C;
  text-shadow: 0 3px 0 #BC4C07, 0 6px 14px rgba(140, 52, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}

.combo-badge.show { animation: comboPop 0.8s cubic-bezier(0.2, 0.9, 0.3, 1.2) both; }

.play-tip {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 24px);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(96, 42, 11, 0.46);
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: #FFF8EA;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.play-tip .mp-icon { width: 15px; height: 15px; }
.play-tip.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 结束 ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 20px calc(26px + var(--safe-bottom));
  background: rgba(73, 30, 3, 0.48);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.over-card {
  position: relative;
  width: 100%;
  max-width: 352px;
  padding: 36px 20px 18px;
  border-radius: 30px;
  background: linear-gradient(180deg, #FFFDF5 0%, #FFF2DC 100%);
  border: 3px solid #FFCE8E;
  box-shadow: 0 26px 60px rgba(62, 24, 0, 0.4), inset 0 2px 0 #fff;
  text-align: center;
  animation: cardPop 0.4s cubic-bezier(0.2, 0.9, 0.25, 1.2) both;
}

.over-ribbon {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  padding: 7px 26px;
  border-radius: 999px;
  background: linear-gradient(180deg, #FFA234, #FF6A12);
  border: 3px solid #FFE0B0;
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 3px;
  white-space: nowrap;
  box-shadow: 0 5px 0 #B94A08, 0 9px 18px rgba(150, 52, 2, 0.3);
  text-shadow: 0 2px 0 rgba(150, 52, 0, 0.35);
}

.over-fruit {
  width: 108px;
  height: 108px;
  margin: -2px auto 0;
}

#overCanvas { display: block; width: 108px; height: 108px; }

.over-card h2 {
  margin: 2px 0 3px;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #7A3512;
}

.over-sub {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: #A56A3E;
}

.over-score {
  display: flex;
  align-items: stretch;
  margin: 14px 0 16px;
  padding: 11px 6px;
  border-radius: 18px;
  background: #FFF7E8;
  border: 2px dashed #FFD59A;
}

.over-score-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.over-score-item span {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #A56A3E;
}

.over-score-item strong {
  font-size: 29px;
  line-height: 1.1;
  font-weight: 900;
  color: #7A3512;
  font-variant-numeric: tabular-nums;
}

.over-score-item strong.gold { color: #E28B00; }

.over-line { width: 1px; background: #FFDDB3; margin: 4px 0; }

.over-cta { min-height: 54px; font-size: 20px; letter-spacing: 2px; }

.ghost-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  height: 42px;
  margin-top: 7px;
  border-radius: 999px;
  background: transparent;
  color: #9C5A28;
  font-size: 13px;
  font-weight: 700;
}

.ghost-btn .mp-icon { width: 18px; height: 18px; }
.ghost-btn:active { background: rgba(214, 141, 70, 0.12); }

/* ---------- 玩法面板 ---------- */
.sheet-wrap {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-mask {
  position: absolute;
  inset: 0;
  background: rgba(66, 28, 3, 0.44);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.sheet {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 9px 22px calc(20px + var(--safe-bottom));
  border-radius: 28px 28px 0 0;
  background: linear-gradient(180deg, #FFFDF6 0%, #FFF3E0 100%);
  border-top: 3px solid #FFD9A5;
  box-shadow: 0 -16px 44px rgba(77, 30, 1, 0.24);
  animation: sheetUp 0.32s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}

.sheet-handle {
  width: 42px;
  height: 4px;
  margin: 0 auto 10px;
  border-radius: 999px;
  background: #F0C79D;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sheet-head h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 1px;
  color: #7A3512;
}

.sheet-close { width: 36px; height: 36px; }
.sheet-close .mp-icon { width: 19px; height: 19px; }

.rules {
  margin: 12px 0 6px;
  padding: 0;
  list-style: none;
}

.rules li {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 11px 0;
  border-bottom: 1px dashed #F3D3AA;
}

.rules li:last-child { border-bottom: 0; }

.rules b {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  border-radius: 50%;
  background: linear-gradient(180deg, #FFB43F, #FF8A20);
  border: 2px solid #FFE0A8;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 3px 0 rgba(191, 82, 9, 0.4);
}

.rules strong {
  display: block;
  margin: 1px 0 2px;
  font-size: 13.5px;
  font-weight: 800;
  color: #7A3512;
}

.rules span {
  display: block;
  font-size: 12px;
  line-height: 1.55;
  color: #9B6240;
}

.sheet-cta { min-height: 54px; margin-top: 12px; font-size: 20px; letter-spacing: 2px; }

/* ---------- 动画 ---------- */
@keyframes logoIn {
  from { opacity: 0; transform: translateY(-14px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

@keyframes scoreBump {
  0% { transform: scale(1); }
  45% { transform: scale(1.24); }
  100% { transform: scale(1); }
}

@keyframes dangerPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.16); }
}

@keyframes comboPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.55) rotate(-5deg); }
  22% { opacity: 1; transform: translate(-50%, -50%) scale(1.18) rotate(2deg); }
  42% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0); }
  78% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.94) translateY(-20px); }
}

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

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

@keyframes cloudFloat {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(14px, 8px, 0); }
}

@keyframes bubbleFloat {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); opacity: 0.65; }
  50% { transform: translate3d(-8px, -14px, 0) scale(1.08); opacity: 0.95; }
}

/* ---------- 小屏适配 ---------- */
@media (max-height: 720px) {
  .logo-frame { margin-top: 42px; width: min(84%, 360px); border-radius: 20px; }
  .plaque { padding: 4px 16px 6px; }
  .plaque-text strong { font-size: 21px; }
  .hero { min-height: 166px; }
  .start-bottom { gap: 6px; }
  .cta { min-height: 54px; font-size: 21px; }
  .start-hint { font-size: 11px; }
}

@media (max-height: 620px) {
  .logo-frame { margin-top: 38px; width: min(76%, 320px); }
  .hero { min-height: 136px; }
  .plaque { margin-top: 7px; }
  .start-hint { display: none; }
  .start-bottom { margin-top: 4px; }
}

@media (max-width: 360px) {
  .start-screen { padding-left: 14px; padding-right: 14px; }
  .hud { left: 10px; right: 10px; }
  .hud-right { gap: 4px; }
  .score-card { min-width: 96px; padding-left: 11px; padding-right: 11px; }
  .score-value { font-size: 23px; }
  .next-card { width: 54px; }
  .cta { font-size: 20px; }
}

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