:root {
  --ink: #3B2A20;
  --ink-soft: #7A6455;
  --ink-faint: #9A8370;
  --cream: #FFF9EE;
  --cream-deep: #F4E9D6;
  --orange: #FF8A3D;
  --orange-deep: #F26522;
  --aqua: #2FB5C4;
  --coral: #F2705D;
}

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

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #147C9E;
  color: var(--ink);
  font-family: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.game {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  overflow: hidden;
}

#scene {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ============ 游戏 HUD ============ */
.hud {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

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

.hud-top {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  left: calc(env(safe-area-inset-left, 0px) + 16px);
  right: calc(env(safe-area-inset-right, 0px) + 16px);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.score-card {
  min-width: 150px;
  padding: 9px 13px 11px;
  border-radius: 18px;
  background: rgba(255, 249, 238, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 24px rgba(8, 74, 90, 0.18), inset 0 1px 0 #FFFFFF;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.score-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}

.best-mini {
  white-space: nowrap;
  letter-spacing: 0;
}

.best-mini b {
  color: var(--ink-soft);
  font-weight: 800;
}

.score-num {
  margin-top: 1px;
  font-size: 30px;
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--orange-deep);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.65);
}

.score-num .unit {
  margin-left: 3px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-faint);
  letter-spacing: 0;
}

.growth-line {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
}

.growth-track {
  flex: 1;
  height: 7px;
  border-radius: 99px;
  background: #EDE0CB;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(80, 50, 30, 0.12);
}

.growth-fill {
  width: 0;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #FFBE5C, #FF8A3D 55%, #F26522);
  box-shadow: 0 0 8px rgba(255, 138, 61, 0.55);
  transition: width 0.25s ease;
}

.level {
  min-width: 30px;
  text-align: right;
  font-size: 10px;
  font-weight: 800;
  color: var(--orange-deep);
}

.hud-actions {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.round-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background: rgba(255, 249, 238, 0.94);
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(8, 74, 90, 0.18);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
  -webkit-appearance: none;
  appearance: none;
}

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

.round-btn:active {
  transform: scale(0.9);
  background: #F4E9D6;
}

.combo-pill {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 106px);
  left: 50%;
  transform: translateX(-50%) scale(0.72);
  padding: 6px 14px;
  border-radius: 99px;
  background: linear-gradient(135deg, #FFB347, #FF8A3D);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.02em;
  white-space: nowrap;
  opacity: 0;
  box-shadow: 0 8px 18px rgba(242, 101, 34, 0.35);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.combo-pill.show {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.combo-pill.pop {
  animation: comboPop 0.3s ease;
}

@keyframes comboPop {
  0% { transform: translateX(-50%) scale(1.35); }
  100% { transform: translateX(-50%) scale(1); }
}

.hint-pill {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 26px);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 99px;
  background: rgba(255, 249, 238, 0.92);
  color: #5D4638;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-50%) translateY(8px);
  box-shadow: 0 8px 20px rgba(8, 74, 90, 0.16);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.hint-pill.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.hint-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 0 4px rgba(255, 138, 61, 0.22);
  animation: hintPulse 1.4s ease-in-out infinite;
}

@keyframes hintPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(255, 138, 61, 0.22); }
  50% { box-shadow: 0 0 0 7px rgba(255, 138, 61, 0.08); }
}

/* ============ 通用弹层 ============ */
.overlay {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.overlay.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.overlay-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) calc(env(safe-area-inset-right, 0px) + 16px) calc(env(safe-area-inset-bottom, 0px) + 12px) calc(env(safe-area-inset-left, 0px) + 16px);
  background: rgba(8, 66, 82, 0.42);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

/* ============ 首页 ============ */
.overlay-start {
  display: flex;
  align-items: flex-end;
  background: linear-gradient(180deg, rgba(10, 80, 100, 0) 0%, rgba(10, 80, 100, 0.06) 38%, rgba(9, 72, 90, 0.3) 100%);
}

.start-sheet {
  position: relative;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 22px calc(env(safe-area-inset-bottom, 0px) + 20px);
  border-radius: 32px 32px 0 0;
  background: var(--cream);
  box-shadow: 0 -20px 50px rgba(7, 61, 77, 0.28), inset 0 1px 0 #FFFFFF;
  transform: translateY(24px);
  transition: transform 0.38s cubic-bezier(0.2, 0.8, 0.2, 1);
  touch-action: pan-y;
}

.overlay-start.show .start-sheet {
  transform: translateY(0);
}

.mascot-wrap {
  position: relative;
  z-index: 1;
  width: 48vw;
  max-width: 184px;
  margin: -96px auto -4px;
  filter: drop-shadow(0 18px 22px rgba(30, 90, 90, 0.24));
  animation: mascotFloat 4s ease-in-out infinite;
}

.mascot {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

@keyframes mascotFloat {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-7px) rotate(1deg); }
}

.start-body {
  position: relative;
  z-index: 2;
  max-width: 440px;
  margin: 0 auto;
  text-align: center;
}

.kicker {
  margin: 0 0 6px;
  color: var(--aqua);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.26em;
  text-indent: 0.26em;
}

.start-body h1 {
  margin: 0;
  font-size: clamp(32px, 9.4vw, 42px);
  line-height: 1.15;
  font-weight: 900;
  letter-spacing: 0.015em;
  color: var(--ink);
}

.lead {
  margin: 9px 0 0;
  font-size: 13.5px;
  line-height: 1.68;
  font-weight: 500;
  color: var(--ink-soft);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 15px 0 16px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid #EADCC5;
  border-radius: 99px;
  background: var(--cream-deep);
  color: #6B533F;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.dot {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.dot-aqua { background: var(--aqua); }
.dot-orange { background: var(--orange); }
.dot-coral { background: var(--coral); }

/* ============ 按钮 ============ */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 56px;
  padding: 0 20px;
  border: 0;
  border-radius: 18px;
  font-family: inherit;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  -webkit-appearance: none;
  appearance: none;
}

.btn:active {
  transform: scale(0.975);
}

.btn-primary {
  background: linear-gradient(135deg, #FFA24D, #FF8A3D 48%, #F26522);
  color: #FFFFFF;
  box-shadow: 0 14px 26px rgba(242, 101, 34, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  text-shadow: 0 1px 2px rgba(160, 60, 10, 0.18);
}

.btn-ghost {
  height: 50px;
  background: #F3E8D7;
  color: #6B533F;
  font-size: 15px;
  box-shadow: inset 0 0 0 1px #EADCC5;
}

.btn-arrow {
  width: 9px;
  height: 9px;
  margin-left: 1px;
  border-right: 2.5px solid #FFFFFF;
  border-bottom: 2.5px solid #FFFFFF;
  border-radius: 1px;
  transform: rotate(-45deg);
}

.record {
  margin: 12px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-faint);
}

.record b {
  color: var(--orange-deep);
  font-size: 14px;
  font-weight: 900;
}

/* ============ 结果 / 暂停弹窗 ============ */
.dialog {
  width: 100%;
  max-width: 352px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 24px 22px calc(env(safe-area-inset-bottom, 0px) + 20px);
  border-radius: 28px;
  background: var(--cream);
  box-shadow: 0 24px 60px rgba(4, 50, 62, 0.35), inset 0 1px 0 #FFFFFF;
  text-align: center;
  transform: translateY(18px) scale(0.97);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.overlay.show .dialog {
  transform: translateY(0) scale(1);
}

.dialog h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.01em;
  color: var(--ink);
}

.dialog-sub {
  margin: 6px 0 0;
  font-size: 12.5px;
  line-height: 1.6;
  font-weight: 500;
  color: var(--ink-soft);
}

.dialog-actions {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.result-badge {
  display: none;
  padding: 5px 12px;
  margin-bottom: 10px;
  border-radius: 99px;
  background: #FFF0D9;
  color: var(--orange-deep);
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.result-badge.show {
  display: inline-block;
}

.big-score {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 5px;
  margin: 14px 0 2px;
  color: var(--orange-deep);
  font-size: 52px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 3px 0 rgba(255, 255, 255, 0.72);
}

.big-score small {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink-faint);
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 18px 0 20px;
  padding: 13px 4px;
  border: 1px solid #EEDFC8;
  border-radius: 18px;
  background: #F6EBD9;
}

.result-stats > div {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.result-stats > div + div::before {
  content: "";
  position: absolute;
  left: 0;
  top: 15%;
  width: 1px;
  height: 70%;
  background: #E7D6BC;
}

.result-stats b {
  font-size: 18px;
  font-weight: 900;
  color: var(--ink);
}

.result-stats span {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-soft);
}

.dialog-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 2px auto 12px;
  border-radius: 50%;
  background: #E4F5F3;
  color: var(--aqua);
}

.dialog-icon .mp-icon {
  width: 26px;
  height: 26px;
}

.pause-dialog .dialog-actions {
  margin-top: 20px;
}

/* ============ 短屏适配 ============ */
@media (max-height: 700px) {
  .mascot-wrap {
    width: 130px;
    margin: -64px auto -2px;
  }

  .start-sheet {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
  }

  .start-body h1 {
    font-size: 30px;
  }

  .lead {
    margin-top: 6px;
    font-size: 12.5px;
    line-height: 1.6;
  }

  .chips {
    margin: 10px 0 12px;
  }

  .btn {
    height: 50px;
    font-size: 16px;
  }

  .record {
    margin-top: 9px;
  }
}

@media (max-height: 560px) {
  .mascot-wrap {
    width: 96px;
    margin: -46px auto 0;
  }

  .kicker,
  .lead,
  .chips {
    display: none;
  }

  .start-body h1 {
    font-size: 26px;
  }

  .start-sheet {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
  }

  .btn {
    height: 46px;
  }

  .record {
    margin-top: 7px;
    font-size: 11px;
  }

  .hud-top {
    top: calc(env(safe-area-inset-top, 0px) + 8px);
  }

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

  .score-num {
    font-size: 24px;
  }

  .growth-line {
    margin-top: 5px;
  }

  .combo-pill {
    top: calc(env(safe-area-inset-top, 0px) + 86px);
  }

  .dialog {
    padding: 16px 18px calc(env(safe-area-inset-bottom, 0px) + 14px);
  }

  .dialog h2 {
    font-size: 20px;
  }

  .big-score {
    margin: 10px 0 0;
    font-size: 40px;
  }

  .result-stats {
    margin: 12px 0;
    padding: 9px 4px;
  }

  .result-stats b {
    font-size: 16px;
  }

  .dialog-actions {
    gap: 7px;
  }

  .btn-ghost {
    height: 44px;
  }
}

@media (max-width: 350px) {
  .score-card {
    min-width: 136px;
  }

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

  .hud-top {
    left: 12px;
    right: 12px;
  }

  .start-sheet {
    padding-left: 18px;
    padding-right: 18px;
  }
}

/* ============ 横屏主布局（本游戏默认） ============ */
@media (orientation: landscape) {
  .overlay-start {
    align-items: center;
    justify-content: center;
    padding: calc(env(safe-area-inset-top, 0px) + 12px) calc(env(safe-area-inset-right, 0px) + 16px) calc(env(safe-area-inset-bottom, 0px) + 12px) calc(env(safe-area-inset-left, 0px) + 16px);
    background:
      radial-gradient(circle at 50% 46%, rgba(10, 80, 100, 0.04) 0%, rgba(6, 55, 70, 0.34) 100%);
  }

  .start-sheet {
    display: flex;
    align-items: center;
    gap: 30px;
    width: calc(100% - 32px);
    max-width: 900px;
    padding: 24px 32px;
    border-radius: 32px;
    background: rgba(255, 249, 238, 0.95);
    box-shadow: 0 24px 60px rgba(4, 50, 62, 0.3), inset 0 1px 0 #FFFFFF;
    transform: translateY(14px) scale(0.98);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
  }

  .overlay-start.show .start-sheet {
    transform: translateY(0) scale(1);
  }

  .mascot-wrap {
    flex: 0 0 38%;
    width: 38%;
    max-width: 320px;
    margin: 0;
    background: radial-gradient(circle at 50% 52%, rgba(111, 221, 216, 0.26) 0%, rgba(111, 221, 216, 0) 70%);
  }

  .start-body {
    flex: 1 1 auto;
    max-width: none;
    margin: 0;
    text-align: left;
  }

  .kicker {
    display: block;
    text-indent: 0;
  }

  .start-body h1 {
    font-size: clamp(34px, 5.6vw, 58px);
    line-height: 1.08;
  }

  .lead {
    display: block;
    margin-top: 10px;
    font-size: 15px;
    line-height: 1.6;
  }

  .chips {
    display: flex;
    justify-content: flex-start;
    margin: 14px 0 16px;
  }

  .start-body .btn {
    width: 100%;
    max-width: 360px;
    height: 54px;
  }

  .record {
    margin-top: 11px;
    font-size: 12px;
    text-align: left;
  }

  .result-card {
    max-width: 600px;
    padding: 18px 26px;
  }

  .result-card .big-score {
    margin: 8px 0 0;
    font-size: 44px;
  }

  .result-card .result-stats {
    margin: 12px 0 14px;
    padding: 10px 4px;
  }

  .result-card .dialog-actions {
    flex-direction: row;
    gap: 10px;
  }

  .result-card .dialog-actions .btn {
    flex: 1 1 0;
    height: 50px;
  }
}

@media (orientation: landscape) and (max-height: 340px) {
  .start-sheet {
    gap: 18px;
    padding: 14px 20px;
    border-radius: 26px;
  }

  .mascot-wrap {
    flex-basis: 34%;
    width: 34%;
    max-width: 210px;
  }

  .kicker {
    margin-bottom: 4px;
    font-size: 9px;
  }

  .start-body h1 {
    font-size: 32px;
  }

  .lead {
    margin-top: 6px;
    font-size: 12px;
    line-height: 1.5;
  }

  .chips {
    margin: 8px 0 10px;
    gap: 5px;
  }

  .chip {
    padding: 5px 8px;
    font-size: 10.5px;
  }

  .start-body .btn {
    height: 44px;
    font-size: 15px;
    border-radius: 14px;
  }

  .record {
    margin-top: 7px;
    font-size: 11px;
  }

  .result-card {
    padding: 12px 20px;
  }

  .result-card .big-score {
    margin: 6px 0 0;
    font-size: 36px;
  }

  .result-card .result-stats {
    margin: 8px 0 10px;
    padding: 8px 4px;
  }

  .result-card .dialog-actions .btn {
    height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mascot-wrap,
  .hint-dot,
  .combo-pill.pop {
    animation: none !important;
  }

  .start-sheet,
  .dialog,
  .hud,
  .overlay,
  .growth-fill {
    transition-duration: 0.01ms !important;
  }
}

button:focus-visible {
  outline: 3px solid rgba(47, 181, 196, 0.55);
  outline-offset: 2px;
}
