:root {
  color-scheme: dark;
  --bg: #07070b;
  --ink: #dcd8e6;
  --muted: #938eaa;
  --line: #26242f;
  --card: #0f0e15;
  --ruby: #d8344c;
  --ruby-light: #ff8c9b;
  --violet: #6a58e0;
  --blue: #3f6fe0;
  --stage: min(112vw, 66vh, 620px);
  --cap-rest: translate(33%, 36%) rotate(118deg) scale(.74);
}
@supports (height: 1svh) {
  :root { --stage: min(112vw, 66svh, 620px); }
}

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

html { background: var(--bg); font-size: 14px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  line-height: 1.7;
  overflow-x: clip;
}
h1, h2, p, dl, dd, ol { margin: 0; padding: 0; }

.banner {
  padding: 6px 16px;
  text-align: center;
  font-size: 12px;
  color: var(--ruby-light);
  border-bottom: 1px solid #3a1620;
  background: #14090d;
}

main {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  /* 舞台比手机屏幕宽（蛋图四周是透明的），在这里裁掉，不然手机浏览器会把整页缩小 */
  overflow-x: hidden;
  overflow-x: clip;
  padding: max(20px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.intro { text-align: center; position: relative; z-index: 2; }
.eyebrow { font-size: 11px; letter-spacing: .28em; color: var(--muted); }
h1 { margin-top: 2px; font-size: 19px; font-weight: 500; letter-spacing: .12em; }
.lede { margin-top: 2px; font-size: 13px; color: var(--muted); }

/* 舞台：蛋图四周留白很多，收掉一些上下边距 */
.stage {
  position: relative;
  flex: none;
  width: var(--stage);
  height: var(--stage);
  margin-block: calc(var(--stage) * -.09);
}
.layer { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.egg { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; pointer-events: none; }
.egg-motion { position: absolute; inset: 0; transform-origin: 50% 66%; animation: breathe 5.2s ease-in-out infinite; }
#shell-back { opacity: 0; }
#egg-cap { opacity: 0; }

.aura {
  position: absolute;
  inset: -6%;
  background:
    radial-gradient(circle at 50% 52%, rgba(106, 88, 224, .3), rgba(63, 111, 224, .12) 34%, transparent 62%),
    radial-gradient(circle at 56% 66%, rgba(216, 52, 76, .12), transparent 40%);
  animation: aura 5.2s ease-in-out infinite;
  pointer-events: none;
}
.stage[data-step="1"] .aura { filter: brightness(1.15); }
.stage[data-step="2"] .aura { filter: brightness(1.3); }
.stage[data-step="3"] .aura { filter: brightness(1.5); }

.flash {
  position: absolute;
  inset: -10%;
  background: radial-gradient(circle at 50% 44%, rgba(255, 244, 248, .95), rgba(190, 170, 255, .5) 22%, transparent 56%);
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}
.stage.opening .flash { animation: flash 1.1s ease-out both; }

.egg-button {
  position: absolute;
  left: 21%;
  top: 14%;
  width: 58%;
  height: 72%;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  z-index: 4;
}
.egg-button:focus-visible { outline: 1px dashed var(--muted); outline-offset: 4px; }
.egg-button:disabled { cursor: default; }

/* 裂纹 */
.crack {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1 2;
  stroke-dashoffset: 1.01;
  opacity: 0;
  transition: stroke-dashoffset .5s ease-out, opacity .25s linear;
}
.crack.on { stroke-dashoffset: 0; opacity: 1; }
.crack-glow { stroke: var(--ruby); stroke-width: 22; }
.crack-dark { stroke: #120a14; stroke-width: 9; }
.crack-core { stroke: #ffe4dc; stroke-width: 3.5; }
#crack-glow-group { opacity: .55; transition: opacity .4s; }
.stage[data-step="2"] #crack-glow-group { opacity: .8; }
.stage[data-step="3"] #crack-glow-group { opacity: 1; }
.stage.bursting #crack-glow-group { opacity: 1; animation: glow-burst .28s ease-in-out infinite alternate; }
.rim { fill: none; stroke: #e6dcf4; stroke-width: 3.5; stroke-linejoin: round; stroke-linecap: round; opacity: 0; }

/* 开壳以后 */
.stage.opened #shell-back,
.stage.opened #egg-cap,
.stage.opened .rim { opacity: 1; }
.stage.opened .crack[data-on-cap] { opacity: 0; }
.stage.opened .crack-glow { opacity: .35; }
.stage.opened .egg-motion { animation: none; }
.stage.opening #egg-cap { animation: cap-fly 1.5s cubic-bezier(.3, .65, .35, 1) both; }
.stage.rested #egg-cap { transform: var(--cap-rest); }

.baby {
  position: absolute;
  left: 27%;
  top: 8%;
  width: 46%;
  height: 46%;
  opacity: 0;
  transform: translateY(62%);
}
.stage.opened .baby { opacity: 1; }
.stage.baby-out .baby { transform: translateY(0); transition: transform .8s cubic-bezier(.3, 1.45, .55, 1); }
.stage.rested .baby { animation: sway 4.6s ease-in-out infinite; }
.baby-eyes { transform-origin: 200px 208px; }
.stage.rested .baby-eyes { animation: blink 5.5s linear infinite; }

/* 迸出来的红珠 */
.spark {
  position: absolute;
  left: 50%;
  top: 42%;
  width: calc(var(--stage) * .017);
  height: calc(var(--stage) * .017);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffc0c8, var(--ruby) 45%, #6d0f20);
  box-shadow: 0 0 8px rgba(216, 52, 76, .7);
  animation: spark var(--time) cubic-bezier(.2, .7, .4, 1) both;
}

/* 三颗红珠计数 */
.beads { display: flex; gap: 14px; list-style: none; position: relative; z-index: 2; margin-top: 2px; }
.beads li {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #1c1218;
  border: 1px solid #3f2630;
  transition: background .35s, box-shadow .35s, border-color .35s;
}
.beads li.lit {
  background: radial-gradient(circle at 35% 30%, #ffc0c8, var(--ruby) 45%, #6d0f20);
  border-color: var(--ruby);
  box-shadow: 0 0 10px rgba(216, 52, 76, .75);
}

.hint { position: relative; z-index: 2; min-height: 1.7em; margin-top: 8px; font-size: 13px; color: var(--muted); text-align: center; }
.hint.error { color: var(--ruby-light); }

.reveal { position: relative; z-index: 2; margin-top: 4px; text-align: center; animation: rise .9s ease-out both; }
.reveal-kicker { font-size: 12px; letter-spacing: .24em; color: var(--muted); }
.reveal-text { margin-top: 2px; font-size: 20px; letter-spacing: .14em; color: #fff; text-shadow: 0 0 18px rgba(216, 52, 76, .6); }
.reveal-time { margin-top: 2px; font-size: 12px; color: var(--muted); }

.card {
  position: relative;
  z-index: 2;
  width: min(100%, 420px);
  margin-top: 20px;
  padding: 16px 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  animation: rise 1s .2s ease-out both;
}
.card h2 { font-size: 13px; font-weight: 500; letter-spacing: .14em; color: var(--ruby-light); }
.card dl { display: grid; grid-template-columns: max-content 1fr; gap: 3px 16px; margin-top: 8px; font-size: 13px; }
.card dt { color: var(--muted); }

.actions { position: relative; z-index: 2; display: flex; gap: 14px; align-items: center; margin-top: 16px; }
.quiet-link { font-size: 12px; color: var(--muted); text-underline-offset: 3px; }
.quiet-link:hover { color: var(--ink); }

button { font: inherit; }
.quiet-button, .ruby-button {
  min-height: 34px;
  padding: 3px 16px;
  font-size: 13px;
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
}
.quiet-button { background: transparent; color: var(--ink); border: 1px solid #3a3746; }
.quiet-button:hover { border-color: var(--muted); }
.ruby-button { background: var(--ruby); color: #fff; border: 1px solid var(--ruby-light); }
.ruby-button:hover { filter: brightness(1.12); }
.ruby-button:disabled { opacity: .6; cursor: default; }

.footer { position: relative; z-index: 2; margin-top: 14px; font-size: 11px; color: #77728c; text-align: center; line-height: 1.8; }

.dialog {
  width: min(86vw, 340px);
  padding: 20px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid #3f2630;
  border-radius: 12px;
  box-shadow: 0 0 44px rgba(216, 52, 76, .22);
}
.dialog::backdrop { background: rgba(3, 3, 6, .72); }
.dialog h2 { font-size: 15px; font-weight: 500; letter-spacing: .06em; }
.dialog p { margin-top: 6px; font-size: 13px; color: var(--muted); }
.dialog-actions { display: flex; gap: 10px; margin-top: 16px; }

@keyframes breathe { 50% { transform: scale(1.012); } }
@keyframes aura { 50% { opacity: .72; } }
@keyframes flash { 0% { opacity: 0; } 18% { opacity: 1; } 100% { opacity: 0; } }
@keyframes glow-burst { to { filter: brightness(1.5); } }
@keyframes cap-fly {
  0% { transform: none; }
  32% { transform: translate(-3%, -16%) rotate(-16deg); }
  58% { transform: translate(14%, -11%) rotate(40deg); }
  100% { transform: var(--cap-rest); }
}
@keyframes spark {
  0% { transform: translate(-50%, -50%) scale(.4); opacity: 0; }
  12% { opacity: 1; }
  62% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx) * 1.2), calc(-50% + var(--dy) + var(--stage) * .3)) scale(.7); opacity: 0; }
}
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes sway { 50% { transform: translateY(0) rotate(2.4deg); } 0%, 100% { transform: translateY(0) rotate(-2deg); } }
@keyframes blink { 0%, 95%, 100% { transform: scaleY(1); } 97.5% { transform: scaleY(.08); } }

@media (prefers-reduced-motion: reduce) {
  .egg-motion, .aura, .stage.rested .baby, .stage.rested .baby-eyes { animation: none; }
  .stage.opening #egg-cap, .stage.opening .flash, .reveal, .card, .spark { animation: none; }
  .stage.opening #egg-cap { transform: var(--cap-rest); }
  .stage.baby-out .baby { transition: none; }
  .crack { transition: none; }
}
