/* 跑偏小陀螺鞭打蹦蹦 —— 样式（全部外置，页面里没有任何内联样式） */
:root {
  --ink: #5b3a24;
  --ink-soft: #8a6248;
  --coral: #ff7a59;
  --coral-deep: #e2583a;
  --gold: #ffc23d;
  --mint: #3fae98;
  --card: rgba(255, 250, 243, 0.96);
  --line: rgba(122, 74, 42, 0.18);
  --font: "PingFang SC", "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", system-ui, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  font-family: var(--font);
  color: var(--ink);
  background-color: #ffe8d2;
  background-image:
    radial-gradient(rgba(255, 150, 100, 0.16) 1.4px, transparent 1.8px),
    radial-gradient(130% 95% at 50% 32%, #fff9f0 0%, #ffecd8 52%, #ffd7b8 100%);
  background-size: 26px 26px, 100% 100%;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
}

#stage {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
body[data-state="playing"] #stage { cursor: crosshair; }

/* ---------- 顶部信息栏 ---------- */
.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 8px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) calc(env(safe-area-inset-right, 0px) + 14px) 0 calc(env(safe-area-inset-left, 0px) + 14px);
  pointer-events: none;
}
.hud-score {
  justify-self: start;
  display: flex;
  flex-direction: column;
  line-height: 1.08;
  min-width: 0;
}
.hud-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
}
.score {
  display: inline-block;
  align-self: flex-start;
  font-size: 30px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--coral-deep);
  text-shadow: 0 2px 0 #fff;
  transform-origin: left center;
}
.score.bump { animation: bump 0.32s cubic-bezier(0.3, 1.6, 0.5, 1); }
.score.drop { animation: drop 0.4s ease; }
.hud-best {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
}
.hud-best b.beat { color: #d98a00; }

.hud-time {
  justify-self: center;
  display: flex;
  align-items: baseline;
  gap: 2px;
  padding: 4px 14px 5px;
  background: rgba(255, 255, 255, 0.78);
  border: 2px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 3px 0 rgba(122, 74, 42, 0.12);
}
.time {
  display: inline-block;
  min-width: 1.3em;
  text-align: center;
  font-size: 24px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.time.urgent { color: #e2483a; animation: pulse 0.9s ease-in-out infinite; }
.unit { font-size: 12px; font-weight: 800; color: var(--ink-soft); }

.hud-btns {
  justify-self: end;
  display: flex;
  gap: 8px;
  pointer-events: auto;
}
.icon-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  font: 19px/1 var(--font);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.88);
  border: 2px solid var(--line);
  border-radius: 50%;
  box-shadow: 0 3px 0 rgba(122, 74, 42, 0.15);
  cursor: pointer;
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(122, 74, 42, 0.15); }
.pause-btn { visibility: hidden; }
body[data-state="playing"] .pause-btn,
body[data-state="ready"] .pause-btn { visibility: visible; }
.pause-ico {
  display: block;
  width: 13px;
  height: 15px;
  border-left: 4px solid currentColor;
  border-right: 4px solid currentColor;
  border-radius: 1px;
}

/* ---------- 浮层：开始 / 暂停 / 结算 ---------- */
.overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
  background: rgba(255, 226, 200, 0.42);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}
.overlay.show {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.25s ease, visibility 0s;
}
.card {
  width: min(440px, 100%);
  max-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 22px 22px 20px;
  text-align: center;
  background: var(--card);
  border: 2px solid rgba(122, 74, 42, 0.16);
  border-radius: 26px;
  box-shadow: 0 18px 40px rgba(160, 82, 30, 0.25), 0 4px 0 rgba(122, 74, 42, 0.08);
}
.overlay.show .card { animation: pop 0.42s cubic-bezier(0.2, 1.4, 0.4, 1) both; }

.kicker {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 800;
  color: var(--coral);
  letter-spacing: 0.05em;
}
.title {
  margin: 0 0 14px;
  font-size: clamp(30px, 9vw, 40px);
  font-weight: 900;
  line-height: 1.1;
}
.title .t1 { display: block; font-size: 0.66em; color: var(--mint); letter-spacing: 0.08em; }
.title .t2 { display: block; color: var(--coral-deep); letter-spacing: 0.06em; text-shadow: 0 3px 0 #ffd9a8; }
.sub-title { margin: 0 0 4px; font-size: 22px; font-weight: 900; }

.rules {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  display: grid;
  gap: 7px;
  text-align: left;
}
.rules li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 12px;
  font-size: 14.5px;
  line-height: 1.45;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 14px;
}
.rules .ico { flex: none; width: 1.5em; font-size: 18px; line-height: 1.25; text-align: center; }
.rules b { color: var(--coral-deep); }
.keys { margin: 0 0 14px; font-size: 12.5px; line-height: 1.5; color: var(--ink-soft); }

.btn {
  font-family: var(--font);
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.05em;
  padding: 14px 36px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}
.btn.primary {
  color: #fff;
  background: linear-gradient(180deg, #ff9270 0%, #f2643f 100%);
  box-shadow: 0 6px 0 #c74d2e, 0 12px 22px rgba(214, 90, 50, 0.32);
  text-shadow: 0 1px 0 rgba(150, 50, 20, 0.35);
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.primary:active { transform: translateY(4px); box-shadow: 0 2px 0 #c74d2e, 0 6px 12px rgba(214, 90, 50, 0.3); }
.btn.ghost {
  display: block;
  margin: 10px auto 0;
  padding: 8px 18px;
  font-size: 15px;
  color: var(--ink-soft);
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.icon-btn:focus-visible,
.btn:focus-visible { outline: 3px solid #ffb347; outline-offset: 3px; }

.best-line { margin: 14px 0 0; font-size: 13px; color: var(--ink-soft); }
.best-line b { color: var(--ink); }

.pause-text { margin: 6px 0 18px; font-size: 15px; line-height: 1.6; color: var(--ink-soft); }

.final-score {
  margin: 2px 0 6px;
  font-size: clamp(48px, 15vw, 66px);
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--coral-deep);
  text-shadow: 0 4px 0 #ffd9a8;
}
.best-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-soft);
}
.best-row b { color: var(--ink); }
.badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 13px;
  font-weight: 900;
  color: #7a4a10;
  background: linear-gradient(180deg, #ffd34d, #ffb020);
  border-radius: 999px;
  box-shadow: 0 2px 0 #d88a00;
  animation: wiggle 1.2s ease-in-out infinite;
}
.stats {
  list-style: none;
  margin: 14px 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.stats li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 2px;
  font-size: 12px;
  color: var(--ink-soft);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 12px;
}
.stats b { font-size: 20px; font-weight: 900; color: var(--ink); font-variant-numeric: tabular-nums; }
.quote {
  margin: 0 0 18px;
  padding: 12px 14px;
  text-align: left;
  background: #fff6e0;
  border: 2px dashed #ffc98a;
  border-radius: 16px;
}
.quote p { margin: 0; font-size: 15px; font-weight: 700; line-height: 1.65; }
.quote cite {
  display: block;
  margin-top: 6px;
  text-align: right;
  font-size: 12.5px;
  font-style: normal;
  font-weight: 800;
  color: var(--mint);
}
.hint { margin: 12px 0 0; font-size: 12px; color: var(--ink-soft); }

.safe-probe {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 1px;
  height: env(safe-area-inset-bottom, 0px);
  visibility: hidden;
  pointer-events: none;
}
.noscript {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9;
  margin: 0;
  padding: 14px;
  text-align: center;
  font-weight: 800;
  background: #fff;
}

/* ---------- 动画 ---------- */
@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.32); color: #ff9a3c; }
  100% { transform: scale(1); }
}
@keyframes drop {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); color: #9b6bd6; }
  75% { transform: translateX(5px); color: #9b6bd6; }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.14); }
}
@keyframes pop {
  from { transform: scale(0.86) translateY(14px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes wiggle {
  0%, 100% { transform: rotate(-4deg) scale(1); }
  50% { transform: rotate(4deg) scale(1.08); }
}

/* ---------- 小屏 / 横屏手机 ---------- */
@media (max-width: 360px) {
  .card { padding: 18px 14px 16px; }
  .rules li { font-size: 13.5px; padding: 8px 10px; }
  .score { font-size: 26px; }
  .stats b { font-size: 17px; }
}
@media (max-height: 560px) {
  .card { padding: 14px 16px 14px; border-radius: 20px; }
  .title { font-size: 26px; margin-bottom: 8px; }
  .rules { gap: 5px; }
  .rules li { padding: 6px 10px; font-size: 13px; }
  .keys { margin-bottom: 10px; }
  .btn { padding: 11px 30px; font-size: 17px; }
  .final-score { font-size: 44px; }
  .stats { margin: 10px 0; }
  .quote { margin-bottom: 12px; padding: 8px 12px; }
  .quote p { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .overlay.show .card,
  .badge,
  .time.urgent,
  .score.bump,
  .score.drop { animation: none; }
}
