:root {
  color-scheme: dark;
  --ink: #f2f1df;
  --muted: #b8b19a;
  --paper: #d8c58f;
  --line: #3b3a2c;
  --accent: #76f7a0;
  --accent-dark: #e0b45e;
  --chalk: #f2f1df;
  --board: #0a1915;
  --bg: #080907;
  --panel: #15170f;
  --rust: #b86b4f;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(118, 247, 160, 0.07), transparent 430px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 80px),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic", sans-serif;
  line-height: 1.75;
}

a {
  color: inherit;
}

.site-header,
.site-footer,
main {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 0 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--accent);
  background: rgba(8, 9, 7, .68);
  color: var(--accent);
  font-family: Consolas, "Courier New", monospace;
  font-size: 16px;
  box-shadow: inset 0 0 18px rgba(118, 247, 160, .12);
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.site-nav a {
  border: 1px solid var(--line);
  padding: 6px 12px;
  text-decoration: none;
  font-size: 13px;
  background: rgba(8, 9, 7, .52);
  color: var(--muted);
  font-family: Consolas, "Courier New", monospace;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 28px;
  padding: 58px 0 36px;
  border-top: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  font-family: Consolas, "Courier New", monospace;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.2;
}

h1 {
  max-width: 820px;
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  font-size: clamp(42px, 7vw, 86px);
  font-weight: 700;
}

h2 {
  font-size: clamp(24px, 3vw, 36px);
}

.hero-copy p:last-child {
  max-width: 740px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 17px;
}

.hero-note {
  display: grid;
  gap: 8px;
  min-width: 170px;
}

.hero-note span {
  border-left: 3px solid var(--accent);
  background: rgba(21, 23, 15, .82);
  padding: 7px 10px;
  color: var(--ink);
  font-size: 13px;
}

.ad-slot {
  display: grid;
  min-height: 86px;
  place-items: center;
  margin: 0 0 34px;
  border: 1px dashed rgba(216, 197, 143, .32);
  background: rgba(21, 23, 15, .52);
  color: var(--muted);
  font-size: 13px;
}

.lab-shell,
.text-section,
.split-section,
.policy-section,
.related-section,
.manual-section,
.comments {
  margin: 34px 0;
  padding: 30px;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(118, 247, 160, .045), transparent 42%),
    rgba(19, 21, 15, .88);
}

.section-head {
  margin-bottom: 20px;
}

.stage-wrap {
  position: relative;
  overflow: hidden;
  border: 10px solid #2d251b;
  background: var(--board);
  box-shadow: inset 0 0 0 2px rgba(216, 197, 143, .08), 0 22px 70px rgba(0, 0, 0, .42);
}

#chalkCanvas {
  display: block;
  width: 100%;
  max-width: 1040px;
  height: auto;
  min-height: 280px;
  touch-action: none;
  cursor: crosshair;
}

.stage-caption {
  position: absolute;
  right: 12px;
  bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  color: rgba(239, 241, 232, .76);
  font-size: 12px;
  pointer-events: none;
}

.stage-caption span {
  background: rgba(7, 18, 15, .58);
  padding: 3px 8px;
}

.fullscreen-hud {
  position: absolute;
  left: 14px;
  bottom: 12px;
  display: none;
  max-width: min(440px, calc(100% - 28px));
  color: rgba(242, 244, 234, .88);
  pointer-events: none;
}

.hud-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 8px;
}

.hud-grid span,
.fullscreen-hud li {
  background: rgba(5, 15, 13, .64);
  border: 1px solid rgba(230, 236, 219, .14);
  padding: 4px 8px;
  font-size: 11px;
  letter-spacing: .08em;
}

.hud-grid strong {
  margin-left: 5px;
  color: #fff;
  font-size: 12px;
}

.fullscreen-hud ul {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.fullscreen-hud li {
  border-left: 2px solid rgba(238, 242, 228, .5);
  line-height: 1.35;
  letter-spacing: 0;
}

.stage-wrap:fullscreen {
  display: grid;
  width: 100vw;
  height: 100vh;
  place-items: center;
  border: 0;
  background: #06110f;
}

.stage-wrap:fullscreen #chalkCanvas {
  width: 100vw;
  height: 100vh;
  max-width: none;
  object-fit: contain;
}

.stage-wrap:fullscreen .stage-caption {
  top: 16px;
  right: 16px;
  bottom: auto;
}

.stage-wrap:fullscreen .fullscreen-hud {
  display: block;
}

.control-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1.2fr) minmax(240px, 1fr) minmax(190px, .75fr);
  gap: 16px;
  margin-top: 18px;
}

.panel {
  border: 1px solid var(--line);
  background: rgba(8, 9, 7, .46);
  padding: 18px;
}

.panel label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  font-family: Consolas, "Courier New", monospace;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid rgba(216, 197, 143, .34);
  background: rgba(8, 9, 7, .58);
  color: var(--ink);
  padding: 12px;
  font: inherit;
  line-height: 1.6;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

button {
  min-height: 38px;
  border: 1px solid rgba(242, 241, 223, .25);
  background: rgba(8, 9, 7, .64);
  color: var(--ink);
  padding: 8px 13px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

button:disabled {
  border-color: rgba(184, 177, 154, .24);
  background: rgba(59, 58, 44, .42);
  color: rgba(184, 177, 154, .62);
  cursor: not-allowed;
}

.primary-actions button:first-child {
  background: var(--accent);
  color: #060806;
}

.range-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.range-list label {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

select {
  width: 100%;
  min-height: 34px;
  border: 1px solid rgba(216, 197, 143, .34);
  background: rgba(8, 9, 7, .72);
  color: var(--ink);
  padding: 5px 9px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
}

.toggle-row input {
  justify-self: start;
}

.status-panel dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.status-panel dl > div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  font-family: Consolas, "Courier New", monospace;
}

dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.observation-log {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.observation-log p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  font-family: Consolas, "Courier New", monospace;
}

.observation-log ul {
  display: grid;
  gap: 7px;
  min-height: 78px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.observation-log li {
  border-left: 2px solid var(--accent);
  padding-left: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.afterimage-panel {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
  border: 1px solid rgba(216, 197, 143, .34);
  background:
    linear-gradient(180deg, rgba(216, 197, 143, .10), rgba(216, 197, 143, .035)),
    rgba(18, 16, 10, .72);
  padding: 18px;
}

.afterimage-panel h3 {
  margin: 0;
  font-size: 19px;
  line-height: 1.35;
}

.afterimage-panel p:last-child {
  margin: 0;
  color: var(--ink);
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(18px, 2.2vw, 25px);
  line-height: 1.75;
  white-space: pre-wrap;
}

.final-panel {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
  border: 1px solid rgba(216, 197, 143, .34);
  background: rgba(21, 23, 15, .82);
  padding: 18px;
}

.final-panel h3 {
  margin: 0;
  font-size: 19px;
  line-height: 1.35;
}

.final-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.final-grid p {
  margin: 0;
  border: 1px solid var(--line);
  background: rgba(8, 9, 7, .38);
  padding: 10px;
}

.final-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  font-family: Consolas, "Courier New", monospace;
}

.final-grid strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}

.final-afterimage {
  grid-column: 1 / -1;
}

.final-afterimage strong {
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(18px, 2vw, 24px);
  white-space: pre-wrap;
}

.text-section p,
.policy-section p {
  max-width: 850px;
  margin: 0 0 12px;
}

.split-section {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px;
}

.plain-list {
  margin: 14px 0 0;
  padding-left: 1.4em;
}

.plain-list li + li {
  margin-top: 8px;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.related-card {
  display: grid;
  gap: 8px;
  min-height: 112px;
  align-content: center;
  border: 1px solid var(--line);
  background: rgba(8, 9, 7, .42);
  padding: 18px;
  text-decoration: none;
}

.related-card span {
  color: var(--muted);
  font-size: 12px;
}

.related-card strong {
  font-size: 18px;
  line-height: 1.3;
}

.manual-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.manual-grid article {
  border: 1px solid var(--line);
  background: rgba(8, 9, 7, .42);
  padding: 20px;
}

.manual-grid h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.35;
}

.manual-grid code {
  border: 1px solid var(--line);
  background: rgba(8, 9, 7, .68);
  padding: 1px 5px;
  font-size: .95em;
}

.term-list {
  display: grid;
  gap: 10px;
  margin: 14px 0 0;
}

.term-list div {
  border-bottom: 1px solid var(--line);
  padding-bottom: 9px;
}

.term-list dt {
  margin-bottom: 3px;
}

.term-list dd {
  color: var(--muted);
  font-weight: 400;
  line-height: 1.6;
}

.comment-box {
  display: grid;
  gap: 12px;
}

.comment-box p {
  margin: 0;
  color: var(--muted);
}

.comment-box button {
  justify-self: start;
}

.bottom-ad {
  margin-top: 34px;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 0 42px;
  color: var(--muted);
  font-size: 13px;
}

.site-footer p {
  margin: 0;
}

@media (max-width: 840px) {
  .site-header,
  .hero,
  .split-section,
  .site-footer {
    display: grid;
  }

  .site-header,
  .site-footer {
    justify-content: stretch;
  }

  .site-nav {
    justify-content: flex-start;
  }

  .hero {
    grid-template-columns: 1fr;
    padding-top: 36px;
  }

  .hero-note {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .control-grid,
  .related-grid,
  .afterimage-panel,
  .final-panel {
    grid-template-columns: 1fr;
  }

  .final-grid {
    grid-template-columns: 1fr 1fr;
  }

  .lab-shell,
  .text-section,
  .split-section,
  .policy-section,
  .related-section,
  .manual-section,
  .comments {
    padding: 20px;
  }

  .manual-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .site-header,
  .site-footer,
  main {
    width: min(100% - 20px, 1120px);
  }

  h1 {
    font-size: 40px;
  }

  .hero-note {
    grid-template-columns: 1fr;
  }

  .stage-wrap {
    border-width: 6px;
  }

  .stage-caption {
    left: 8px;
    right: 8px;
    justify-content: flex-start;
  }

  .range-list label {
    grid-template-columns: 1fr;
  }

  button {
    flex: 1 1 auto;
  }

  .final-grid {
    grid-template-columns: 1fr;
  }
}
