:root[data-hue="phosphorus"] {
  --bg: #000;
  --ink: #3dff62;
  --hot: #c8ffd4;
  --dim: #14943a;
  --faint: #0c4d20;
  --line: rgba(61, 255, 98, 0.4);
  --glow: 0 0 12px rgba(40, 255, 90, 0.38);
  --panel: rgba(61, 255, 98, 0.05);
  --wash: rgba(61, 255, 98, 0.1);
}

:root[data-hue="sulfur"] {
  --bg: #000;
  --ink: #f0f04a;
  --hot: #ffffb0;
  --dim: #a8a018;
  --faint: #55520c;
  --line: rgba(240, 240, 74, 0.42);
  --glow: 0 0 12px rgba(230, 220, 40, 0.34);
  --panel: rgba(240, 240, 74, 0.05);
  --wash: rgba(240, 240, 74, 0.1);
}

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

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  min-height: 100%;
}

body {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 15px;
  line-height: 1.5;
  text-shadow: var(--glow);
}

body::before {
  content: "";
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.045) 0 1px,
    transparent 1px 3px
  );
}

body::after {
  content: "";
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 41;
  background: radial-gradient(ellipse at center, transparent 58%, rgba(0, 0, 0, 0.42) 100%);
}

::selection { background: var(--ink); color: #000; text-shadow: none; }

button, input {
  font: inherit;
  color: inherit;
  text-shadow: inherit;
}

button {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.65rem 0.9rem;
  cursor: pointer;
  touch-action: manipulation;
}

button:hover { background: var(--wash); }
button:focus-visible, input:focus-visible {
  outline: 2px solid var(--hot);
  outline-offset: 2px;
}
button[aria-pressed="true"] {
  background: var(--ink);
  color: #000;
  text-shadow: none;
  border-color: var(--ink);
}
button.primary {
  background: var(--ink);
  color: #000;
  text-shadow: none;
  border-color: var(--ink);
  font-weight: 600;
}
button:disabled { opacity: 0.38; cursor: not-allowed; }

input {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0.55rem 0.6rem;
}

label { display: block; margin: 0.75rem 0 0.35rem; color: var(--hot); }

h1, h2, h3, .essay, blockquote, .subhead, .pts b, .win-card h2, #cover h2, #gate h2 {
  font-family: Fraunces, Georgia, serif;
  font-weight: 500;
  text-shadow: none;
  letter-spacing: -0.03em;
}

h1 {
  font-size: clamp(3.2rem, 9vw, 6.6rem);
  line-height: 0.86;
  margin: 0.15rem 0 0.4rem;
  font-style: italic;
}
h1 em { font-style: italic; color: var(--hot); }
h2 { font-size: 1.7rem; line-height: 1.1; margin: 0 0 0.5rem; }
h3 { font-size: 1rem; margin: 1rem 0 0.35rem; font-family: "IBM Plex Mono", ui-monospace, monospace; letter-spacing: 0; font-weight: 600; }

p { margin: 0.4rem 0; }
a { color: inherit; }

.kicker {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--dim);
  margin: 0 0 0.4rem;
}

.hue {
  position: fixed;
  top: 0.7rem;
  right: 0.7rem;
  z-index: 50;
  display: flex;
  gap: 0.35rem;
  background: #000;
}
.hue button { padding: 0.4rem 0.7rem; font-size: 0.78rem; }

#gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 4.5rem 1.2rem 2rem;
}
.gate-card { max-width: 40rem; }
.gate-card h2 { font-size: clamp(2.4rem, 6vw, 4rem); font-style: italic; }
blockquote {
  margin: 1.2rem 0;
  padding: 0 0 0 1rem;
  border-left: 2px solid var(--ink);
  color: var(--hot);
  font-size: clamp(1.35rem, 3vw, 1.8rem);
  line-height: 1.25;
  font-style: italic;
}
.ack {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin: 1rem 0;
  color: var(--ink);
}
.ack input { width: 1.15rem; height: 1.15rem; margin: 0.2rem 0 0; accent-color: var(--ink); }
#enter { width: 100%; padding: 0.9rem 1rem; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  padding: 4.2rem 1.2rem 0.4rem;
  max-width: 1180px;
  margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 0.6rem; text-decoration: none; }
.logo { width: 86px; height: 48px; }
.logo .stick, .logo .ring { stroke: var(--hot); }
.brand span { font-family: Fraunces, Georgia, serif; font-style: italic; font-size: 1.25rem; }
.presence { color: var(--dim); margin: 0; font-size: 0.82rem; }

main { max-width: 1180px; margin: 0 auto; padding: 0 1.2rem 3rem; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 1.5rem;
  align-items: end;
  padding-top: 0.5rem;
}
.subhead { font-size: clamp(1.25rem, 2.4vw, 1.7rem); font-style: italic; color: var(--hot); margin-top: 0; }
.essay p { font-size: 1.08rem; line-height: 1.55; max-width: 42rem; }
.hero-mark { margin: 0; }
.mark { width: 100%; height: auto; }
.mark .bone, .mark .ground { fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.mark .ground { stroke: var(--faint); stroke-width: 1; }
.mark .stick { stroke: var(--hot); stroke-width: 6; stroke-linecap: round; }
.mark .ring { fill: none; stroke: var(--hot); stroke-width: 3; }
.mark .tag { fill: var(--dim); font: 12px "IBM Plex Mono", ui-monospace, monospace; }
figcaption { color: var(--dim); font-size: 0.8rem; }

.modes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 1.5rem;
}
.card, .manual, .board-card, .win-card, .cover-card {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 1rem;
}
.index { color: var(--dim); letter-spacing: 0.12em; margin: 0; }
.card h2 { font-style: italic; }
.card p { color: var(--hot); font-size: 0.92rem; }
.hint { color: var(--dim) !important; font-size: 0.78rem !important; }
.field { margin-top: 0.7rem; }
.field > span, .pair h3 { display: block; color: var(--hot); margin-bottom: 0.3rem; font-size: 0.85rem; }
.choice { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.3rem 0 0.5rem; }
.choice button { flex: 1; }
.choice.wide { margin-top: 0.8rem; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.moves input { max-width: 7rem; }
.card .primary { width: 100%; margin-top: 0.8rem; }

.lower {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 0.8rem;
  margin-top: 0.8rem;
}
.manual ul { margin: 0.3rem 0 0.6rem; padding-left: 1.1rem; }
.manual li { margin: 0.2rem 0; }
.board-head p { color: var(--dim); }
.board-wrap { overflow: auto; max-height: 520px; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; min-width: 680px; font-size: 0.82rem; }
th, td { text-align: left; padding: 0.45rem 0.4rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { position: sticky; top: 0; background: #000; color: var(--dim); font-weight: 500; }
td.empty { color: var(--dim); white-space: normal; }
.nick { color: var(--hot); }
.dens { font-variant-numeric: tabular-nums; }

footer { margin-top: 1.4rem; color: var(--dim); font-size: 0.82rem; }
footer p { margin: 0.15rem 0; }

#play { position: relative; padding-top: 0.4rem; }
.play-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 1rem;
  align-items: baseline;
  justify-content: space-between;
}
#relation {
  font-family: Fraunces, Georgia, serif;
  font-style: italic;
  font-size: 1.4rem;
  margin: 0;
}
#story { max-width: 48rem; color: var(--hot); }
#length-note { color: var(--dim); font-size: 0.85rem; }

.scoreline {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.8rem;
  align-items: stretch;
}
.side { border: 1px solid var(--line); padding: 0.7rem 0.8rem; background: var(--panel); min-height: 7.5rem; }
.side.right { text-align: right; }
.side .who { font-family: Fraunces, Georgia, serif; font-style: italic; font-size: 1.5rem; margin: 0; }
.side .meta, .side .place { color: var(--dim); font-size: 0.78rem; margin: 0.15rem 0; }
.was { color: var(--hot); }
.pts { display: flex; gap: 0.7rem; align-items: baseline; margin: 0.35rem 0 0; }
.side.right .pts { justify-content: flex-end; }
.pts b { font-size: 2.3rem; line-height: 1; font-variant-numeric: tabular-nums; }
.pts span { color: var(--dim); font-size: 0.78rem; }
.meter { height: 2px; background: var(--faint); margin-top: 0.45rem; }
.meter i { display: block; height: 100%; background: var(--hot); width: 0; }
.mid { align-self: center; color: var(--dim); margin: 0; letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.72rem; }

.stage-wrap {
  margin-top: 0.7rem;
  border: 1px solid var(--line);
  background:
    radial-gradient(ellipse at 50% 80%, var(--wash), transparent 60%),
    #000;
  box-shadow: inset 0 0 80px #000;
}
#stage { width: 100%; height: auto; display: block; color: var(--ink); }
#stage .bone { fill: none; stroke: currentColor; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
#stage .stick { fill: none; stroke: var(--hot); stroke-width: 7; stroke-linecap: round; }
#stage .ring { fill: none; stroke: var(--hot); stroke-width: 3.5; }
#stage .ring.hit { animation: pulse 0.55s ease 3; }
#stage .ground { stroke: var(--faint); stroke-width: 1; }
#stage .tag, #stage .q {
  fill: var(--dim);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}
#stage .q { font-size: 28px; fill: var(--hot); }
#stage .link { stroke: var(--ink); stroke-width: 1.2; stroke-dasharray: 3 4; opacity: 0.7; }

@keyframes pulse {
  50% { stroke-width: 8; }
}

#log { min-height: 1.4rem; margin: 0.7rem 0; }
#log p { margin: 0.15rem 0; }

#pickers { display: grid; gap: 0.8rem; }
#pickers.two { grid-template-columns: 1fr 1fr; }
.picker { border: 1px solid var(--line); margin: 0; padding: 0.8rem; }
.picker legend { padding: 0 0.4rem; color: var(--hot); }
.poses, .aims { display: grid; gap: 0.4rem; }
.poses { grid-template-columns: repeat(3, 1fr); }
.aims { grid-template-columns: repeat(4, 1fr); margin-top: 0.45rem; }
.poses button, .aims button {
  border-radius: 0.9rem;
  min-height: 3.4rem;
  text-align: left;
}
.poses button span, .aims button span {
  display: block;
  color: var(--dim);
  font-size: 0.68rem;
  margin-top: 0.15rem;
}
button[aria-pressed="true"] span { color: #000; opacity: 0.72; }
#lock, #loop-stop { width: 100%; margin-top: 0.8rem; padding: 0.85rem; }

#cover {
  position: absolute;
  inset: 0;
  z-index: 6;
  background: rgba(0, 0, 0, 0.78);
  display: grid;
  place-items: center;
  padding: 1rem;
}
.cover-card { max-width: 28rem; width: min(100%, 28rem); }
#cover h2 { font-style: italic; font-size: 2.2rem; }
#cover-go { width: 100%; margin-top: 0.6rem; }

#win { margin-top: 0.6rem; position: relative; }
#fw {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 30;
}
.win-card { position: relative; z-index: 32; max-width: 40rem; }
.win-card h2 { font-style: italic; font-size: clamp(2rem, 5vw, 3.4rem); }
.win-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.8rem; }

#err { color: var(--hot); min-height: 1.2rem; }
.noscript {
  max-width: 40rem;
  margin: 1rem auto;
  padding: 0 1rem;
}

@media (max-width: 980px) {
  .hero, .modes, .lower, #pickers.two { grid-template-columns: 1fr; }
  .top { padding-top: 3.6rem; }
}

@media (max-width: 700px) {
  .pair, .scoreline { grid-template-columns: 1fr 1fr; }
  .scoreline .mid { grid-column: 1 / -1; order: -1; text-align: center; }
  .poses { grid-template-columns: 1fr 1fr; }
  .aims { grid-template-columns: 1fr 1fr; }
  .side.right { text-align: left; }
  .side.right .pts { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  body::before { display: none; }
  #stage .ring.hit { animation: none; }
}
