/* 跑酷躲障碍20 — 竖屏 H5 跑酷
   卡通沙漠配色：薄荷天空 + 奶油卡片 + 主色 #FF8A3D */
:root {
  --orange: #FF8A3D;
  --orange-deep: #E86217;
  --orange-soft: #FFD9B8;
  --cream: #FFF8EA;
  --cream-2: #FFF1D7;
  --ink: #4A2A16;
  --ink-soft: #6E4A30;
  --muted: #9A7A5C;
  --teal: #43C2AE;
  --line: rgba(116, 72, 38, .14);
  --shadow: 0 14px 34px rgba(92, 51, 18, .18);
  --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 {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #23150c;
  overscroll-behavior: none;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "HarmonyOS Sans SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(120% 80% at 50% -10%, #5a3821 0%, #2b1a10 48%, #1b110a 100%);
}

#app {
  position: fixed;
  inset: 0;
  left: 0;
  right: 0;
  margin: 0 auto;
  max-width: 560px;
  overflow: hidden;
  background: #FFE8C5;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}

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

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 6;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: calc(12px + var(--safe-top)) 16px 0;
  pointer-events: none;
  opacity: 1;
  transform: translateY(0);
  transition: opacity .3s ease, transform .35s cubic-bezier(.2, .9, .3, 1.15);
}

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

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 40px;
  padding: 0 13px 0 7px;
  border-radius: 999px;
  background: rgba(255, 249, 236, .9);
  border: 1.5px solid rgba(255, 255, 255, .92);
  box-shadow: 0 6px 16px rgba(84, 46, 18, .16), inset 0 1px 0 #fff;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ink);
  font-weight: 800;
}

.hud-ico {
  width: 27px;
  height: 27px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #FFE7CE, #FFD3A8);
  color: var(--orange-deep);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8);
}

.hud-ico .mp-icon { width: 16px; height: 16px; }

.score-val {
  min-width: 2ch;
  text-align: right;
  font-size: 21px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: -.02em;
  color: var(--orange-deep);
  font-variant-numeric: tabular-nums;
}

.hud-pill .unit {
  font-size: 11px;
  color: var(--muted);
  font-weight: 800;
  margin-top: 2px;
}

.hud-pill--best {
  gap: 4px;
  padding: 0 12px;
  background: rgba(255, 249, 236, .78);
}

.hud-pill--best > .mp-icon {
  width: 17px;
  height: 17px;
  color: #F5A623;
  margin-right: 1px;
}

.hud-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
}

.hud-pill--best b {
  font-size: 15px;
  font-weight: 900;
  color: #6B4226;
  font-variant-numeric: tabular-nums;
}

/* ---------- 通用屏幕 ---------- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  opacity: 1;
  visibility: visible;
  transition: opacity .3s ease, transform .32s cubic-bezier(.2, .9, .3, 1), visibility 0s;
}

.screen.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .24s ease, transform .28s ease, visibility 0s .28s;
}

.scrim {
  position: absolute;
  inset: 0;
  background: rgba(51, 30, 14, .42);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

/* ---------- 开始页 ---------- */
.screen--ready {
  justify-content: space-between;
  padding: calc(20px + var(--safe-top)) 18px calc(18px + var(--safe-bottom));
  background:
    linear-gradient(180deg, rgba(255, 250, 236, .56) 0%, rgba(255, 250, 236, 0) 34%,
      rgba(64, 38, 18, 0) 66%, rgba(64, 38, 18, .16) 100%);
}

.screen--ready.is-hidden { transform: translateY(-10px); }

.ready-top {
  position: relative;
  z-index: 1;
  padding: 2px 4px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  padding: 7px 12px 7px 9px;
  border-radius: 999px;
  background: rgba(255, 249, 236, .84);
  border: 1.5px solid rgba(255, 255, 255, .92);
  box-shadow: 0 6px 16px rgba(78, 44, 18, .13), inset 0 1px 0 #fff;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #7A4A25;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .1em;
}

.brand .mp-icon {
  width: 17px;
  height: 17px;
  color: var(--orange);
}

h1 {
  margin: 16px 0 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: .88;
  letter-spacing: -.045em;
  filter: drop-shadow(0 6px 14px rgba(119, 62, 21, .12));
}

.h1-top {
  font-size: clamp(28px, 8.4vw, 38px);
  font-weight: 900;
  letter-spacing: .12em;
  color: #6B4226;
  text-shadow: 0 2px 0 rgba(255, 248, 234, .7);
}

.h1-main {
  position: relative;
  margin-top: 4px;
  font-size: clamp(49px, 14.4vw, 64px);
  line-height: .96;
  font-weight: 900;
  letter-spacing: -.035em;
  color: var(--orange);
  -webkit-text-stroke: 1.6px #FFF8EA;
  paint-order: stroke fill;
  text-shadow: 0 5px 0 rgba(201, 92, 25, .16), 0 12px 26px rgba(118, 58, 18, .18);
}

.h1-main::after {
  content: "";
  position: absolute;
  left: 4px;
  bottom: -10px;
  width: 72%;
  height: 5px;
  border-radius: 99px;
  background: #FFD15C;
  transform: rotate(-1.6deg);
  box-shadow: 0 2px 0 rgba(255, 248, 234, .6);
}

.lede {
  margin: 21px 0 0 4px;
  font-size: 13.5px;
  line-height: 1.62;
  font-weight: 700;
  color: #70472B;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .42);
}

/* 底部控制卡 */
.dock {
  position: relative;
  z-index: 2;
  width: 100%;
  padding: 12px 13px 11px;
  border-radius: 24px;
  background: rgba(255, 249, 236, .9);
  border: 1.5px solid rgba(255, 255, 255, .95);
  box-shadow: 0 16px 38px rgba(80, 44, 16, .2), inset 0 1px 0 #fff;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: dockIn .65s cubic-bezier(.2, .9, .3, 1.08) both;
}

@keyframes dockIn {
  from { opacity: 0; transform: translateY(26px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.dock-tip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0 0 9px;
  color: #8B6245;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.dock-tip .mp-icon {
  width: 16px;
  height: 16px;
  color: var(--orange);
  flex: 0 0 auto;
}

.dock-tip .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #D4B79E;
  flex: 0 0 auto;
}

.btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  height: 54px;
  padding: 0 18px;
  border: 0;
  border-radius: 17px;
  font-family: inherit;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: .01em;
  cursor: pointer;
  outline: none;
  transition: transform .1s ease, box-shadow .1s ease, filter .2s ease;
  -webkit-appearance: none;
  appearance: none;
}

.btn .mp-icon { width: 22px; height: 22px; flex: 0 0 auto; }

.btn-primary {
  color: #fff;
  background: linear-gradient(180deg, #FFA862 0%, #FF8A3D 48%, #FA7525 100%);
  box-shadow: 0 5px 0 #CB5714, 0 12px 20px rgba(211, 91, 24, .3),
    inset 0 2px 0 rgba(255, 255, 255, .42);
  text-shadow: 0 1px 0 rgba(156, 61, 11, .38);
}

.btn-primary:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #CB5714, 0 5px 10px rgba(211, 91, 24, .24),
    inset 0 2px 0 rgba(255, 255, 255, .34);
}

.btn:focus-visible {
  outline: 3px solid rgba(255, 138, 61, .45);
  outline-offset: 3px;
}

.best-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-top: 9px;
  color: #8B6245;
  font-size: 11.5px;
  font-weight: 700;
}

.best-row .mp-icon {
  width: 15px;
  height: 15px;
  color: #F5A623;
}

.best-row b {
  color: var(--orange-deep);
  font-size: 14.5px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

/* ---------- 结束页 ---------- */
.screen--over,
.screen--pause {
  align-items: center;
  justify-content: center;
  padding: 20px 18px calc(20px + var(--safe-bottom));
  overflow: auto;
  overscroll-behavior: contain;
}

.over-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 344px;
  margin-top: 24px;
  padding: 18px 18px 15px;
  border-radius: 28px;
  text-align: center;
  background: var(--cream);
  border: 2px solid #fff;
  box-shadow: 0 26px 60px rgba(38, 20, 8, .4), inset 0 0 0 4px #FFF0D5;
}

.screen--over.pop .over-card {
  animation: cardPop .48s cubic-bezier(.18, .9, .3, 1.18) both;
}

@keyframes cardPop {
  from { opacity: 0; transform: translateY(20px) scale(.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.over-avatar {
  width: 58px;
  height: 58px;
  margin: -46px auto 7px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(160deg, #FFB26B, #FF7A2B);
  border: 3px solid #fff;
  box-shadow: 0 8px 18px rgba(208, 89, 20, .34), inset 0 2px 0 rgba(255, 255, 255, .36);
}

.over-avatar .mp-icon { width: 30px; height: 30px; }

.record-pill {
  position: absolute;
  top: 14px;
  right: 12px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 5px 9px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(180deg, #FFB049, #FF7A2B);
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: .04em;
  box-shadow: 0 3px 0 #C95614;
  transform: rotate(5deg);
  animation: recordPulse 1.5s ease-in-out infinite;
}

.record-pill .mp-icon { width: 13px; height: 13px; }

@keyframes recordPulse {
  0%, 100% { transform: rotate(5deg) scale(1); }
  50% { transform: rotate(5deg) scale(1.06); }
}

.over-card h2,
.pause-card h2 {
  margin: 3px 0 0;
  font-size: 23px;
  line-height: 1.2;
  font-weight: 900;
  letter-spacing: -.02em;
  color: var(--ink);
}

.over-sub {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.result {
  display: flex;
  align-items: center;
  margin: 15px 0 2px;
  padding: 13px 8px;
  border-radius: 18px;
  background: linear-gradient(180deg, #FFF5E1, #FFEDD1);
  border: 1px solid #F4DCB8;
  box-shadow: inset 0 1px 0 #fff;
}

.result-cell { flex: 1; min-width: 0; }

.result-label {
  display: block;
  color: #A17A5B;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .05em;
}

.result-num {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 2px;
  margin-top: 2px;
  line-height: 1;
}

.result-num b {
  font-size: 42px;
  font-weight: 900;
  letter-spacing: -.04em;
  color: var(--orange-deep);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 #FFDDBB;
}

.result-num em {
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
  color: #B6805C;
}

.result-num--small b {
  font-size: 28px;
  color: #6B4226;
  text-shadow: 0 2px 0 #FFF4DF;
}

.result-divider {
  width: 1px;
  height: 42px;
  margin: 0 6px;
  background: #EDD4B1;
}

.over-card .btn { margin-top: 13px; }

.over-hint {
  margin: 9px 0 0;
  color: #B09279;
  font-size: 10.5px;
  font-weight: 600;
}

/* ---------- 暂停页 ---------- */
.pause-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 306px;
  padding: 22px 18px 16px;
  border-radius: 26px;
  text-align: center;
  background: var(--cream);
  border: 2px solid #fff;
  box-shadow: 0 24px 56px rgba(38, 20, 8, .38), inset 0 0 0 4px #FFF0D5;
  animation: cardPop .4s cubic-bezier(.18, .9, .3, 1.18) both;
}

.pause-ico {
  width: 54px;
  height: 54px;
  margin: 0 auto 10px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--orange-deep);
  background: #FFE9D2;
  border: 1.5px solid #FFD6B0;
}

.pause-ico .mp-icon { width: 28px; height: 28px; }

.pause-card p {
  margin: 6px 0 15px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

/* ---------- 开始/受击反馈 ---------- */
.go-flash {
  position: absolute;
  z-index: 8;
  top: 38%;
  left: 50%;
  padding: 0 10px;
  font-size: clamp(40px, 12vw, 54px);
  font-weight: 900;
  letter-spacing: .02em;
  color: #FFF6E4;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(.7) rotate(-3deg);
  text-shadow: 0 4px 0 #D9621B, 0 8px 0 rgba(154, 65, 13, .2), 0 18px 34px rgba(70, 35, 12, .35);
  -webkit-text-stroke: 2px #E86217;
  paint-order: stroke fill;
}

.go-flash.on { animation: goPop .82s cubic-bezier(.16, .8, .3, 1) both; }

@keyframes goPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.55) rotate(-5deg); }
  24% { opacity: 1; transform: translate(-50%, -50%) scale(1.1) rotate(-2deg); }
  46% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-2deg); }
  100% { opacity: 0; transform: translate(-50%, -62%) scale(1.04) rotate(-1deg); }
}

.hit-flash {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 32% 72%, rgba(255, 92, 58, .58), rgba(255, 92, 58, 0) 62%);
}

.hit-flash.on { animation: hitFlash .46s ease-out both; }

@keyframes hitFlash {
  0% { opacity: 0; }
  18% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- 适配 ---------- */
@media (max-height: 700px) {
  .screen--ready { padding-top: calc(12px + var(--safe-top)); }
  h1 { margin-top: 10px; }
  .h1-top { font-size: 25px; }
  .h1-main { font-size: 44px; }
  .lede { margin-top: 15px; font-size: 12px; }
  .dock { padding: 10px 12px 9px; border-radius: 21px; }
  .dock-tip { margin-bottom: 7px; font-size: 10.5px; }
  .btn { height: 48px; font-size: 16px; border-radius: 15px; }
  .best-row { margin-top: 7px; }
  .over-card { transform-origin: center; }
}

@media (max-width: 350px) {
  .screen--ready { padding-left: 14px; padding-right: 14px; }
  .dock-tip { font-size: 10.5px; gap: 4px; }
  .hud { padding-left: 12px; padding-right: 12px; }
  .hud-pill { height: 36px; padding-right: 10px; }
  .score-val { font-size: 19px; }
}

@media (min-width: 700px) {
  #app { box-shadow: 0 0 0 1px rgba(255, 255, 255, .06), 0 30px 90px rgba(0, 0, 0, .5); }
}

@media (hover: hover) {
  .btn-primary:hover { filter: brightness(1.045); }
}

@media (prefers-reduced-motion: reduce) {
  .dock, .over-card, .pause-card, .record-pill { animation: none; }
  .screen, .hud, .btn { transition-duration: .01ms; }
}
