:root {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #542812;
  background: #179fdf;
  font-synthesis: none;
}

* { box-sizing: border-box; }

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

body {
  display: grid;
  place-items: center;
  background: #159fe1;
  user-select: none;
  -webkit-user-select: none;
}

button { font: inherit; -webkit-tap-highlight-color: transparent; }

.page-art {
  position: fixed;
  inset: -30px;
  background:
    linear-gradient(rgba(31, 153, 210, .12), rgba(67, 133, 32, .2)),
    url("assets/start-reference-v2.png") center / cover no-repeat;
  filter: blur(18px) saturate(.9);
  transform: scale(1.06);
}

.game-shell {
  --run-progress: 0;
  position: relative;
  width: min(100vw, calc(100dvh * .5625));
  height: min(100dvh, calc(100vw * 1.7777778));
  max-width: 720px;
  max-height: 1280px;
  overflow: hidden;
  isolation: isolate;
  touch-action: none;
  background: #42b8eb;
  box-shadow: 0 25px 90px rgba(23, 83, 43, .34);
  transition: width .42s cubic-bezier(.2,.8,.2,1), height .42s cubic-bezier(.2,.8,.2,1);
}

.scene-bg {
  position: absolute;
  inset: -1.5%;
  background: url("assets/orchard-v2.png") center / cover no-repeat;
  transform: scale(1.018);
  transform-origin: 50% 48%;
  will-change: transform;
}

.sun-glow {
  position: absolute;
  z-index: 1;
  left: 20%;
  top: -10%;
  width: 62%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.58), transparent 68%);
  mix-blend-mode: screen;
  pointer-events: none;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hud {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  color: #fff;
  font-weight: 950;
  text-shadow: 0 3px 9px rgba(37, 78, 50, .25);
}

.score-pill {
  position: absolute;
  top: max(3.2%, env(safe-area-inset-top));
  left: 4.5%;
  display: flex;
  align-items: baseline;
  gap: .35em;
  padding: 1.35% 3.2%;
  border: 2px solid rgba(255,255,255,.84);
  border-radius: 999px;
  color: #2e2019;
  background: rgba(255,255,255,.92);
  box-shadow: 0 10px 24px rgba(38, 88, 46, .14), inset 0 2px 0 #fff;
  text-shadow: none;
  backdrop-filter: blur(12px);
}

.score-pill span { font-size: clamp(14px, 3.7vw, 26px); }
.score-pill b { font-size: clamp(19px, 5vw, 36px); line-height: 1; }

.distance-pill {
  position: absolute;
  top: max(3.9%, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: clamp(18px, 5vw, 36px);
  letter-spacing: -.04em;
}

.distance-pill b { font-size: 1.25em; }
.distance-pill span { margin-left: .08em; font-size: .7em; }

.target-card {
  position: absolute;
  top: max(2.2%, env(safe-area-inset-top));
  right: 3.5%;
  display: grid;
  justify-items: center;
  width: 22%;
}

.target-bubble {
  width: 62%;
  aspect-ratio: 1;
  border: 2px solid rgba(255,255,255,.7);
  border-radius: 50%;
  background-color: rgba(255,255,255,.24);
  box-shadow: inset 0 0 0 5px rgba(255,255,255,.13), 0 8px 18px rgba(34,75,42,.14);
  transition: transform .24s cubic-bezier(.2,1.8,.4,1);
}

.target-bubble.pop { transform: scale(1.2) rotate(8deg); }
.target-card small { margin-top: 3%; font-size: clamp(10px, 2.8vw, 20px); white-space: nowrap; }

.fruit-ui {
  display: inline-block;
  width: 1.55em;
  aspect-ratio: 1;
  background-image: url("assets/fruit-sprites-v2.png");
  background-repeat: no-repeat;
  background-size: 300% 200%;
  vertical-align: middle;
}

.fruit-ui.strawberry { background-position: 0 0; }
.fruit-ui.orange { background-position: 50% 0; }
.fruit-ui.watermelon { background-position: 100% 0; }
.fruit-ui.grape { background-position: 0 100%; }

.fruit-legend {
  position: absolute;
  z-index: 12;
  left: 4.5%;
  right: 4.5%;
  bottom: max(2.5%, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2.2%;
  pointer-events: none;
}

.legend-pill {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3%;
  padding: 3% 2%;
  border: 2px solid rgba(255,255,255,.82);
  border-radius: 999px;
  background: rgba(255,255,246,.93);
  box-shadow: 0 9px 20px rgba(51,83,35,.16), inset 0 2px 0 #fff;
  white-space: nowrap;
}

.legend-pill span { font-size: clamp(22px, 6vw, 43px); flex: 0 0 auto; }
.legend-pill b { min-width: 0; font-size: clamp(10px, 2.9vw, 20px); }

.jump-button {
  position: absolute;
  z-index: 15;
  right: 5%;
  bottom: 14.8%;
  display: grid;
  place-items: center;
  width: 19%;
  aspect-ratio: 1;
  padding: 0;
  border: 2px solid rgba(255,255,255,.76);
  border-radius: 50%;
  color: #672818;
  background:
    radial-gradient(circle at 34% 23%, rgba(255,255,255,.98) 0 5%, transparent 6%),
    linear-gradient(145deg, #fff1bf, #ffc671 57%, #ed8e39);
  box-shadow: inset 0 0 0 7px rgba(255,255,255,.2), inset -9px -11px 18px rgba(189,82,26,.14), 0 13px 0 #c76524, 0 21px 30px rgba(76,63,29,.26);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}

.jump-button:active,
.jump-button.is-jumping { transform: translateY(8px) scale(.95); box-shadow: inset 0 0 0 7px rgba(255,255,255,.2), 0 5px 0 #c76524, 0 10px 18px rgba(76,63,29,.2); }
.jump-button b { align-self: end; font-size: clamp(18px, 5vw, 36px); line-height: 1; }
.jump-button small { align-self: start; margin-top: 6%; font-size: clamp(6px, 1.5vw, 11px); opacity: .5; }
.jump-shine { position: absolute; inset: 9%; border-radius: 50%; border-top: 2px solid rgba(255,255,255,.78); transform: rotate(-25deg); }

.toast {
  position: absolute;
  z-index: 20;
  left: 50%;
  top: 22%;
  transform: translate(-50%, 12px) scale(.86);
  color: #fff;
  font-size: clamp(27px, 7vw, 52px);
  font-weight: 1000;
  text-shadow: 0 4px 0 rgba(141,70,28,.24), 0 8px 20px rgba(36,66,34,.24);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .35s cubic-bezier(.16,1.4,.34,1);
}

.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.combo-badge {
  position: absolute;
  z-index: 20;
  top: 14.5%;
  left: 50%;
  transform: translate(-50%, -8px) scale(.9);
  padding: .75% 3%;
  border: 2px solid rgba(255,255,255,.7);
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #ff6852, #ffa328);
  box-shadow: 0 7px 18px rgba(132,70,30,.22);
  font-size: clamp(11px, 3vw, 21px);
  font-weight: 950;
  opacity: 0;
  transition: .22s ease;
}

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

.fever-meter {
  position: absolute;
  z-index: 18;
  top: 10.4%;
  left: 50%;
  display: grid;
  grid-template-columns: auto minmax(76px, 22vw) auto;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid rgba(255,255,255,.72);
  border-radius: 999px;
  color: #77330e;
  background: rgba(255,249,221,.86);
  box-shadow: 0 7px 18px rgba(67,78,31,.15), inset 0 1px 0 #fff;
  font-size: clamp(8px, 2.2vw, 15px);
  font-weight: 950;
  transform: translateX(-50%);
  backdrop-filter: blur(8px);
  transition: color .25s ease, background .25s ease, box-shadow .25s ease;
  pointer-events: none;
}

.fever-meter i {
  position: relative;
  display: block;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(119,69,24,.14);
  box-shadow: inset 0 1px 2px rgba(72,41,14,.18);
}

.fever-meter i b {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffb52e, #ff6c43, #da59cf);
  transition: width .18s linear;
}

.fever-meter em { min-width: 2.5em; font-style: normal; text-align: right; }

.game-shell.fever .fever-meter {
  color: #fff;
  background: linear-gradient(100deg, rgba(255,116,53,.94), rgba(211,76,190,.92));
  box-shadow: 0 0 0 3px rgba(255,255,255,.42), 0 8px 24px rgba(203,66,96,.35);
}

.game-shell.fever::after {
  content: "";
  position: absolute;
  z-index: 9;
  inset: 0;
  border: 5px solid rgba(255,217,83,.45);
  box-shadow: inset 0 0 45px rgba(255,108,79,.16);
  pointer-events: none;
  animation: fever-glow .7s ease-in-out infinite alternate;
}

.countdown {
  position: absolute;
  z-index: 30;
  left: 50%;
  top: 39%;
  transform: translate(-50%, -50%);
  color: #fff9d8;
  font-size: clamp(72px, 22vw, 160px);
  font-weight: 1000;
  -webkit-text-stroke: 4px #cf6d16;
  text-shadow: 0 8px 0 #8e410d, 0 18px 35px rgba(44,76,43,.25);
  pointer-events: none;
}

.start-panel,
.result-panel {
  position: absolute;
  inset: 0;
  z-index: 40;
  overflow: hidden;
  transition: opacity .35s ease, visibility .35s ease;
}

.start-panel.hidden,
.result-panel.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.start-panel {
  background: #2aace7;
}

.start-mobile-art {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(17,153,224,.08) 0 48%, rgba(47,110,21,.1)),
    url("assets/orchard-v2.png") center / cover no-repeat;
}

.start-mascot {
  position: absolute;
  z-index: 2;
  right: -3%;
  bottom: 13.5%;
  width: 69%;
  filter: drop-shadow(0 24px 12px rgba(75,60,24,.25));
  transform: rotate(-5deg);
  pointer-events: none;
  animation: mascot-float 2.2s ease-in-out infinite;
}

.start-brand {
  position: absolute;
  z-index: 3;
  top: max(6.2%, env(safe-area-inset-top));
  left: 6%;
  right: 5%;
}

.start-kicker,
.result-kicker {
  display: inline-block;
  padding: 1.8% 4.5%;
  border: 2px solid rgba(255,255,255,.9);
  border-radius: 999px;
  color: #a84010;
  background: rgba(255,252,235,.93);
  box-shadow: 0 8px 20px rgba(72,70,29,.14);
  font-size: clamp(11px, 3vw, 21px);
  font-weight: 950;
}

.start-brand h1 {
  margin: 2.5% 0 0;
  color: #fff8d4;
  font-size: clamp(58px, 17vw, 118px);
  line-height: .95;
  letter-spacing: -.08em;
  -webkit-text-stroke: clamp(3px, .8vw, 6px) #a9510a;
  paint-order: stroke fill;
  text-shadow: 0 .06em 0 #f2a82e, 0 .12em 0 #a54b08, 0 .17em .18em rgba(95,55,17,.28);
}

.start-brand h1 span { margin-right: .06em; }
.start-brand p {
  display: inline-block;
  margin: 7% 0 0;
  padding: 2.1% 4%;
  border-radius: 999px;
  color: #84370f;
  background: rgba(255,252,238,.9);
  box-shadow: 0 8px 20px rgba(68,75,30,.14);
  font-size: clamp(11px, 3vw, 21px);
  font-weight: 900;
}

.start-button {
  position: absolute;
  z-index: 5;
  left: 8%;
  bottom: max(7.3%, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5em;
  width: 55%;
  padding: 3.5% 5%;
  border: 3px solid rgba(255,255,255,.82);
  border-radius: 999px;
  color: #fffbe7;
  background: linear-gradient(180deg, #ff9d2e, #ef6b15);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.5), 0 8px 0 #9f3f0d, 0 18px 30px rgba(102,54,18,.32);
  font-size: clamp(21px, 5.6vw, 40px);
  font-weight: 1000;
  cursor: pointer;
}

.start-button i { font-style: normal; transition: transform .2s ease; }
.start-button:hover i { transform: translateX(5px); }
.start-button:active { transform: translateY(6px); box-shadow: inset 0 2px 0 rgba(255,255,255,.5), 0 2px 0 #9f3f0d, 0 8px 18px rgba(102,54,18,.24); }
.start-tip { position: absolute; z-index: 4; bottom: max(2.5%, env(safe-area-inset-bottom)); left: 6%; right: 6%; color: rgba(76,48,25,.64); text-align: center; font-size: clamp(8px, 2.1vw, 15px); font-weight: 800; }

.result-panel {
  display: grid;
  place-items: center;
  padding: 7%;
  background: linear-gradient(rgba(55,161,205,.22), rgba(49,102,26,.32));
  backdrop-filter: blur(5px);
}

.result-card {
  width: 100%;
  padding: 8% 7% 7%;
  border: 3px solid rgba(255,255,255,.88);
  border-radius: clamp(28px, 8vw, 58px);
  text-align: center;
  background: rgba(255,252,230,.94);
  box-shadow: inset 0 2px 0 #fff, 0 26px 70px rgba(45,76,35,.28);
}

.result-card h2 { margin: 3% 0 1%; color: #7b310d; font-size: clamp(40px, 12vw, 86px); line-height: 1; }
.final-score { margin: 4% 0; }
.final-score small { display: block; color: #956647; font-weight: 850; }
.final-score b { display: block; color: #f06e18; font-size: clamp(58px, 17vw, 122px); line-height: 1; }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3%; }
.result-grid div { display: grid; justify-items: center; padding: 8% 2%; border-radius: 22px; background: rgba(255,231,169,.68); }
.result-grid span { font-size: clamp(29px, 8vw, 58px); }
.result-grid b { color: #713017; font-size: clamp(19px, 5vw, 36px); }
.result-grid small { color: #96644c; font-size: clamp(9px, 2.4vw, 17px); }
.result-card p { margin: 5% 0; font-size: clamp(13px, 3.5vw, 25px); }
.result-card button { width: 72%; padding: 4% 7%; border: 0; border-radius: 999px; color: #fff; background: linear-gradient(#ff9d2e,#ef6b15); box-shadow: 0 7px 0 #a84710; font-size: clamp(20px, 5vw, 36px); font-weight: 1000; cursor: pointer; }

.game-shell[data-state="running"] .start-panel { opacity: 0; visibility: hidden; pointer-events: none; }
.game-shell[data-state="finished"] .jump-button { opacity: 0; pointer-events: none; }
.game-shell[data-state="finished"] .fruit-legend { opacity: .25; }

@keyframes mascot-float {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50% { transform: translateY(-12px) rotate(-3deg); }
}

@keyframes fever-glow {
  from { opacity: .48; }
  to { opacity: 1; }
}

@media (orientation: landscape) and (min-width: 800px) and (min-height: 500px) {
  .game-shell[data-state="ready"] {
    width: min(100vw, calc(100dvh * 1.9043));
    height: min(100dvh, calc(100vw * .5251));
    max-width: 1731px;
    max-height: 909px;
  }

  .game-shell[data-state="ready"] .start-panel {
    background: url("assets/start-reference-v2.png") center / cover no-repeat;
  }

  .game-shell[data-state="ready"] .start-mobile-art,
  .game-shell[data-state="ready"] .start-mascot,
  .game-shell[data-state="ready"] .start-brand,
  .game-shell[data-state="ready"] .start-tip { display: none; }

  .game-shell[data-state="ready"] .start-button {
    left: 50%;
    bottom: 5.5%;
    width: auto;
    min-width: 230px;
    padding: 1.15% 3.3%;
    transform: translateX(-50%);
    font-size: clamp(22px, 2vw, 36px);
    box-shadow: inset 0 2px 0 rgba(255,255,255,.5), 0 7px 0 #9f3f0d, 0 16px 28px rgba(102,54,18,.3);
  }

  .game-shell[data-state="ready"] .start-button:active { transform: translate(-50%, 6px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  .scene-bg { transform: scale(1.018); }
}
