:root {
  --night: #2a0a1c;
  --plum: #4a1433;
  --cran: #e0336b;
  --butter: #ffd65a;
  --marker: #3fa7ff;
  --sage: #8fd6a8;
  --cream: #fff1e4;
  --pumpkin: #ff8a3d;
  --panel: rgba(42, 10, 28, 0.8);
  --display: "Bowlby One", "Arial Black", sans-serif;
  --body: "Figtree", system-ui, sans-serif;
  --measure: 36rem;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--night);
  color: var(--cream);
  font-family: var(--body);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 0;
}
body.no-webgl #scene { display: none; }
body.no-webgl {
  background: radial-gradient(ellipse at 70% 20%, #5c1a3f, var(--night) 60%) fixed;
}

.loading {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: var(--night);
  font-family: var(--display); font-size: 1.4rem; color: var(--butter);
  transition: opacity .8s ease, visibility .8s;
}
.loading.done { opacity: 0; visibility: hidden; }

/* top bar */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .9rem clamp(1rem, 3vw, 2.2rem);
  background: linear-gradient(var(--night), rgba(42,10,28,0));
}
.brand {
  font-family: var(--display); color: var(--butter); text-decoration: none; font-size: 1.05rem;
  text-shadow: 2px 2px 0 var(--cran);
}
.topbar nav { display: flex; gap: .25rem; flex-wrap: wrap; justify-content: flex-end; }
.topbar nav a {
  color: var(--cream); text-decoration: none; font-weight: 600; font-size: .9rem;
  padding: .35rem .7rem; border-radius: 999px;
  transition: background .2s, color .2s;
}
.topbar nav a:hover { background: rgba(255,241,228,.12); }
.topbar nav a.active { background: var(--butter); color: var(--night); }

/* beats */
main { position: relative; z-index: 1; }
.beat {
  min-height: 100vh;
  display: flex; align-items: center;
  padding: 6rem clamp(1rem, 4vw, 4rem);
  pointer-events: none;
}
.beat[data-side="right"] { justify-content: flex-end; }
.beat#top { min-height: 100vh; }

.panel {
  pointer-events: auto;
  width: 100%;
  max-width: var(--measure);
  padding: clamp(1.4rem, 2.6vw, 2.2rem);
  background: var(--panel);
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  border: 1px solid rgba(255, 214, 90, .18);
  border-radius: 22px;
}
.panel.wide { max-width: 54rem; }
.hero-panel { background: rgba(42,10,28,.62); max-width: 38rem; }

.panel > :first-child { margin-top: 0; }
.panel > :last-child { margin-bottom: 0; }

p { margin: 0 0 1em; }
strong { font-weight: 800; }
em { font-style: italic; }
q { font-style: italic; color: var(--butter); }
a { color: var(--butter); }
:focus-visible { outline: 3px solid var(--butter); outline-offset: 3px; border-radius: 6px; }

/* type */
.display {
  font-family: var(--display);
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: -0.01em;
  color: var(--butter);
  text-shadow: 3px 3px 0 var(--cran), 6px 6px 0 rgba(0,0,0,.35);
  margin: 0 0 .5em;
}
h1.display { font-size: clamp(2.4rem, 4.8vw, 4.3rem); }
h2.display { font-size: clamp(2.2rem, 4.6vw, 3.8rem); }
h2.display.small { font-size: clamp(1.8rem, 3.4vw, 2.7rem); }
.game-title { color: var(--accent); text-shadow: 3px 3px 0 var(--cran), 6px 6px 0 rgba(0,0,0,.35); }
#drawful .game-title { text-shadow: 3px 3px 0 var(--cream), 6px 6px 0 var(--cran); }

h3 { font-family: var(--body); font-weight: 800; font-size: 1.2rem; line-height: 1.3; margin: 1.6em 0 .5em; color: var(--cream); }
.step-head { font-family: var(--display); font-weight: 400; font-size: 1.6rem; color: var(--butter); margin-top: 0; }
.lede { font-size: 1.2rem; line-height: 1.5; }
.aside { color: rgba(255,241,228,.72); font-size: .95rem; }
.era-years { font-family: var(--display); color: var(--cran); font-size: 1.1rem; margin-bottom: .3em; text-shadow: 1px 1px 0 rgba(0,0,0,.4); }

.scroll-cue { display: flex; align-items: center; gap: .6rem; margin-top: 1.8rem; font-weight: 600; color: var(--sage); }
.cue-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--sage); animation: cue 1.8s ease-in-out infinite; }
@keyframes cue { 0%,100% { transform: translateY(-3px); opacity: .5 } 50% { transform: translateY(5px); opacity: 1 } }
@media (prefers-reduced-motion: reduce) { .cue-dot { animation: none; } }

/* facts */
.facts {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: .6rem; margin: 1.4rem 0 0;
}
.facts div { background: rgba(255,241,228,.07); border-radius: 12px; padding: .55rem .8rem; }
.facts dt { font-size: .8rem; color: rgba(255,241,228,.65); }
.facts dd { margin: 0; font-weight: 800; line-height: 1.25; }

/* steps */
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0 0 .5rem; }
.steps li { counter-increment: s; position: relative; padding-left: 3rem; margin-bottom: 1rem; }
.steps li::before {
  content: counter(s);
  position: absolute; left: 0; top: .05rem;
  width: 2.1rem; height: 2.1rem; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--display); font-size: 1rem;
  background: var(--butter); color: var(--night);
  box-shadow: 2px 2px 0 var(--cran);
}
.ticks { padding-left: 1.2rem; margin: 0; }
.ticks li { margin-bottom: .45rem; }
.ticks li::marker { color: var(--marker); }

.pack-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .45rem; margin: 0 0 1.1rem; }
.pack-list li { padding: .3rem .8rem; border-radius: 999px; background: rgba(255,241,228,.1); font-weight: 600; }
.pack-list li.hl { background: var(--butter); color: var(--night); font-weight: 800; }

/* drawing pad */
.pad-prompt { display: flex; align-items: baseline; flex-wrap: wrap; gap: .4rem .6rem; margin-bottom: .8rem; }
.pad-prompt strong { font-family: "Caveat", cursive; font-size: 1.7rem; color: var(--butter); line-height: 1; }
#pad {
  width: 100%; aspect-ratio: 4 / 3; display: block;
  background: var(--cream); border-radius: 14px;
  touch-action: none; cursor: crosshair;
  box-shadow: inset 0 0 0 3px rgba(42,10,28,.15);
}
.pad-tools { display: flex; align-items: center; gap: .6rem; margin: .9rem 0 .6rem; flex-wrap: wrap; }
.swatches { display: flex; gap: .5rem; margin-right: auto; }
.swatch {
  width: 2.4rem; height: 2.4rem; border-radius: 50%; border: 3px solid transparent; cursor: pointer;
  box-shadow: 0 0 0 2px rgba(255,241,228,.3);
}
.swatch[aria-pressed="true"] { border-color: var(--cream); box-shadow: 0 0 0 3px var(--butter); }

.btn {
  font: 800 1rem var(--body);
  background: var(--butter); color: var(--night);
  border: 0; border-radius: 999px; padding: .65rem 1.2rem; cursor: pointer;
  box-shadow: 3px 3px 0 var(--cran);
  transition: transform .12s, box-shadow .12s;
}
.btn:hover { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 var(--cran); }
.btn:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--cran); }
.btn.ghost { background: transparent; color: var(--cream); box-shadow: inset 0 0 0 2px rgba(255,241,228,.4); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.link-btn { font: 600 .95rem var(--body); background: none; border: 0; color: var(--sage); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: .2rem 0; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* fibbage play */
.fib-round { font-weight: 800; color: var(--cran); margin-bottom: .3rem; }
.fib-q { font-family: var(--display); font-size: clamp(1.3rem, 2.4vw, 1.7rem); line-height: 1.2; color: var(--cream); }
.lie-form label { display: block; font-weight: 600; margin-bottom: .35rem; }
.lie-row { display: flex; gap: .5rem; margin-bottom: .4rem; }
.lie-row input {
  flex: 1; min-width: 0;
  font: 600 1.05rem var(--body);
  padding: .65rem .9rem; border-radius: 12px;
  border: 2px solid rgba(255,241,228,.3); background: rgba(255,241,228,.08); color: var(--cream);
}
.lie-row input:focus { border-color: var(--butter); outline: none; }
.choices { display: grid; gap: .5rem; margin: .4rem 0 1rem; }
.choice {
  text-align: left; font: 700 1.05rem var(--body);
  padding: .7rem 1rem; border-radius: 14px; cursor: pointer;
  background: rgba(255,241,228,.1); color: var(--cream); border: 2px solid transparent;
}
.choice:hover:not(:disabled) { border-color: var(--butter); }
.choice:disabled { cursor: default; }
.choice.mine { opacity: .55; font-style: italic; }
.choice.truth { background: var(--butter); color: var(--night); }
.choice.picked:not(.truth) { background: var(--cran); color: var(--cream); }
.fib-result { min-height: 1.6em; }
.fib-result strong { color: var(--butter); }
.fib-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.fib-score { margin: 0; font-weight: 600; }
.fib-score strong { font-family: var(--display); font-weight: 400; color: var(--butter); font-size: 1.3rem; }

/* family */
.lineages { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.4rem; margin-top: 1.2rem; }
.lineage h3 { margin-top: 0; color: var(--accent); font-family: var(--display); font-weight: 400; font-size: 1.35rem; }
.lineage > p { color: rgba(255,241,228,.75); font-size: .95rem; }
.lineage ul { list-style: none; padding: 0; margin: 0; }
.lineage li { padding: .5rem 0; border-top: 1px solid rgba(255,241,228,.12); font-size: .95rem; line-height: 1.45; }
.lineage li strong { color: var(--accent); }

/* faq */
.faq dt { font-weight: 800; font-size: 1.1rem; color: var(--butter); margin-top: 1rem; }
.faq dt:first-child { margin-top: 0; }
.faq dd { margin: .2rem 0 0; }

/* footer */
.foot {
  position: relative; z-index: 1;
  padding: 3rem clamp(1rem, 4vw, 4rem) 4rem;
  background: linear-gradient(rgba(42,10,28,0), var(--night) 40%);
  font-size: .9rem; color: rgba(255,241,228,.7);
}
.foot p { max-width: 50rem; }

/* mobile */
@media (max-width: 820px) {
  .topbar nav a:not(.active) { display: none; }
  .topbar nav a.active { display: inline-block; }
  .beat, .beat[data-side="right"] {
    justify-content: center; align-items: flex-end;
    min-height: 115vh; padding: 45vh 1rem 2rem;
  }
  .beat#top { padding-top: 40vh; }
  .panel, .hero-panel { background: rgba(42,10,28,.86); }
  .lineages { grid-template-columns: 1fr; }
  .lie-row { flex-direction: column; }
}
