:root {
  --bg: #000;
  --ink: #d6d6d6;
  --lit: #ffffff;
  --dusk: #9b9b9b;
  --gram: #686868;
  --shadow: #363636;
  --rule: #262626;
  --faint: #777;
  --sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Courier New", monospace;
  --col: 640px;
  --gutter: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100svh;
  overflow-x: hidden;
  transition: background-color 2.4s ease, color 2.4s ease;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; }
.mono { font-family: var(--mono); }
[hidden] { display: none !important; }

/* ── top rail ─────────────────────────────── */
.top {
  position: fixed; inset: 0 0 auto 0; z-index: 5;
  display: flex; gap: 18px; align-items: baseline;
  padding: 18px var(--gutter);
  font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--faint);
  pointer-events: none;
  background: linear-gradient(var(--bg) 55%, transparent);
  transition: background 2.4s ease;
}
.top .mark { color: var(--ink); letter-spacing: .32em; }
.top .how {
  pointer-events: auto;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px;
  color: var(--faint);
}
.top .how:hover { color: var(--ink); }
.top .how { white-space: nowrap; }
.top .status { margin-left: auto; font-family: var(--mono); letter-spacing: .04em; text-transform: none; }

/* ── scenes ───────────────────────────────── */
main { position: relative; z-index: 2; }
.scene {
  display: none;
  max-width: calc(var(--col) + var(--gutter) * 2);
  margin: 0 auto;
  padding: 18vh var(--gutter) 30vh;
  opacity: 0;
  transition: opacity .9s ease;
}
.scene.on { display: block; }
.scene.shown { opacity: 1; }

.label {
  margin: 0 0 10px;
  font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--faint);
}
.fine { font-size: 13px; color: var(--faint); margin: 18px 0 0; }
.fine a, .link { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.link { color: var(--faint); }
.link:hover, .fine a:hover { color: var(--ink); }
.dot { color: var(--shadow); margin: 0 6px; }

.go {
  font-size: 15px; letter-spacing: .02em;
  padding: 10px 0;
  border-bottom: 1px solid currentColor;
  color: var(--lit);
  transition: opacity .3s ease, color .3s ease;
}
.go:hover { opacity: .7; }
.go:disabled { color: var(--faint); border-color: transparent; cursor: default; opacity: 1; }
.go.quiet { color: var(--dusk); }
:focus-visible { outline: 1px dotted var(--dusk); outline-offset: 4px; }

.row { display: flex; align-items: baseline; justify-content: space-between; gap: 24px; margin-top: 18px; flex-wrap: wrap; }
.row.end { justify-content: flex-start; gap: 36px; margin-top: 40px; }

/* ── 0 threshold ──────────────────────────── */
#threshold { padding-top: 22vh; }
.lines p {
  margin: 0 0 .55em;
  font-size: clamp(19px, 2.6vw, 25px);
  line-height: 1.4;
  letter-spacing: -.005em;
  color: var(--ink);
  text-wrap: balance;
  opacity: 0; transform: translateY(4px);
  transition: opacity 1.6s ease, transform 1.6s ease;
}
.lines p.in { opacity: 1; transform: none; }
.lines p:nth-child(4) { margin-top: 1.3em; color: var(--lit); }
.act { margin-top: 44px; opacity: 0; transition: opacity 1.4s ease; text-shadow: 0 0 10px #000, 0 0 4px #000; }
.act.in { opacity: 1; }

/* ── I the wall ───────────────────────────── */
.prompt { text-wrap: balance; font-size: clamp(20px, 2.8vw, 26px); line-height: 1.35; color: var(--lit); margin: 0 0 10px; max-width: 34ch; }
.prompt.inked { max-width: 520px; }
.prompt .ink {   /* the card, in Peter's hand: an alpha mask painted in the scene's color */
  display: block; width: 100%;
  background: currentColor;
  -webkit-mask-size: contain; mask-size: contain;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: left center; mask-position: left center;
}
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.aside { margin: 0 0 30px; font-size: 13px; }
.hand { margin: -2px 0 10px; font-size: 13px; color: var(--faint); }
textarea {
  display: block; width: 100%;
  min-height: 34vh;
  background: transparent; color: var(--ink);
  border: 0; border-top: 1px solid var(--rule);
  padding: 22px 0 0;
  font: inherit; font-size: 19px; line-height: 1.6;
  resize: none; outline: none;
  caret-color: var(--lit);
  overflow: hidden;
}
textarea:focus-visible { outline: none; }
textarea::placeholder { color: var(--faint); opacity: 1; }
body.s-ascent .aside { display: none; }
.count { font-family: var(--mono); font-size: 12px; color: var(--faint); }
.was { margin: 0 0 20px; }
.chips { margin: 0; font-family: var(--mono); font-size: 13px; color: var(--dusk); line-height: 1.9; }
.chips span { display: inline-block; margin-right: 14px; }

/* ── II the fire ──────────────────────────── */
.verdict { text-wrap: balance; font-size: clamp(22px, 3.2vw, 30px); line-height: 1.3; color: var(--lit); margin: 0 0 10px; max-width: 32ch; }
.sub { margin: 0 0 22px; color: var(--dusk); font-size: 15px; max-width: 44ch; }
.scale { font-size: 12px; line-height: 1.7; color: var(--gram); margin: 0 0 30px; white-space: pre; overflow-x: auto; }
.scale .you { color: var(--lit); }
.scale .cap { font-family: var(--sans); white-space: normal; font-size: 13px; line-height: 1.5; color: var(--faint); margin: 12px 0 0; max-width: 52ch; }
.hint { font-size: 13px; color: var(--faint); margin: 0 0 18px; }
.text {
  font-size: 20px; line-height: 1.75;
  border-top: 1px solid var(--rule); padding-top: 22px;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.w { cursor: pointer; color: var(--ink); transition: color .7s ease, opacity .7s ease; border-radius: 2px; }
.w.cast.lit     { color: var(--lit); }
.w.cast.dusk    { color: var(--dusk); }
.w.cast.grammar { color: var(--gram); }
.w.cast.first   { color: var(--dusk); }
.w.cast.mark    { color: var(--gram); }
.w.cast.shadow  { color: var(--shadow); }
.w.verb   { text-decoration: line-through; text-decoration-thickness: 1px; text-decoration-color: #8a8a8a; }
.w.frame  { text-decoration: underline dotted; text-decoration-thickness: 1px; text-underline-offset: 5px; text-decoration-color: #8a8a8a; }
.w.sel    { background: #1d1d1d; outline: 1px solid #3a3a3a; }
.w:hover  { background: #111; }
.linewrap { margin-top: 34px; }
.line { font-size: 11px; line-height: 1.1; letter-spacing: .06em; margin: 0; overflow-wrap: anywhere; }
.line b { font-weight: 400; }
.line .l { color: var(--lit); } .line .d { color: var(--dusk); } .line .s { color: var(--shadow); }

/* ── ghost panel ──────────────────────────── */
.ghost {
  position: fixed; z-index: 8;
  left: 50%; bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(calc(100vw - 32px), 560px);
  background: #050505; border: 1px solid #2c2c2c;
  padding: 18px 20px 16px;
  font-size: 14px; line-height: 1.5;
  box-shadow: 0 -30px 60px #000;
}
.ghost .x { position: absolute; top: 8px; right: 12px; font-size: 20px; color: var(--faint); padding: 4px 6px; }
.gword { font-size: 20px; color: var(--lit); margin: 0 0 12px; padding-right: 30px; }
.ghost dl { margin: 0; display: grid; grid-template-columns: 9.5em 1fr; gap: 6px 14px; }
.ghost dt { font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--faint); padding-top: 4px; }
.ghost dd { margin: 0; color: var(--ink); }
.ghost dd.mono { font-size: 13px; }
@media (max-width: 480px) {
  .ghost dl { grid-template-columns: 1fr; gap: 2px; }
  .ghost dd { margin-bottom: 8px; }
}

/* ── III daylight ─────────────────────────── */
body.s-day { --bg: #f5f5f2; --ink: #1a1a1a; --lit: #000; --faint: #8a8a86; --rule: #ddd; background: var(--bg); color: var(--ink); color-scheme: light; }
body.s-day .top .mark { color: #000; }
#day { padding-top: 20vh; }
.poem { font-size: clamp(22px, 3vw, 30px); line-height: 1.5; color: #000; margin: 0 0 30px; word-spacing: .22em; max-width: 30ch; }
.after { color: #555; margin: 0 0 8px; }
.last { margin: 56px 0 0; font-size: 19px; color: #000; }
body.s-day .go { color: #000; }
body.s-day .fine, body.s-day .link { color: #8a8a86; }
.support { margin-top: 40px; }

/* your days by the fire: months grow toward now; amber by how much stayed lit */
.daysbox { margin: 48px 0 0; }
.days { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.month { display: flex; flex-direction: column; gap: 6px; }
.month span { font-family: var(--mono); font-size: 10px; color: #8a8a86; letter-spacing: .04em; }
.mgrid { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, var(--s)); grid-auto-columns: var(--s); gap: 2px; }
.mgrid b, .mgrid i { display: block; border-radius: 2px; }
.mgrid b { background: #e4e1d9; }
.mgrid b.future { background: transparent; box-shadow: inset 0 0 0 1px #ebe8e1; }
.mgrid b.l1 { background: #f2d8a4; }
.mgrid b.l2 { background: #e9b45a; }
.mgrid b.l3 { background: #d98a1f; }
.mgrid b.l4 { background: #b5600a; }
.mgrid b.today { box-shadow: 0 0 0 1px #1a1a1a; }
body.s-day .support a { color: #1a1a1a; }

/* ── fire ─────────────────────────────────── */
.fire {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1;
  height: 36vh; margin: 0; overflow: hidden;
  font-family: var(--mono); font-size: 10px; line-height: 10px; letter-spacing: 0;
  color: #cfcfcf;
  display: flex; align-items: flex-end; justify-content: center; white-space: pre;
  pointer-events: none; user-select: none;
  -webkit-mask-image: linear-gradient(to top, #000 40%, transparent);
          mask-image: linear-gradient(to top, #000 40%, transparent);
  transition: height 1.6s ease, opacity 1.6s ease;
}
body.s-wall .fire, body.s-ascent .fire { height: 16vh; opacity: .55; }
body.s-read .fire { height: 14vh; opacity: .4; }
body.s-read.casting .fire { height: 44vh; opacity: 1; }
body.s-day .fire { opacity: 0; }
body::before {  /* firelight on the wall */
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(120% 60% at 50% 110%, rgba(255,255,255,.07), transparent 70%);
  transition: opacity 2s ease;
}
body.s-day::before { opacity: 0; }

.noscript { padding: 30vh 16px; max-width: 40ch; margin: 0 auto; }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .scene { padding-top: 14vh; }
  .text { font-size: 18px; }
  textarea { font-size: 18px; }
  .top { gap: 12px; }
  .top .stage { display: none; }
  .top { flex-wrap: wrap; row-gap: 6px; }
  .top .status { flex-basis: 100%; margin-left: 0; }   /* its own line: the download size and percentage both stay readable */
  .fire { height: 30vh; }
  #threshold { padding-top: 12vh; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; }
}
