:root {
  --ink: #3a1f0b;
  --cream: #fff6e2;
  --wood-hi: #c97a3c;
  --wood: #a95727;
  --wood-lo: #7b3514;
  --orange: #ff8a3d;
  --orange-hi: #ffb063;
  --orange-lo: #ef6d13;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #09150f;
  color: #2b1a0c;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body {
  background:
    radial-gradient(120% 90% at 50% 0%, #193a2a 0%, #0d1d15 55%, #07100b 100%);
}
button { font-family: inherit; border: 0; background: none; color: inherit; padding: 0; cursor: pointer; }
img { display: block; }

.app, .stage {
  height: 100vh;
  height: 100dvh;
}
.stage {
  position: relative;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  overflow: hidden;
  background: #84c9f2;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  isolation: isolate;
}

/* ---------- 场景 ---------- */
.scene {
  position: absolute;
  inset: 0;
  background-image: url("images/gen/scene-clean.jpg");
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  z-index: 0;
  will-change: transform;
}
.scene-light {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(16, 72, 128, 0.28) 0%, rgba(28, 100, 150, 0.02) 20%, rgba(28, 100, 150, 0) 64%, rgba(16, 52, 12, 0.28) 100%),
    radial-gradient(120% 86% at 50% 42%, rgba(255, 255, 255, 0) 52%, rgba(18, 58, 22, 0.3) 100%),
    radial-gradient(60% 34% at 22% 8%, rgba(255, 244, 205, 0.32) 0%, rgba(255, 244, 205, 0) 70%);
}
.scene-light::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(116deg, rgba(255, 251, 224, 0.16) 0%, rgba(255, 251, 224, 0) 28%),
    linear-gradient(244deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0) 34%);
  mix-blend-mode: screen;
}

.scene.kick { animation: sceneKick 0.18s ease-out; }
@keyframes sceneKick {
  0% { transform: translateY(2px) scale(1.006); }
  45% { transform: translateY(-2px) scale(1.012); }
  100% { transform: translateY(0) scale(1); }
}

/* ---------- 环境光点 / 飞絮 ---------- */
.ambient {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}
.pollen {
  position: absolute;
  top: 0;
  left: 0;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 32%, #fffdf0 0%, #ffe9a1 56%, rgba(255, 214, 110, 0) 100%);
  opacity: 0;
  box-shadow: 0 0 6px rgba(255, 240, 180, 0.7);
  animation-name: pollenDrift;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
@keyframes pollenDrift {
  0% { transform: translate3d(0, 0, 0) scale(0.6); opacity: 0; }
  12% { opacity: 0.75; }
  50% { transform: translate3d(22px, -34vh, 0) scale(1); opacity: 0.6; }
  88% { opacity: 0.35; }
  100% { transform: translate3d(-10px, -74vh, 0) scale(0.55); opacity: 0; }
}

.world {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.targets, .trajectory, .fx { position: absolute; inset: 0; }
.fx { z-index: 6; }

/* ---------- 水果目标 ---------- */
.fruit {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform;
  transform-origin: 50% 50%;
}
.fruit img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 7px 8px rgba(18, 42, 10, 0.28)) drop-shadow(0 1px 2px rgba(18, 42, 10, 0.2));
  pointer-events: none;
  transform: translateZ(0);
}
.fruit .fruit-halo {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 118%;
  height: 118%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid rgba(255, 220, 120, 0.9);
  box-shadow: 0 0 14px rgba(255, 205, 90, 0.65), inset 0 0 10px rgba(255, 235, 160, 0.35);
  opacity: 0;
  transition: opacity 0.12s ease;
}
.fruit.locked .fruit-halo { opacity: 1; }
.fruit.pop { animation: fruitPop 0.2s ease-out forwards; }
@keyframes fruitPop {
  0% { opacity: 1; }
  55% { opacity: 1; filter: brightness(1.2); }
  100% { opacity: 0; }
}
.fruit.spawn { animation: fruitFadeIn 0.22s ease-out both; }
.fruit.spawn img { animation: fruitImgSpawn 0.3s cubic-bezier(0.2, 1.5, 0.5, 1) both; }
@keyframes fruitFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes fruitImgSpawn {
  from { transform: scale(0.3); }
  to { transform: scale(1); }
}

/* ---------- 瞄准 ---------- */
.trajectory { z-index: 3; }
.traj-dot {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #ffffff 0%, #ffffff 55%, #e3f3ff 100%);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.65);
  opacity: 0.82;
}
.aim {
  position: absolute;
  left: 0;
  top: 0;
  width: 72px;
  height: 72px;
  margin: -36px 0 0 -36px;
  z-index: 4;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.aim.show { opacity: 1; }
.aim-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.55), inset 0 0 8px rgba(255, 255, 255, 0.28);
  animation: aimPulse 1.5s ease-in-out infinite;
}
@keyframes aimPulse {
  0%, 100% { transform: scale(1); opacity: 0.92; }
  50% { transform: scale(1.1); opacity: 1; }
}
.aim-tick {
  position: absolute;
  left: 50%;
  top: 50%;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 2px;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.55);
}
.tick-n { width: 2px; height: 12px; margin: -38px 0 0 -1px; }
.tick-s { width: 2px; height: 12px; margin: 26px 0 0 -1px; }
.tick-w { width: 12px; height: 2px; margin: -1px 0 0 -38px; }
.tick-e { width: 12px; height: 2px; margin: -1px 0 0 26px; }
.aim-core {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.9);
}
.aim.locked .aim-ring {
  border-color: #ffe08a;
  box-shadow: 0 0 16px rgba(255, 200, 70, 0.8), inset 0 0 10px rgba(255, 220, 130, 0.5);
}
.aim.locked .aim-tick, .aim.locked .aim-core { background: #ffe08a; }
.aim.locked .aim-core { box-shadow: 0 0 10px rgba(255, 205, 80, 0.95); }

/* ---------- 弹弓皮兜 / 弹丸 ---------- */
.pouch-cover {
  position: absolute;
  left: 0;
  top: 0;
  width: 64px;
  height: 48px;
  margin: -24px 0 0 -32px;
  z-index: 3;
  border-radius: 48% 48% 52% 52% / 42% 42% 58% 58%;
  background:
    radial-gradient(70% 58% at 50% 26%, #d3542d 0%, #b5391c 36%, #8c2410 72%, #5f1508 100%);
  box-shadow:
    inset 0 5px 9px rgba(70, 12, 0, 0.72),
    inset 0 -3px 6px rgba(255, 142, 92, 0.32),
    0 3px 7px rgba(40, 20, 0, 0.28);
  opacity: 0;
  transition: opacity 0.14s ease;
}
.pouch-cover.show { opacity: 1; }
.pouch-rim {
  position: absolute;
  left: 7px;
  right: 7px;
  top: 4px;
  height: 9px;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 192, 145, 0.5), rgba(255, 146, 92, 0));
}

.stone {
  position: absolute;
  left: 0;
  top: 0;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  z-index: 5;
  background:
    radial-gradient(circle at 34% 26%, #f0f0ec 0%, #d2d2ce 20%, #a3a39f 48%, #777774 74%, #4f4f4d 100%);
  box-shadow:
    inset -3px -4px 8px rgba(0, 0, 0, 0.38),
    inset 3px 3px 6px rgba(255, 255, 255, 0.42),
    0 5px 10px rgba(20, 25, 10, 0.3);
  opacity: 0;
  will-change: transform, opacity;
}
.stone.show { opacity: 1; }
.stone-glint {
  position: absolute;
  left: 22%;
  top: 17%;
  width: 26%;
  height: 20%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  transform: rotate(-24deg);
  filter: blur(1px);
}
.stone-trail { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.trail-dot {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 50%;
  background: rgba(255, 250, 235, 0.75);
  box-shadow: 0 0 6px rgba(255, 245, 215, 0.7);
  will-change: transform, opacity;
  animation: trailFade 0.32s ease-out forwards;
}
@keyframes trailFade {
  from { opacity: 0.7; transform: translate3d(var(--tx), var(--ty), 0) scale(1); }
  to { opacity: 0; transform: translate3d(var(--tx), var(--ty), 0) scale(0.3); }
}

/* ---------- 粒子 / 飘字 ---------- */
.juice {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 50%;
  will-change: transform, opacity;
}
.splash-ring {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.9);
  will-change: transform, opacity;
}
.float-score {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  font-size: 27px;
  font-weight: 900;
  color: #fff;
  letter-spacing: 1px;
  text-shadow: 0 2px 0 #e2661a, 0 3px 8px rgba(120, 50, 0, 0.45);
  animation: floatScore 0.75s ease-out forwards;
  pointer-events: none;
  white-space: nowrap;
}
@keyframes floatScore {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.7); }
  22% { opacity: 1; transform: translate(-50%, -70%) scale(1.08); }
  100% { opacity: 0; transform: translate(-50%, -190%) scale(1); }
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  z-index: 20;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 12px;
  right: 12px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.hud-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 16px 0 8px;
  border-radius: 999px;
  color: var(--cream);
  background:
    linear-gradient(180deg, #b96a33 0%, #94491d 45%, #783713 72%, #632a0e 100%);
  border: 2px solid #f6d49b;
  box-shadow:
    inset 0 2px 0 rgba(255, 231, 189, 0.6),
    inset 0 -4px 0 rgba(70, 28, 5, 0.38),
    0 6px 13px rgba(39, 24, 4, 0.34);
  position: relative;
}
.hud-pill::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(72, 27, 4, 0.36), rgba(48, 17, 2, 0.06));
  pointer-events: none;
}
.hud-pill > * { position: relative; z-index: 1; }
.hud-apple-wrap {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, rgba(255, 238, 196, 0.22), rgba(255, 238, 196, 0));
}
.hud-apple {
  width: 33px;
  height: 33px;
  object-fit: contain;
  margin: -2px 0 0 -1px;
  transform: rotate(-8deg);
  filter: drop-shadow(0 3px 3px rgba(45, 18, 0, 0.5));
}
.hud-num {
  font-size: 22px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0.4px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 rgba(72, 29, 4, 0.6), 0 1px 5px rgba(42, 14, 0, 0.3);
}
.score-pill { min-width: 96px; justify-content: flex-start; justify-self: start; }
.timer-pill { gap: 8px; padding: 0 15px 0 11px; justify-self: center; }
.hud-timer-icon { width: 26px; height: 26px; color: #ffe7bd; filter: drop-shadow(0 2px 1px rgba(70, 28, 4, 0.5)); }
.score-pill.bump .hud-num { animation: numBump 0.26s ease-out; }
.score-pill.bump .hud-apple-wrap { animation: numBump 0.3s ease-out; }
@keyframes numBump {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); color: #ffe58f; }
  100% { transform: scale(1); }
}
.timer-pill.urgent { animation: urgentPulse 0.9s ease-in-out infinite; }
.timer-pill.urgent .hud-num { color: #ffd5b0; }
@keyframes urgentPulse {
  0%, 100% { box-shadow: inset 0 2px 0 rgba(255, 225, 178, 0.55), inset 0 -4px 0 rgba(70, 28, 5, 0.38), 0 6px 12px rgba(39, 24, 4, 0.32); }
  50% { box-shadow: inset 0 2px 0 rgba(255, 225, 178, 0.55), inset 0 -4px 0 rgba(70, 28, 5, 0.38), 0 0 0 4px rgba(255, 123, 40, 0.45), 0 6px 14px rgba(120, 44, 0, 0.4); }
}
.icon-btn {
  pointer-events: auto;
  justify-self: end;
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff6e6;
  background: linear-gradient(180deg, #b96a33, #8a4219 58%, #6b2f0f);
  border: 2px solid #f6d49b;
  box-shadow: inset 0 2px 0 rgba(255, 225, 178, 0.5), inset 0 -3px 0 rgba(70, 28, 5, 0.4), 0 6px 12px rgba(39, 24, 4, 0.32);
  transition: transform 0.09s ease, filter 0.09s ease;
}
.icon-btn .mp-icon { width: 24px; height: 24px; filter: drop-shadow(0 2px 1px rgba(70, 28, 4, 0.45)); }
.icon-btn:active { transform: scale(0.9); filter: brightness(1.08); }

/* ---------- 引导 ---------- */
.hint {
  position: absolute;
  z-index: 15;
  left: 50%;
  top: 61.5%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 17px 10px 13px;
  border-radius: 999px;
  color: #fff9ec;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
  background: rgba(24, 55, 24, 0.58);
  border: 1px solid rgba(255, 244, 214, 0.5);
  box-shadow: 0 6px 16px rgba(10, 32, 8, 0.25);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  animation: hintFloat 2.2s ease-in-out infinite;
}
.hint .mp-icon { width: 21px; height: 21px; color: #ffe9a8; }
.hint.gone { opacity: 0; transform: translateX(-50%) translateY(8px); }
@keyframes hintFloat {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-5px); }
}

/* ---------- 弹层 ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(7, 24, 16, 0.5);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
  animation: overlayIn 0.22s ease-out;
}
.overlay.hidden { display: none; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.panel {
  width: min(86vw, 336px);
  border-radius: 26px;
  overflow: hidden;
  background: #fdf3dd;
  border: 3px solid #6e3814;
  box-shadow:
    0 0 0 2px rgba(255, 226, 178, 0.45) inset,
    0 22px 40px rgba(8, 20, 8, 0.45),
    0 4px 0 #4e250b;
  animation: panelIn 0.32s cubic-bezier(0.2, 1.35, 0.45, 1);
}
@keyframes panelIn {
  from { opacity: 0; transform: translateY(18px) scale(0.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.panel-wood {
  position: relative;
  padding: 17px 16px 16px;
  text-align: center;
  color: #fff4e0;
  font-size: 23px;
  font-weight: 900;
  letter-spacing: 3px;
  background:
    linear-gradient(180deg, #b96a33 0%, #94491d 50%, #783713 100%);
  border-bottom: 3px solid #5c2a0e;
  text-shadow: 0 2px 0 rgba(64, 26, 4, 0.65);
  box-shadow: inset 0 2px 0 rgba(255, 226, 180, 0.45);
}
.panel-wood::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 3px;
  height: 4px;
  background: linear-gradient(90deg, rgba(255, 232, 190, 0), rgba(255, 232, 190, 0.35), rgba(255, 232, 190, 0));
}
.panel-body { padding: 20px 22px 24px; }

.pause-fruits, .result-fruits {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
  margin: 2px 0 14px;
}
.pause-fruits img {
  width: 46px;
  height: 46px;
  object-fit: contain;
  filter: drop-shadow(0 4px 4px rgba(90, 45, 5, 0.22));
}
.pause-fruits img:first-child { transform: rotate(-8deg); }
.pause-fruits img:last-child { transform: rotate(7deg); }
.panel-note {
  margin: 0 0 20px;
  text-align: center;
  font-size: 14px;
  color: #8b5c2f;
  font-weight: 600;
}
.result-fruits { height: 74px; margin-top: 0; margin-bottom: 6px; position: relative; animation: fruitBounce 2.4s ease-in-out infinite; }
.rf {
  object-fit: contain;
  filter: drop-shadow(0 5px 5px rgba(90, 45, 5, 0.22));
}
.rf-a { width: 62px; height: 62px; transform: rotate(-10deg); }
.rf-b { width: 72px; height: 72px; margin-bottom: 6px; }
.rf-c { width: 58px; height: 58px; transform: rotate(8deg); }
@keyframes fruitBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.result-label {
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #96683a;
}
.result-score {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  margin: 0 0 10px;
  line-height: 1;
}
.result-score span {
  font-size: 68px;
  font-weight: 900;
  color: #f07818;
  letter-spacing: -2px;
  text-shadow: 0 3px 0 #ffe6ba, 0 6px 10px rgba(198, 98, 10, 0.22);
  font-variant-numeric: tabular-nums;
}
.result-score em {
  font-style: normal;
  font-size: 15px;
  font-weight: 700;
  color: #8b5c2f;
}
.best-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0 auto 18px;
  padding: 8px 12px;
  width: fit-content;
  border-radius: 999px;
  background: #f5e5c5;
  border: 1px solid #e3c99b;
  color: #7a4a1c;
  font-size: 13px;
  font-weight: 600;
}
.best-row .mp-icon { width: 18px; height: 18px; color: #f2a11c; }
.best-row strong { color: #d96b10; font-size: 15px; }
.best-row.is-new { animation: bestGlow 1.2s ease-in-out infinite; }
@keyframes bestGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(242, 161, 28, 0); }
  50% { box-shadow: 0 0 0 5px rgba(242, 161, 28, 0.18); }
}
.btn {
  width: 100%;
  height: 54px;
  border-radius: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #fff;
  background: linear-gradient(180deg, #ffa95c 0%, #fb8b2f 45%, #f07616 100%);
  border: 2px solid #d15e0e;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.45),
    0 5px 0 #a94908,
    0 10px 18px rgba(155, 70, 0, 0.28);
  text-shadow: 0 2px 0 rgba(160, 62, 0, 0.5);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.btn .mp-icon { width: 23px; height: 23px; }
.btn:active {
  transform: translateY(4px);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35), 0 1px 0 #a94908, 0 3px 8px rgba(155, 70, 0, 0.24);
}

@media (max-width: 370px) {
  .hud { left: 9px; right: 9px; gap: 6px; }
  .hud-pill { height: 42px; }
  .hud-num { font-size: 19px; }
  .hud-apple { width: 28px; height: 28px; }
  .score-pill { min-width: 80px; padding-right: 12px; }
  .timer-pill { padding: 0 11px 0 9px; }
  .icon-btn { width: 42px; height: 42px; }
  .hint { font-size: 13px; padding: 9px 14px 9px 11px; }
}
@media (max-height: 680px) {
  .hint { top: 59%; font-size: 13px; }
  .panel-body { padding: 16px 18px 18px; }
  .result-fruits { height: 60px; margin-bottom: 2px; }
  .rf-a { width: 50px; height: 50px; }
  .rf-b { width: 58px; height: 58px; }
  .rf-c { width: 46px; height: 46px; }
  .result-score span { font-size: 56px; }
  .best-row { margin-bottom: 13px; }
  .btn { height: 50px; }
}
@media (min-width: 620px) {
  .stage { border-radius: 26px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5); }
}
