/* ============================================================
   滑雪躲树12 · 横屏滑雪竞速
   成品图承载首页，Canvas 承载可玩雪道。
   ============================================================ */

:root {
  --orange: #FF8A3D;
  --orange-light: #FFB15A;
  --orange-hot: #FFD25A;
  --orange-deep: #C45B0A;
  --navy: #0D2039;
  --navy-2: #152F52;
  --ink: #07182C;
  --ice: #EAF7FF;
  --muted: #9FC4E2;
  --white: #FFFFFF;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--ink);
  color: var(--white);
  font-family: var(--font);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: none;
}

body { position: fixed; inset: 0; }

button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

img { -webkit-user-drag: none; user-select: none; }

button:focus-visible {
  outline: 3px solid rgba(255, 210, 90, 0.95);
  outline-offset: 3px;
}

.app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #07182C;
  isolation: isolate;
}

.screen {
  position: absolute;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.42s ease, visibility 0.42s ease, transform 0.42s ease;
}

.screen.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ============================================================
   首页
   ============================================================ */

.home {
  background: #07182C;
  transform: scale(1);
}

.home.is-leaving {
  opacity: 0;
  transform: scale(1.035);
  pointer-events: none;
}

.home-bg {
  position: absolute;
  inset: -7%;
  background-image: url("images/gen/gptimg_1795334901_look.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  filter: blur(20px) brightness(0.48) saturate(1.2);
  transform: scale(1.08);
  z-index: 0;
}

.home-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(70% 65% at 50% 47%, rgba(5, 19, 38, 0) 0%, rgba(5, 19, 38, 0.38) 68%, rgba(3, 13, 27, 0.74) 100%),
    linear-gradient(180deg, rgba(3, 14, 28, 0.46), rgba(3, 14, 28, 0) 22%, rgba(3, 14, 28, 0) 74%, rgba(3, 14, 28, 0.55));
}

.home-stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(100vw, 175vh);
  height: min(66.6667vw, 116.6667vh);
  aspect-ratio: 3 / 2;
  transform: translate(-50%, -50%);
  overflow: hidden;
  border-radius: clamp(0px, 1.4vh, 18px);
  background: #8FD0F2;
  box-shadow:
    0 26px 90px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.08),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  z-index: 1;
}

.home-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.home-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(30% 27% at 2% 3%, rgba(5, 18, 35, 0.82) 0%, rgba(5, 18, 35, 0.52) 46%, rgba(5, 18, 35, 0) 78%),
    radial-gradient(30% 27% at 98% 3%, rgba(5, 18, 35, 0.74) 0%, rgba(5, 18, 35, 0.46) 46%, rgba(5, 18, 35, 0) 78%),
    linear-gradient(180deg, rgba(5, 18, 35, 0.3) 0%, rgba(5, 18, 35, 0) 17%, rgba(5, 18, 35, 0) 72%, rgba(5, 18, 35, 0.34) 100%),
    radial-gradient(120% 88% at 50% 46%, rgba(0, 0, 0, 0) 54%, rgba(3, 14, 28, 0.24) 100%);
}

/* 游戏名缎带 */
.title-ribbon {
  position: absolute;
  left: 50%;
  top: 30.2%;
  transform: translate(-50%, -50%) rotate(-1.6deg);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 0.55em 1.2em 0.5em;
  border-radius: 999px;
  background: linear-gradient(180deg, #FFC46A 0%, #FF9A3F 46%, #FF7A22 100%);
  border: 2px solid #0F2542;
  box-shadow:
    0 0.22em 0 #A84B0B,
    0 0.55em 1.2em rgba(0, 0, 0, 0.35),
    inset 0 0.12em 0 rgba(255, 255, 255, 0.6);
  color: #0F2542;
  white-space: nowrap;
  pointer-events: none;
}

.title-cn {
  display: block;
  font-size: clamp(15px, 2.7vmin, 30px);
  font-weight: 1000;
  letter-spacing: 0.05em;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.title-sub {
  display: block;
  margin-top: 0.32em;
  font-size: clamp(8px, 1.35vmin, 13px);
  font-weight: 900;
  letter-spacing: 0.2em;
  line-height: 1;
  opacity: 0.82;
}

/* 首页真正的开始按钮：盖在成品图的播放键上 */
.play-btn {
  position: absolute;
  left: 50.7%;
  top: 65%;
  width: 19%;
  aspect-ratio: 1.8 / 1;
  transform: translate(-50%, -50%);
  border-radius: clamp(10px, 2.2vh, 26px);
  background:
    radial-gradient(80% 70% at 50% 12%, rgba(255, 255, 255, 0.65) 0%, rgba(255, 255, 255, 0) 58%),
    linear-gradient(180deg, #FFD75E 0%, #FFB227 38%, #FF8A1E 72%, #F07813 100%);
  border: clamp(2px, 0.34vmin, 4px) solid rgba(125, 58, 7, 0.35);
  box-shadow:
    0 0.52em 0 #C45B0A,
    0 0.9em 1.6em rgba(0, 0, 0, 0.32),
    inset 0 0.16em 0 rgba(255, 255, 255, 0.62),
    inset 0 -0.12em 0 rgba(166, 71, 4, 0.34);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
  z-index: 4;
}

.play-btn::before {
  content: "";
  position: absolute;
  inset: 7%;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.34);
  pointer-events: none;
}

.play-btn:active {
  transform: translate(-50%, -46%) scale(0.955);
  box-shadow:
    0 0.18em 0 #C45B0A,
    0 0.34em 0.8em rgba(0, 0, 0, 0.3),
    inset 0 0.12em 0 rgba(255, 255, 255, 0.55);
  filter: brightness(1.04);
}

.play-gloss {
  position: absolute;
  left: 9%;
  right: 9%;
  top: 8%;
  height: 36%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.64), rgba(255, 255, 255, 0.04));
  pointer-events: none;
}

.play-tri {
  position: absolute;
  left: 54%;
  top: 50%;
  width: 25%;
  height: 52%;
  transform: translate(-38%, -50%);
  clip-path: polygon(14% 0%, 100% 50%, 14% 100%);
  background: linear-gradient(180deg, #FFFFFF 0%, #FFF7E8 100%);
  filter: drop-shadow(0 0.09em 0.08em rgba(126, 58, 6, 0.4));
}

.play-ring {
  position: absolute;
  inset: -7%;
  border-radius: inherit;
  border: clamp(1px, 0.3vmin, 3px) solid rgba(255, 205, 104, 0.72);
  animation: playPulse 2.3s ease-out infinite;
  pointer-events: none;
}

@keyframes playPulse {
  0% { opacity: 0.8; transform: scale(0.97); }
  70% { opacity: 0; transform: scale(1.14); }
  100% { opacity: 0; transform: scale(1.14); }
}

.play-hint {
  position: absolute;
  left: 50%;
  top: 77.2%;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  padding: 0.46em 0.92em;
  border-radius: 999px;
  background: rgba(10, 29, 52, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 0.5em 1.4em rgba(0, 0, 0, 0.28);
  color: #FFF4E6;
  font-size: clamp(10px, 1.75vmin, 16px);
  font-weight: 800;
  letter-spacing: 0.08em;
  white-space: nowrap;
  pointer-events: auto;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 0.12s ease, background 0.12s ease;
}

.play-hint:active {
  transform: translate(-50%, -50%) scale(0.95);
  background: rgba(255, 138, 61, 0.9);
}

.play-hint .mp-icon {
  width: 1.2em;
  height: 1.2em;
  color: var(--orange-light);
}

/* 首页悬浮信息 */
.home-ui {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}

.player-chip {
  position: absolute;
  top: calc(14px + var(--safe-top));
  left: calc(16px + var(--safe-left));
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 14px 7px 7px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(18, 43, 73, 0.88), rgba(9, 26, 47, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow:
    0 10px 26px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.13);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  max-width: 46vw;
}

.avatar {
  width: clamp(32px, 5.6vh, 42px);
  height: clamp(32px, 5.6vh, 42px);
  flex: 0 0 auto;
  border-radius: 50%;
  object-fit: cover;
  background: #EAF7FF;
  border: 2px solid #FFB15A;
  box-shadow: 0 0 0 2px rgba(255, 138, 61, 0.24);
}

.player-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
}

.player-meta strong {
  display: block;
  max-width: 25vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(12px, 2.1vmin, 16px);
  font-weight: 900;
  color: #FFFFFF;
  letter-spacing: 0.01em;
}

.player-meta span {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: clamp(8px, 1.35vmin, 11px);
  color: #9FC4E2;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.player-meta .mp-icon {
  width: 1.25em;
  height: 1.25em;
  color: var(--orange-light);
}

.best-pill {
  position: absolute;
  top: calc(14px + var(--safe-top));
  right: calc(16px + var(--safe-right));
  display: flex;
  align-items: center;
  gap: 0.4em;
  min-height: clamp(34px, 5.8vh, 44px);
  padding: 0 0.85em;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(18, 43, 73, 0.88), rgba(9, 26, 47, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow:
    0 10px 26px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.13);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  white-space: nowrap;
}

.best-pill .mp-icon {
  width: clamp(16px, 2.6vh, 20px);
  height: clamp(16px, 2.6vh, 20px);
  color: #FFD25A;
}

.best-pill span {
  font-size: clamp(9px, 1.45vmin, 12px);
  color: #A9CBE6;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.best-pill strong {
  font-size: clamp(13px, 2.25vmin, 18px);
  color: #FFFFFF;
  font-weight: 1000;
  letter-spacing: 0.02em;
}

.stage-card {
  position: absolute;
  left: calc(16px + var(--safe-left));
  bottom: calc(15px + var(--safe-bottom));
  min-width: clamp(156px, 23vw, 220px);
  padding: 9px 14px 10px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(18, 43, 73, 0.92), rgba(8, 23, 43, 0.94));
  border: 1px solid rgba(255, 177, 90, 0.42);
  box-shadow:
    0 14px 32px rgba(0, 0, 0, 0.36),
    inset 0 1px 0 rgba(255, 255, 255, 0.13);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  text-align: left;
}

.stage-kicker {
  font-size: clamp(7px, 1.1vmin, 9px);
  font-weight: 900;
  letter-spacing: 0.26em;
  color: #FFC276;
  line-height: 1;
  margin-bottom: 0.55em;
}

.stage-name {
  display: flex;
  align-items: baseline;
  gap: 0.45em;
  line-height: 1.05;
}

.stage-name span {
  font-size: clamp(9px, 1.35vmin, 11px);
  font-weight: 800;
  color: #9FC4E2;
  white-space: nowrap;
}

.stage-name strong {
  font-size: clamp(15px, 2.5vmin, 20px);
  font-weight: 1000;
  color: #FFFFFF;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.stage-goal {
  display: flex;
  align-items: center;
  gap: 0.3em;
  margin-top: 0.5em;
  font-size: clamp(9px, 1.4vmin, 12px);
  font-weight: 700;
  color: #C9E4F8;
  white-space: nowrap;
}

.stage-goal .mp-icon {
  width: 1.25em;
  height: 1.25em;
  color: var(--orange-light);
}

.stage-goal b {
  color: #FFD25A;
  font-size: 1.12em;
  font-weight: 1000;
}

.home-tip {
  position: absolute;
  right: calc(16px + var(--safe-right));
  bottom: calc(18px + var(--safe-bottom));
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.45em 0.8em;
  border-radius: 999px;
  background: rgba(8, 23, 43, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #D8ECFC;
  font-size: clamp(8px, 1.3vmin, 11px);
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.home-tip .mp-icon {
  width: 1.3em;
  height: 1.3em;
  color: var(--orange-light);
}

.home-snow {
  position: absolute;
  inset: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ============================================================
   游戏画面
   ============================================================ */

.game {
  background: #0A1A2E;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.game-hud {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  padding: 0;
}

.hud-left {
  position: absolute;
  left: calc(13px + var(--safe-left));
  top: calc(12px + var(--safe-top));
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(38px, 6.2vh, 48px);
  height: clamp(38px, 6.2vh, 48px);
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(18, 43, 73, 0.82), rgba(8, 23, 43, 0.9));
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow:
    0 8px 18px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.14);
  color: #FFFFFF;
  pointer-events: auto;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform 0.12s ease, background 0.12s ease;
}

.icon-btn:active {
  transform: scale(0.92);
  background: rgba(255, 138, 61, 0.9);
}

.icon-btn .mp-icon {
  width: 48%;
  height: 48%;
}

.mini-player {
  display: flex;
  align-items: center;
  gap: 7px;
  height: clamp(38px, 6.2vh, 48px);
  padding: 4px 12px 4px 5px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(18, 43, 73, 0.82), rgba(8, 23, 43, 0.9));
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.mini-player img {
  width: clamp(28px, 4.8vh, 38px);
  height: clamp(28px, 4.8vh, 38px);
  border-radius: 50%;
  border: 1.5px solid #FFB15A;
  object-fit: cover;
  background: #EAF7FF;
}

.mini-player div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  text-align: left;
}

.mini-player strong {
  max-width: 92px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(10px, 1.55vmin, 12px);
  font-weight: 900;
  color: #FFFFFF;
}

.mini-player span {
  font-size: clamp(7px, 1.05vmin, 9px);
  color: #9FC4E2;
  font-weight: 700;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.hud-center {
  position: absolute;
  left: 50%;
  top: calc(14px + var(--safe-top));
  transform: translateX(-50%);
  width: min(38vw, 400px);
  min-width: 190px;
}

.hud-stage-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  padding: 0 3px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
}

.hud-stage-line span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(9px, 1.45vmin, 12px);
  font-weight: 800;
  color: rgba(255, 255, 255, 0.9);
  letter-spacing: 0.04em;
}

.hud-stage-line b {
  flex: 0 0 auto;
  font-size: clamp(10px, 1.55vmin, 13px);
  font-weight: 1000;
  color: #FFFFFF;
  letter-spacing: 0.02em;
}

.hud-progress {
  position: relative;
  height: clamp(6px, 1.05vh, 9px);
  border-radius: 999px;
  background: rgba(8, 26, 47, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.hud-progress i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  transform: scaleX(0);
  transform-origin: 0 50%;
  background: linear-gradient(90deg, #FFD25A 0%, #FF9A3F 55%, #FF7A22 100%);
  box-shadow: 0 0 12px rgba(255, 160, 60, 0.55);
  transition: transform 0.12s linear;
}

.hud-right {
  position: absolute;
  right: calc(13px + var(--safe-right));
  top: calc(12px + var(--safe-top));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}

.speed-chip {
  display: flex;
  align-items: center;
  gap: 0.28em;
  min-height: clamp(34px, 5.4vh, 42px);
  padding: 0 0.72em;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(18, 43, 73, 0.86), rgba(8, 23, 43, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  white-space: nowrap;
}

.speed-chip .mp-icon {
  width: clamp(15px, 2.4vh, 19px);
  height: clamp(15px, 2.4vh, 19px);
  color: var(--orange-light);
}

.speed-chip strong {
  font-size: clamp(16px, 2.7vmin, 21px);
  font-weight: 1000;
  color: #FFFFFF;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.speed-chip span {
  font-size: clamp(7px, 1.1vmin, 9px);
  font-weight: 800;
  color: #9FC4E2;
  letter-spacing: 0.06em;
}

.best-chip {
  display: flex;
  align-items: center;
  gap: 0.32em;
  padding: 0.24em 0.62em;
  border-radius: 999px;
  background: rgba(8, 23, 43, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #C9E4F8;
  font-size: clamp(8px, 1.2vmin, 10px);
  font-weight: 800;
  letter-spacing: 0.08em;
  white-space: nowrap;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.best-chip .mp-icon {
  width: 1.15em;
  height: 1.15em;
  color: #FFD25A;
}

.best-chip b {
  color: #FFFFFF;
  font-size: 1.1em;
  font-weight: 1000;
  letter-spacing: 0.01em;
}

.touch-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(14px + var(--safe-bottom));
  z-index: 11;
  display: flex;
  justify-content: space-between;
  padding: 0 calc(17px + var(--safe-right)) 0 calc(17px + var(--safe-left));
  pointer-events: none;
}

.steer-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(46px, 8.6vh, 66px);
  height: clamp(46px, 8.6vh, 66px);
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(17, 41, 70, 0.48), rgba(7, 22, 42, 0.62));
  border: 1.5px solid rgba(255, 255, 255, 0.28);
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
  color: #FFFFFF;
  pointer-events: auto;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 0.1s ease, background 0.1s ease, border-color 0.1s ease;
}

.steer-btn .mp-icon {
  width: 52%;
  height: 52%;
  color: #FFFFFF;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
}

.steer-btn:active,
.steer-btn.is-down {
  transform: scale(0.93);
  background: linear-gradient(180deg, rgba(255, 168, 73, 0.92), rgba(237, 111, 24, 0.92));
  border-color: rgba(255, 236, 190, 0.8);
}

/* 倒计时 */
.countdown {
  position: absolute;
  inset: 0;
  z-index: 22;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  background: radial-gradient(circle at 50% 56%, rgba(8, 25, 48, 0) 0%, rgba(8, 25, 48, 0.12) 44%, rgba(6, 20, 39, 0.42) 100%);
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

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

.count-number {
  display: block;
  font-size: clamp(82px, 21vh, 190px);
  line-height: 0.9;
  font-weight: 1000;
  color: #FFFFFF;
  letter-spacing: -0.04em;
  text-shadow:
    0 0.055em 0 #D96312,
    0 0.09em 0.16em rgba(0, 0, 0, 0.42),
    0 0 0.32em rgba(255, 164, 66, 0.55);
  -webkit-text-stroke: clamp(2px, 0.55vh, 6px) #0D2340;
  paint-order: stroke fill;
}

.count-number.is-pop {
  animation: countPop 0.58s cubic-bezier(0.18, 1.4, 0.36, 1) both;
}

@keyframes countPop {
  0% { opacity: 0; transform: scale(1.65) rotate(-4deg); }
  24% { opacity: 1; transform: scale(0.96) rotate(1deg); }
  55% { transform: scale(1.04) rotate(-0.5deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}

.count-label {
  display: inline-block;
  padding: 0.5em 1.15em;
  border-radius: 999px;
  background: rgba(10, 28, 50, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #FFD9AE;
  font-size: clamp(11px, 2.1vh, 18px);
  font-weight: 900;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 0.18s ease;
}

.count-label.is-go {
  color: #0D2340;
  background: linear-gradient(180deg, #FFD25A, #FF9A3F);
  border-color: rgba(255, 244, 210, 0.8);
  letter-spacing: 0.18em;
  text-indent: 0.18em;
}

/* ============================================================
   弹层 / 结算 / 暂停
   ============================================================ */

.modal-layer {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    calc(14px + var(--safe-top))
    calc(14px + var(--safe-right))
    calc(14px + var(--safe-bottom))
    calc(14px + var(--safe-left));
  background: rgba(4, 13, 25, 0.64);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.24s ease, visibility 0.24s ease;
}

.modal-layer.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal-card {
  position: relative;
  width: min(86vw, 430px);
  max-height: 88vh;
  overflow: auto;
  padding: clamp(18px, 3.4vh, 30px) clamp(18px, 3vw, 28px) clamp(18px, 3vh, 26px);
  border-radius: clamp(20px, 3.2vh, 28px);
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(255, 138, 61, 0.16) 0%, rgba(255, 138, 61, 0) 58%),
    linear-gradient(180deg, #17385C 0%, #0C2340 62%, #081B33 100%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow:
    0 26px 74px rgba(0, 0, 0, 0.52),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
  text-align: center;
  transform: translateY(16px) scale(0.955);
  transition: transform 0.3s cubic-bezier(0.18, 1.16, 0.4, 1);
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.modal-layer.open .modal-card {
  transform: translateY(0) scale(1);
}

.modal-card::before {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  top: 0;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 210, 90, 0), rgba(255, 210, 90, 0.9), rgba(255, 210, 90, 0));
  pointer-events: none;
}

.pause-card { width: min(82vw, 380px); }

.modal-kicker {
  font-size: clamp(8px, 1.3vh, 11px);
  font-weight: 1000;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  color: #FFB15A;
  line-height: 1;
}

.modal-card h2 {
  margin: 0.42em 0 0.18em;
  font-size: clamp(24px, 4.4vh, 36px);
  line-height: 1.1;
  font-weight: 1000;
  letter-spacing: 0.015em;
  color: #FFFFFF;
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.24);
}

.modal-sub {
  margin: 0 auto 1.15em;
  max-width: 27em;
  color: #A9CBE6;
  font-size: clamp(11px, 1.85vh, 14px);
  line-height: 1.55;
  font-weight: 500;
}

.result-medal {
  display: flex;
  align-items: center;
  justify-content: center;
  width: clamp(52px, 8.6vh, 70px);
  height: clamp(52px, 8.6vh, 70px);
  margin: 0 auto 0.65em;
  border-radius: 50%;
  background: linear-gradient(160deg, #FFD25A 0%, #FF9A3F 52%, #F2761B 100%);
  border: 2px solid rgba(255, 244, 210, 0.62);
  box-shadow:
    0 8px 22px rgba(255, 120, 30, 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.5);
  color: #0D2340;
}

.result-medal .mp-icon {
  width: 55%;
  height: 55%;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.3));
}

.result-medal.is-crash {
  background: linear-gradient(160deg, #B8DCF5 0%, #78B4E2 60%, #4A86BB 100%);
  border-color: rgba(234, 247, 255, 0.68);
  color: #0D2340;
  box-shadow: 0 8px 22px rgba(70, 140, 200, 0.28), inset 0 2px 0 rgba(255, 255, 255, 0.5);
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 0 0 1.1em;
  padding: 0.7em 0.2em;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.result-stats > div {
  display: flex;
  flex-direction: column;
  gap: 0.35em;
  padding: 0 0.2em;
  position: relative;
}

.result-stats > div + div::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10%;
  bottom: 10%;
  width: 1px;
  background: rgba(255, 255, 255, 0.12);
}

.result-stats span {
  font-size: clamp(8px, 1.3vh, 10px);
  font-weight: 800;
  letter-spacing: 0.16em;
  color: #8FB8D8;
}

.result-stats strong {
  font-size: clamp(15px, 2.4vh, 21px);
  font-weight: 1000;
  color: #FFFFFF;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  width: 100%;
  min-height: clamp(44px, 7.2vh, 58px);
  padding: 0 1em;
  border-radius: clamp(13px, 1.8vh, 17px);
  font-size: clamp(14px, 2.25vh, 18px);
  font-weight: 1000;
  letter-spacing: 0.03em;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease, background 0.12s ease;
}

.btn .mp-icon {
  width: 1.22em;
  height: 1.22em;
}

.btn-primary {
  background:
    radial-gradient(90% 80% at 50% 0%, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0) 62%),
    linear-gradient(180deg, #FFD25A 0%, #FFA12C 45%, #FF7A22 100%);
  border: 1px solid rgba(255, 255, 255, 0.48);
  color: #12243D;
  box-shadow:
    0 0.32em 0 #B4510C,
    0 0.7em 1.5em rgba(255, 120, 30, 0.3),
    inset 0 0.12em 0 rgba(255, 255, 255, 0.5);
}

.btn-primary:active {
  transform: translateY(0.28em) scale(0.99);
  box-shadow:
    0 0.06em 0 #B4510C,
    0 0.2em 0.6em rgba(255, 120, 30, 0.24);
  filter: brightness(1.03);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.065);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #EAF7FF;
}

.btn-ghost:active {
  background: rgba(255, 255, 255, 0.12);
  transform: scale(0.985);
}

.btn-row {
  display: flex;
  gap: 9px;
  margin-top: 10px;
}

.btn-row .btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 0 0.55em;
  font-size: clamp(12px, 1.9vh, 15px);
  letter-spacing: 0.01em;
}

.btn-row .btn .mp-icon {
  width: 1.15em;
  height: 1.15em;
}

.btn-link {
  min-height: 42px;
  margin-top: 7px;
  background: transparent;
  color: #8FB8D8;
  font-size: clamp(11px, 1.65vh, 13px);
  font-weight: 800;
  letter-spacing: 0.08em;
}

.btn-link:active { color: #FFFFFF; }

.sound-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  min-height: 34px;
  margin-top: 10px;
  padding: 0 0.85em;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.13);
  color: #A9CBE6;
  font-size: clamp(9px, 1.35vh, 11px);
  font-weight: 800;
  letter-spacing: 0.06em;
}

.sound-btn .mp-icon {
  width: 1.35em;
  height: 1.35em;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(88px + var(--safe-bottom));
  z-index: 50;
  transform: translate(-50%, 12px);
  padding: 0.6em 1em;
  border-radius: 999px;
  background: rgba(8, 23, 43, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #EAF7FF;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

/* ============================================================
   响应式：横屏短屏 / 竖屏兜底 / 超宽屏
   ============================================================ */

@media (max-height: 500px) {
  .player-chip { padding: 5px 11px 5px 5px; gap: 7px; }
  .avatar { width: 30px; height: 30px; }
  .player-meta strong { font-size: 11px; max-width: 22vw; }
  .player-meta span { font-size: 8px; }
  .best-pill { min-height: 32px; padding: 0 0.7em; }
  .best-pill span { font-size: 8px; }
  .best-pill strong { font-size: 12px; }
  .title-ribbon { top: 30.6%; padding: 0.42em 0.95em 0.38em; }
  .title-cn { font-size: 14px; }
  .title-sub { font-size: 7px; letter-spacing: 0.14em; }
  .play-hint { top: 77.8%; font-size: 9px; padding: 0.38em 0.72em; }
  .stage-card { min-width: 148px; padding: 7px 11px 8px; border-radius: 13px; }
  .stage-kicker { display: none; }
  .stage-name span { font-size: 9px; }
  .stage-name strong { font-size: 14px; }
  .stage-goal { font-size: 10px; margin-top: 0.32em; }
  .home-tip { font-size: 8px; bottom: 14px; padding: 0.35em 0.65em; }
  .hud-stage-line { margin-bottom: 4px; }
  .hud-stage-line span { font-size: 10px; }
  .hud-stage-line b { font-size: 11px; }
  .hud-center { top: calc(12px + var(--safe-top)); }
  .mini-player span { display: none; }
  .mini-player { padding-right: 9px; }
  .mini-player strong { font-size: 10px; max-width: 72px; }
  .speed-chip { min-height: 32px; }
  .speed-chip strong { font-size: 16px; }
  .best-chip { display: none; }
  .modal-card { padding-top: 16px; padding-bottom: 16px; }
  .modal-card h2 { font-size: 23px; }
  .modal-sub { margin-bottom: 0.8em; }
  .result-medal { width: 46px; height: 46px; margin-bottom: 0.45em; }
  .result-stats { margin-bottom: 0.8em; padding: 0.55em 0.15em; }
  .result-stats strong { font-size: 16px; }
  .btn { min-height: 42px; }
  .btn-link { min-height: 34px; margin-top: 2px; }
  .btn-row { margin-top: 7px; }
  .touch-controls { bottom: calc(10px + var(--safe-bottom)); }
  .steer-btn { width: 46px; height: 46px; }
}

@media (max-width: 620px) and (orientation: landscape) {
  .mini-player div { display: none; }
  .mini-player { padding-right: 5px; }
  .hud-center { min-width: 150px; }
}

@media (max-width: 700px) and (orientation: portrait) {
  .home-stage {
    width: max(100vw, 150vh);
    height: 100vh;
    aspect-ratio: auto;
    border-radius: 0;
    box-shadow: none;
  }
  .player-meta span { display: none; }
  .player-chip { max-width: 56vw; }
  .home-tip { display: none; }
  .stage-card { min-width: 148px; }
  .hud-center { width: 44vw; min-width: 150px; }
  .mini-player div { display: none; }
  .mini-player { padding-right: 5px; }
  .count-number { font-size: 26vh; }
}

@media (prefers-reduced-motion: reduce) {
  .play-ring { animation: none; opacity: 0.4; }
  .screen { transition: none; }
  .modal-card { transition: none; }
  .count-number.is-pop { animation-duration: 0.01ms; }
}
