:root {
  --bg: #0e1014;
  --surface: #171a20;
  --ink: #ecebe6;
  --muted: #9ea3ab;
  --hair: #2a2f38;
  --led: #ffb000;          /* 発車標の LED */
  --led-dim: #3a2a12;
  --line: #ffb000;         /* lit track */
  --rail: #4a505a;
  --sleeper: #2f2a25;
  --ground: #13161b;
  --bldg: #1f232b;
  --win: #e9d9a0;
  --badge: #f3efe4;
  --badge-ink: #111311;
  --badge-ring: #d9534a;
  --danger: #ff6a55;

  --r-ctl: 3px;
  --r-box: 2px;
  --ui: "BIZ UDPGothic", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", sans-serif;
  --dot: "DotGothic16", "BIZ UDPGothic", monospace;
  --display: "Shippori Antique B1", "BIZ UDPGothic", serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.7 var(--ui);
  min-height: 100dvh;
}
::selection { background: var(--led); color: var(--bg); }
a { color: inherit; }

main, .board-head, .foot-note { max-width: 520px; margin: 0 auto; padding: 0 16px; }

.board-head {
  display: flex; justify-content: space-between; align-items: center;
  height: 48px; font-size: 13px; color: var(--muted);
  border-bottom: 1px solid var(--hair);
}
.home { text-decoration: none; }
.home { font-weight: 700; }
.home::before { content: "← "; }
.issue { font-family: var(--dot); letter-spacing: .04em; }

/* 発車標: two LED rows on a black panel */
.sign {
  margin: 18px 0 0;
  background: #050605;
  border: 1px solid var(--hair);
  border-radius: var(--r-box);
  padding: 10px 12px 8px;
  font-family: var(--dot);
  color: var(--led);
  text-shadow: 0 0 6px rgba(255, 176, 0, .35);
}
.sign-row { display: grid; align-items: baseline; gap: 10px; }
.sign-top { grid-template-columns: auto 1fr auto auto; font-size: 22px; line-height: 1.3; }
.sign-kind { color: #7bd88f; text-shadow: 0 0 6px rgba(123, 216, 143, .3); }
.sign-note { font-size: 14px; color: var(--danger); border: 1px solid var(--danger); padding: 0 4px; line-height: 1.4; text-shadow: none; }
.sign-bottom {
  grid-template-columns: auto auto 1fr; font-size: 15px; margin-top: 4px;
  border-top: 1px dashed var(--led-dim); padding-top: 4px;
}
.now { font-size: 20px; }
.left-row { justify-self: end; }
.left-row b { font-weight: 400; font-size: 20px; padding: 0 2px; }
.left-row.tight { color: var(--danger); animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

.title {
  font: 400 30px/1.2 var(--display); margin: 22px 0 6px; letter-spacing: .04em;
}
.lede { margin: 0; color: var(--muted); font-size: 14px; }

/* the three stations as a line diagram */
.stops {
  list-style: none; margin: 18px 0 10px; padding: 0;
  display: grid; grid-template-columns: repeat(3, 1fr);
  position: relative;
}
.stops::before {
  content: ""; position: absolute; left: 12%; right: 12%; top: 11px; height: 4px; background: var(--rail);
}
.stops li { position: relative; text-align: center; font-size: 13px; color: var(--muted); }
.stops .num, .result-marks .num {
  display: inline-block; font: 700 11px/1 var(--ui); letter-spacing: .02em;
  background: var(--badge); color: var(--badge-ink);
  border: 3px solid var(--rail); border-radius: 4px; padding: 3px 4px; min-width: 38px;
}
.stops .nm { display: block; margin-top: 4px; }
.stops li.on { color: var(--ink); }
.stops li.on .num { border-color: var(--badge-ring); }

.board-wrap { margin: 4px -8px 0; }
#board { display: block; width: 100%; height: auto; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
#board .ground { fill: var(--ground); }
#board .grid line { stroke: var(--hair); stroke-width: 1; }
#board .cell { cursor: pointer; -webkit-tap-highlight-color: transparent; }
#board .cell.kB, #board .cell.kE { cursor: default; }
#board .cell:focus { outline: none; }
#board .cell:focus-visible .piece > rect { stroke: var(--led); stroke-width: 2; }
#board .piece { transform-box: fill-box; transform-origin: center; transition: transform 140ms ease-out; }
#board .rails line, #board .rails path, #board .rail { stroke: var(--rail); stroke-width: 3.2; fill: none; stroke-linecap: butt; }
#board .sleepers line { stroke: var(--sleeper); stroke-width: 4; }
#board .cell.lit .rails line, #board .cell.lit .rails path { stroke: var(--line); }
#board .cell.lit .sleepers line { stroke: #4b3a1c; }
#board .edge.goal.lit .rail, #board .edge.start .rail { stroke: var(--line); }
#board .bldg { fill: var(--bldg); }
#board .win { fill: var(--win); opacity: .8; }
#board .plat, #board .platforms rect { fill: #59606b; }
#board .cell.lit .platforms rect { fill: #b9bec6; }
#board .buffer { fill: var(--danger); }
#board .edge-label { fill: var(--muted); font: 700 11px var(--ui); text-anchor: middle; }
#board .badge rect { fill: var(--badge); stroke: var(--rail); stroke-width: 2; }
#board .cell.lit .badge rect { stroke: var(--badge-ring); }
#board .badge text { fill: var(--badge-ink); font: 700 8px var(--ui); text-anchor: middle; }
#board .train rect { fill: #e9e7e0; }
#board .train .lamp { fill: var(--led); }
@media (hover: hover) {
  #board .cell.kS:hover .rails line, #board .cell.kC:hover .rails path, #board .cell.kC:hover .rails line { stroke: #8a909b; }
  #board .cell.lit.kS:hover .rails line, #board .cell.lit.kC:hover .rails path { stroke: #ffc46e; }
}

.foot { margin: 14px 0 0; }
.depart {
  width: 100%; min-height: 52px; border: 0; border-radius: var(--r-ctl);
  font: 700 17px var(--ui); letter-spacing: .04em;
  background: var(--led); color: #1b1305; cursor: pointer;
}
.depart:disabled { background: var(--surface); color: var(--muted); border: 1px solid var(--hair); font-weight: 400; font-size: 14px; cursor: default; }
.depart:not(:disabled):active { transform: translateY(1px); }
.hint { margin: 8px 0 0; font-size: 12px; color: var(--muted); }

.result { margin: 26px 0 0; padding: 20px 0 0; border-top: 1px solid var(--hair); }
.result-time { font: 44px/1 var(--dot); color: var(--led); margin: 0; text-shadow: 0 0 10px rgba(255, 176, 0, .3); }
.result h2 { font: 400 24px/1.3 var(--display); letter-spacing: .04em; margin: 10px 0 4px; }
.result-note { margin: 0; color: var(--muted); font-size: 14px; }
.result-marks { list-style: none; padding: 0; margin: 14px 0 0; display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.result-marks li { display: flex; align-items: center; gap: 6px; }
.result-marks li.on { color: var(--ink); }
.result-marks li.on .num { border-color: var(--badge-ring); }
.share { display: flex; gap: 10px; margin: 18px 0 0; }
.btn {
  flex: 1; min-height: 48px; border-radius: var(--r-ctl); cursor: pointer;
  font: 700 15px var(--ui); color: var(--ink); background: transparent; border: 1px solid #3a404b;
}
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.counts { font-size: 13px; color: var(--ink); margin: 16px 0 0; padding: 10px 12px; background: var(--surface); border-radius: var(--r-box); }
.next { font-size: 12px; color: var(--muted); margin: 14px 0 0; }
.practice { font-size: 13px; color: var(--muted); margin: 18px 0 0; }

.foot-note { margin-top: 36px; padding-bottom: 28px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--hair); padding-top: 12px; }

@media (prefers-reduced-motion: reduce) {
  #board .piece { transition: none; }
  .left-row.tight { animation: none; }
}
