:root {
  --bg: #0a0614;
  --ink: #f7f1ff;
  --muted: #a294c4;
  --pink: #ff4d9d;
  --violet: #b388ff;
  --cyan: #4cc9f0;
  --gold: #ffd166;
  --radius: 22px;
  --pad: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
    env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  --font: "SF Pro Display", -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

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

/* 细颗粒噪点，避免大色块渐变出现色带 */
.grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.16;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
}

/* ─────────────── 声音开关 ─────────────── */
.sound {
  position: absolute;
  top: calc(88px + env(safe-area-inset-top, 0px));
  right: calc(14px + env(safe-area-inset-right, 0px));
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(18, 10, 32, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #e6dcff;
  font-size: 15px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 12;
  opacity: 0.8;
  transition: opacity 0.2s ease, transform 0.14s ease;
}

.sound:active {
  transform: scale(0.92);
}

.sound:hover {
  opacity: 1;
}

.sound svg {
  width: 18px;
  height: 18px;
}

.sound .off {
  display: none;
}

.sound.is-muted .on {
  display: none;
}

.sound.is-muted .off {
  display: block;
}

.sound.is-muted {
  opacity: 0.45;
}

/* ─────────────── 屏幕层 ─────────────── */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(20px + env(safe-area-inset-top, 0px)) 18px
    calc(20px + env(safe-area-inset-bottom, 0px));
  background: radial-gradient(
    120% 90% at 50% 0%,
    rgba(20, 8, 40, 0.55),
    rgba(6, 3, 14, 0.86) 70%
  );
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  z-index: 10;
  animation: fade 0.22s ease both;
}

.screen[hidden] {
  display: none;
}

.screen.slim {
  background: rgba(6, 3, 14, 0.72);
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.panel {
  width: min(100%, 420px);
  max-height: 100%;
  overflow-y: auto;
  text-align: center;
  padding: 6px 2px 10px;
  scrollbar-width: none;
}

.panel::-webkit-scrollbar {
  display: none;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  color: var(--violet);
  opacity: 0.85;
}

.title {
  margin: 0;
  font-size: clamp(38px, 12vw, 56px);
  line-height: 1.02;
  font-weight: 900;
  letter-spacing: -0.02em;
  background: linear-gradient(100deg, #fff 10%, var(--violet) 45%, var(--pink) 78%, #fff 100%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shine 7s linear infinite;
}

.title span {
  display: inline-block;
}

.title.sm {
  font-size: clamp(28px, 8vw, 36px);
  animation: none;
  background: linear-gradient(100deg, #fff, #d9c7ff 60%, var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
}

@keyframes shine {
  to {
    background-position: 220% 0;
  }
}

.lede {
  margin: 14px auto 0;
  max-width: 30ch;
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--muted);
}

/* ─────────────── 表情行 ─────────────── */
.emoji-row {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 18px 0 4px;
  font-size: clamp(24px, 8vw, 32px);
  line-height: 1;
}

.emoji-row span {
  display: inline-block;
  animation: bob 2.4s ease-in-out infinite;
  animation-delay: var(--d);
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0) rotate(-3deg);
  }
  50% {
    transform: translateY(-7px) rotate(3deg);
  }
}

/* ─────────────── 图例 ─────────────── */
.legend {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 16px 0 18px;
  padding: 12px 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.legend div {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
}

.legend span {
  font-size: 17px;
  line-height: 1;
}

.legend b {
  font-size: 12.5px;
  font-weight: 600;
  color: #e7ddff;
}

.legend i {
  font-style: normal;
  font-size: 11px;
  padding: 2px 5px;
  border-radius: 6px;
  background: rgba(179, 136, 255, 0.16);
  color: #cbb4ff;
}

/* ─────────────── 模式切换 ─────────────── */
.modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.mode {
  appearance: none;
  padding: 12px 8px 11px;
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.18s ease, background 0.18s ease;
}

.mode b {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  color: #e9e1ff;
  letter-spacing: 0.01em;
}

.mode b em {
  font-style: normal;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  vertical-align: 1.5px;
  margin-left: 2px;
  padding: 2px 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--pink), var(--violet));
  color: #1a0b2b;
}

.mode i {
  display: block;
  margin-top: 4px;
  font-style: normal;
  font-size: 10.5px;
  opacity: 0.75;
}

.mode.is-active {
  border-color: rgba(179, 136, 255, 0.75);
  background: linear-gradient(160deg, rgba(179, 136, 255, 0.24), rgba(255, 77, 157, 0.12));
  box-shadow: 0 0 0 1px rgba(179, 136, 255, 0.25), 0 10px 26px -12px rgba(179, 136, 255, 0.85);
}

.mode:active {
  transform: scale(0.97);
}

/* ─────────────── 按钮 ─────────────── */
.cta {
  width: 100%;
  padding: 17px 20px;
  border: 0;
  border-radius: 17px;
  font-family: inherit;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(96deg, #ff4d9d, #b388ff 58%, #6ee7ff);
  background-size: 160% 100%;
  box-shadow: 0 12px 34px -12px rgba(255, 77, 157, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.14s ease, box-shadow 0.2s ease, background-position 0.5s ease;
}

.cta:hover {
  background-position: 100% 0;
}

.cta:active {
  transform: scale(0.975);
  box-shadow: 0 6px 18px -10px rgba(255, 77, 157, 0.9);
}

.link {
  margin-top: 14px;
  padding: 8px 12px;
  border: 0;
  background: none;
  font-family: inherit;
  font-size: 13px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: rgba(162, 148, 196, 0.4);
  cursor: pointer;
}

.link:active {
  opacity: 0.6;
}

.best {
  margin: 13px 0 0;
  font-size: 12.5px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.best b {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.hint {
  margin: 12px 0 0;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.5;
  text-align: left;
  color: #ffd9e4;
  background: rgba(255, 77, 157, 0.12);
  border: 1px solid rgba(255, 77, 157, 0.32);
}

.hint[hidden] {
  display: none;
}

.check-link {
  margin: 10px 0 0;
  font-size: 11.5px;
}

.check-link a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px dashed rgba(162, 148, 196, 0.45);
  padding-bottom: 1px;
}

.check-link a:active {
  opacity: 0.6;
}

/* ─────────────── 结算 ─────────────── */
.over-sub {
  margin: 8px 0 0;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.score-big {
  margin: 6px 0 2px;
  font-size: clamp(56px, 19vw, 84px);
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  background: linear-gradient(180deg, #fff, #cbb4ff 70%, #9d7bff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 8px 26px rgba(179, 136, 255, 0.35));
}

.record {
  margin: 6px 0 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.06em;
}

.record[hidden] {
  display: none;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 20px 0 22px;
  padding: 14px 6px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.stats b {
  display: block;
  font-size: 19px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #fff;
}

.stats i {
  display: block;
  margin-top: 3px;
  font-style: normal;
  font-size: 10.5px;
  color: var(--muted);
}

/* ─────────────── Toast ─────────────── */
.toast {
  position: absolute;
  left: 50%;
  /* 放在顶部：底部是指令条，提示盖上去会挡住要做的动作 */
  top: calc(104px + env(safe-area-inset-top, 0px));
  bottom: auto;
  transform: translate(-50%, -12px);
  max-width: min(88vw, 340px);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 12.5px;
  line-height: 1.45;
  text-align: center;
  color: #f4ecff;
  background: rgba(28, 16, 46, 0.92);
  border: 1px solid rgba(179, 136, 255, 0.3);
  box-shadow: 0 14px 40px -16px #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 30;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

#cam {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  transform: scaleX(-1);
}

@media (prefers-reduced-motion: reduce) {
  .title,
  .emoji-row span {
    animation: none;
  }
}

@media (max-height: 680px) {
  .legend {
    margin: 10px 0 12px;
    padding: 9px 8px;
  }
  .lede {
    margin-top: 10px;
    font-size: 13px;
  }
  .emoji-row {
    margin: 10px 0 0;
    font-size: 24px;
  }
  .cta {
    padding: 14px 18px;
    font-size: 16px;
  }
  .stats {
    margin: 14px 0 16px;
  }
}
