:root {
  --night: #0b1020;
  --amber: #ffb35c;
  --lamp: #ffd9a0;
  --ink: #e8e4da;
  --dim: #8a94b0;
  --hair: rgba(232, 228, 218, .28);
  --ease: cubic-bezier(.22, .8, .2, 1);
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; background: var(--night); overflow: hidden; }
body { font-family: var(--mono); color: var(--ink); -webkit-font-smoothing: antialiased; }
.serif { font-family: var(--serif); font-style: italic; font-weight: 400; }
.mono { font-family: var(--mono); letter-spacing: .14em; text-transform: lowercase; }
button { font: inherit; color: inherit; }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- shared pieces ---------- */
.eyebrow { font-size: 11px; color: var(--dim); letter-spacing: .32em; }
.pill {
  font-size: clamp(19px, 2.2vw, 24px); color: var(--ink);
  background: rgba(11, 16, 32, .18); border: 1px solid var(--hair); border-radius: 999px;
  padding: 15px 40px 16px; cursor: pointer;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: border-color .6s var(--ease), background .6s var(--ease), box-shadow .8s var(--ease), color .6s var(--ease);
}
.pill:hover, .pill:focus-visible {
  border-color: rgba(255, 217, 160, .75); color: #fff6e6;
  background: rgba(255, 217, 160, .06);
  box-shadow: 0 0 40px rgba(255, 179, 92, .18), inset 0 0 18px rgba(255, 179, 92, .06);
  outline: none;
}
.pill.primary { border-color: rgba(255, 217, 160, .5); }

/* ---------- arrival ---------- */
#enter {
  position: fixed; inset: 0; z-index: 3;
  display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 46%, rgba(6, 8, 18, .25) 0%, rgba(6, 8, 18, .62) 70%);
  transition: opacity 1.8s var(--ease), visibility 0s linear 1.8s;
}
#enter.gone { opacity: 0; visibility: hidden; pointer-events: none; }
.enter-inner { text-align: center; padding: 0 24px; }
.enter-inner > * { opacity: 0; transform: translateY(10px); animation: rise 1.6s var(--ease) forwards; }
.enter-inner > :nth-child(1) { animation-delay: .4s; }
.enter-inner > :nth-child(2) { animation-delay: .8s; }
.enter-inner > :nth-child(3) { animation-delay: 1.5s; }
.enter-inner > :nth-child(4) { animation-delay: 2.1s; }
.enter-inner > :nth-child(5) { animation-delay: 2.6s; }
@keyframes rise { to { opacity: 1; transform: none; } }
#enter h1 {
  margin-top: 26px; font-size: clamp(30px, 4.6vw, 58px); line-height: 1.12; letter-spacing: -.005em;
  color: var(--ink); text-shadow: 0 2px 40px rgba(0, 0, 0, .55);
}
.rule { margin-top: 22px; font-size: 12px; color: var(--dim); }
#enterBtn { margin-top: 46px; }
.note { margin-top: 20px; font-size: 11px; color: var(--dim); min-height: 1.4em; }
.note .dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--amber); margin-right: 10px; vertical-align: 1px; box-shadow: 0 0 10px var(--amber); animation: breathe 4.5s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .35; } }
.footnote {
  position: fixed; left: 0; right: 0; bottom: max(26px, env(safe-area-inset-bottom));
  text-align: center; font-size: 10px; color: rgba(138, 148, 176, .7);
  opacity: 0; animation: rise 1.6s var(--ease) 3.2s forwards;
}

/* ---------- while sitting ---------- */
#hud {
  position: fixed; top: max(5vh, 28px); left: 0; right: 0; z-index: 2;
  text-align: center; pointer-events: none; padding: 0 20px;
}
#line1 {
  font-size: clamp(18px, 2.4vw, 27px); color: var(--ink);
  text-shadow: 0 2px 28px rgba(0, 0, 0, .7);
  opacity: 0; transform: translateY(6px);
  transition: opacity 2.4s var(--ease), transform 2.4s var(--ease);
}
#line2 {
  margin-top: 12px; font-size: 11px; color: var(--dim);
  opacity: 0; transition: opacity 2.4s var(--ease) .6s;
}
#hud.on #line1, #hud.on #line2 { opacity: 1; transform: none; }
#hud.on.quiet #line1 { opacity: 0; transform: translateY(-4px); }
#hud.on.quiet #line2 { opacity: .75; }

#timer {
  position: fixed; left: 0; right: 0; bottom: max(30px, calc(env(safe-area-inset-bottom) + 18px));
  text-align: center; font-size: 13px; letter-spacing: .3em; color: rgba(232, 228, 218, .55);
  opacity: 0; transition: opacity 2s var(--ease); pointer-events: none; z-index: 2;
  font-variant-numeric: tabular-nums;
}
#timer.on { opacity: 1; }

/* ---------- after ---------- */
#end {
  position: fixed; inset: 0; z-index: 4; display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 50%, rgba(6, 8, 18, .45), rgba(6, 8, 18, .78));
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fadeIn 1.4s var(--ease);
}
#end[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } }
#endCard { text-align: center; max-width: min(92vw, 620px); padding: 24px; }
#endCard > * { opacity: 0; transform: translateY(8px); animation: rise 1.4s var(--ease) forwards; }
#endCard > :nth-child(1) { animation-delay: .2s; }
#endCard > :nth-child(2) { animation-delay: .45s; }
#endCard > :nth-child(3) { animation-delay: .9s; }
#endCard > :nth-child(4) { animation-delay: 1.3s; }
#endCard > :nth-child(5) { animation-delay: 1.7s; }
#endTime {
  margin-top: 18px; font-size: clamp(76px, 13vw, 148px); line-height: .95; font-style: normal; font-weight: 400;
  color: var(--lamp); font-variant-numeric: lining-nums tabular-nums;
  text-shadow: 0 0 60px rgba(255, 179, 92, .28);
}
#endLine { margin-top: 18px; font-size: clamp(17px, 2.1vw, 22px); color: var(--ink); }
#endStats { margin-top: 26px; font-size: 11px; color: var(--dim); line-height: 2.1; }
#endStats div::before { content: ""; display: inline-block; width: 14px; height: 1px; background: rgba(138, 148, 176, .5); vertical-align: middle; margin-right: 12px; }
#endStats div::after { content: ""; display: inline-block; width: 14px; height: 1px; background: rgba(138, 148, 176, .5); vertical-align: middle; margin-left: 12px; }
.row { margin-top: 40px; display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.row .pill { font-size: 18px; padding: 12px 32px 13px; }

/* ---------- share ---------- */
#share {
  position: fixed; inset: 0; z-index: 7; display: grid; place-items: center; padding: 20px;
  background: rgba(4, 6, 14, .72); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: fadeIn .6s var(--ease);
}
#share[hidden] { display: none; }
#sharePanel { position: relative; width: min(720px, 100%); text-align: center; animation: rise .8s var(--ease); }
#shareImg {
  display: block; width: 100%; aspect-ratio: 1200 / 630; margin: 18px 0 26px; border-radius: 10px;
  border: 1px solid rgba(232, 228, 218, .14); box-shadow: 0 30px 80px rgba(0, 0, 0, .55), 0 0 60px rgba(255, 179, 92, .08);
  background: var(--night);
}
.shareRow { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.shareRow .pill { font-size: 17px; padding: 11px 26px 12px; }
.shareRow.small { margin-top: 20px; gap: 26px; }
.link {
  background: none; border: none; cursor: pointer; font-size: 11px; color: var(--dim);
  text-decoration: underline; text-decoration-color: rgba(138, 148, 176, .35); text-underline-offset: 5px;
}
.link:hover, .link:focus-visible { color: var(--lamp); text-decoration-color: var(--lamp); outline: none; }
.x { position: absolute; top: -4px; right: 0; background: none; border: none; cursor: pointer; font-size: 11px; color: var(--dim); }
.x:hover { color: var(--ink); }
#shareToast { margin-top: 18px; min-height: 1.4em; font-size: 11px; color: var(--lamp); opacity: 0; transition: opacity .5s; }
#shareToast.on { opacity: 1; }

#offlineBadge {
  position: fixed; top: 18px; right: 20px; z-index: 5;
  font-size: 10px; color: var(--dim); padding: 6px 12px; border: 1px solid rgba(138, 148, 176, .3); border-radius: 999px;
}
#offlineBadge[hidden] { display: none; }

/* ---------- credit ---------- */
#credit {
  position: fixed; right: max(22px, env(safe-area-inset-right)); bottom: max(20px, env(safe-area-inset-bottom)); z-index: 5;
  display: flex; align-items: center; gap: 12px; font-size: 10px; color: rgba(138, 148, 176, .75);
  opacity: 1; transition: opacity 1.4s var(--ease);
}
#credit a { display: inline-flex; color: inherit; padding: 4px; margin: -4px; border-radius: 6px; transition: color .4s var(--ease); }
#credit a[hidden] { display: none; }
#credit a:hover, #credit a:focus-visible { color: var(--lamp); outline: none; }
#credit svg { width: 13px; height: 13px; fill: currentColor; }
body.sitting #credit { opacity: 0; pointer-events: none; }
@media (max-width: 560px) { #credit { right: 50%; transform: translateX(50%); bottom: max(12px, env(safe-area-inset-bottom)); } .footnote { bottom: 44px; } }

/* ---------- test build bar ---------- */
#devbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 10px; z-index: 6;
  display: flex; gap: 6px; align-items: center; padding: 6px 8px 6px 12px;
  background: rgba(6, 8, 18, .72); border: 1px dashed rgba(138, 148, 176, .4); border-radius: 999px;
  font-size: 10px; color: var(--dim); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
#devbar[hidden] { display: none; }
#devbar .devtag { color: #c9a24a; margin-right: 4px; }
#devbar button {
  font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: lowercase;
  background: none; border: 1px solid rgba(138, 148, 176, .35); color: var(--ink);
  border-radius: 999px; padding: 5px 11px; cursor: pointer;
}
#devbar button[aria-pressed="false"] { color: var(--dim); border-style: dashed; }
#devbar button:hover { border-color: var(--lamp); }
body.testing #timer { bottom: 56px; }
body.testing .footnote { bottom: 58px; }

@media (prefers-reduced-motion: reduce) {
  .enter-inner > *, #endCard > *, .footnote { animation-duration: .01s; animation-delay: 0s !important; }
}
