:root {
  --orange: #FF8A3D;
  --orange-hi: #FFB25E;
  --orange-deep: #F26A1B;
  --navy: #0B2A55;
  --ink: #062244;
  --gold: #FFD24A;
  --red: #FF4D5E;
  --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: #071B38;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}

body { position: fixed; inset: 0; }

button { font-family: inherit; }

.app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #0B2A55;
  touch-action: none;
  isolation: isolate;
}

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

/* 顶部与边缘光晕，让白色文字和 HUD 在任何画面上都清楚 */
.vignette {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  background:
    radial-gradient(ellipse 95% 72% at 50% 42%, rgba(3, 20, 48, 0) 52%, rgba(2, 14, 34, 0.32) 100%);
}

.top-scrim {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: calc(120px + var(--safe-top));
  z-index: 9;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(3, 20, 48, 0.66) 0%, rgba(3, 20, 48, 0.26) 55%, rgba(3, 20, 48, 0) 100%);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.app[data-state="playing"] .top-scrim,
.app[data-state="paused"] .top-scrim,
.app[data-state="dying"] .top-scrim { opacity: 1; }

/* ---------------- 游戏内 HUD ---------------- */
.hud {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  z-index: 20;
  padding: calc(10px + var(--safe-top)) 14px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.app[data-state="playing"] .hud,
.app[data-state="paused"] .hud,
.app[data-state="dying"] .hud {
  opacity: 1;
  transform: translateY(0);
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.62);
  background: linear-gradient(180deg, rgba(54, 147, 238, 0.96) 0%, rgba(14, 74, 152, 0.96) 100%);
  box-shadow: 0 4px 12px rgba(3, 20, 50, 0.4), inset 0 2px 0 rgba(255, 255, 255, 0.4);
  display: grid;
  place-items: center;
  color: #fff;
  pointer-events: auto;
  transition: transform 0.1s ease;
}

.icon-btn:active { transform: scale(0.92); }
.icon-btn .mp-icon { width: 24px; height: 24px; }

.score-pill {
  height: 46px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 15px 0 11px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(14, 51, 104, 0.8) 0%, rgba(5, 27, 60, 0.84) 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.34);
  box-shadow: 0 4px 14px rgba(3, 20, 50, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.26);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
}

.score-pill .mp-icon {
  width: 23px;
  height: 23px;
  color: var(--gold);
  filter: drop-shadow(0 2px 0 rgba(120, 62, 0, 0.4));
}

.score-pill span {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.28);
}

.hearts {
  display: flex;
  gap: 4px;
  padding-top: 8px;
  filter: drop-shadow(0 3px 6px rgba(2, 18, 44, 0.35));
}

.heart { display: inline-flex; }
.heart .mp-icon {
  width: 27px;
  height: 27px;
  color: var(--red);
  filter: drop-shadow(0 2px 0 #8E1626) drop-shadow(0 0 5px rgba(255, 77, 94, 0.3));
}
.heart.empty .mp-icon {
  color: rgba(255, 255, 255, 0.32);
  filter: none;
}
.heart.pop { animation: heartPop 0.38s ease; }

@keyframes heartPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

/* ---------------- 开始界面 ---------------- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 30;
  transition: opacity 0.38s ease, visibility 0.38s ease;
}

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

.start-art {
  position: absolute;
  inset: -2%;
  background-color: #1B6CC4;
  background-image: url("images/gen/game-keyart.jpg");
  background-position: center 62%;
  background-size: cover;
  background-repeat: no-repeat;
  transform: scale(1.02);
  animation: artDrift 18s ease-in-out infinite alternate;
}

@keyframes artDrift {
  from { transform: scale(1.02) translate3d(0, 0, 0); }
  to { transform: scale(1.07) translate3d(0, -1.4%, 0); }
}

.start-scrim {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 82% 34% at 50% 48%, rgba(3, 23, 54, 0.58) 0%, rgba(3, 23, 54, 0.18) 62%, rgba(3, 23, 54, 0) 100%),
    linear-gradient(180deg, rgba(3, 20, 48, 0.94) 0%, rgba(3, 20, 48, 0.62) 7%, rgba(3, 20, 48, 0.12) 17%, rgba(3, 20, 48, 0.02) 27%, rgba(3, 20, 48, 0) 45%, rgba(3, 20, 48, 0.36) 80%, rgba(2, 14, 34, 0.72) 100%);
}

.start-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 26px calc(17vh + var(--safe-bottom));
  text-align: center;
  animation: riseIn 0.6s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.46);
  background: rgba(7, 34, 72, 0.4);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 3px;
  color: rgba(255, 255, 255, 0.94);
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--orange-hi);
  box-shadow: 0 0 9px rgba(255, 138, 61, 0.95);
}

.game-title {
  margin: 12px 0 0;
  font-size: clamp(44px, 12.4vw, 60px);
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: 1px;
  color: #fff;
  text-shadow:
    0 3px 0 #1B4E8C,
    0 6px 0 rgba(8, 32, 66, 0.6),
    0 12px 26px rgba(0, 0, 0, 0.45);
}

.game-title span {
  color: #FFA05A;
  text-shadow:
    0 3px 0 #A8480F,
    0 6px 0 rgba(84, 32, 6, 0.55),
    0 12px 26px rgba(0, 0, 0, 0.4);
}

.game-sub {
  margin: 12px 0 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.96);
  text-shadow: 0 2px 8px rgba(0, 20, 50, 0.7);
}

.best-chip {
  margin-top: 17px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 15px;
  border-radius: 999px;
  background: rgba(5, 28, 62, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.28);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font-size: 12.5px;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.86);
}

.best-chip .mp-icon {
  width: 17px;
  height: 17px;
  color: var(--gold);
  filter: drop-shadow(0 1px 0 rgba(120, 62, 0, 0.4));
}

.best-chip b {
  margin-left: 2px;
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  font-variant-numeric: tabular-nums;
}

/* ---------------- 通用按钮 ---------------- */
.btn {
  position: relative;
  border: 0;
  padding: 0;
  font-weight: 800;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  touch-action: manipulation;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.15s ease;
}

.btn:active { transform: translateY(3px) scale(0.988); }
.btn .mp-icon { width: 23px; height: 23px; }

.btn-primary {
  margin-top: 21px;
  min-width: 204px;
  height: 58px;
  padding: 0 32px;
  font-size: 19px;
  letter-spacing: 3px;
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.55);
  background: linear-gradient(180deg, #FFB25E 0%, #FF8A3D 46%, #F26A1B 100%);
  box-shadow:
    0 6px 0 #B44A0E,
    0 14px 26px rgba(255, 106, 27, 0.42),
    inset 0 2px 0 rgba(255, 255, 255, 0.55),
    inset 0 -3px 0 rgba(140, 50, 0, 0.22);
  text-shadow: 0 2px 0 rgba(140, 52, 0, 0.35);
  animation: btnPulse 2.4s ease-in-out infinite;
}

@keyframes btnPulse {
  0%, 100% { box-shadow: 0 6px 0 #B44A0E, 0 14px 26px rgba(255, 106, 27, 0.36), inset 0 2px 0 rgba(255, 255, 255, 0.55), inset 0 -3px 0 rgba(140, 50, 0, 0.22); }
  50% { box-shadow: 0 6px 0 #B44A0E, 0 18px 36px rgba(255, 138, 61, 0.58), inset 0 2px 0 rgba(255, 255, 255, 0.55), inset 0 -3px 0 rgba(140, 50, 0, 0.22); }
}

.btn-primary:active {
  box-shadow: 0 3px 0 #B44A0E, 0 6px 14px rgba(255, 106, 27, 0.35), inset 0 2px 0 rgba(255, 255, 255, 0.4);
  animation: none;
}

.btn-secondary {
  height: 52px;
  min-width: 180px;
  font-size: 16px;
  letter-spacing: 2px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.btn-secondary:active { background: rgba(255, 255, 255, 0.2); }

.btn-ghost {
  height: 46px;
  min-width: 140px;
  font-size: 14px;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.7);
  background: transparent;
}

.btn-ghost:active { color: #fff; }

.btn-block {
  display: flex;
  width: 100%;
  margin-top: 12px;
}
.btn-block:first-of-type { margin-top: 0; }

.hint {
  margin: 19px 0 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  letter-spacing: 1.2px;
  color: rgba(255, 255, 255, 0.76);
  text-shadow: 0 1px 6px rgba(0, 20, 50, 0.7);
}

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

/* ---------------- 弹层 ---------------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) 24px calc(24px + var(--safe-bottom));
  background: rgba(3, 16, 38, 0.58);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.26s ease, visibility 0.26s ease;
}

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

.panel {
  position: relative;
  width: min(88vw, 344px);
  padding: 26px 22px 20px;
  border-radius: 28px;
  text-align: center;
  background:
    radial-gradient(ellipse 120% 60% at 50% 0%, rgba(72, 156, 255, 0.3) 0%, rgba(72, 156, 255, 0) 64%),
    linear-gradient(180deg, #1C5195 0%, #0F3268 55%, #092247 100%);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow:
    0 26px 64px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.36),
    inset 0 -1px 0 rgba(0, 0, 0, 0.3);
  transform: scale(0.9) translateY(14px);
  transition: transform 0.3s cubic-bezier(0.2, 1.4, 0.4, 1);
}

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

.panel-title {
  margin: 4px 0 0;
  font-size: 27px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #fff;
  text-shadow: 0 3px 0 rgba(4, 24, 52, 0.55);
}

.panel-desc {
  margin: 10px 0 22px;
  font-size: 13px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.65);
}

.pause-panel .btn-secondary { margin-top: 12px; }
.pause-panel .btn-ghost { margin-top: 8px; }

.over-kicker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  padding: 0 13px;
  border-radius: 999px;
  background: linear-gradient(180deg, #FFA45B, #F26A1B);
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 3px 10px rgba(242, 106, 27, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 3px;
  color: #fff;
  text-shadow: 0 1px 0 rgba(130, 45, 0, 0.35);
}

.final-score {
  margin-top: 14px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 7px;
  line-height: 1;
}

.final-score .mp-icon {
  width: 32px;
  height: 32px;
  align-self: center;
  color: var(--gold);
  filter: drop-shadow(0 3px 0 rgba(120, 62, 0, 0.35));
}

.final-score span {
  font-size: 64px;
  font-weight: 900;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
  color: #fff;
  text-shadow: 0 4px 0 rgba(4, 24, 52, 0.55), 0 10px 24px rgba(0, 0, 0, 0.35);
}

.final-score small {
  font-size: 15px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.65);
}

.newbest {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
  height: 24px;
  padding: 0 11px;
  border-radius: 999px;
  background: rgba(255, 210, 74, 0.16);
  border: 1px solid rgba(255, 210, 74, 0.6);
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
  animation: bestBlink 1.4s ease-in-out infinite;
}

.newbest[hidden] { display: none; }

@keyframes bestBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.best-line {
  margin: 12px 0 20px;
  font-size: 13px;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.62);
}

.best-line b {
  margin-left: 4px;
  font-size: 17px;
  font-weight: 800;
  color: #FFD79A;
  font-variant-numeric: tabular-nums;
}

.over-panel .btn-primary {
  margin-top: 0;
  min-width: 0;
  height: 54px;
  font-size: 17px;
  letter-spacing: 2px;
  animation: none;
}

.over-panel .btn-ghost { margin-top: 6px; }

@media (max-height: 700px) {
  .start-content { padding-bottom: calc(12vh + var(--safe-bottom)); }
  .game-title { font-size: clamp(38px, 11vw, 50px); }
  .game-sub { margin-top: 9px; }
  .best-chip { margin-top: 12px; }
  .btn-primary { margin-top: 16px; height: 54px; }
  .hint { margin-top: 14px; }
  .final-score span { font-size: 54px; }
}

@media (prefers-reduced-motion: reduce) {
  .start-art, .btn-primary, .newbest, .start-content { animation: none; }
}

.score-pill span.bump {
  animation: scoreBump 0.24s ease;
}

@keyframes scoreBump {
  0% { transform: scale(1); }
  45% { transform: scale(1.22); color: #FFD79A; }
  100% { transform: scale(1); }
}

/* 遮掉参考图里自带的计分/炸弹，只保留画面主体 */
.start-scrim::before,
.start-scrim::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.start-scrim::before {
  left: 0;
  top: 0;
  width: min(64vw, 330px);
  height: 185px;
  background: radial-gradient(ellipse 100% 100% at 0% 0%,
    rgba(3, 20, 48, 0.86) 0%,
    rgba(3, 20, 48, 0.52) 44%,
    rgba(3, 20, 48, 0) 100%);
}

.start-scrim::after {
  left: 0;
  bottom: 0;
  width: min(62vw, 260px);
  height: 270px;
  background: radial-gradient(ellipse 100% 100% at 0% 100%,
    rgba(2, 14, 34, 0.88) 0%,
    rgba(2, 14, 34, 0.42) 50%,
    rgba(2, 14, 34, 0) 100%);
}


.start-best {
  position: absolute;
  z-index: 3;
  left: 14px;
  top: calc(8px + var(--safe-top));
  margin: 0;
  height: 44px;
  padding: 0 16px 0 12px;
  background: linear-gradient(180deg, rgba(13, 48, 96, 0.82) 0%, rgba(4, 25, 56, 0.86) 100%);
  border: 1.5px solid rgba(255, 255, 255, 0.38);
  box-shadow: 0 4px 14px rgba(2, 16, 38, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.26);
  font-size: 12.5px;
}

.start-best .mp-icon {
  width: 20px;
  height: 20px;
}

.start-best b {
  font-size: 18px;
}

@media (max-width: 340px) {
  .start-best { height: 38px; padding: 0 12px 0 10px; font-size: 11.5px; }
  .start-best .mp-icon { width: 17px; height: 17px; }
  .start-best b { font-size: 16px; }
}
