:root {
  --ink: #1b1e19;
  --ink-soft: #343a31;
  --ink-mute: #6f6d60;
  --paper: #f7f1e4;
  --paper-2: #efe5d2;
  --paper-3: #e4d7bf;
  --orange: #ff8a3d;
  --orange-deep: #ef7428;
  --seal: #d4562f;
  --line: rgba(31, 35, 28, 0.13);
  --shadow: 0 18px 46px rgba(38, 35, 26, 0.18);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-synthesis: none;
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #191c18;
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  display: grid;
  place-items: center;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
}

.stage {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--paper);
  isolation: isolate;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

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

.paper-glow {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(72% 40% at 76% 18%, rgba(255, 166, 100, 0.18), transparent 68%),
    radial-gradient(90% 52% at 50% 104%, rgba(255, 250, 240, 0.26), transparent 70%);
  mix-blend-mode: soft-light;
}

.vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(118% 82% at 50% 42%, transparent 52%, rgba(29, 32, 26, 0.17) 100%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 22%, transparent 74%, rgba(35, 36, 29, 0.16));
}

/* ---------------- HUD ---------------- */

.hud {
  position: absolute;
  z-index: 10;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: calc(14px + var(--safe-top)) 16px 0;
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.hud.is-hidden {
  opacity: 0;
  transform: translateY(-8px);
}

.score-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 14px 7px 8px;
  border: 1px solid rgba(31, 35, 28, 0.14);
  border-radius: 18px;
  background: rgba(250, 245, 235, 0.76);
  box-shadow: 0 7px 20px rgba(38, 35, 26, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.score-seal {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  color: #2d1c0d;
  font-family: "STKaiti", "KaiTi", "Kaiti SC", serif;
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  background: linear-gradient(145deg, #ffa25d, var(--orange) 58%, var(--orange-deep));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 3px 8px rgba(200, 95, 28, 0.25);
}

.score-num {
  min-width: 26px;
  font-size: 25px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.01em;
  color: #20241d;
  font-variant-numeric: tabular-nums;
  transition: transform 0.16s ease;
}

.hud.bump .score-chip {
  animation: chipBump 0.36s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}

@keyframes chipBump {
  0% { transform: scale(1); }
  35% { transform: scale(1.075); }
  100% { transform: scale(1); }
}

.best-chip {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-top: 1px;
  padding: 8px 12px;
  border: 1px solid rgba(31, 35, 28, 0.1);
  border-radius: 15px;
  background: rgba(250, 245, 235, 0.58);
  box-shadow: 0 5px 16px rgba(38, 35, 26, 0.07);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.best-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: #777466;
}

.best-num {
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  color: #3a3e34;
  font-variant-numeric: tabular-nums;
}

/* ---------------- Screens ---------------- */

.screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.38s ease, visibility 0.38s ease;
}

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

/* ---------------- Start ---------------- */

.start {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.start-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(247, 241, 228, 0.94) 0%, rgba(247, 241, 228, 0.78) 27%, rgba(247, 241, 228, 0.28) 48%, rgba(247, 241, 228, 0.02) 62%, rgba(247, 241, 228, 0.9) 100%),
    radial-gradient(76% 46% at 18% 16%, rgba(255, 255, 255, 0.5), transparent 70%);
  pointer-events: none;
}

.start-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  padding: calc(12vh + var(--safe-top)) 26px calc(58px + var(--safe-bottom));
}

.start-head {
  animation: fadeUp 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.brand-rule {
  display: block;
  width: 26px;
  height: 1px;
  background: var(--ink);
  opacity: 0.55;
}

.brand-kicker {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.36em;
  color: #5f6055;
}

.title {
  display: flex;
  align-items: flex-start;
  gap: 3px;
  margin: 0;
  font-family: "STKaiti", "KaiTi", "Kaiti SC", "Songti SC", serif;
  font-size: clamp(74px, 21.5vw, 112px);
  font-weight: 700;
  line-height: 0.88;
  letter-spacing: -0.01em;
  color: #171a15;
}

.title-char {
  display: inline-block;
  background: linear-gradient(158deg, #0d0f0c 4%, #343a30 49%, #101310 92%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 0 rgba(255, 255, 255, 0.22));
  animation: titleRise 0.95s cubic-bezier(0.16, 0.9, 0.28, 1.08) both;
}

.title-char:nth-child(2) {
  transform: translateY(0.07em);
  animation-delay: 0.1s;
}

.title-stamp {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin: 8px 0 0 12px;
  border: 1.5px solid rgba(196, 74, 42, 0.9);
  border-radius: 8px;
  color: var(--seal);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 19px;
  line-height: 1;
  transform: rotate(6deg);
  opacity: 0.92;
  box-shadow: inset 0 0 0 2px rgba(212, 86, 47, 0.12);
}

.tagline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 19px 0 0;
  font-family: "STKaiti", "KaiTi", "Kaiti SC", "Songti SC", serif;
  font-size: 17px;
  letter-spacing: 0.2em;
  color: #43483d;
}

.tagline::after {
  content: "";
  display: block;
  width: 44px;
  height: 1px;
  background: linear-gradient(90deg, rgba(43, 47, 39, 0.45), transparent);
}

.start-desc {
  margin: 14px 0 0;
  max-width: 290px;
  font-size: 13px;
  line-height: 1.9;
  letter-spacing: 0.04em;
  color: #6b6b5e;
}

.start-actions {
  width: 100%;
  max-width: 340px;
  margin: 0 auto;
  animation: fadeUp 0.8s 0.18s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.start-best {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 4px 13px;
  padding-bottom: 11px;
  border-bottom: 1px dashed rgba(55, 60, 49, 0.24);
}

.start-best-label {
  font-size: 11px;
  letter-spacing: 0.16em;
  color: #757265;
}

.start-best-value {
  display: flex;
  align-items: baseline;
  gap: 3px;
  color: #3e4338;
}

.start-best-value b {
  font-size: 23px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.start-best-value i {
  font-style: normal;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: #7c7869;
}

/* ---------------- Buttons ---------------- */

.btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 58px;
  padding: 0 18px;
  border-radius: 999px;
  overflow: hidden;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.14s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.btn-primary {
  color: #2a1c0e;
  background: linear-gradient(135deg, #ffa45f 0%, var(--orange) 48%, #f47b2d 100%);
  box-shadow:
    0 14px 30px rgba(190, 88, 25, 0.3),
    0 3px 0 rgba(173, 77, 19, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.52);
}

.btn-primary::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(255, 249, 239, 0.34);
  border-radius: inherit;
  pointer-events: none;
}

.btn-primary:active {
  transform: translateY(1px) scale(0.982);
  box-shadow:
    0 7px 16px rgba(190, 88, 25, 0.25),
    0 2px 0 rgba(173, 77, 19, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.btn-text {
  position: relative;
  z-index: 1;
  font-family: "STKaiti", "KaiTi", "Kaiti SC", "Songti SC", serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-indent: 0.18em;
}

.btn-arrow {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(44, 28, 14, 0.12);
  color: #2a1c0e;
}

.btn-arrow .mp-icon {
  font-size: 19px;
}

.btn-sheen {
  position: absolute;
  top: -40%;
  left: -30%;
  width: 44%;
  height: 180%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.38), transparent);
  transform: rotate(16deg);
  animation: sheen 3.8s 1.2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes sheen {
  0%, 58% { transform: translateX(-60%) rotate(16deg); opacity: 0; }
  70% { opacity: 1; }
  100% { transform: translateX(390%) rotate(16deg); opacity: 0; }
}

.tap-hint {
  margin: 12px 0 0;
  text-align: center;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: #787668;
}

.start-foot {
  position: absolute;
  z-index: 1;
  left: 0;
  right: 0;
  bottom: calc(13px + var(--safe-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-size: 9px;
  letter-spacing: 0.16em;
  color: rgba(78, 79, 68, 0.66);
}

.foot-dot {
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
}

/* ---------------- Game over ---------------- */

.over {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
}

.over-scrim {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(72% 58% at 50% 44%, rgba(26, 29, 23, 0.18), rgba(22, 25, 20, 0.55) 100%),
    linear-gradient(180deg, rgba(247, 241, 228, 0.12), rgba(247, 241, 228, 0.04));
  -webkit-backdrop-filter: blur(2.5px);
  backdrop-filter: blur(2.5px);
}

.over-card {
  position: relative;
  width: min(100%, 342px);
  padding: 33px 24px 24px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 28px;
  text-align: center;
  background:
    radial-gradient(130% 70% at 22% 0%, rgba(255, 255, 255, 0.72), transparent 55%),
    linear-gradient(158deg, #fdf8ed 0%, #f6eedd 58%, #efe2cb 100%);
  box-shadow:
    0 30px 70px rgba(18, 21, 16, 0.38),
    0 3px 0 rgba(255, 255, 255, 0.4) inset,
    0 0 0 6px rgba(248, 241, 228, 0.1);
  animation: cardIn 0.5s cubic-bezier(0.18, 0.9, 0.26, 1.06) both;
}

.over-card::before {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(56, 59, 48, 0.1);
  border-radius: 21px;
  pointer-events: none;
}

.over-card::after {
  content: "";
  position: absolute;
  left: 22px;
  right: 22px;
  top: 15px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(58, 62, 50, 0.16), transparent);
}

.over-stamp {
  position: absolute;
  top: 16px;
  right: 18px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1.5px solid rgba(196, 74, 42, 0.82);
  border-radius: 8px;
  color: var(--seal);
  font-family: "STKaiti", "KaiTi", serif;
  font-size: 18px;
  line-height: 1;
  transform: rotate(7deg);
  opacity: 0.9;
}

.over-kicker {
  margin: 2px 0 0;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.44em;
  text-indent: 0.44em;
  color: #8a8373;
}

.over-title {
  margin: 12px 0 0;
  font-family: "STKaiti", "KaiTi", "Kaiti SC", "Songti SC", serif;
  font-size: 43px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.12em;
  text-indent: 0.12em;
  color: #23271f;
}

.new-record {
  display: inline-flex;
  align-items: center;
  height: 24px;
  margin: 13px 0 0;
  padding: 0 10px;
  border: 1px solid rgba(212, 86, 47, 0.34);
  border-radius: 999px;
  color: #b64a28;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
  background: rgba(212, 86, 47, 0.07);
}

.new-record.is-hidden {
  display: none;
}

.over-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
  margin: 26px 0 0;
  padding: 17px 0;
  border-top: 1px solid rgba(58, 62, 50, 0.1);
  border-bottom: 1px solid rgba(58, 62, 50, 0.1);
}

.over-stat {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 82px;
}

.stat-label {
  font-size: 9px;
  letter-spacing: 0.2em;
  color: #827d6e;
}

.stat-value {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 3px;
  color: #2b3027;
}

.stat-value b {
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-value i {
  font-style: normal;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: #898474;
}

.stat-line {
  width: 1px;
  height: 34px;
  background: linear-gradient(180deg, transparent, rgba(56, 60, 49, 0.22), transparent);
}

.over-quote {
  margin: 17px 0 20px;
  font-family: "STKaiti", "KaiTi", "Kaiti SC", "Songti SC", serif;
  font-size: 14px;
  letter-spacing: 0.12em;
  color: #66685a;
}

.over .btn {
  height: 54px;
}

.over .btn-text {
  font-size: 20px;
  letter-spacing: 0.12em;
  text-indent: 0.12em;
}

/* ---------------- Toast ---------------- */

.toast {
  position: absolute;
  z-index: 30;
  top: calc(74px + var(--safe-top));
  left: 50%;
  max-width: 82%;
  padding: 8px 15px;
  border: 1px solid rgba(31, 35, 28, 0.12);
  border-radius: 999px;
  background: rgba(250, 245, 235, 0.8);
  box-shadow: 0 7px 20px rgba(38, 35, 26, 0.1);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #52564a;
  font-size: 11px;
  letter-spacing: 0.1em;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, -8px);
  transition: opacity 0.28s ease, transform 0.28s ease;
  pointer-events: none;
}

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

/* ---------------- Motion ---------------- */

@keyframes titleRise {
  0% { opacity: 0; transform: translateY(26px) scale(0.98); filter: blur(5px); }
  100% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

@keyframes fadeUp {
  0% { opacity: 0; transform: translateY(14px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes cardIn {
  0% { opacity: 0; transform: translateY(22px) scale(0.94); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------------- Responsive ---------------- */

@media (max-width: 360px) {
  .start-inner {
    padding-left: 21px;
    padding-right: 21px;
  }
  .start-desc {
    font-size: 12px;
  }
  .btn {
    height: 54px;
  }
  .btn-text {
    font-size: 20px;
  }
  .over-card {
    padding: 30px 20px 22px;
  }
}

@media (max-height: 680px) {
  .start-inner {
    padding-top: calc(8vh + var(--safe-top));
    padding-bottom: calc(44px + var(--safe-bottom));
  }
  .brand-row {
    margin-bottom: 12px;
  }
  .title {
    font-size: clamp(62px, 19vw, 88px);
  }
  .tagline {
    margin-top: 13px;
    font-size: 15px;
  }
  .start-desc {
    margin-top: 10px;
    line-height: 1.75;
  }
  .start-best {
    margin-bottom: 10px;
    padding-bottom: 8px;
  }
  .tap-hint {
    margin-top: 9px;
  }
  .over-card {
    padding: 27px 22px 20px;
  }
  .over-title {
    font-size: 37px;
  }
  .over-stats {
    margin-top: 19px;
    padding: 13px 0;
  }
  .over-quote {
    margin: 13px 0 16px;
  }
}

@media (min-width: 620px) and (min-height: 700px) {
  body {
    background:
      radial-gradient(90% 80% at 50% 30%, #2b312a, #151814 76%);
  }
  .stage {
    width: min(calc(100dvh * 0.5), 500px);
    height: min(100dvh, 1000px);
    border-radius: 30px;
    box-shadow:
      0 40px 100px rgba(0, 0, 0, 0.55),
      0 0 0 1px rgba(255, 255, 255, 0.09),
      0 0 0 9px rgba(255, 255, 255, 0.025);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
