/* 合成大西瓜 · 竖屏 H5 游戏 */
:root {
  --theme: #FF8A3D;
  --theme-deep: #E4671B;
  --ink: #4A2A18;
  --ink-soft: #8A6A50;
  --cream: #FFF7EC;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: radial-gradient(120% 90% at 50% 0%, #FFD9AC 0%, #FFE9CF 45%, #FFDDBC 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

body {
  position: fixed;
  inset: 0;
}

.stage {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #FFF3E0;
  touch-action: none;
}

@media (min-width: 560px) {
  .stage {
    box-shadow: 0 0 0 1px rgba(160, 90, 30, .06), 0 24px 80px rgba(130, 65, 20, .22);
  }
}

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

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: 14px;
  right: 14px;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 10px;
  pointer-events: none;
}

.hud-pill {
  background: rgba(255, 252, 245, .92);
  border: 1.5px solid rgba(255, 255, 255, .95);
  border-radius: 17px;
  box-shadow:
    0 5px 16px rgba(186, 105, 38, .16),
    0 1px 0 rgba(255, 255, 255, .9) inset,
    0 -3px 0 rgba(255, 165, 90, .10) inset;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  padding: 6px 13px 8px;
  min-width: 82px;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.score-pill { grid-column: 1; justify-self: start; }
.best-pill { grid-column: 3; justify-self: end; }

.hud-label {
  font-size: 10px;
  line-height: 1.1;
  letter-spacing: .12em;
  color: #B18B6A;
  font-weight: 600;
}

.hud-value {
  display: block;
  margin-top: 1px;
  font-size: 23px;
  line-height: 1.08;
  font-weight: 900;
  color: var(--theme-deep);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  transition: transform .16s ease;
  transform-origin: left center;
}

.best-pill .hud-value {
  color: #9A6B45;
}

.hud-value.bump {
  animation: scoreBump .26s cubic-bezier(.34, 1.56, .64, 1);
}

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

.next-pill {
  grid-column: 2;
  justify-self: center;
  flex-direction: row;
  align-items: center;
  gap: 5px;
  padding: 4px 10px 4px 12px;
  min-width: 0;
  justify-content: center;
}

.next-pill .hud-label {
  letter-spacing: .08em;
}

#nextCv {
  width: 40px;
  height: 40px;
  display: block;
}

/* ---------- 提示 ---------- */
.hint {
  position: absolute;
  left: 50%;
  top: calc(44% + env(safe-area-inset-top, 0px));
  z-index: 4;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px 8px 12px;
  border-radius: 999px;
  background: rgba(255, 250, 242, .82);
  border: 1px solid rgba(255, 255, 255, .9);
  box-shadow: 0 5px 16px rgba(175, 100, 40, .14);
  color: #967355;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .03em;
  pointer-events: none;
  animation: hintFloat 2.6s ease-in-out infinite;
  transition: opacity .35s ease, transform .35s ease;
}

.hint .mp-icon {
  width: 17px;
  height: 17px;
  color: var(--theme);
}

.hint.gone {
  opacity: 0;
  transform: translate(-50%, calc(-50% + 8px));
}

@keyframes hintFloat {
  0%, 100% { margin-bottom: 0; }
  50% { margin-bottom: 4px; }
}

/* ---------- 结束弹层 ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(28px + env(safe-area-inset-top, 0px)) 24px calc(28px + env(safe-area-inset-bottom, 0px));
  background: rgba(74, 36, 12, .40);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  opacity: 0;
  transition: opacity .26s ease;
}

.overlay[hidden] {
  display: none;
}

.overlay.show {
  opacity: 1;
}

.over-card {
  position: relative;
  width: min(324px, 88vw);
  padding: 34px 22px 22px;
  border-radius: 27px;
  border: 1px solid rgba(255, 255, 255, .9);
  background:
    radial-gradient(120% 70% at 50% 0%, #FFFDF7 0%, #FFF6E8 58%, #FFEED7 100%);
  box-shadow:
    0 24px 60px rgba(85, 38, 8, .36),
    0 2px 0 rgba(255, 255, 255, .9) inset,
    0 -6px 0 rgba(255, 170, 95, .14) inset;
  text-align: center;
  transform: translateY(14px) scale(.94);
  transition: transform .32s cubic-bezier(.22, 1.2, .36, 1);
}

.overlay.show .over-card {
  transform: translateY(0) scale(1);
}

.over-fruit {
  position: absolute;
  top: -33px;
  left: 50%;
  width: 66px;
  height: 66px;
  margin-left: -33px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 27%, #A6E8A1 0%, #55B967 42%, #2B8746 78%, #17602F 100%);
  box-shadow: 0 8px 18px rgba(30, 100, 50, .30), 0 0 0 5px #FFFCF5;
  overflow: hidden;
  transform: rotate(-8deg);
}

.over-fruit::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: repeating-linear-gradient(102deg, transparent 0 9px, rgba(22, 92, 45, .38) 9px 14px);
}

.over-fruit::after {
  content: "";
  position: absolute;
  top: 5px;
  left: 50%;
  width: 17px;
  height: 21px;
  margin-left: -3px;
  border-radius: 0 90% 0 90%;
  background: linear-gradient(140deg, #79D183, #3B9550);
  transform: rotate(24deg);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .35) inset;
}

.over-kicker {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .22em;
  color: #C08B62;
}

.over-title {
  margin: 7px 0 16px;
  font-size: 20px;
  line-height: 1.3;
  font-weight: 900;
  letter-spacing: .01em;
  color: #4A2A18;
}

.over-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 11px 16px 12px;
  border-radius: 18px;
  background: linear-gradient(180deg, #FFF0D9, #FFE7C6);
  border: 1px solid rgba(255, 190, 125, .5);
  box-shadow: 0 2px 0 rgba(255, 255, 255, .65) inset;
}

.over-score span {
  font-size: 11px;
  letter-spacing: .14em;
  color: #A97A55;
  font-weight: 600;
}

.over-score strong {
  font-size: 42px;
  line-height: 1.05;
  font-weight: 900;
  color: var(--theme-deep);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.03em;
}

.over-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
  font-size: 12px;
  color: #9A7A60;
  font-weight: 600;
}

.over-meta b {
  color: #8A5A35;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.new-record {
  padding: 3px 9px;
  border-radius: 999px;
  background: linear-gradient(180deg, #FFD37A, #FFB13D);
  color: #8A4A08;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  box-shadow: 0 2px 5px rgba(230, 140, 30, .32);
}

.new-record[hidden] {
  display: none;
}

.btn-primary {
  width: 100%;
  height: 53px;
  margin-top: 18px;
  border: 0;
  border-radius: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(180deg, #FFA857 0%, #FF8A3D 48%, #F1731B 100%);
  color: #fff;
  font-family: inherit;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: .04em;
  cursor: pointer;
  box-shadow:
    0 6px 0 #C95911,
    0 12px 22px rgba(238, 108, 28, .34),
    0 1px 0 rgba(255, 255, 255, .45) inset;
  transition: transform .1s ease, box-shadow .1s ease;
}

.btn-primary .mp-icon {
  width: 21px;
  height: 21px;
  color: #fff;
}

.btn-primary:active {
  transform: translateY(4px);
  box-shadow:
    0 2px 0 #C95911,
    0 5px 10px rgba(238, 108, 28, .28),
    0 1px 0 rgba(255, 255, 255, .45) inset;
}

.over-tip {
  margin: 13px 0 0;
  font-size: 11px;
  line-height: 1.4;
  color: #B09479;
}

@media (max-height: 620px) {
  .overlay {
    align-items: flex-start;
    padding-top: calc(58px + env(safe-area-inset-top, 0px));
  }
}

@media (max-height: 700px) {
  .over-card { padding: 30px 18px 17px; }
  .over-title { font-size: 18px; margin-bottom: 12px; }
  .over-score strong { font-size: 35px; }
  .over-fruit { width: 58px; height: 58px; margin-left: -29px; top: -29px; }
  .btn-primary { height: 49px; margin-top: 14px; }
}
