/* 合成大西瓜 · 竖屏休闲游戏 */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --orange: #FF8A3D;
  --orange-deep: #F06918;
  --orange-soft: #FFE3C8;
  --cream: #FFF8EE;
  --ink: #3A2A1D;
  --muted: #A0836B;
  --green: #49A85B;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

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

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(130% 86% at 50% -14%, #FFFBF2 0%, #FFF1DC 36%, #FFE4C7 68%, #FFD7B0 100%);
}

.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.7) 1.4px, transparent 1.6px);
  background-size: 26px 26px;
  opacity: 0.5;
  pointer-events: none;
}

.stage::after {
  content: "";
  position: absolute;
  left: -25%;
  right: -25%;
  bottom: -32%;
  height: 62%;
  background: radial-gradient(50% 58% at 50% 100%, rgba(255, 255, 255, 0.58), rgba(255, 255, 255, 0) 72%);
  pointer-events: none;
}

.glow {
  position: absolute;
  top: -150px;
  left: 50%;
  width: 420px;
  height: 360px;
  margin-left: -210px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 226, 168, 0.85), rgba(255, 226, 168, 0));
  pointer-events: none;
}

.cloud {
  position: absolute;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.52);
  filter: blur(0.4px);
  pointer-events: none;
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: inherit;
}

.cloud-a {
  top: 18%;
  left: -36px;
  width: 116px;
  height: 34px;
}

.cloud-a::before {
  width: 52px;
  height: 52px;
  left: 16px;
  top: -24px;
}

.cloud-a::after {
  width: 34px;
  height: 34px;
  left: 58px;
  top: -13px;
}

.cloud-b {
  top: 31%;
  right: -42px;
  width: 132px;
  height: 38px;
  opacity: 0.75;
}

.cloud-b::before {
  width: 58px;
  height: 58px;
  left: 22px;
  top: -28px;
}

.cloud-b::after {
  width: 38px;
  height: 38px;
  left: 70px;
  top: -15px;
}

.cloud-c {
  top: 47%;
  left: -58px;
  width: 106px;
  height: 30px;
  opacity: 0.55;
}

.cloud-c::before {
  width: 44px;
  height: 44px;
  left: 18px;
  top: -21px;
}

.blob {
  position: absolute;
  border-radius: 46% 54% 52% 48%;
  pointer-events: none;
  filter: blur(1px);
}

.blob-a {
  left: -58px;
  bottom: 12%;
  width: 148px;
  height: 190px;
  background: linear-gradient(150deg, rgba(137, 199, 116, 0.32), rgba(137, 199, 116, 0));
  transform: rotate(-16deg);
}

.blob-b {
  right: -66px;
  bottom: 4%;
  width: 168px;
  height: 220px;
  background: linear-gradient(210deg, rgba(137, 199, 116, 0.28), rgba(137, 199, 116, 0));
  transform: rotate(14deg);
}

/* 顶部计分浮层：不是标题栏，也不放导航 */
.hud {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 30;
  display: flex;
  align-items: stretch;
  gap: 8px;
  width: calc(100% - 28px);
  max-width: 430px;
  margin: 0 auto;
  padding-top: calc(var(--safe-top) + 10px);
  transform: translateX(-50%);
}

.score-card {
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px 14px 9px;
  border: 1px solid rgba(255, 255, 255, 0.92);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(255, 255, 255, 0.94));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.95) inset, 0 8px 20px rgba(181, 95, 38, 0.13);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.score-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.hud-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--muted);
  white-space: nowrap;
}

.score-value {
  font-size: 30px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  transform-origin: left center;
}

.score-value.pop {
  animation: scorePop 0.32s cubic-bezier(0.2, 1.7, 0.4, 1);
}

@keyframes scorePop {
  0% { transform: scale(1); }
  45% { transform: scale(1.16); color: var(--orange-deep); }
  100% { transform: scale(1); }
}

.best-row {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 3px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1;
}

.best-row .mp-icon {
  width: 13px;
  height: 13px;
  color: #FFB13B;
}

.best-row b {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--orange-deep);
  font-variant-numeric: tabular-nums;
}

.next-card {
  flex: 0 0 86px;
  width: 86px;
  padding: 6px 4px 1px;
  border: 1px solid rgba(255, 255, 255, 0.92);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.98), rgba(255, 255, 255, 0.94));
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.95) inset, 0 8px 20px rgba(181, 95, 38, 0.13);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.next-card canvas {
  display: block;
  width: 54px;
  height: 54px;
  margin-top: -1px;
}

.icon-btn {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  align-self: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.92);
  border-radius: 16px;
  background: linear-gradient(180deg, #FFFDF8, #FFFFFF);
  color: var(--orange);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.95) inset, 0 8px 18px rgba(181, 95, 38, 0.13);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, background 0.12s ease;
}

.icon-btn .mp-icon {
  width: 22px;
  height: 22px;
}

.icon-btn:active {
  transform: scale(0.92);
  background: #FFF1DF;
}

.game-canvas {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.hint {
  position: absolute;
  left: 50%;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  background: rgba(255, 252, 246, 0.94);
  box-shadow: 0 8px 18px rgba(160, 85, 35, 0.14);
  color: #9A6B45;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, 0);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

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

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

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding-bottom: calc(24px + var(--safe-bottom));
  background: rgba(62, 37, 19, 0.44);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.28s ease, visibility 0.28s ease;
}

.overlay.show {
  opacity: 1;
  visibility: visible;
}

.result-card {
  width: 100%;
  max-width: 340px;
  padding: 6px 20px 20px;
  border: 1px solid rgba(255, 255, 255, 0.92);
  border-radius: 30px;
  background: linear-gradient(180deg, #FFFCF6, #FFF3E1);
  box-shadow: 0 26px 64px rgba(81, 40, 10, 0.32), 0 1px 0 #FFFFFF inset;
  text-align: center;
  transform: translateY(16px) scale(0.94);
  transition: transform 0.34s cubic-bezier(0.2, 0.9, 0.25, 1.18);
}

.overlay.show .result-card {
  transform: none;
}

.result-art {
  height: 128px;
  margin-top: -8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#resultCanvas {
  display: block;
  width: 220px;
  height: 160px;
  margin-top: -14px;
}

.result-kicker {
  margin: 0;
  color: var(--orange-deep);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
}

.result-title {
  margin: 7px 0 0;
  color: var(--ink);
  font-size: 21px;
  font-weight: 800;
  line-height: 1.32;
  letter-spacing: -0.01em;
}

.result-score {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  margin-top: 3px;
}

.result-score span {
  color: var(--orange-deep);
  font-size: 48px;
  font-weight: 800;
  line-height: 1.06;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.result-score small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 9px 0 17px;
}

.result-meta span {
  padding: 6px 11px;
  border: 1px solid rgba(255, 210, 166, 0.72);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1;
}

.result-meta b {
  color: #6C4A2D;
  font-weight: 800;
}

.primary-btn {
  width: 100%;
  height: 52px;
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(180deg, #FFA45C, #FF7A26);
  box-shadow: 0 6px 0 #E25F10, 0 12px 24px rgba(235, 105, 25, 0.3);
  color: #FFFFFF;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.primary-btn .mp-icon {
  width: 20px;
  height: 20px;
}

.primary-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #E25F10, 0 6px 14px rgba(235, 105, 25, 0.25);
}

@media (hover: hover) {
  .icon-btn:hover {
    background: #FFF6E9;
  }

  .primary-btn:hover {
    background: linear-gradient(180deg, #FFB06F, #FF852F);
  }
}

@media (max-width: 362px) {
  .hud {
    width: calc(100% - 20px);
    gap: 6px;
  }

  .score-card {
    padding: 7px 11px 8px;
  }

  .score-value {
    font-size: 26px;
  }

  .next-card {
    flex-basis: 76px;
    width: 76px;
  }

  .next-card canvas {
    width: 48px;
    height: 48px;
  }

  .icon-btn {
    flex-basis: 42px;
    width: 42px;
    height: 42px;
  }

  .result-card {
    padding-left: 16px;
    padding-right: 16px;
  }

  .result-title {
    font-size: 19px;
  }
}

@media (max-height: 706px) {
  .result-art {
    height: 104px;
  }

  #resultCanvas {
    width: 190px;
    height: 138px;
    margin-top: -14px;
  }

  .result-score span {
    font-size: 42px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .score-value.pop {
    animation: none;
  }

  .result-card,
  .hint,
  .overlay {
    transition-duration: 0.01ms;
  }
}
