/* 滑雪躲树13 — H5 街机跑酷 */
* { box-sizing: border-box; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  color: #102a43;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

button { font-family: inherit; }

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

.game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.scene-tint {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(110% 62% at 50% 105%, rgba(9, 34, 56, 0.22), transparent 62%),
    linear-gradient(180deg, rgba(9, 30, 50, 0.08), transparent 18%);
  z-index: 1;
}

/* ---------------- HUD ---------------- */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 4;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.app[data-state="ready"] .hud,
.app[data-state="crashing"] .hud {
  opacity: 0;
  transform: translateY(-10px);
}

.distance-card {
  min-width: 138px;
  padding: 9px 15px 10px;
  border-radius: 19px;
  color: #fff;
  background: linear-gradient(155deg, rgba(12, 38, 61, 0.78), rgba(12, 38, 61, 0.52));
  border: 1px solid rgba(255, 255, 255, 0.24);
  box-shadow: 0 10px 26px rgba(6, 27, 45, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
}

.hud-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: rgba(255, 255, 255, 0.66);
  margin-bottom: 2px;
}

.distance-line {
  display: flex;
  align-items: baseline;
  gap: 3px;
  line-height: 1;
}

.distance-line #distance {
  font-size: 37px;
  font-weight: 900;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.22);
}

.distance-line .unit {
  font-size: 13px;
  font-weight: 800;
  color: #ffc59f;
  letter-spacing: 0.02em;
}

.best-line {
  margin-top: 3px;
  font-size: 10.5px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.64);
  letter-spacing: 0.03em;
}

.best-line b {
  color: #ffb27a;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.hud-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(155deg, rgba(12, 38, 61, 0.7), rgba(12, 38, 61, 0.46));
  box-shadow: 0 8px 20px rgba(6, 27, 45, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  pointer-events: auto;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s ease;
  touch-action: manipulation;
}

.icon-btn:active { transform: scale(0.92); }
.icon-btn .mp-icon { width: 21px; height: 21px; }
.icon-btn .icon-sound-off { display: none; }
.app.is-muted .icon-sound-on { display: none; }
.app.is-muted .icon-sound-off { display: inline-block; }

.speed-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 112px;
  padding: 8px 12px 11px;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(155deg, rgba(12, 38, 61, 0.58), rgba(12, 38, 61, 0.36));
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 20px rgba(6, 27, 45, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.speed-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff8a3d;
  box-shadow: 0 0 0 4px rgba(255, 138, 61, 0.18);
  flex: 0 0 auto;
}

.speed-value {
  display: flex;
  align-items: baseline;
  gap: 2px;
  line-height: 1;
}

.speed-value b {
  font-size: 17px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.speed-value small {
  font-size: 8.5px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.68);
}

.speed-track {
  display: block;
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 4px;
  height: 2px;
  border-radius: 2px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.18);
}

.speed-track i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: linear-gradient(90deg, #ffd0a6, #ff8a3d);
  transition: width 0.2s linear;
}

/* ---------------- 操作提示 ---------------- */
.hint {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(9, 30, 50, 0.52);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 22px rgba(4, 18, 32, 0.22);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transform: translate(-50%, 10px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
  white-space: nowrap;
}

.hint .mp-icon { width: 15px; height: 15px; color: #ffc59f; }
.hint.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- 通用遮罩 ---------------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.32s ease, visibility 0.32s ease;
}

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

/* ---------------- 开始页 ---------------- */
.start-overlay {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  background:
    radial-gradient(95% 46% at 50% 6%, rgba(255, 255, 255, 0.16), transparent 62%),
    linear-gradient(180deg, rgba(5, 22, 38, 0.48) 0%, rgba(5, 22, 38, 0.2) 24%, rgba(6, 24, 40, 0.04) 43%, rgba(7, 27, 46, 0) 55%, rgba(7, 27, 46, 0.1) 63%, rgba(6, 23, 39, 0.74) 87%, rgba(5, 21, 36, 0.92) 100%);
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.start-overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.start-content {
  width: 100%;
  max-width: 480px;
  height: 100%;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 30px) 22px calc(env(safe-area-inset-bottom, 0px) + 24px);
  display: flex;
  flex-direction: column;
}

.start-top {
  padding-top: clamp(38px, 9vh, 84px);
  animation: rise-in 0.7s cubic-bezier(0.2, 0.8, 0.25, 1) both;
}

.game-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(9, 32, 53, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.26);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.kicker-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #ffb27a;
  box-shadow: 0 0 8px rgba(255, 178, 122, 0.9);
}

.game-title {
  margin: 16px 0 0;
  filter: drop-shadow(0 2px 18px rgba(5, 22, 38, 0.45));
  font-size: clamp(48px, 14.2vw, 64px);
  line-height: 0.98;
  font-weight: 900;
  letter-spacing: -0.055em;
  color: #fff;
  text-shadow: 0 3px 0 rgba(17, 56, 84, 0.18), 0 14px 34px rgba(4, 25, 43, 0.36);
  white-space: nowrap;
}

.title-num {
  display: inline-block;
  margin-left: 0.06em;
  color: #ff9a52;
  text-shadow: 0 3px 0 rgba(154, 64, 4, 0.2), 0 12px 30px rgba(255, 122, 36, 0.4);
}

.game-sub {
  margin: 14px 0 0;
  font-size: 14px;
  line-height: 1.7;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.88);
  letter-spacing: 0.04em;
  text-shadow: 0 2px 12px rgba(4, 25, 43, 0.3);
}

.start-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 13px;
  animation: rise-in 0.8s 0.12s cubic-bezier(0.2, 0.8, 0.25, 1) both;
}

.best-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: rgba(9, 32, 53, 0.36);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.best-badge .mp-icon { width: 15px; height: 15px; color: #ffb27a; }
.best-badge b {
  color: #ffc59f;
  font-size: 13px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

/* ---------------- 主按钮 ---------------- */
.primary-btn {
  position: relative;
  width: 100%;
  max-width: 360px;
  min-height: 60px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 24px;
  border: 0;
  border-radius: 20px;
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, #ffa85e 0%, #ff8a3d 44%, #f5701f 100%);
  box-shadow:
    0 14px 30px rgba(194, 78, 12, 0.36),
    0 4px 0 #c95813,
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.primary-btn .mp-icon { width: 21px; height: 21px; }
.primary-btn:active {
  transform: translateY(3px) scale(0.985);
  box-shadow:
    0 6px 16px rgba(194, 78, 12, 0.3),
    0 1px 0 #c95813,
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
  filter: brightness(0.98);
}

@media (hover: hover) {
  .primary-btn:hover { filter: brightness(1.04); }
  .icon-btn:hover { background: rgba(12, 38, 61, 0.62); }
}

.control-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.62);
  text-align: center;
  letter-spacing: 0.02em;
}

.control-tip .mp-icon { width: 14px; height: 14px; flex: 0 0 auto; opacity: 0.8; }

/* ---------------- 结算 ---------------- */
.result-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px calc(env(safe-area-inset-bottom, 0px) + 24px);
  background: rgba(4, 19, 34, 0.44);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.result-card {
  position: relative;
  width: min(90vw, 366px);
  max-height: calc(100vh - 60px);
  overflow: auto;
  padding: 25px 22px 22px;
  border-radius: 30px;
  background: linear-gradient(180deg, #ffffff 0%, #f3faff 100%);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 28px 70px rgba(2, 18, 32, 0.42), inset 0 1px 0 #fff;
  transform: translateY(26px) scale(0.955);
  opacity: 0;
  touch-action: pan-y;
  transition: transform 0.38s cubic-bezier(0.2, 0.9, 0.25, 1), opacity 0.32s ease;
}

.result-overlay.is-visible .result-card {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.result-card::before {
  content: "";
  position: absolute;
  top: -80px;
  right: -60px;
  width: 210px;
  height: 210px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 138, 61, 0.26), rgba(255, 138, 61, 0) 68%);
  pointer-events: none;
}

.result-card::after {
  content: "";
  position: absolute;
  left: -70px;
  bottom: -90px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(86, 170, 220, 0.16), rgba(86, 170, 220, 0) 70%);
  pointer-events: none;
}

.record-badge {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 1;
  padding: 5px 11px;
  border-radius: 999px;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  background: linear-gradient(160deg, #ffa85e, #f26b16);
  box-shadow: 0 6px 14px rgba(222, 91, 15, 0.34);
  transform: rotate(3deg) scale(0);
  opacity: 0;
  transition: transform 0.4s 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s 0.18s ease;
}

.result-card.has-record .record-badge {
  transform: rotate(3deg) scale(1);
  opacity: 1;
}

.result-kicker {
  position: relative;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: #e2732c;
}

.result-title {
  position: relative;
  margin: 5px 0 0;
  font-size: 30px;
  line-height: 1.15;
  font-weight: 900;
  letter-spacing: -0.04em;
  color: #12314c;
}

.result-quip {
  position: relative;
  margin: 6px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  font-weight: 500;
  color: #7890a3;
}

.result-distance {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin: 14px 0 15px;
  line-height: 0.9;
  color: #ff7a24;
}

.result-distance span {
  font-size: 70px;
  font-weight: 900;
  letter-spacing: -0.055em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 4px 0 rgba(255, 138, 61, 0.12);
}

.result-distance small {
  font-size: 17px;
  font-weight: 900;
  color: #f5a365;
}

.result-stats {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin: 0 0 18px;
}

.result-stat {
  padding: 10px 12px 11px;
  border-radius: 15px;
  background: linear-gradient(160deg, #eef7fd, #e4f2fb);
  border: 1px solid rgba(151, 190, 218, 0.26);
}

.result-stat span {
  display: block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #7c95a8;
  margin-bottom: 3px;
}

.result-stat b {
  display: block;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: #18405f;
  font-variant-numeric: tabular-nums;
}

.result-card .primary-btn {
  position: relative;
  max-width: none;
  min-height: 56px;
  border-radius: 18px;
  font-size: 17px;
}

/* ---------------- 提示气泡 ---------------- */
.toast {
  position: absolute;
  top: 27%;
  left: 50%;
  z-index: 12;
  padding: 9px 22px;
  border-radius: 999px;
  color: #fff;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.08em;
  white-space: nowrap;
  background: linear-gradient(160deg, rgba(255, 157, 87, 0.96), rgba(240, 108, 20, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 12px 30px rgba(182, 72, 8, 0.34);
  opacity: 0;
  transform: translate(-50%, 8px) scale(0.9);
  pointer-events: none;
}

.toast.show {
  animation: toast-pop 1.15s cubic-bezier(0.2, 0.9, 0.25, 1) both;
}

@keyframes toast-pop {
  0% { opacity: 0; transform: translate(-50%, 12px) scale(0.86); }
  16% { opacity: 1; transform: translate(-50%, 0) scale(1.02); }
  26% { transform: translate(-50%, 0) scale(1); }
  74% { opacity: 1; transform: translate(-50%, -3px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -14px) scale(0.98); }
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------- 小屏适配 ---------------- */
@media (max-height: 720px) {
  .start-top { padding-top: 24px; }
  .game-title { font-size: clamp(42px, 12.5vw, 54px); }
  .game-sub { margin-top: 10px; font-size: 13px; }
  .start-bottom { gap: 10px; }
  .primary-btn { min-height: 54px; border-radius: 18px; font-size: 17px; }
  .best-badge { padding: 6px 12px; }
  .result-card { padding: 21px 19px 19px; }
  .result-distance span { font-size: 60px; }
}

@media (max-height: 620px) {
  .start-top { padding-top: 8px; }
  .game-kicker { display: none; }
  .game-title { font-size: 40px; }
  .game-sub { display: none; }
  .result-title { font-size: 26px; }
  .result-distance span { font-size: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  .start-top, .start-bottom { animation: none; }
  .overlay, .result-card, .hud, .hint { transition-duration: 0.01s; }
}

@media (min-width: 700px) {
  .hud { max-width: 560px; margin-left: auto; margin-right: auto; }
}

.app[data-state="over"] { touch-action: auto; }
.app[data-state="over"] .result-card { touch-action: pan-y; }
