/* ——— 动效语言 ———
   与阳台观星日历、窗前过境、地球今天的声音共用：--ease 用于出现、移动、换位（快起慢停），--ease-exit 用于离场。
   按下 90ms，小的换内容 160ms，面板与位置 240ms，首次呈现 420ms。系统要求减少动态效果时归零。 */
:root {
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-exit: cubic-bezier(0.4, 0, 1, 1);
  --ease-ripple: cubic-bezier(0.2, 0.6, 0.3, 1);
  --dur-press: 90ms;
  --dur-quick: 160ms;
  --dur-base: 240ms;
  --dur-slow: 420ms;

  --bg: #f3f1ec;
  --card: #fbfaf7;
  --ink: #1b1a17;
  --muted: #6b675f;
  --line: #dcd7cc;
  --accent: #ff5b35;
  --accent-ink: #fff;
  --accent-soft: #ff5b351f;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --rounded: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --orb: min(62vw, 248px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111110;
    --card: #1a1a18;
    --ink: #f1eee7;
    --muted: #9b968b;
    --line: #2e2c28;
    --accent: #ff6a45;
    --accent-soft: #ff6a4524;
  }
}
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-press: 0ms;
    --dur-quick: 0ms;
    --dur-base: 0ms;
    --dur-slow: 0ms;
  }
}
@media (max-height: 680px) {
  :root {
    --orb: min(50vw, 196px);
  }
}

* {
  box-sizing: border-box;
}
/* hidden 永远胜过组件自己的 display，界面上不会残留此刻没用的东西。 */
[hidden] {
  display: none !important;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button,
input {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button:disabled {
  cursor: default;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
a,
button,
input {
  transition:
    color var(--dur-quick) var(--ease),
    background-color var(--dur-quick) var(--ease),
    border-color var(--dur-quick) var(--ease),
    box-shadow var(--dur-quick) var(--ease),
    opacity var(--dur-quick) var(--ease),
    scale var(--dur-press) var(--ease);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ——— 顶栏 ——— */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 0
    max(20px, env(safe-area-inset-left));
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: inherit;
  text-decoration: none;
  font-weight: 650;
  letter-spacing: 0.04em;
}
.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 50%, var(--accent-ink) 0 2.4px, transparent 2.8px),
    var(--accent);
  box-shadow: inset 0 0 0 5px var(--accent);
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 5px 4px 5px 7px;
  border: 2px solid var(--accent-ink);
  border-left-color: transparent;
  border-bottom-color: transparent;
  border-radius: 50%;
  rotate: 45deg;
}
#language {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 13px;
}
#language:hover {
  border-color: var(--muted);
}
#language:active,
.primary:not(:disabled):active,
.secondary:not(:disabled):active,
.quiet:active,
.chip:active {
  scale: 0.96;
}

/* ——— 舞台 ——— */
main {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: clamp(18px, 5vh, 56px) 22px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.copy {
  min-height: 9.6em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}
.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.12em;
}
h1 {
  margin: 0;
  font-size: clamp(30px, 8.4vw, 44px);
  line-height: 1.15;
  letter-spacing: -0.01em;
  font-weight: 700;
  text-wrap: balance;
}
.lede {
  margin: 12px 0 0;
  max-width: 26em;
  color: var(--muted);
  text-wrap: pretty;
}
.friend {
  margin: 0 0 14px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: 14px;
}

/* ——— 圆圈：整个测试里唯一的主按钮，开始 → 调好了 → 听不见了／听到了 ——— */
.orb-wrap {
  margin: clamp(26px, 6vh, 52px) 0 clamp(18px, 3.5vh, 30px);
  display: grid;
  place-items: center;
}
.orb {
  position: relative;
  width: var(--orb);
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: none;
  color: var(--accent-ink);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.orb:focus-visible {
  outline-offset: 8px;
}
.orb-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(
    circle at 34% 28%,
    color-mix(in oklab, var(--accent) 72%, #fff) 0%,
    var(--accent) 58%,
    color-mix(in oklab, var(--accent) 84%, #000) 100%
  );
  box-shadow:
    0 22px 44px -22px color-mix(in oklab, var(--accent) 80%, transparent),
    inset 0 1px 0 #ffffff59;
  font-size: clamp(19px, 5.2vw, 23px);
  font-weight: 650;
  letter-spacing: 0.03em;
  transition:
    scale var(--dur-press) var(--ease),
    opacity var(--dur-base) var(--ease),
    filter var(--dur-base) var(--ease);
}
.orb:active .orb-face {
  scale: 0.95;
}
.rings,
.rings i {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
}
.rings i {
  border: 1.5px solid var(--accent);
  opacity: 0;
}
@keyframes ripple {
  from {
    opacity: 0.5;
    scale: 1;
  }
  to {
    opacity: 0;
    scale: 1.6;
  }
}
@keyframes breathe {
  from {
    scale: 1;
  }
  to {
    scale: 1.025;
  }
}
@keyframes hit {
  from {
    scale: 0.92;
  }
}
@keyframes burst {
  from {
    opacity: 0.7;
    scale: 1;
  }
  to {
    opacity: 0;
    scale: 1.35;
  }
}
/* 首页：圆圈缓缓泛起涟漪，邀请人按下去。 */
#stage[data-state="intro"] .rings i,
#stage[data-state="silent"] .rings i {
  animation: ripple 3.3s var(--ease-ripple) infinite;
}
#stage[data-state="intro"] .rings i:nth-child(2) {
  animation-delay: 1.1s;
}
#stage[data-state="intro"] .rings i:nth-child(3) {
  animation-delay: 2.2s;
}
#stage[data-state="silent"] .rings i:not(:first-child) {
  animation: none;
}
/* 调音量：涟漪与参考音同拍，一声一圈。 */
#stage[data-state="volume"] .rings i:first-child {
  animation: ripple 1.15s var(--ease-ripple) infinite;
  animation-delay: var(--sync, 0s);
}
/* 测试中：匀速呼吸，和声音的高低无关，不会给出提示。 */
#stage[data-phase="playing"] .orb-face {
  animation: breathe 1.3s ease-in-out infinite alternate;
}
#stage[data-phase="playing"] .rings i {
  animation: ripple 2.6s var(--ease-ripple) infinite;
}
#stage[data-phase="playing"] .rings i:nth-child(2) {
  animation-delay: 0.87s;
}
#stage[data-phase="playing"] .rings i:nth-child(3) {
  animation-delay: 1.73s;
}
/* 两轮之间与开播前：圆圈暂时按不了，就让它淡一点。 */
#stage[data-phase="ready"] .orb-face,
#stage[data-phase="between"] .orb-face {
  opacity: 0.5;
  filter: saturate(0.7);
}
.orb.hit .orb-face {
  animation: hit var(--dur-slow) var(--ease);
}
.orb.hit .rings i:first-child {
  animation: burst var(--dur-slow) var(--ease-ripple);
}
@media (prefers-reduced-motion: reduce) {
  .rings i,
  .orb-face {
    animation: none !important;
  }
  #stage[data-phase="playing"] .rings i:first-child,
  #stage[data-state="volume"] .rings i:first-child {
    opacity: 0.35;
    scale: 1.12;
  }
}

/* ——— 进度 ——— */
.rounds {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 0;
  padding: 0;
  list-style: none;
}
.rounds li {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  transition:
    background-color var(--dur-quick) var(--ease),
    border-color var(--dur-quick) var(--ease),
    color var(--dur-quick) var(--ease),
    scale var(--dur-base) var(--ease);
}
.rounds li.current {
  border-color: var(--accent);
  color: var(--accent);
}
.rounds li.done {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.rounds li.done.fresh {
  animation: hit var(--dur-slow) var(--ease);
}
.status {
  min-height: 1.6em;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
}
.aside {
  min-height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.help {
  max-width: 26em;
  color: var(--muted);
  font-size: 14px;
}
.help p {
  margin: 0 0 12px;
}
.fineprint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

/* ——— 按钮 ——— */
.primary,
.secondary {
  min-height: 46px;
  padding: 0 22px;
  border-radius: 999px;
  font-weight: 600;
}
.primary {
  border: 0;
  background: var(--ink);
  color: var(--bg);
}
.primary:hover {
  background: color-mix(in oklab, var(--ink) 86%, var(--bg));
}
.secondary {
  border: 1.5px solid var(--line);
  background: transparent;
}
.secondary:hover {
  border-color: var(--muted);
}
.quiet {
  border: 0;
  background: none;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 14px;
  text-decoration: underline;
  text-decoration-color: color-mix(in oklab, var(--muted) 45%, transparent);
  text-underline-offset: 4px;
}
.quiet:hover {
  color: var(--ink);
}
.fades {
  transition:
    opacity var(--dur-quick) var(--ease),
    translate var(--dur-quick) var(--ease),
    display var(--dur-quick) allow-discrete;
}
.fades[hidden] {
  display: none;
  opacity: 0;
  translate: 0 4px;
}
@starting-style {
  .fades:not([hidden]) {
    opacity: 0;
    translate: 0 4px;
  }
}

/* ——— 结果 ——— */
.result {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.result > .eyebrow {
  margin: 0;
}
.age {
  margin: 2px 0 0;
  font-family: var(--rounded);
  font-weight: 700;
  font-size: clamp(104px, 32vw, 168px);
  line-height: 0.95;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}
.age .unit {
  margin-left: 0.08em;
  font-size: 0.2em;
  letter-spacing: 0;
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 600;
}
.age-edge {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}
.hz {
  margin: 8px 0 0;
  font-size: 18px;
}
.hz b {
  font-family: var(--rounded);
  font-variant-numeric: tabular-nums;
}
@property --p {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}
.ruler {
  width: 100%;
  margin: 26px 0 0;
}
.track {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: var(--line);
}
.fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: calc(var(--p) * 1%);
  border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in oklab, var(--accent) 35%, transparent), var(--accent));
}
.mark {
  position: absolute;
  top: 50%;
  left: calc(var(--p) * 1%);
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow:
    0 0 0 3px var(--bg),
    0 4px 10px -2px #0000004d;
}
.mark.friend {
  left: calc(var(--f, 0) * 1%);
  background: var(--bg);
  box-shadow:
    0 0 0 2px var(--muted),
    0 0 0 5px var(--bg);
}
.ticks {
  position: relative;
  height: 40px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.ticks span {
  position: absolute;
  top: 0;
  translate: -50% 0;
  display: grid;
  line-height: 1.35;
  white-space: nowrap;
}
.ticks span:first-child {
  translate: 0 0;
  text-align: left;
}
.ticks span:last-child {
  translate: -100% 0;
  text-align: right;
}
/* 窄屏上 18k 与 20k 挨得太近，只留两端。 */
@media (max-width: 520px) {
  .ticks span.minor {
    display: none;
  }
}
.ticks small {
  font-size: 11px;
  opacity: 0.8;
}
.compare,
.remark {
  margin: 14px 0 0;
  max-width: 28em;
  font-size: 15px;
}
.remark {
  color: var(--muted);
  font-size: 14px;
}
.real-age {
  margin-top: 22px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 10px;
  font-size: 15px;
}
.real-age input {
  width: 4.2em;
  height: 38px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.real-age input:hover {
  border-color: var(--muted);
}
.real-age input:focus {
  border-color: var(--accent);
  outline: none;
}
.real-age output {
  min-width: 9em;
  text-align: left;
  font-weight: 600;
}
.result-actions {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.ladder-box {
  width: 100%;
  margin-top: 40px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}
.ladder-box h2 {
  margin: 0;
  font-size: 18px;
}
.ladder-box p {
  margin: 4px 0 16px;
  color: var(--muted);
  font-size: 14px;
}
.ladder {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.chip {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 0;
  padding: 9px 4px 8px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  line-height: 1.25;
}
.chip:hover {
  border-color: var(--muted);
}
.chip b {
  font-family: var(--rounded);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.chip small {
  color: var(--muted);
  font-size: 11px;
}
.chip.within b {
  color: var(--accent);
}
.chip .bar {
  position: absolute;
  inset: auto 0 0 0;
  height: 3px;
  background: var(--accent);
  transform-origin: left;
  scale: 0 1;
}
.chip.playing {
  border-color: var(--accent);
}
.chip.playing .bar {
  animation: progress var(--len, 1.2s) linear forwards;
}
@keyframes progress {
  to {
    scale: 1 1;
  }
}
#again {
  margin-top: 26px;
}

.foot {
  max-width: 560px;
  margin: 0 auto;
  padding: 18px 22px max(22px, env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.foot p {
  margin: 0;
}

/* ——— 微信里保存图片 ——— */
dialog {
  max-width: min(92vw, 420px);
  padding: 18px;
  border: 0;
  border-radius: 22px;
  background: var(--card);
  color: var(--ink);
  text-align: center;
  opacity: 0;
  scale: 0.96;
  transition:
    opacity var(--dur-base) var(--ease),
    scale var(--dur-base) var(--ease),
    overlay var(--dur-base) allow-discrete,
    display var(--dur-base) allow-discrete;
}
dialog[open] {
  opacity: 1;
  scale: 1;
}
@starting-style {
  dialog[open] {
    opacity: 0;
    scale: 0.96;
  }
}
dialog::backdrop {
  background: #0008;
}
dialog img {
  display: block;
  width: 100%;
  max-height: 64vh;
  object-fit: contain;
  border-radius: 12px;
}
dialog p {
  margin: 12px 0;
  color: var(--muted);
  font-size: 14px;
}

/* 切换语言：新旧文字交叠淡换，期间点击直接落到页面上。 */
::view-transition {
  pointer-events: none;
}
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: var(--dur-base);
  animation-timing-function: var(--ease);
}
.noscript {
  text-align: center;
}
:lang(en) .eyebrow {
  letter-spacing: 0.04em;
}
