:root {
  --orange: #FF8A3D;
  --orange-deep: #EF6A16;
  --orange-soft: #FFDFC7;
  --ink: #15343D;
  --ink-soft: #5C7A83;
  --ink-faint: #8AA3AA;
  --snow-card: rgba(255, 255, 255, 0.94);
  --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);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0C2831;
  overscroll-behavior: none;
}

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

button { font-family: inherit; }

.game {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  background: #0C2831;
}

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

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

.stat {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 108px;
  padding: 7px 13px 8px 10px;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(180deg, rgba(17, 51, 62, .80), rgba(10, 36, 45, .64));
  border: 1px solid rgba(255, 255, 255, .26);
  box-shadow: 0 8px 22px rgba(7, 31, 41, .26), inset 0 1px 0 rgba(255, 255, 255, .16);
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
}
.stat-right { flex-direction: row-reverse; text-align: right; }

.stat-icon {
  width: 22px;
  height: 22px;
  flex: none;
  color: #FFC08A;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .2));
}
.stat-text { display: flex; flex-direction: column; gap: 1px; line-height: 1; }
.stat-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .18em;
  color: rgba(255, 255, 255, .62);
}
.stat-value {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stat.pulse { animation: stat-pulse .32s ease; }

@keyframes stat-pulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.08); box-shadow: 0 8px 26px rgba(255, 138, 61, .38); }
  100% { transform: scale(1); }
}

/* ---------- 左右操作 ---------- */
.steer-layer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 110px;
  z-index: 19;
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s ease;
}
.steer-layer.show { opacity: 1; }

.steer {
  position: absolute;
  bottom: calc(14px + var(--safe-bottom));
  width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .44);
  background: radial-gradient(circle at 32% 24%, rgba(255, 255, 255, .34), rgba(255, 255, 255, .12));
  box-shadow: 0 6px 18px rgba(7, 31, 41, .22), inset 0 1px 0 rgba(255, 255, 255, .3);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  pointer-events: auto;
  touch-action: none;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.steer.left { left: calc(14px + var(--safe-left)); }
.steer.right { right: calc(14px + var(--safe-right)); }
.steer .mp-icon { width: 30px; height: 30px; }
.steer:active,
.steer.pressed {
  transform: scale(.92);
  background: rgba(255, 138, 61, .8);
  border-color: rgba(255, 255, 255, .75);
}

/* ---------- 覆盖层 ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(12px + var(--safe-top)) calc(14px + var(--safe-right)) calc(12px + var(--safe-bottom)) calc(14px + var(--safe-left));
  background: radial-gradient(ellipse at 50% 54%, rgba(7, 28, 36, .04) 0%, rgba(7, 28, 36, .42) 100%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .28s ease, visibility .28s ease;
}
.overlay.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.start-overlay {
  background: radial-gradient(ellipse at 50% 54%, rgba(7, 28, 36, .02) 0%, rgba(7, 28, 36, .28) 100%);
}

.card {
  position: relative;
  width: min(94vw, 810px);
  border-radius: 28px;
  color: var(--ink);
  background:
    linear-gradient(155deg, rgba(255, 255, 255, .97), rgba(236, 248, 253, .92));
  border: 1px solid rgba(255, 255, 255, .95);
  box-shadow:
    0 28px 70px rgba(6, 31, 41, .32),
    0 2px 0 rgba(255, 255, 255, .9) inset,
    0 0 0 1px rgba(180, 218, 231, .25);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  overflow: hidden;
}
.overlay.show .card { animation: card-in .38s cubic-bezier(.18, .9, .28, 1.04) both; }

@keyframes card-in {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- 开始页 ---------- */
.start-card {
  display: grid;
  grid-template-columns: minmax(0, 1.22fr) minmax(218px, .78fr);
  align-items: center;
  gap: clamp(16px, 3.2vmin, 34px);
  padding: clamp(19px, 3.6vmin, 36px);
}
.start-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 92% -14%, rgba(255, 138, 61, .22), transparent 46%),
    radial-gradient(circle at -8% 122%, rgba(122, 202, 236, .26), transparent 52%);
  pointer-events: none;
}
.start-main,
.start-side { position: relative; z-index: 1; }
.start-main { min-width: 0; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px 5px 8px;
  border-radius: 999px;
  background: rgba(255, 138, 61, .13);
  border: 1px solid rgba(255, 138, 61, .18);
  color: #D55E10;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .15em;
  white-space: nowrap;
}
.eyebrow .mp-icon { width: 15px; height: 15px; }

.title {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 10px 0 0;
  font-size: clamp(38px, 7.4vmin, 68px);
  line-height: 1.02;
  font-weight: 900;
  letter-spacing: -.035em;
  color: #123039;
  text-shadow: 0 2px 0 rgba(255, 255, 255, .85);
}
.title-num {
  margin-top: .13em;
  padding: .13em .32em .19em;
  border-radius: 10px;
  background: linear-gradient(158deg, #FFA35E, #F1711F);
  color: #fff;
  font-size: .32em;
  line-height: 1;
  letter-spacing: 0;
  box-shadow: 0 7px 15px rgba(240, 110, 26, .32), inset 0 1px 0 rgba(255, 255, 255, .42);
}

.tagline {
  margin: 11px 0 0;
  font-size: clamp(12px, 2.1vmin, 15px);
  line-height: 1.68;
  color: var(--ink-soft);
  font-weight: 500;
}

.hints {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: clamp(12px, 2.6vmin, 21px);
}
.hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #69868E;
  white-space: nowrap;
}
.hint .mp-icon { width: 16px; height: 16px; color: var(--orange); }

.start-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-left: clamp(15px, 2.8vmin, 30px);
  border-left: 1px dashed rgba(21, 51, 61, .17);
}

.best-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 14px;
  background: linear-gradient(135deg, #FFF4EA, #FFE1C9);
  border: 1px solid #FFD0AC;
  color: #A54D0F;
  font-size: 11px;
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8);
}
.best-pill .mp-icon { width: 18px; height: 18px; color: #EF7420; flex: none; }
.best-pill strong {
  margin-left: auto;
  font-size: 16px;
  font-weight: 900;
  color: #D75D0E;
  font-variant-numeric: tabular-nums;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 54px;
  padding: 0 18px;
  border: 0;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: .03em;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .1s ease, box-shadow .15s ease, filter .15s ease;
}
.btn .mp-icon { width: 22px; height: 22px; }
.btn.primary {
  color: #fff;
  background: linear-gradient(180deg, #FFA55F, #F5731F);
  box-shadow:
    0 13px 26px rgba(240, 110, 26, .34),
    inset 0 1px 0 rgba(255, 255, 255, .44),
    inset 0 -2px 0 rgba(190, 73, 4, .18);
}
.btn.primary:active {
  transform: translateY(2px) scale(.985);
  box-shadow: 0 6px 14px rgba(240, 110, 26, .3), inset 0 1px 0 rgba(255, 255, 255, .38);
}
.btn.primary:focus-visible {
  outline: 3px solid rgba(255, 138, 61, .45);
  outline-offset: 3px;
}

.side-note {
  margin: -2px 0 0;
  text-align: center;
  font-size: 10px;
  line-height: 1.5;
  color: var(--ink-faint);
}

/* ---------- 结束页 ---------- */
.over-card {
  width: min(92vw, 410px);
  padding: clamp(21px, 4.2vmin, 34px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  overflow: visible;
}
.crash-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #EF7524;
  background: radial-gradient(circle at 35% 28%, #FFE7D3, #FFD2AE);
  border: 1px solid #FFC79D;
  box-shadow: 0 8px 18px rgba(239, 117, 36, .18), inset 0 1px 0 #fff;
}
.crash-icon .mp-icon { width: 30px; height: 30px; }

.over-title {
  margin: 10px 0 0;
  font-size: clamp(26px, 5.4vmin, 35px);
  font-weight: 900;
  letter-spacing: -.02em;
  color: #14323B;
}
.over-sub {
  margin: 5px 0 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-faint);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  width: 100%;
  margin: 17px 0 17px;
  padding: 13px 6px;
  border-radius: 16px;
  background: rgba(21, 51, 61, .055);
  border: 1px solid rgba(21, 51, 61, .05);
}
.result { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.result span {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .15em;
  color: var(--ink-faint);
}
.result strong {
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  white-space: nowrap;
}
.result strong.accent { color: #ED6F1D; }
.btn.wide { width: 100%; }

.small-note {
  margin: 10px 0 0;
  font-size: 10px;
  color: var(--ink-faint);
}

.new-best {
  position: absolute;
  top: -12px;
  left: 50%;
  z-index: 2;
  padding: 5px 14px;
  border-radius: 999px;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .16em;
  white-space: nowrap;
  background: linear-gradient(90deg, #FF9C4F, #F06A18);
  box-shadow: 0 7px 16px rgba(240, 106, 24, .32), inset 0 1px 0 rgba(255, 255, 255, .4);
  transform: translateX(-50%) rotate(-2deg);
  opacity: 0;
  transition: opacity .25s ease;
}
.new-best.show { opacity: 1; animation: best-pop .45s cubic-bezier(.2, 1.4, .4, 1) both; }

@keyframes best-pop {
  from { opacity: 0; transform: translateX(-50%) rotate(-2deg) scale(.7); }
  to { opacity: 1; transform: translateX(-50%) rotate(-2deg) scale(1); }
}

/* ---------- 小屏横屏 ---------- */
@media (max-width: 700px) {
  .start-card {
    grid-template-columns: 1fr;
    gap: 13px;
    padding: 18px 19px 19px;
    width: min(93vw, 470px);
  }
  .start-side {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    gap: 9px;
    padding-left: 0;
    padding-top: 12px;
    border-left: 0;
    border-top: 1px dashed rgba(21, 51, 61, .17);
  }
  .best-pill { grid-column: 1 / -1; }
  .start-side .btn { grid-column: 1 / -1; }
  .side-note { grid-column: 1 / -1; display: none; }
  .title { font-size: clamp(34px, 8.6vmin, 52px); }
  .tagline { font-size: 12px; }
  .hints { margin-top: 12px; }
}

@media (max-height: 470px) {
  .hud { top: calc(7px + var(--safe-top)); }
  .stat { min-width: 96px; padding: 6px 11px 7px 9px; gap: 7px; border-radius: 13px; }
  .stat-icon { width: 19px; height: 19px; }
  .stat-value { font-size: 17px; }
  .stat-label { font-size: 8px; }
  .steer { width: 52px; height: 52px; bottom: calc(11px + var(--safe-bottom)); }
  .steer .mp-icon { width: 27px; height: 27px; }
  .start-card { padding-top: 15px; padding-bottom: 15px; }
  .title { font-size: clamp(30px, 8.2vmin, 44px); }
  .tagline { margin-top: 7px; line-height: 1.55; }
  .hints { margin-top: 9px; }
  .start-side { gap: 9px; padding-top: 10px; }
  .best-pill { padding: 7px 10px; }
  .btn { min-height: 47px; border-radius: 14px; font-size: 15px; }
  .over-card { padding-top: 19px; padding-bottom: 19px; }
  .crash-icon { width: 46px; height: 46px; }
  .crash-icon .mp-icon { width: 25px; height: 25px; }
  .over-title { font-size: 25px; margin-top: 7px; }
  .result-grid { margin: 12px 0; padding: 10px 4px; }
  .result strong { font-size: 16px; }
  .small-note { margin-top: 7px; }
}

@media (max-height: 390px) and (max-width: 700px) {
  .title { font-size: 29px; }
  .tagline { display: none; }
  .hints { margin-top: 8px; }
  .eyebrow { font-size: 9px; padding: 4px 9px 4px 7px; }
  .start-card { gap: 9px; padding: 13px 16px 14px; }
  .start-side { padding-top: 8px; }
  .side-note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .overlay.show .card,
  .new-best.show { animation: none; }
  .hud, .steer-layer, .overlay { transition-duration: .01ms; }
}
