/* Hitchage — a dark rail yard. Pixel display face, grotesk figures, one green hitch-light. Written for this drop. */
:root {
  --ground: #0A0D0B; --tie: #1C2620; --tie2: #2A3A30; --ink: #DDE8DC; --dim: #7E9484; --mute: #4E6256;
  --hitch: #2EE86A; --hitch-deep: #178A3E; --hitch-glow: #2EE86A55; --strand: #F05A3C; --strand-dim: #6B2A1E;
  --pix: "Pixelify Sans", "Courier New", monospace; --grot: "Space Grotesk", system-ui, sans-serif;
  --rail: 56px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ground); color: var(--ink); }
body {
  font: 15px/1.5 var(--grot); min-height: 100vh; -webkit-font-smoothing: antialiased;
  background-image: radial-gradient(#1A241E 1px, transparent 1.2px); background-size: 14px 14px; background-position: 7px 7px;
}
a { color: var(--hitch); text-decoration: none; }
a:hover { text-decoration: underline; }
img { image-rendering: pixelated; }
code, .fig { font-family: var(--grot); font-variant-numeric: tabular-nums; }
button { font-family: inherit; cursor: pointer; }

/* ---------- the siding: fixed rail ---------- */
#siding {
  position: fixed; left: 0; top: 132px; width: var(--rail); height: 560px; z-index: 30;
  display: flex; flex-direction: column; align-items: stretch;
  background: #0E1410; border-right: 2px solid var(--tie2); border-top: 2px solid var(--tie2); border-bottom: 2px solid var(--tie2);
  box-shadow: 6px 0 0 var(--ground);
}
.sid-copy {
  flex: 0 0 56px; border: 0; border-bottom: 2px solid var(--tie2); background: var(--hitch); color: #04140A;
  font: 700 13px/1 var(--pix); letter-spacing: .06em; text-transform: uppercase;
}
.sid-copy[data-live="0"] { background: var(--tie2); color: var(--dim); }
.sid-copy[data-done="1"] { background: var(--ink); color: var(--ground); }
.sid-track {
  flex: 1 1 auto; min-height: 0; display: flex; flex-direction: row; justify-content: center; align-items: flex-start; gap: 6px; padding: 10px 0;
  writing-mode: vertical-rl; text-orientation: mixed; overflow: hidden;
  background: repeating-linear-gradient(180deg, transparent 0 18px, #16201A 18px 22px);
}
.sid-tag { font: 700 12px/1 var(--pix); color: var(--hitch); letter-spacing: .08em; }
.sid-addr { font: 500 10.5px/1 var(--grot); letter-spacing: .04em; color: var(--ink); word-break: break-all; }
.sid-addr[data-live="0"] { color: var(--dim); font-family: var(--pix); font-size: 12px; }
.sid-gmgn { font: 600 11px/1 var(--pix); color: var(--dim); }
.sid-wide { display: none; }

/* ---------- the yard ---------- */
#yard { margin-left: calc(var(--rail) + 6px); padding: 14px 12px 40px 10px; max-width: 100%; font-size: 20px; }
.mast, .hitchform, .trains, .rail-side, .buffers { font-size: 15px; }
.signal { margin: 0 0 12px; font: 700 30px/1.08 var(--pix); letter-spacing: .02em; color: var(--ink); text-shadow: 3px 3px 0 var(--hitch-deep); }
.signal::after { content: ""; display: block; width: 64px; height: 6px; background: var(--hitch); margin-top: 10px; box-shadow: 0 0 10px var(--hitch-glow); }
.mast { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; min-height: 36px; }
.mast span { font: 700 20px/1 var(--pix); letter-spacing: .04em; }
.mast em { font: 500 11px/1 var(--grot); color: var(--dim); font-style: normal; text-transform: uppercase; letter-spacing: .1em; margin-left: 4px; }
.mast-cuff { margin-left: auto; background: transparent; color: var(--ink); border: 2px solid var(--tie2); padding: 6px 10px; font: 600 12px/1 var(--pix); }
.mast-cuff[data-on="1"] { border-color: var(--hitch-deep); color: var(--hitch); }

/* the hitch form — the first thing on the page */
.hitchform { background: #0E1410; border: 2px solid var(--tie2); padding: 12px; margin-bottom: 14px; }
.hf-lede { font: 600 13px/1.35 var(--grot); color: var(--dim); margin: 0 0 10px; }
.hf-lede b { color: var(--ink); font-weight: 700; }
.hf-picks { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
.hf-pick {
  background: var(--ground); border: 2px solid var(--tie2); color: var(--ink); padding: 8px 4px 6px; text-align: center; min-height: 64px;
  display: flex; flex-direction: column; gap: 3px; align-items: center; justify-content: center;
}
.hf-pick b { font: 700 14px/1 var(--pix); letter-spacing: .04em; }
.hf-pick s { text-decoration: none; font: 700 18px/1 var(--grot); }
.hf-pick u { text-decoration: none; font: 500 10px/1 var(--grot); color: var(--dim); }
.hf-pick[aria-pressed="true"] { border-color: var(--hitch); box-shadow: 0 0 0 2px var(--hitch-glow), 0 0 14px var(--hitch-glow); }
.hf-pick[data-st="left"] { border-color: var(--hitch); background: #12261A; }
.hf-pick[data-st="stranded"] { border-color: var(--strand-dim); color: var(--dim); }
.hf-pick:disabled { opacity: .55; cursor: default; }
.hf-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.hf-out { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hf-out i { font: 500 11px/1 var(--grot); color: var(--dim); font-style: normal; text-transform: uppercase; letter-spacing: .08em; }
.hf-out b { font: 700 26px/1.05 var(--grot); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hf-out em { font: 500 12px/1.3 var(--grot); color: var(--dim); font-style: normal; }
.hf-go {
  background: var(--hitch); color: #04140A; border: 0; padding: 0 18px; min-height: 52px; font: 700 18px/1 var(--pix); letter-spacing: .06em; text-transform: uppercase;
  box-shadow: 0 4px 0 var(--hitch-deep); white-space: nowrap;
}
.hf-go:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--hitch-deep); }
.hf-go:disabled { background: var(--tie2); color: var(--dim); box-shadow: none; cursor: default; }
.hf-note { margin: 8px 0 0; font: 500 12px/1.4 var(--grot); color: var(--dim); }

/* the trains — four rows of twelve wagon cells */
.trains { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.trn { display: grid; grid-template-columns: 58px 1fr; gap: 6px; align-items: center; border: 2px solid var(--tie); background: #0C110E; padding: 6px; }
.trn[data-st="left"] { border-color: var(--hitch); box-shadow: inset 0 0 0 1px var(--hitch-glow); }
.trn[data-st="stranded"] { border-color: var(--strand-dim); }
.trn[data-lead="1"] .trn-lab i { color: var(--hitch); }
.trn-lab { display: flex; flex-direction: column; gap: 2px; }
.trn-lab b { font: 700 13px/1 var(--pix); letter-spacing: .04em; }
.trn-lab i { font: 700 15px/1 var(--grot); font-style: normal; }
.trn-lab u { text-decoration: none; font: 500 9.5px/1.2 var(--grot); color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }
.trn-lab u[data-k="left"] { color: var(--hitch); }
.trn-lab u[data-k="stranded"] { color: var(--strand); }
.wags { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; }
.wag {
  position: relative; aspect-ratio: 1 / 1.25; border: 2px solid var(--tie2); background: var(--ground);
  display: flex; align-items: center; justify-content: center; font: 500 9px/1 var(--grot); color: var(--mute);
}
.wag::before, .wag::after { content: ""; position: absolute; bottom: -5px; width: 5px; height: 5px; background: var(--tie2); }
.wag::before { left: 2px; } .wag::after { right: 2px; }
.wag[data-s="hitched"] { background: var(--hitch-deep); border-color: var(--hitch); color: #04140A; font-weight: 700; }
.wag[data-s="hitched"]::before, .wag[data-s="hitched"]::after { background: var(--hitch); }
.wag[data-s="next"] { border-color: var(--hitch); animation: hitchblink 1.1s steps(2, end) infinite; color: var(--hitch); }
.wag[data-s="twelfth"] { background: var(--hitch); border-color: var(--ink); color: #04140A; box-shadow: 0 0 12px var(--hitch-glow); font-weight: 700; }
.trn[data-st="stranded"] .wag[data-s="hitched"] { background: var(--strand-dim); border-color: var(--strand); color: var(--ink); }
.trn[data-st="stranded"] .wag[data-s="hitched"]::before, .trn[data-st="stranded"] .wag[data-s="hitched"]::after { background: var(--strand); }
@keyframes hitchblink { 50% { background: var(--hitch-glow); } }
.trn-foot { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 8px; font: 500 10.5px/1.3 var(--grot); color: var(--dim); margin-top: 6px; }
.trn-foot b { color: var(--ink); font-weight: 600; }

/* the rail side: tape, ledger, rules */
.rail-side { display: flex; flex-direction: column; gap: 10px; }
.crate { border: 2px solid var(--tie); background: #0C110E; }
.crate-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 8px 10px; border-bottom: 2px solid var(--tie); }
.crate-head b { font: 700 14px/1 var(--pix); letter-spacing: .05em; }
.crate-head span { font: 500 11px/1 var(--grot); color: var(--dim); }
.crate-body { padding: 8px 10px; }
.tp-line { display: grid; grid-template-columns: 34px 1fr auto; gap: 8px; align-items: baseline; padding: 5px 0; border-bottom: 1px dashed var(--tie); font: 500 12px/1.3 var(--grot); }
.tp-line:last-child { border-bottom: 0; }
.tp-line i { font-style: normal; font: 700 12px/1 var(--pix); color: var(--hitch); }
.tp-line[data-k="left"] i { color: var(--ink); }
.tp-line[data-k="shunted"] i { color: var(--strand); }
.tp-line em { font-style: normal; color: var(--ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-line u { text-decoration: none; color: var(--dim); font-size: 11px; }
.quiet { color: var(--dim); font: 500 12.5px/1.45 var(--grot); margin: 0; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.stat { background: var(--ground); border: 2px solid var(--tie); padding: 8px 6px; text-align: center; }
.stat b { display: block; font: 700 20px/1 var(--grot); }
.stat i { display: block; font: 500 9.5px/1.3 var(--grot); color: var(--dim); font-style: normal; text-transform: uppercase; letter-spacing: .06em; margin-top: 3px; }
.led-row { display: grid; grid-template-columns: 34px 1fr auto; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--tie); font: 500 12px/1.3 var(--grot); align-items: baseline; }
.led-row:last-child { border-bottom: 0; }
.led-row b { font: 700 12px/1 var(--pix); color: var(--dim); }
.led-row em { font-style: normal; }
.led-row u { text-decoration: none; font-weight: 700; }
.led-row[data-k="shunted"] u { color: var(--dim); font-weight: 500; }
.rulebook { margin: 0; }
.rulebook summary { cursor: pointer; padding: 8px 10px; font: 700 14px/1 var(--pix); letter-spacing: .05em; list-style: none; display: flex; justify-content: space-between; }
.rulebook summary::-webkit-details-marker { display: none; }
.rulebook summary::after { content: "+"; color: var(--hitch); }
.rulebook[open] summary::after { content: "–"; }
.rulebook summary span { font: 500 11px/1 var(--grot); color: var(--dim); }
.rule { padding: 0 10px 10px; font: 500 12.5px/1.5 var(--grot); color: var(--dim); }
.rule b { color: var(--ink); font-weight: 700; }
.rule p { margin: 0 0 8px; }
.rule .step { display: grid; grid-template-columns: 30px 1fr; gap: 6px; margin-bottom: 8px; }
.rule .step i { font: 700 22px/1 var(--grot); font-style: normal; color: var(--hitch); }

/* pages: ledger / rules / my wagons */
.leaf { border: 2px solid var(--tie); background: #0C110E; padding: 12px; margin-bottom: 12px; }
.leaf .hd { font: 700 22px/1.1 var(--pix); letter-spacing: .03em; margin: 0 0 8px; }
.leaf p { margin: 0 0 8px; color: var(--dim); font: 500 13px/1.5 var(--grot); }
.leaf p b { color: var(--ink); }
.grid-ledger { display: flex; flex-direction: column; gap: 6px; }
.gl-row { display: grid; grid-template-columns: 40px 1fr auto; gap: 8px; align-items: center; border: 2px solid var(--tie); padding: 8px; font: 500 12.5px/1.35 var(--grot); }
.gl-row b { font: 700 13px/1 var(--pix); color: var(--dim); }
.gl-row em { font-style: normal; }
.gl-row u { text-decoration: none; font-weight: 700; white-space: nowrap; }
.gl-row .mini { display: flex; gap: 3px; margin-top: 4px; }
.gl-row .mini s { text-decoration: none; display: inline-block; width: 22px; height: 6px; background: var(--tie2); }
.gl-row .mini s[data-w="left"] { background: var(--hitch); }
.gl-row .mini s[data-w="stranded"] { background: var(--strand-dim); }
.claim { background: var(--hitch); color: #04140A; border: 0; padding: 8px 12px; font: 700 12px/1 var(--pix); letter-spacing: .05em; box-shadow: 0 3px 0 var(--hitch-deep); }
.claim:disabled { background: var(--tie2); color: var(--dim); box-shadow: none; }

/* footer: the buffers */
.buffers { margin-top: 18px; padding-top: 12px; border-top: 2px dashed var(--tie2); font: 500 11.5px/1.6 var(--grot); color: var(--dim); }
.buffers code { display: block; word-break: break-all; color: var(--ink); font-size: 11px; }
.buffers .bf-links { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.buffers .bf-links a { font: 700 12px/1 var(--pix); letter-spacing: .05em; }

/* the hatch (modal) */
#hatch { position: fixed; inset: 0; background: #000000B8; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
#hatch[hidden] { display: none; }
.hatch-box { width: 100%; max-width: 480px; background: #0E1410; border: 2px solid var(--tie2); border-bottom: 0; }
.hatch-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 2px solid var(--tie); font: 700 16px/1 var(--pix); letter-spacing: .04em; }
.hatch-shut { background: transparent; border: 2px solid var(--tie2); color: var(--ink); width: 32px; height: 32px; font-size: 18px; line-height: 1; }
.hatch-body { padding: 12px; font: 500 13.5px/1.5 var(--grot); }
.hatch-body p { margin: 0 0 10px; }
.hatch-body .fire { width: 100%; background: var(--hitch); color: #04140A; border: 0; padding: 14px; font: 700 16px/1 var(--pix); letter-spacing: .06em; text-transform: uppercase; box-shadow: 0 4px 0 var(--hitch-deep); }
.hatch-body .fire:disabled { background: var(--tie2); color: var(--dim); box-shadow: none; }
.wellpick { display: flex; flex-direction: column; gap: 6px; }
.wellpick button { display: flex; align-items: center; gap: 10px; background: var(--ground); border: 2px solid var(--tie2); color: var(--ink); padding: 10px; font: 600 14px/1 var(--grot); }
.wellpick img { width: 24px; height: 24px; image-rendering: auto; }
.sparknote { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--ground); padding: 10px 14px; font: 700 13px/1 var(--pix); letter-spacing: .04em; z-index: 70; max-width: 90vw; text-align: center; }

/* ---------- 720 – 999: wider measure ---------- */
@media (min-width: 720px) {
  :root { --rail: 64px; }
  #yard { padding: 20px 22px 48px 18px; }
  .mast span { font-size: 24px; }
  .signal { font-size: 42px; margin-bottom: 16px; }
  .hitchform { padding: 16px; }
  .hf-pick { min-height: 76px; }
  .hf-pick b { font-size: 16px; } .hf-pick s { font-size: 22px; } .hf-pick u { font-size: 11px; }
  .hf-out b { font-size: 34px; }
  .hf-go { min-height: 60px; font-size: 22px; padding: 0 26px; }
  .trn { grid-template-columns: 90px 1fr; padding: 8px; }
  .trn-lab b { font-size: 15px; } .trn-lab i { font-size: 18px; }
  .wags { gap: 5px; }
  .wag { font-size: 11px; }
  .stat b { font-size: 26px; }
  .sid-addr { font-size: 12px; }
}

/* ---------- ≥ 1000: the siding becomes a column, the yard recomposes into two ---------- */
@media (min-width: 1000px) {
  :root { --rail: 250px; }
  #siding {
    top: 0; height: 100vh; width: var(--rail); border-top: 0; border-bottom: 0; box-shadow: none;
    flex-direction: column; padding: 0;
  }
  .sid-copy { order: 2; flex: 0 0 auto; margin: 0 16px 14px; border: 0; padding: 14px; font-size: 15px; }
  .sid-track {
    order: 1; flex: 0 0 auto; writing-mode: horizontal-tb; text-orientation: initial; flex-direction: column; align-items: stretch; gap: 8px;
    padding: 16px; background: none; border-top: 2px solid var(--tie2); border-bottom: 2px solid var(--tie2); margin: 14px 0;
  }
  .sid-tag { font-size: 14px; }
  .sid-addr { font-size: 12.5px; line-height: 1.5; }
  .sid-addr[data-live="0"] { font-size: 16px; }
  .sid-gmgn { font-size: 13px; }
  .sid-wide { order: 0; display: flex; flex-direction: column; gap: 14px; padding: 18px 16px 0; }
  .sid-mark { display: flex; align-items: center; gap: 10px; color: var(--ink); }
  .sid-mark span { font: 700 26px/1 var(--pix); letter-spacing: .04em; }
  .sid-clock { display: flex; flex-direction: column; gap: 2px; }
  .sid-clock b { font: 700 40px/1 var(--grot); letter-spacing: -.02em; }
  .sid-clock i { font: 500 11px/1.3 var(--grot); color: var(--dim); font-style: normal; text-transform: uppercase; letter-spacing: .08em; }
  .sid-nav { display: flex; flex-direction: column; gap: 4px; }
  .sid-nav a { font: 700 15px/1 var(--pix); letter-spacing: .05em; color: var(--dim); padding: 6px 0; border-bottom: 1px dashed var(--tie); }
  .sid-nav a[aria-current="page"] { color: var(--hitch); }
  .sid-social { display: flex; gap: 12px; font: 700 13px/1 var(--pix); }
  .sid-cuff { background: transparent; color: var(--ink); border: 2px solid var(--tie2); padding: 10px; font: 700 14px/1 var(--pix); }
  .sid-cuff[data-on="1"] { border-color: var(--hitch-deep); color: var(--hitch); }
  .mast { display: none; }
  #yard {
    margin-left: var(--rail); padding: 28px 32px 60px; max-width: calc(var(--rail) + 1180px);
    display: grid; grid-template-columns: minmax(0, 1fr) 360px; grid-template-areas: "head side" "form side" "trains side" "foot foot"; gap: 0 26px; align-content: start;
  }
  .signal { grid-area: head; font-size: 58px; margin-bottom: 20px; max-width: 760px; }
  .hitchform { grid-area: form; padding: 22px; margin-bottom: 18px; }
  .hf-lede { font-size: 15px; }
  .hf-picks { gap: 10px; margin-bottom: 16px; }
  .hf-pick { min-height: 92px; gap: 5px; }
  .hf-pick b { font-size: 18px; } .hf-pick s { font-size: 28px; } .hf-pick u { font-size: 12px; }
  .hf-out b { font-size: 44px; }
  .hf-out em { font-size: 13.5px; }
  .hf-go { min-height: 68px; font-size: 26px; padding: 0 34px; }
  .hf-note { font-size: 13px; }
  .trains { grid-area: trains; gap: 12px; }
  .trn { grid-template-columns: 110px 1fr; padding: 12px; }
  .trn-lab b { font-size: 17px; } .trn-lab i { font-size: 22px; } .trn-lab u { font-size: 10.5px; }
  .wags { gap: 7px; }
  .wag { font-size: 12px; }
  .wag::before, .wag::after { width: 7px; height: 7px; bottom: -7px; }
  .trn-foot { font-size: 12px; margin-top: 10px; }
  .rail-side { grid-area: side; position: sticky; top: 28px; align-self: start; }
  .buffers { grid-area: foot; }
  .leaf { grid-area: form; }
  .leaf .hd { font-size: 30px; }
  .leaf p { font-size: 14.5px; }
  #hatch { align-items: center; }
  .hatch-box { border-bottom: 2px solid var(--tie2); }
}
