/* ============================================================
   指尖粘粘乐 · 果园粘粘猫
   主色 #FF8A3D / 奶油卡片 / 卡通农场景
   ============================================================ */

:root {
  --orange: #FF8A3D;
  --orange-deep: #E8641C;
  --orange-light: #FFB067;
  --cream: #FFF8EC;
  --cream-deep: #FFF1DC;
  --ink: #3E2719;
  --ink-soft: #8A6A57;
  --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;
  background: #7ec8f0;
}

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

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

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

/* ---------------- 游戏中 HUD ---------------- */

.hud {
  position: absolute;
  top: calc(var(--safe-top) + 10px);
  left: 16px;
  right: 16px;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

body.playing .hud {
  opacity: 1;
  transform: translateY(0);
}

.hud-left,
.hud-right {
  flex: 0 0 auto;
  padding-top: 6px;
}

.hearts {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255, 252, 245, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 4px 14px rgba(36, 76, 50, 0.16);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.heart {
  width: 21px;
  height: 21px;
  color: #ff5a46;
  filter: drop-shadow(0 1px 0 rgba(180, 50, 30, 0.18));
  transition: color 0.2s ease, transform 0.2s ease;
}

.heart.off {
  color: rgba(120, 92, 78, 0.24);
  filter: none;
}

.heart.pop {
  animation: heartPop 0.42s ease;
}

@keyframes heartPop {
  0% { transform: scale(1); }
  35% { transform: scale(1.45) rotate(-10deg); }
  100% { transform: scale(1); }
}

.hud-center {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  text-align: center;
  min-width: 110px;
}

.score-line {
  display: flex;
  align-items: baseline;
  justify-content: center;
  line-height: 1;
  color: #fff;
  text-shadow: 0 3px 0 rgba(194, 80, 16, 0.5), 0 7px 18px rgba(32, 65, 45, 0.3);
}

#score {
  font-size: clamp(36px, 10.5vw, 48px);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
}

.score-unit {
  font-size: 12px;
  font-weight: 800;
  margin-left: 3px;
  opacity: 0.9;
}

.combo {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 11px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ff9e4d, #ff6328);
  border: 1.5px solid rgba(255, 255, 255, 0.7);
  color: #fff;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
  opacity: 0;
  transform: scale(0.82) translateY(-3px);
  transition: opacity 0.16s ease, transform 0.16s ease;
  box-shadow: 0 4px 10px rgba(214, 82, 20, 0.34);
}

.combo.show {
  opacity: 1;
  transform: scale(1) translateY(0);
}

body.fever .combo {
  opacity: 0;
}

.power {
  --p: 0;
  position: relative;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  padding: 4px;
  background: conic-gradient(#ff8a3d calc(var(--p) * 1%), rgba(255, 255, 255, 0.42) 0);
  box-shadow: 0 4px 14px rgba(36, 76, 50, 0.18), inset 0 0 0 1px rgba(255, 255, 255, 0.55);
  transition: box-shadow 0.25s ease;
}

.power-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #fffdf8, #fff2dd);
  color: #ff8a3d;
  box-shadow: inset 0 1px 0 #fff;
}

.power .mp-icon {
  width: 23px;
  height: 23px;
  filter: drop-shadow(0 1px 0 rgba(200, 90, 20, 0.2));
}

.power.full {
  animation: powerPulse 1.15s ease-in-out infinite;
}

@keyframes powerPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(255, 170, 80, 0.22), 0 0 18px rgba(255, 140, 50, 0.55); }
  50% { box-shadow: 0 0 0 7px rgba(255, 170, 80, 0.1), 0 0 28px rgba(255, 140, 50, 0.8); }
}

/* ---------------- 粘力全开横幅 ---------------- */

.fever-banner {
  position: absolute;
  top: calc(var(--safe-top) + 100px);
  left: 50%;
  z-index: 11;
  transform: translate(-50%, -8px) scale(0.82);
  padding: 8px 20px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffb23e, #ff6b2c);
  border: 2px solid rgba(255, 255, 255, 0.7);
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.16em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.2, 1.6, 0.4, 1);
  box-shadow: 0 7px 22px rgba(255, 105, 40, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  text-shadow: 0 2px 0 rgba(178, 68, 0, 0.3);
}

.fever-banner.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
  animation: feverBreathe 1s ease-in-out infinite;
}

@keyframes feverBreathe {
  0%, 100% { transform: translate(-50%, 0) scale(1); }
  50% { transform: translate(-50%, 0) scale(1.05); }
}

/* ---------------- 开局拖动提示 ---------------- */

.drag-hint {
  position: absolute;
  top: calc(var(--safe-top) + 118px);
  left: 50%;
  z-index: 12;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px 8px 11px;
  border-radius: 999px;
  background: rgba(47, 33, 20, 0.44);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff8ec;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.02em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -5px) scale(0.96);
  transition: opacity 0.25s ease, transform 0.25s ease;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 16px rgba(38, 24, 12, 0.18);
  text-shadow: 0 1px 2px rgba(30, 18, 8, 0.3);
}

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

.drag-hint .mp-icon {
  width: 18px;
  height: 18px;
  color: #ffd2a1;
}

/* ---------------- 通用屏幕 ---------------- */

.screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

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

/* ---------------- 开始界面 ---------------- */

.start-screen {
  align-items: stretch;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(255, 239, 205, 0.14), rgba(24, 55, 40, 0) 58%),
    linear-gradient(180deg, rgba(20, 58, 40, 0.02) 0%, rgba(20, 52, 36, 0.1) 62%, rgba(18, 46, 32, 0.28) 100%);
}

.start-inner {
  position: relative;
  width: 100%;
  max-width: 430px;
  height: 100%;
  margin: 0 auto;
  padding: calc(var(--safe-top) + clamp(30px, 8.5vh, 80px)) 20px calc(var(--safe-bottom) + 20px);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.logo {
  text-align: center;
  animation: logoFloat 3.6s ease-in-out infinite;
  transform-origin: 50% 40%;
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.logo-kicker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 13px;
  border-radius: 999px;
  background: rgba(255, 249, 236, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.9);
  color: #b06a3a;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  box-shadow: 0 4px 12px rgba(50, 80, 55, 0.14);
}

.logo-title {
  margin: 6px 0 0;
  line-height: 1;
}

.logo-small {
  display: block;
  margin-bottom: 10px;
  color: #fffdf6;
  font-size: clamp(17px, 4.6vw, 22px);
  font-weight: 800;
  letter-spacing: 0.48em;
  margin-left: 0.48em;
  text-shadow: 0 2px 0 rgba(196, 84, 24, 0.45), 0 5px 12px rgba(35, 65, 45, 0.32);
}

.logo-big {
  display: block;
  color: var(--orange);
  font-size: clamp(52px, 14.8vw, 68px);
  font-weight: 900;
  letter-spacing: 0.02em;
  -webkit-text-stroke: 9px #fff9ee;
  paint-order: stroke fill;
  filter: drop-shadow(0 5px 0 #e06118) drop-shadow(0 11px 16px rgba(84, 43, 12, 0.28));
}

.tagline {
  margin: 14px 0 0;
  color: #fffdf8;
  font-size: clamp(13px, 3.6vw, 15px);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 6px rgba(34, 64, 44, 0.48);
}

.start-card {
  position: relative;
  width: 100%;
  max-width: 360px;
  margin-top: auto;
  margin-bottom: clamp(175px, 24vh, 215px);
  padding: 16px 16px 15px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255, 253, 247, 0.98), rgba(255, 242, 224, 0.98));
  border: 1.5px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 18px 44px rgba(62, 46, 22, 0.2), inset 0 1px 0 #fff;
  animation: cardIn 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

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

.card-top {
  display: flex;
  justify-content: center;
  margin: 0 0 11px;
}

.card-top .best-chip {
  padding: 6px 14px;
}

.best-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 13px;
  border-radius: 999px;
  background: #fff2dc;
  border: 1px solid #ffe1bb;
  color: #a4612a;
  font-size: 12.5px;
  font-weight: 700;
}

.best-chip .mp-icon {
  width: 17px;
  height: 17px;
  color: #f5a623;
}

.best-chip b {
  color: #e8641c;
  font-size: 16px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.start-desc {
  margin: 0 4px 13px;
  color: #95705a;
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

.start-desc b {
  color: #7c5238;
  font-weight: 800;
}

.btn {
  position: relative;
  width: 100%;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: none;
  border-radius: 19px;
  font-family: inherit;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.04em;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.15s ease;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(180deg, #ffae6c 0%, #ff8a3d 42%, #ff7a2e 100%);
  box-shadow: 0 6px 0 #d95c17, 0 13px 24px rgba(216, 92, 23, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.55);
  text-shadow: 0 2px 0 rgba(174, 70, 8, 0.28);
}

.btn-primary .mp-icon {
  width: 24px;
  height: 24px;
  color: #fff;
  filter: drop-shadow(0 1px 0 rgba(174, 70, 8, 0.3));
}

.btn-primary:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #d95c17, 0 6px 12px rgba(216, 92, 23, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.55);
  filter: brightness(0.98);
}

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

.how {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed #f2d9bb;
}

.how-item {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #8a6a57;
  font-size: 11px;
  font-weight: 600;
}

.how-item .mp-icon {
  width: 20px;
  height: 20px;
  color: #ff8a3d;
}


/* ---------------- 结算界面 ---------------- */

.over-screen {
  background:
    radial-gradient(circle at 50% 32%, rgba(255, 178, 98, 0.2), rgba(22, 48, 34, 0.64) 72%);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.over-card {
  position: relative;
  width: calc(100% - 40px);
  max-width: 340px;
  padding: 26px 20px 20px;
  border-radius: 30px;
  background: linear-gradient(180deg, rgba(255, 253, 247, 0.99), rgba(255, 241, 222, 0.99));
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 24px 60px rgba(28, 42, 26, 0.35), inset 0 1px 0 #fff;
  text-align: center;
  animation: overIn 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

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

.record-badge {
  position: absolute;
  top: -15px;
  right: 20px;
  padding: 5px 13px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffe27a, #ffc23c);
  border: 2px solid #fff8e0;
  color: #8b4b00;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.04em;
  transform: rotate(-7deg);
  box-shadow: 0 6px 14px rgba(170, 105, 10, 0.28);
  animation: badgeWiggle 1.6s ease-in-out infinite;
}

.record-badge.hidden {
  display: none;
}

@keyframes badgeWiggle {
  0%, 100% { transform: rotate(-7deg) scale(1); }
  50% { transform: rotate(-3deg) scale(1.06); }
}

.over-kicker {
  color: #a16a47;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.22em;
}

.final-line {
  display: flex;
  align-items: baseline;
  justify-content: center;
  margin-top: 4px;
  color: #e8641c;
  line-height: 1;
}

#finalScore {
  font-size: clamp(58px, 17vw, 72px);
  font-weight: 900;
  letter-spacing: -2px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.9), 0 7px 0 rgba(255, 174, 108, 0.35);
}

.final-unit {
  margin-left: 4px;
  font-size: 14px;
  font-weight: 800;
  color: #b06a3a;
}

.over-best {
  margin-top: 9px;
  color: #8a6a57;
  font-size: 12.5px;
  font-weight: 600;
}

.over-best b {
  color: #e8641c;
  font-size: 15px;
  font-weight: 900;
}

.over-stats {
  display: flex;
  gap: 8px;
  margin: 16px 0 18px;
}

.stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 6px;
  border-radius: 15px;
  background: #fff4e2;
  border: 1px solid #ffe3c2;
}

.stat span {
  color: #a08068;
  font-size: 10.5px;
  font-weight: 600;
}

.stat b {
  color: #5c3a24;
  font-size: 19px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.over-tip {
  margin: 13px 0 0;
  color: #b89a82;
  font-size: 10.5px;
  letter-spacing: 0.08em;
}

/* ---------------- 小屏适配 ---------------- */

@media (max-height: 700px) {
  .start-inner {
    padding-top: calc(var(--safe-top) + 22px);
  }

  .logo-big {
    font-size: clamp(44px, 13vw, 54px);
    -webkit-text-stroke-width: 7px;
  }

  .logo-small {
    font-size: 16px;
  }

  .logo-kicker {
    font-size: 10px;
    padding: 5px 11px;
  }

  .tagline {
    margin-top: 10px;
    font-size: 12.5px;
  }

  .start-card {
    padding: 14px 14px 12px;
    border-radius: 24px;
    margin-bottom: clamp(160px, 22vh, 210px);
  }

  .card-top {
    margin-bottom: 9px;
  }

  .start-desc {
    margin: 8px 4px 10px;
    font-size: 11px;
  }

  .btn {
    min-height: 50px;
    font-size: 17px;
    border-radius: 17px;
  }

  .how {
    margin-top: 10px;
    padding-top: 9px;
  }

  .how-item {
    font-size: 10px;
  }

  .over-card {
    padding: 20px 18px 16px;
  }
}

@media (max-height: 600px) {
  .start-desc {
    display: none;
  }

  .start-card {
    margin-bottom: 170px;
  }

  .card-top {
    margin-bottom: 7px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .logo,
  .record-badge,
  .fever-banner.show,
  .power.full {
    animation: none;
  }
}

/* ---------------- 首页：gpt-image 整图铺满 ---------------- */

.start-screen {
  background: #8fd0f5;
}

/* 方图按 cover 铺满竖屏：边长取屏宽与屏高中较大者，居中裁切 */
.home-art {
  position: absolute;
  left: 50%;
  top: 50%;
  width: max(100vw, 100vh);
  height: max(100vw, 100vh);
  transform: translate(-50%, -50%);
}

.home-img {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  -webkit-user-drag: none;
}

/* 透明热区，正好盖住图上的黄色播放键 */
.home-play {
  position: absolute;
  left: 33.4%;
  top: 63.2%;
  width: 33.2%;
  height: 20.6%;
  padding: 0;
  border: none;
  border-radius: 44% / 50%;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  animation: homePlayPulse 1.8s ease-in-out infinite;
  transition: transform 0.1s ease, background 0.1s ease;
}

.home-play:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.22);
}

.home-play:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.95);
  outline-offset: 2px;
}

@keyframes homePlayPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 214, 90, 0); }
  50% { box-shadow: 0 0 0 10px rgba(255, 214, 90, 0.35); }
}

.home-best {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 22px);
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(78, 46, 24, 0.72);
  border: 1.5px solid rgba(255, 214, 150, 0.85);
  color: #ffe9c8;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 6px 16px rgba(40, 24, 10, 0.3);
}

.home-best .mp-icon {
  width: 18px;
  height: 18px;
  color: #ffc94a;
}

.home-best b {
  color: #ffb067;
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  .home-play { animation: none; }
}
