/* Two Eras. The two machines are two eras on one timeline: SNES always left (first when
   stacked), DS always right. Each side has a ruler of time ticks on its inner edge, every slot
   numeral sits in a dial, and the wire from the slot that continues to the slot it replaces
   passes through a gate of rings in the crossing. A drawn pixel pointer marks the slot that
   continues and follows keyboard focus. Colour says only "which side", "the gate" and "does not
   cross" (amber). Every ornament is drawn here or in app.js. See web/DESIGN.md for the rules
   that must not erode. */

@font-face {
  font-family: "Jersey 15"; /* pixel face, 27 px to the em: set only at 27 px or 54 px */
  src: url("assets/fonts/jersey15.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Sides Sans"; /* Source Sans 3, subset and renamed: see assets/fonts/README.md */
  src: url("assets/fonts/sides-sans.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --page: #f4efe4;
  --ink: #1c1a24;
  --mute: #4d4856;
  --snes: #ece0cb;
  --ds: #dce5ee;
  --slot: #fcf8f0;
  --slot-ds: #f6f9fc;
  --edge: #6f6878;
  --rule: #bfb5a3;
  --stay: #8a4100;
  --stay-tint: #f2dfc7;
  --tick: #8f8576;
  --tick-ds: #7d8796;
  --gate-1: #5a3fb0;
  --gate-2: #13806f;
  --wire: #1c1a24;
  --focus: #1c1a24;
  --pointer: #1c1a24;
  --sans: "Sides Sans", Seravek, Calibri, "Segoe UI", system-ui, sans-serif;
  --era: "Jersey 15", "Avenir Next Condensed", "Arial Narrow", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  /* Jersey 15 has 27 pixels to the em; these are its only sizes (1 and 2 screen pixels a pixel). */
  --px1: 27px;
  --px2: 54px;

  /* Pixel drawings, used as masks so they take the colour of the text around them. */
  --px-pointer: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 5 9' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h1v1h1v1h1v1h1v1h1v1h-1v1h-1v1h-1v1h-1v1h-1z'/%3E%3C/svg%3E");
  --px-hourglass: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 11' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h9v1H0zM1 1h1v2H1zM7 1h1v2H7zM2 3h1v1H2zM6 3h1v1H6zM3 4h1v1H3zM5 4h1v1H5zM4 5h1v1H4zM3 6h1v1H3zM5 6h1v1H5zM2 7h1v1H2zM4 7h1v1H4zM6 7h1v1H6zM1 8h1v1H1zM3 8h3v1H3zM7 8h1v1H7zM1 9h7v1H1zM0 10h9v1H0z'/%3E%3C/svg%3E");
  --px-clock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 11' shape-rendering='crispEdges'%3E%3Cpath d='M3 0h5v1H3zM2 1h1v1H2zM8 1h1v1H8zM1 2h1v1H1zM9 2h1v1H9zM0 3h1v5H0zM10 3h1v5h-1zM1 8h1v1H1zM9 8h1v1H9zM2 9h1v1H2zM8 9h1v1H8zM3 10h5v1H3zM5 2h1v4H5zM6 5h1v1H6zM7 4h1v1H7zM8 3h1v1H8z'/%3E%3C/svg%3E");
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #0f0e1c;
    --ink: #f3eee2;
    --mute: #c0b9cd;
    --snes: #241a26;
    --ds: #112230;
    --slot: #35283b;
    --slot-ds: #1b3446;
    --edge: #998fab;
    --rule: #4a4059;
    --stay: #ffb257;
    --stay-tint: #45311b;
    --tick: #7d6f84;
    --tick-ds: #5f7a91;
    --gate-1: #b9a7ff;
    --gate-2: #7fe0d0;
    --wire: #f3eee2;
    --focus: #f3eee2;
    --pointer: #f3eee2;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { background: var(--page); color: var(--ink); }
body { margin: 0; font: 400 1rem/1.45 var(--sans); -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
a { color: inherit; text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
h1, h2, h3 { text-wrap: balance; }
[tabindex="-1"]:focus { outline: none; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.filename { font-weight: 600; overflow-wrap: anywhere; }
.hint { color: var(--mute); font-size: .9rem; }
.verbatim { white-space: pre-line; }
.strong { font-weight: 700; }

/* The pixel face. Line heights and letter spacing are whole pixels, so stems land on the grid.
   macOS widens glyph edges when it smooths text; grayscale smoothing keeps the pixels square. */
.top h1, .platform, .slot .n, .drop-veil p, .wire .cross,
.ledger h3, .commit h3, .downloads h3, .ask .warnings h3, .refusal h3,
.engine-failure h2, .direction, .ask-direction h2, .prep b, .btn.go, .wire-label, .route-text {
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
.top h1, .ledger h3, .commit h3, .downloads h3, .ask .warnings h3, .refusal h3,
.engine-failure h2, .direction, .ask-direction h2, .prep b, .btn.go, .wire-label, .route-text {
  font-family: var(--era); font-weight: 400; font-size: var(--px1); line-height: 27px;
  letter-spacing: 1px; text-transform: none;
}

/* ---------- header: a time scale, and footer ---------- */
.top {
  position: relative; display: flex; justify-content: space-between; align-items: center;
  gap: .25rem 1.5rem; flex-wrap: wrap; padding: 1rem 1.75rem 1.6rem;
}
/* The scale under the title: a long tick every 96 px, a short one every 16 px. Decoration only. */
.top::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 14px; pointer-events: none;
  background:
    repeating-linear-gradient(90deg, var(--tick) 0 2px, transparent 2px 96px) 28px 100% / 100% 14px no-repeat,
    repeating-linear-gradient(90deg, var(--tick) 0 1px, transparent 1px 16px) 28px 100% / 100% 6px no-repeat,
    linear-gradient(var(--tick), var(--tick)) 0 100% / 100% 1px no-repeat;
}
.top h1 { margin: 0; display: flex; align-items: center; gap: 12px; }
.top h1::before {
  content: ""; flex: none; width: 22px; height: 22px; background: var(--gate-1);
  -webkit-mask: var(--px-clock) center / 22px 22px no-repeat; mask: var(--px-clock) center / 22px 22px no-repeat;
}
.top .engine { margin: 0; color: var(--mute); font-size: .95rem; }
/* The loading hourglass: the converter is getting ready, a preview or conversion is running. */
.top .engine.working::before, .checking::before, .btn.go:disabled::before {
  content: ""; display: inline-block; width: 18px; height: 22px; margin-right: 10px; vertical-align: -5px;
  background: currentColor; -webkit-mask: var(--px-hourglass) center / 18px 22px no-repeat; mask: var(--px-hourglass) center / 18px 22px no-repeat;
}
@media (prefers-reduced-motion: no-preference) {
  /* It turns over every 0.8 s, in one step, while the converter works. */
  .top .engine.working::before, .checking::before, .btn.go:disabled::before { animation: turn 1.6s steps(1, end) infinite; }
  @keyframes turn { 0% { transform: none; } 50%, 100% { transform: rotate(180deg); } }
}
.engine-failure { margin: 1rem 1.75rem; padding: 1rem 1.25rem; border: 3px solid var(--stay); }
.engine-failure h2 { margin: 0 0 .4rem; color: var(--stay); }
.engine-failure p { margin: 0 0 .6rem; }

.foot { padding: 1.2rem 1.75rem 1.75rem; color: var(--mute); font-size: .86rem; display: flex; flex-wrap: wrap; gap: .25rem 1.75rem; }
.foot p { margin: 0; }

/* ---------- buttons ---------- */
.btn {
  font: 700 1rem/1.1 var(--sans); padding: .78rem 1.1rem; min-height: 2.75rem;
  border: 2px solid var(--ink); background: var(--ink); color: var(--page); cursor: pointer; border-radius: 3px;
}
.btn.line { background: var(--slot); color: var(--ink); border-width: 1.5px; font-weight: 600; font-size: .95rem; padding: .62rem .9rem; }
.ds .btn.line { background: var(--slot-ds); }
.btn.small { font-size: .9rem; padding: .45rem .75rem; min-height: 2.25rem; }
.btn.go { width: 100%; padding: 14px 10px 12px; }
.btn:disabled { cursor: progress; opacity: .75; }
.btn.go:disabled { opacity: 1; position: relative; }
.btn.go:disabled::before { position: absolute; left: 14px; top: calc(50% - 11px); margin: 0; }
.btn.link { background: none; border: 0; border-radius: 0; padding: .3rem 0; min-height: 0; color: inherit; font: inherit; font-size: .9rem; text-decoration: underline; text-underline-offset: 3px; }
/* Column gaps leave room for the pointer (10 px, outside the 6 px focus ring) between controls. */
.acts { display: flex; flex-wrap: wrap; gap: .5rem 1.75rem; align-items: center; margin: .6rem 0 0; }
.acts.stack { flex-direction: column; align-items: stretch; }

/* ---------- the bench: [SNES][crossing][DS], seven shared rows ---------- */
.bench {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(11rem, 14rem) minmax(0, 1fr);
  grid-template-rows: auto auto auto auto auto auto 1fr;
}
.side { grid-row: 1 / span 7; display: grid; grid-template-rows: subgrid; align-content: start; }
/* The inner edge is wider: it carries the ruler, and the pointer must stay clear of it. */
.snes { padding: 0 40px 28px 30px; }
.ds { padding: 0 30px 28px 40px; }
/* Each era has a ruler of time ticks on its inner edge, facing the crossing. Decoration only. */
.snes {
  grid-column: 1;
  background:
    repeating-linear-gradient(180deg, var(--tick) 0 2px, transparent 2px 96px) right 0 top 20px / 14px 100% no-repeat,
    repeating-linear-gradient(180deg, var(--tick) 0 1px, transparent 1px 16px) right 0 top 20px / 7px 100% no-repeat,
    var(--snes);
}
.ds {
  grid-column: 3;
  background:
    repeating-linear-gradient(180deg, var(--tick-ds) 0 2px, transparent 2px 96px) left 0 top 20px / 14px 100% no-repeat,
    repeating-linear-gradient(180deg, var(--tick-ds) 0 1px, transparent 1px 16px) left 0 top 20px / 7px 100% no-repeat,
    var(--ds);
}
.crossing { grid-column: 2; grid-row: 1 / span 6; padding: 1.4rem 1.25rem 0; text-align: center; }
.commit { grid-column: 2; grid-row: 7; padding: 1rem 1.25rem 1.75rem; }
.r1 { grid-row: 1; } .r2 { grid-row: 2; } .r3 { grid-row: 3; } .r7 { grid-row: 7; }
.slots { grid-row: 4 / span 3; display: grid; grid-template-rows: subgrid; }

.platform { margin: 0; padding: 22px 0 6px; font: 400 var(--px2)/54px var(--era); letter-spacing: 2px; text-transform: uppercase; }
.platform small { display: block; margin-top: .4rem; font: 600 .95rem/1.3 var(--sans); text-transform: none; letter-spacing: 0; color: var(--mute); }

.fileline, .picker { padding: .35rem 0 .7rem; }
.fileline p, .picker p { margin: 0; }
.fileline .meta { color: var(--mute); font-size: .9rem; }
.file-acts { display: flex; flex-wrap: wrap; gap: 0 1.75rem; }
.picker p { margin-bottom: .55rem; color: var(--mute); }

.ask { padding-bottom: .3rem; }
.ask > * { margin: 0 0 .8rem; }
.notice { color: var(--mute); font-size: .92rem; }
.slots-q { font-weight: 700; margin: .2rem 0 .6rem; }

/* Questions: native radios in an outlined row; the chosen one is heavier. */
.choice { border: 0; padding: 0; margin: 0 0 .8rem; min-width: 0; }
.choice legend { padding: 0; margin-bottom: .3rem; font-weight: 700; }
.choice .hint { margin: 0 0 .5rem; }
.seg { display: flex; flex-wrap: wrap; gap: .5rem 1.75rem; }
.seg label { position: relative; display: flex; align-items: center; gap: .5rem; min-height: 2.75rem; padding: .45rem .8rem; border: 1.5px solid var(--edge); border-radius: 3px; background: var(--slot); cursor: pointer; font-size: .95rem; }
.ds .seg label { background: var(--slot-ds); }
.seg label.on { border: 3px solid var(--ink); padding: calc(.45rem - 1.5px) calc(.8rem - 1.5px); font-weight: 700; }
.seg input { accent-color: var(--ink); width: 1.05rem; height: 1.05rem; margin: 0; }

/* ---------- slots ----------
   State is carried by the outline: continuing or new = heavy solid; to be replaced = heavy
   dashed; blocked = amber outline, hatch and a text tag. The dial repeats it, never alone. */
.slot {
  position: relative; display: grid; grid-template-columns: 4rem minmax(0, 1fr); gap: 0 .9rem; align-items: center;
  min-height: 5.4rem; margin: 0 0 .5rem; padding: .6rem .9rem; background: var(--slot); border: 1.5px solid transparent; border-radius: 4px;
}
.ds .slot:not(.blank, .none) { background: var(--slot-ds); }
/* Every numeral sits in a dial: twelve ticks round the edge. */
.slot .n {
  position: relative; display: grid; place-items: center; width: 4rem; height: 4rem; border-radius: 50%;
  font: 400 var(--px2)/54px var(--era);
}
.slot .n::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: repeating-conic-gradient(var(--tick) 0 3deg, transparent 3deg 30deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 7px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 7px));
}
.ds .slot .n::before { background: repeating-conic-gradient(var(--tick-ds) 0 3deg, transparent 3deg 30deg); }
.slot.src .n::before, .slot.new .n::before, .slot.dst .n::before { background: repeating-conic-gradient(var(--ink) 0 4deg, transparent 4deg 30deg); }
.slot.blocked .n::before { background: repeating-conic-gradient(var(--stay) 0 4deg, transparent 4deg 30deg); }
.slot.blank .n::before, .slot.none .n::before { opacity: .6; }
.who-wrap { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.slot .who { font-weight: 700; font-size: 1.06rem; overflow-wrap: anywhere; }
.slot .stats { color: var(--mute); font: .86rem/1.35 var(--mono); font-variant-numeric: tabular-nums; }
.tags { display: flex; flex-wrap: wrap; gap: .1rem .8rem; margin-top: .15rem; font-size: .84rem; font-weight: 600; }
.tag.role, .marker { font: 700 .8rem/1.25 var(--sans); text-transform: uppercase; letter-spacing: .07em; }
.slot.src, .slot.new { border: 3px solid var(--ink); padding: calc(.6rem - 1.5px) calc(.9rem - 1.5px); }
.slot.dst { border: 3px dashed var(--ink); padding: calc(.6rem - 1.5px) calc(.9rem - 1.5px); }
.slot.none, .slot.blank { background: transparent; border: 1.5px dashed var(--edge); color: var(--mute); }
.slot.none .who { font-weight: 400; font-size: .9rem; }
.slot.blank { min-height: 4.75rem; }
.slot.blocked {
  border: 3px solid var(--stay); padding: calc(.6rem - 1.5px) calc(.9rem - 1.5px);
  background: repeating-linear-gradient(135deg, transparent 0 10px, var(--stay-tint) 10px 13px), var(--slot);
}
.ds .slot.blocked { background: repeating-linear-gradient(135deg, transparent 0 10px, var(--stay-tint) 10px 13px), var(--slot-ds); }
.slot.blocked .tag.role { color: var(--stay); }
.slot.pickable { cursor: pointer; }
/* An unchosen slot that can be chosen gets a 3:1 edge so it reads as a control. */
.slot.pickable:not(.src, .dst, .blocked) { border-color: var(--edge); }
.slot.pickable:hover:not(.src, .dst, .blocked) { border-color: var(--ink); }
.slot input[type="radio"] { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.slot:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 3px; }
@media (prefers-reduced-motion: no-preference) { .slot { transition: border-color .12s; } }

/* ---------- the pointer ----------
   A drawn 5 x 9 pixel pointer, 2 screen pixels a pixel. At rest it marks the slot whose outline
   says it continues (the new slot once converted); a blocked slot gets none. When a control has
   keyboard focus, the one pointer moves beside that control instead. It sits outside the focus
   ring and never replaces it, and it never stands for a slot's state on its own. On wide screens
   a DS slot takes it on its outer (right) edge, mirrored, so it never meets the wire. */
.btn, .opt, summary, .foot a { position: relative; }
.bench[data-phase="preview"] .slot.src::before,
.bench[data-phase="done"] .slot.new::before,
.slot:has(input:focus-visible)::before,
.seg label:has(input:focus-visible)::before,
.opt:has(input:focus-visible)::before,
.btn:focus-visible::before,
summary:focus-visible::before,
.foot a:focus-visible::before {
  content: ""; position: absolute; left: var(--ptr-x, -20px);
  top: var(--ptr-y, calc(50% - 9px)); top: var(--ptr-y, round(down, 50% - 9px, 1px));
  width: 10px; height: 18px; background: var(--pointer); pointer-events: none;
  -webkit-mask: var(--px-pointer) center / 10px 18px no-repeat; mask: var(--px-pointer) center / 10px 18px no-repeat;
}
.slot { --ptr-x: -23px; }
@media (min-width: 52.01rem) {
  .ds .slot::before { left: auto !important; right: -23px; transform: scaleX(-1); }
}
.foot a { --ptr-x: -18px; }
.opt { --ptr-y: 3px; }
/* One pointer: while keyboard focus is on another control, the resting pointer gives way. */
body:has(:is(.slot input, .seg input, .opt input, .btn, summary, .foot a):focus-visible)
  .slot:is(.src, .new):not(:has(input:focus-visible))::before { display: none; }
@media (prefers-reduced-motion: no-preference) {
  /* A single nudge when it arrives, then still. */
  .slot::before, .seg label::before, .opt::before, .btn::before, summary::before, .foot a::before { animation: nudge .18s steps(1, end) 2 alternate; }
  @keyframes nudge { from { translate: 2px 0; } to { translate: 0 0; } }
}

/* ---------- ledgers under the slots ---------- */
.ledger { padding-top: .6rem; }
.ledger h3, .commit h3, .downloads h3, .ask .warnings h3 { margin: 1.1rem 0 .5rem; }
.ledger > :first-child h3:first-child { margin-top: .3rem; }
.ledger h3.stay { color: var(--stay); }
.ledger p { margin: 0 0 .5rem; }
.plain { margin: 0; padding: 0; list-style: none; }
.plain li { padding: .3rem 0; border-top: 1px solid var(--rule); }
.restoration .hint { margin-bottom: .2rem; }

.loss { padding: .55rem 0 .7rem; border-top: 1px solid var(--rule); }
.loss > p { margin: 0; }
.loss > p.verbatim { font-weight: 600; }
.marker { margin-top: .2rem !important; }
.marker.lost { color: var(--stay); }

/* Ledger lists: names on dotted leaders, counts in monospace tabular figures. */
.items { margin: .45rem 0 0; padding: 0; list-style: none; columns: 2 12rem; column-gap: 1.6rem; font-size: .93rem; }
.items li { display: flex; align-items: baseline; gap: .35rem; padding: .08rem 0; break-inside: avoid; }
.items li::after { content: ""; order: 1; flex: 1; border-bottom: 1px dotted var(--rule); min-width: .8rem; transform: translateY(-.25em); }
.items .item-count { order: 2; font: .84rem var(--mono); font-variant-numeric: tabular-nums; color: var(--mute); min-width: 2.2em; text-align: right; }
.more { margin-top: .35rem; }
.more summary { cursor: pointer; font-weight: 600; font-size: .92rem; padding: .3rem 0; }
.more .count { font-weight: 400; color: var(--mute); }

.options { margin-top: .4rem; }
.opt { display: flex; gap: .65rem; align-items: flex-start; margin: 0 0 .7rem; cursor: pointer; }
.opt input { accent-color: var(--ink); width: 1.15rem; height: 1.15rem; margin: .18rem 0 0; flex: none; }
.opt small { display: block; color: var(--mute); font-size: .88rem; }

.next-step p { font-size: 1.05rem; }
.summary { margin: .4rem 0 0; padding: .7rem .8rem; font: .82rem/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; background: var(--slot); border-radius: 3px; }
.ds .summary { background: var(--slot-ds); }

/* ---------- downloads ---------- */
.downloads h3:first-child { margin-top: .2rem; }
.dl { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .35rem 1.75rem; align-items: center; padding: .75rem 0; border-top: 1.5px solid var(--ink); }
.dl:last-of-type { border-bottom: 1.5px solid var(--ink); }
.dl p { margin: 0; }
.dl p span { display: block; color: var(--mute); font-size: .86rem; }
.dl .dl-note { grid-column: 1 / -1; font-size: .93rem; }
.downloads > .hint { margin: .5rem 0 0; }

/* ---------- refusals ---------- */
.refusal { border-top: 3px solid var(--stay); padding-top: .7rem; margin: 0 0 .8rem; }
.refusal h3 { margin: 0 0 .4rem !important; color: var(--stay); }
.refusal p { margin: 0 0 .45rem; }
.refusal .next { font-weight: 700; }
.refusal .choice { margin-top: .6rem; }

/* ---------- the crossing ---------- */
.drop-hint { margin: 1.4rem 0 0; color: var(--mute); font-size: .92rem; }
.direction { margin: .2rem 0 .5rem; }
.crossing .hint { margin: 0 0 .6rem; }
.reverse { margin: .1rem auto 0; }
.ask-direction h2 { margin: .4rem 0 .5rem; }
.ask-direction .btn { display: block; width: 100%; margin: .5rem 0 0; }
.commit .refusal h3 { text-align: left; }

/* A closed gate stands in the crossing until the page knows which way the game goes and from
   which saved game. */
.bench:is([data-phase="empty"], [data-phase="partial"], [data-phase="ask"]) .crossing::before {
  content: ""; display: block; width: 4.25rem; height: 7rem; margin: 1.5rem auto 0; border-radius: 50%;
  border: 4px solid var(--gate-1); box-shadow: inset 0 0 0 9px var(--page), inset 0 0 0 12px var(--gate-2);
}
.bench[data-phase="ask"] .crossing::before { width: 2.75rem; height: 4.5rem; margin-top: .2rem; box-shadow: inset 0 0 0 6px var(--page), inset 0 0 0 9px var(--gate-2); }
.bench[data-phase="preview"] .crossing:not(:has(.route))::after {
  content: ""; display: block; width: 2.75rem; height: 4.5rem; margin: 1.5rem auto 0; border-radius: 50%;
  border: 4px solid var(--gate-1); box-shadow: inset 0 0 0 6px var(--page), inset 0 0 0 9px var(--gate-2);
}

/* Wide screens: the route sentence is read by assistive technology; the SVG wire shows it.
   The gate is three rings at the wire's midpoint; refused, it turns dashed amber with a ×. */
.route { margin: 0; }
.wire { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; color: var(--wire); }
.wire path { fill: none; stroke: currentColor; stroke-width: 4; }
.wire path.head { fill: currentColor; stroke: none; }
.wire.broken { color: var(--stay); }
.wire.pending path { stroke-dasharray: 2 8; stroke-width: 3; }
.wire .cross { fill: var(--stay); font: 400 var(--px2) var(--era); text-anchor: middle; }
.wire .gate { fill: none; stroke-width: 3; }
.wire .gate-1 { stroke: var(--gate-1); stroke-width: 4; }
.wire .gate-2 { stroke: var(--gate-2); }
.wire .gate-3 { stroke: var(--gate-1); stroke-width: 2; stroke-dasharray: 3 5; }
.wire.pending .gate { stroke-dasharray: 3 6; }
.wire.broken .gate { stroke: var(--stay); stroke-dasharray: 6 6; }
.wire.broken .gate-3 { display: none; }
.wire-label {
  position: absolute; margin: 0; padding: 2px 6px 0; max-width: 13rem; text-align: center; text-wrap: balance; letter-spacing: 0;
  background: var(--page); pointer-events: none; transform: translate(-50%, -100%);
}
.wire-label.under { transform: translate(-50%, 0); }
.wire-label.under::before { content: ""; display: block; height: 2px; margin: 0 auto 4px; width: 40px; background: var(--gate-1); }
.wire-label.broken { color: var(--stay); }
.wire-label.broken::before { background: var(--stay); }
@media (prefers-reduced-motion: no-preference) {
  .wire:not(.pending) path:not(.head) { animation: draw .35s ease-out; }
  @keyframes draw { from { opacity: 0; } }
  /* The rings open once (a single pass, then still). */
  .wire .gate { transform-box: fill-box; transform-origin: center; animation: open .7s cubic-bezier(.2, .7, .2, 1) both; }
  .wire .gate-2 { animation-delay: .08s; }
  .wire .gate-3 { animation-delay: .16s; }
  @keyframes open { from { transform: scale(.2); opacity: 0; } }
}

/* ---------- commit (what moves, Convert) ---------- */
.moves { margin: 0 0 1rem; padding: 0; list-style: none; text-align: center; font-size: .93rem; }
.moves li { padding: .28rem 0; border-bottom: 1px solid var(--rule); }
.commit h3 { text-align: center; margin-top: .3rem; }
.commit .hint { text-align: center; margin: .5rem 0 0; }
.warnings { margin: 0 0 1rem; }
.warnings p { margin: 0 0 .5rem; font-size: .93rem; }
.ask .warnings h3 { margin-top: .2rem; }
.checking { text-align: center; color: var(--mute); }

/* ---------- first visit: three marks on the scale ---------- */
.prep { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; margin: 0 1.75rem; }
.prep p {
  margin: 0; padding: 1.1rem 0 .9rem; font-size: .95rem;
  background:
    repeating-linear-gradient(90deg, var(--tick) 0 1px, transparent 1px 16px) 0 0 / 100% 6px no-repeat,
    linear-gradient(var(--tick), var(--tick)) 0 0 / 100% 1px no-repeat;
}
.prep b { display: block; margin-bottom: .3rem; color: var(--ink); }

/* ---------- drag and drop ---------- */
.drop-veil { display: none; }
body.dragging .drop-veil {
  display: grid; place-items: center; position: fixed; inset: 0; z-index: 10;
  background: color-mix(in srgb, var(--page) 85%, transparent); outline: 4px dashed var(--gate-1); outline-offset: -14px;
}
.drop-veil p { margin: 0 1rem; text-align: center; font: 400 var(--px2)/54px var(--era); letter-spacing: 2px; }

/* ---------- wide screens only ---------- */
@media (min-width: 52.01rem) {
  .route { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* ---------- stacked (phone): SNES, crossing, DS, commit ----------
   The wire becomes a vertical route in the crossing, with the gate on it. */
@media (max-width: 52rem) {
  .top { padding: .9rem 1.25rem 1.5rem; }
  .bench { display: flex; flex-direction: column; }
  .side, .slots { display: block; }
  .side, .snes, .ds { padding: 0 1.25rem 1.25rem 2.5rem; }
  .crossing { padding: .9rem 1.75rem; }
  .commit { padding: .4rem 1.75rem 1.25rem; }
  .platform { padding-top: 16px; }
  .slot { min-height: 0; grid-template-columns: 3.5rem minmax(0, 1fr); gap: 0 .75rem; padding-left: .75rem; padding-right: .75rem; }
  .slot.src, .slot.new, .slot.dst, .slot.blocked { padding-left: calc(.75rem - 1.5px); padding-right: calc(.75rem - 1.5px); }
  .slot .n { width: 3.5rem; height: 3.5rem; font-size: var(--px1); line-height: 27px; }
  .slot .n::before { -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 6px)); mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 6px)); }
  .slot.blank { min-height: 4.25rem; }
  .drop-hint { margin: .6rem 0 .2rem; }
  .bench:is([data-phase="empty"], [data-phase="partial"]) .crossing::before { width: 2.5rem; height: 4rem; margin-top: .2rem; box-shadow: inset 0 0 0 5px var(--page), inset 0 0 0 8px var(--gate-2); }
  .bench[data-phase="ask"] .crossing::before { width: 2.5rem; height: 4rem; box-shadow: inset 0 0 0 5px var(--page), inset 0 0 0 8px var(--gate-2); }
  .wire, .wire-label { display: none !important; }
  .route { display: flex; flex-direction: column; align-items: center; gap: .35rem; margin: .6rem 0 0; }
  .route-line { position: relative; display: block; width: 4px; height: 6rem; background: var(--wire); }
  /* The gate on the route: two rings the line passes through. */
  .route-line::before {
    content: ""; position: absolute; left: 50%; top: 50%; width: 2.25rem; height: 3.5rem; transform: translate(-50%, -50%);
    border-radius: 50%; border: 4px solid var(--gate-1); box-shadow: inset 0 0 0 5px var(--page), inset 0 0 0 8px var(--gate-2);
  }
  .route[data-arrow="down"] .route-line::after,
  .route[data-arrow="up"] .route-line::after { content: ""; position: absolute; left: -7px; border: 9px solid transparent; }
  .route[data-arrow="down"] .route-line::after { bottom: -10px; border-bottom: 0; border-top: 13px solid var(--wire); }
  .route[data-arrow="up"] .route-line::after { top: -10px; border-top: 0; border-bottom: 13px solid var(--wire); }
  .route[data-arrow="down"] { flex-direction: column; }
  .route[data-arrow="up"] { flex-direction: column-reverse; }
  .route[data-arrow="down"] .route-line { margin-bottom: .75rem; }
  .route[data-arrow="up"] .route-line { margin-top: .75rem; }
  .route.broken .route-line { background: linear-gradient(180deg, var(--stay) 0 22%, transparent 22% 78%, var(--stay) 78%); }
  .route.broken .route-line::before { border: 4px dashed var(--stay); box-shadow: none; }
  .route.broken .route-line::after { content: "×"; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); border: 0; color: var(--stay); font: 400 var(--px1)/27px var(--era); }
  .route.broken .route-text { color: var(--stay); }
  .dl { grid-template-columns: minmax(0, 1fr); }
  .dl .btn { justify-self: start; }
  .prep { grid-template-columns: 1fr; gap: 0; margin: 0 1.25rem; }
  .prep p { padding: 1rem 0 .8rem; }
  .foot { padding: 1rem 1.25rem; }
  .items { columns: 1; }
}

/* ---------- forced colours: shape carries the state, not tone; decoration drops ---------- */
@media (forced-colors: active) {
  .top::after, .prep p { background: none; }
  .prep p { border-top: 1px solid CanvasText; }
  .snes, .ds { background: Canvas; border: 1px solid CanvasText; }
  .side, .slot, .seg label { forced-color-adjust: auto; }
  .slot.blank, .slot.none { border-color: GrayText; }
  .slot.blocked { border-style: double; border-width: 5px; padding: calc(.6rem - 3.5px) calc(.9rem - 3.5px); }
  .slot .n::before { forced-color-adjust: none; background: repeating-conic-gradient(CanvasText 0 3deg, transparent 3deg 30deg) !important; }
  .top h1::before, .top .engine.working::before, .checking::before, .btn.go:disabled::before { forced-color-adjust: none; background: CanvasText; }
  .btn:focus-visible::before, .slot::before, .seg label::before, .opt::before, summary::before, .foot a::before { forced-color-adjust: none; background: CanvasText !important; }
  .wire, .wire.broken { color: CanvasText; }
  .wire .gate { stroke: CanvasText !important; }
  .wire .cross { fill: CanvasText; }
  .wire-label { forced-color-adjust: auto; }
  .wire-label::before { background: CanvasText !important; }
  .crossing::before, .crossing::after { border-color: CanvasText !important; box-shadow: none !important; }
  .route-line { background: CanvasText !important; }
  .route-line::before { border-color: CanvasText !important; box-shadow: none !important; }
}
