/* 水果下落 · 暖色黄昏果园视觉 */
:root {
  --cream: #fff8ea;
  --cream-deep: #fff1d6;
  --ink: #4a2a17;
  --ink-soft: #7b4a2a;
  --ink-faint: #9b7151;
  --orange: #f26b3a;
  --orange-deep: #d74324;
  --gold: #ffb03a;
  --leaf: #6f9a50;
  --shadow-warm: rgba(112, 62, 24, 0.16);
  --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;
  overflow: hidden;
  background: #ffe7bc;
}

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei",
    -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  overscroll-behavior: none;
}

.app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  background: #ffe7bc;
}

#game {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ---------------------------------------------------------------- HUD */

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  padding: calc(var(--safe-top) + 12px) 16px 0;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.hud.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.hud-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 9px;
}

.hud-chip {
  min-width: 74px;
  padding: 7px 13px 8px;
  text-align: center;
  border-radius: 18px;
  background: rgba(255, 252, 244, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.86);
  box-shadow: 0 7px 20px rgba(112, 62, 24, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  backdrop-filter: blur(14px) saturate(1.15);
}

.hud-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: rgba(74, 42, 23, 0.52);
  line-height: 1;
  white-space: nowrap;
}

.hud-label .mp-icon {
  width: 11px;
  height: 11px;
  color: #d99a2b;
}

.hud-value {
  display: block;
  margin-top: 4px;
  font-size: 23px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  transform-origin: center bottom;
}

.hud-value.is-pulsing {
  animation: score-pop 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}

.timer-chip {
  display: flex;
  align-items: baseline;
  justify-content: center;
  min-width: 96px;
  padding: 10px 14px 9px;
  border-radius: 20px;
  color: #fff3d9;
  background: linear-gradient(155deg, #5f3921 0%, #452714 55%, #351d0f 100%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 10px 24px rgba(66, 31, 12, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.timer-chip .mp-icon {
  width: 17px;
  height: 17px;
  margin-right: 5px;
  color: #ffbe6b;
  align-self: center;
  transition: color 0.3s ease;
}

.timer-num {
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.timer-unit {
  margin-left: 2px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  opacity: 0.62;
}

.timer-chip.is-low {
  background: linear-gradient(155deg, #d5553b 0%, #b52f23 55%, #8e1f18 100%);
  box-shadow: 0 10px 24px rgba(157, 37, 24, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  animation: timer-pulse 1s ease-in-out infinite;
}

.timer-chip.is-low .mp-icon {
  color: #ffe0a3;
}

.time-track {
  position: relative;
  height: 5px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 252, 244, 0.5);
  box-shadow: inset 0 1px 2px rgba(107, 59, 24, 0.14);
}

.time-fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #7fae57 0%, #f3b33c 68%, #f06a3c 100%);
  transition: width 0.2s linear, background 0.3s ease;
}

.time-fill.is-low {
  background: linear-gradient(90deg, #f08a4b 0%, #e8493f 100%);
}

/* ------------------------------------------------------------ countdown */

.countdown {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.countdown.is-showing {
  opacity: 1;
}

.countdown span {
  display: block;
  font-size: clamp(88px, 27vw, 126px);
  font-weight: 900;
  line-height: 1;
  color: #fff8e8;
  letter-spacing: -0.04em;
  text-shadow: 0 8px 0 rgba(108, 55, 26, 0.16), 0 22px 50px rgba(88, 40, 16, 0.36);
  transform: scale(0.6);
}

.countdown.is-popping span {
  animation: count-pop 0.66s cubic-bezier(0.16, 0.86, 0.3, 1.12) both;
}

/* ----------------------------------------------------------------- tip */

.tip {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 176px);
  z-index: 18;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px 8px 10px;
  border-radius: 999px;
  color: #fff4dc;
  background: rgba(64, 35, 18, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 20px rgba(58, 26, 8, 0.24);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-50%) translateY(8px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.tip.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.tip-hand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #ffca7d;
  background: rgba(255, 255, 255, 0.12);
}

.tip-hand .mp-icon {
  width: 14px;
  height: 14px;
}

/* -------------------------------------------------------------- screens */

.screen {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  transition: opacity 0.38s ease, transform 0.38s ease, visibility 0.38s;
}

.screen.is-hidden {
  visibility: hidden;
  pointer-events: none;
  opacity: 0;
}

.start-screen {
  justify-content: space-between;
  padding: calc(var(--safe-top) + 54px) 24px calc(var(--safe-bottom) + 22px);
  text-align: center;
  background: linear-gradient(
    180deg,
    rgba(255, 245, 221, 0.16) 0%,
    rgba(255, 245, 221, 0) 28%,
    rgba(255, 243, 218, 0) 55%,
    rgba(255, 243, 218, 0.68) 76%,
    rgba(255, 246, 227, 0.94) 100%
  );
}

.start-screen.is-hidden {
  transform: translateY(10px);
}

.start-top {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(255, 252, 243, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.78);
  box-shadow: 0 4px 14px rgba(120, 65, 25, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  color: #8a5a33;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.2em;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.eyebrow-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 0 3px rgba(242, 107, 58, 0.16);
  animation: dot-breathe 2.2s ease-in-out infinite;
}

.hero-title {
  margin: 18px 0 0;
  font-size: clamp(58px, 16.5vw, 78px);
  font-weight: 900;
  line-height: 0.97;
  letter-spacing: 0.015em;
  color: var(--ink);
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.35);
}

.title-line {
  display: block;
}

.title-line.accent {
  position: relative;
  z-index: 0;
  display: inline-block;
  color: #f0562f;
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.6), 0 10px 26px rgba(240, 86, 47, 0.2);
}

.title-line.accent::after {
  content: "";
  position: absolute;
  left: 2%;
  right: 1%;
  bottom: 4px;
  z-index: -1;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(
    90deg,
    rgba(255, 171, 64, 0) 0%,
    rgba(255, 176, 58, 0.55) 18%,
    rgba(240, 86, 47, 0.45) 82%,
    rgba(240, 86, 47, 0) 100%
  );
  transform: rotate(-1.2deg);
}

.hero-sub {
  margin: 15px auto 0;
  max-width: 280px;
  color: rgba(74, 42, 23, 0.67);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.85;
  letter-spacing: 0.05em;
}

.start-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
}

.rule-row {
  display: flex;
  justify-content: center;
  gap: 7px;
  width: 100%;
  margin-bottom: 17px;
}

.rule-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 10px;
  border-radius: 12px;
  background: rgba(255, 252, 244, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.82);
  box-shadow: 0 3px 10px rgba(120, 65, 25, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  color: #7b4a2a;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.rule-pill .mp-icon {
  width: 14px;
  height: 14px;
  color: #ef7a32;
}

.btn-primary {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 58px;
  padding: 0 22px;
  overflow: hidden;
  border: 0;
  border-radius: 20px;
  color: #fff9ee;
  background: linear-gradient(135deg, #ff9e42 0%, #ff7a34 38%, #ee4f2c 100%);
  box-shadow: 0 12px 26px rgba(217, 66, 34, 0.32), 0 3px 0 #c43e22,
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  font-family: inherit;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}

.btn-primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0) 46%);
  pointer-events: none;
}

.btn-primary:active {
  transform: translateY(3px) scale(0.985);
  box-shadow: 0 5px 12px rgba(217, 66, 34, 0.28), 0 1px 0 #c43e22,
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

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

.btn-primary .mp-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}

.best-line {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 14px;
  color: #8f6647;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.best-line .mp-icon {
  width: 14px;
  height: 14px;
  color: #d99a2b;
}

.best-line strong {
  color: #5a321c;
  font-size: 15px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.start-hint {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 10px 0 0;
  color: rgba(143, 102, 71, 0.82);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.03em;
}

.start-hint .mp-icon {
  width: 12px;
  height: 12px;
}

/* -------------------------------------------------------------- results */

.end-screen {
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-top) + 20px) 22px calc(var(--safe-bottom) + 20px);
  background: rgba(56, 28, 14, 0.34);
  -webkit-backdrop-filter: blur(9px) saturate(0.9);
  backdrop-filter: blur(9px) saturate(0.9);
}

.result-card {
  width: min(86vw, 352px);
  padding: 25px 22px 22px;
  border-radius: 30px;
  background: linear-gradient(180deg, #fffdf6 0%, #fff4df 100%);
  border: 1px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 26px 64px rgba(58, 26, 8, 0.34), inset 0 1px 0 #ffffff;
  text-align: center;
  animation: card-in 0.5s cubic-bezier(0.2, 0.9, 0.25, 1.18) both;
}

.result-label {
  color: #b07a4d;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.28em;
}

.result-title {
  margin: 5px 0 0;
  color: var(--ink);
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.score-big {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 3px;
  margin-top: 8px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.score-big span {
  font-size: 68px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.045em;
}

.score-big small {
  color: #9a6b4a;
  font-size: 15px;
  font-weight: 700;
}

.new-record {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  padding: 5px 11px;
  border-radius: 999px;
  color: #8a5312;
  background: linear-gradient(180deg, #ffe6a4 0%, #ffd06a 100%);
  border: 1px solid rgba(255, 255, 255, 0.76);
  box-shadow: 0 4px 10px rgba(211, 143, 28, 0.22);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  animation: badge-in 0.45s 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}

.new-record .mp-icon {
  width: 12px;
  height: 12px;
}

.new-record.is-hidden {
  display: none;
}

.result-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 18px 0 19px;
  padding: 12px 4px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(232, 207, 171, 0.66);
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.meta-item + .meta-item {
  border-left: 1px solid rgba(196, 158, 112, 0.26);
}

.meta-item span {
  color: #a47a58;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.meta-item strong {
  color: var(--ink);
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------ animation */

@keyframes score-pop {
  0% { transform: scale(1); }
  38% { transform: scale(1.32); color: #e8493f; }
  100% { transform: scale(1); }
}

@keyframes timer-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.045); }
}

@keyframes count-pop {
  0% { transform: scale(0.45); opacity: 0; }
  22% { transform: scale(1.08); opacity: 1; }
  55% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.28); opacity: 0; }
}

@keyframes dot-breathe {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 3px rgba(242, 107, 58, 0.16); }
  50% { transform: scale(1.18); box-shadow: 0 0 0 5px rgba(242, 107, 58, 0.1); }
}

@keyframes card-in {
  0% { transform: translateY(18px) scale(0.9); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes badge-in {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* -------------------------------------------------------------- responsive */

@media (max-height: 720px) {
  .start-screen {
    padding-top: calc(var(--safe-top) + 34px);
  }
  .hero-title {
    margin-top: 13px;
    font-size: clamp(48px, 14.5vw, 64px);
  }
  .hero-sub {
    margin-top: 10px;
    font-size: 12.5px;
    line-height: 1.7;
  }
  .rule-row {
    margin-bottom: 12px;
  }
  .btn-primary {
    height: 54px;
    font-size: 17px;
  }
  .best-line {
    margin-top: 10px;
  }
  .start-hint {
    display: none;
  }
}

@media (max-height: 600px) {
  .start-screen {
    padding-top: calc(var(--safe-top) + 22px);
  }
  .eyebrow {
    padding: 5px 11px;
  }
  .hero-title {
    font-size: clamp(42px, 13vw, 54px);
  }
  .hero-sub {
    display: none;
  }
  .rule-row {
    margin-bottom: 10px;
  }
  .rule-pill {
    padding: 6px 8px;
    font-size: 9.5px;
  }
  .result-card {
    padding: 20px 18px 18px;
  }
  .score-big span {
    font-size: 56px;
  }
  .result-meta {
    margin: 13px 0 14px;
  }
}

@media (min-width: 520px) {
  .start-bottom {
    max-width: 340px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
  .screen,
  .hud,
  .tip,
  .countdown {
    transition-duration: 0.001ms !important;
  }
}
