:root {
  color-scheme: light;
  --paper: #f5f4ef;
  --white: #fffefa;
  --ink: #202821;
  --muted: #555f55;
  --line: #d8dcd3;
  --checkpoint: #19584d;
  --checkpoint-soft: #e7f2eb;
  --room: #794621;
  --room-soft: #f8eee2;
  --mono: "IBM Plex Mono", Consolas, monospace;
  font-family: Inter, "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.65;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
h1, h2, h3, p { margin: 0; }
code { font: .85em var(--mono); overflow-wrap: anywhere; }
a { color: var(--checkpoint); text-underline-offset: .18em; }
:focus-visible { outline: 3px solid var(--checkpoint); outline-offset: 4px; }

main {
  width: min(1080px, calc(100% - 64px));
  margin: 0 auto;
  padding: 54px 0 34px;
}

.intro { padding: 22px 0 34px; border-top: 3px solid var(--ink); }
h1 {
  font-size: clamp(2.1rem, 5vw, 3.75rem);
  line-height: 1.19;
  letter-spacing: -.055em;
  text-wrap: balance;
  word-break: keep-all;
}
.intro p { margin-top: 14px; max-width: 670px; color: var(--muted); word-break: keep-all; }

.lanes {
  --columns: 136px minmax(0, 1fr) minmax(0, 1fr);
  --gap: 18px;
}

.lane-headings, .step {
  display: grid;
  grid-template-columns: var(--columns);
  gap: var(--gap);
}

.lane-headings { align-items: end; margin-bottom: 12px; }
.lane-heading { border-radius: 9px 9px 0 0; padding: 12px 18px; font-size: 1.03rem; }
.lane-heading.checkpoint { background: var(--checkpoint-soft); color: var(--checkpoint); }
.lane-heading.room { background: var(--room-soft); color: var(--room); }
.lane-heading span { display: block; margin-top: 1px; font-size: .8rem; font-weight: 500; }

.steps { list-style: none; padding: 0; margin: 0; }
.step { position: relative; padding-bottom: 14px; }
.step:last-child { padding-bottom: 0; }
.step-title {
  position: relative;
  align-self: stretch;
  padding: 16px 0 0 40px;
  font-size: .99rem;
  line-height: 1.4;
}
.step-title::before {
  content: "";
  position: absolute;
  width: 1px;
  background: #b9c1b7;
  left: 13px;
  top: 39px;
  bottom: -30px;
}
.step:last-child .step-title::before { content: none; }
.step-number {
  position: absolute;
  inset: 11px auto auto 0;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--white);
  font: 600 .78rem var(--mono);
}

.node {
  min-width: 0;
  padding: 15px 17px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--lane);
  border-radius: 6px 9px 9px 6px;
  background: var(--white);
}
.node.checkpoint { --lane: var(--checkpoint); --soft: var(--checkpoint-soft); }
.node.room { --lane: var(--room); --soft: var(--room-soft); }
.node h3 { font-size: 1rem; line-height: 1.4; word-break: keep-all; }
.node p { margin-top: 5px; color: var(--muted); font-size: .89rem; word-break: keep-all; overflow-wrap: break-word; }
.node .commands { color: var(--lane); margin-top: 10px; }
.commands code { display: inline-block; padding: 1px 6px; background: var(--soft); border-radius: 4px; }
.mobile-lane { display: none; }

.finish {
  margin-top: 34px;
  border-top: 1px solid var(--line);
  padding-top: 23px;
}
.finish h2 { font-size: 1.32rem; letter-spacing: -.035em; }
.scenario-control { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 16px; }
.scenario-control[hidden] { display: none; }
.scenario-control button {
  min-height: 44px;
  padding: 7px 15px;
  border: 1px solid #b9c1b7;
  border-radius: 7px;
  background: var(--white);
  color: var(--ink);
  font-family: inherit;
  font-size: .87rem;
  font-weight: 600;
  cursor: pointer;
}
.scenario-control button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--white);
  border-color: var(--ink);
}
.scenario { margin: 0; }
.scenario:not([hidden]) + .scenario:not([hidden]) { margin-top: 16px; }
.scenario figcaption { margin-bottom: 8px; font-size: .86rem; color: var(--muted); }
.scenario-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 32px;
  margin: 0;
  padding: 0;
}
.scenario-list li {
  position: relative;
  display: grid;
  align-content: start;
  gap: 4px;
  padding: 13px 15px;
  border-radius: 8px;
  background: var(--room-soft);
  color: var(--room);
  font-size: .91rem;
}
.scenario-list li::after {
  content: "→";
  position: absolute;
  right: -25px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 1.15rem;
}
.scenario-list li:last-child::after { content: none; }
.scenario-list li span { color: var(--ink); font-size: .82rem; overflow-wrap: anywhere; }
.scenario-list .board-result { color: var(--checkpoint); background: var(--checkpoint-soft); }

.details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 26px;
}
details { border-top: 1px solid var(--line); }
summary { padding: 12px 0; font-size: .91rem; font-weight: 700; cursor: pointer; }
details p { font-size: .86rem; color: var(--muted); }
details p + p { margin-top: 8px; }

@media (max-width: 700px) {
  main { width: calc(100% - 32px); padding-top: 26px; }
  .intro { padding-top: 16px; padding-bottom: 25px; }
  .lanes { --columns: minmax(0, 1fr); --gap: 9px; }
  .lane-headings { display: none; }
  .step { padding-bottom: 20px; }
  .step-title { min-height: 30px; padding: 5px 0 0 38px; }
  .step-title::before { content: none; }
  .step-number { top: 0; }
  .node { padding: 12px 14px; }
  .mobile-lane { display: block; margin-bottom: 3px; color: var(--lane); font-size: .78rem; font-weight: 700; }
  .scenario-list { grid-template-columns: 1fr; gap: 24px; }
  .scenario-list li::after { content: "↓"; inset: auto auto -24px 15px; transform: none; }
  .details-grid { grid-template-columns: 1fr; gap: 6px; }
}

@media print {
  main { width: 100%; padding: 0; }
  .scenario-control { display: none; }
  .scenario[hidden] { display: block; }
  .scenario + .scenario { margin-top: 16px; }
  .step, .scenario, details { break-inside: avoid; }
}
