:root {
  --white: #FCFCF8;
  --ink: #1A2330;
  --green: #168A4A;
  --red: #E23D28;
  --blue: #2F6F9F;
  --yellow: #FFD400;
  --font-display: "Dela Gothic One", "Hiragino Sans", "Noto Sans JP", sans-serif;
  --font-body: "Zen Kaku Gothic New", "Hiragino Sans", "Noto Sans JP", sans-serif;
  --board-shadow: 0 5px 0 var(--ink), 0 12px 26px #1A233026;
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; }
body {
  color: var(--ink);
  background: var(--white);
  font: 500 16px/1.7 var(--font-body);
  overflow: hidden;
  overflow-wrap: anywhere;
  line-break: strict;
}
button, a { -webkit-tap-highlight-color: transparent; }
button, .button {
  min-height: 44px;
  min-width: 44px;
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: var(--white);
  color: var(--ink);
  padding: 9px 12px;
  font: 900 16px/1.5 var(--font-body);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--ink);
  touch-action: manipulation;
}
button:active:not(:disabled), .button:active { transform: translateY(2px); box-shadow: none; }
button:disabled { opacity: 0.5; cursor: default; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 4px; }
.primary { background: var(--green); color: var(--white); }
.board, .title-board, #sound-toggle {
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: var(--white);
  box-shadow: var(--board-shadow);
}
#map { width: 100%; height: 100dvh; background: #dce7e8; z-index: 0; }
.topbar {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  pointer-events: none;
  z-index: 600;
}
.title-board { margin: 0; padding: 8px 14px; font: 400 23px/1.5 var(--font-display); }
#sound-toggle { pointer-events: auto; white-space: nowrap; }
#dial {
  position: fixed;
  left: 50%;
  top: 42dvh;
  width: min(78vw, 46dvh, 420px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  z-index: 500;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s;
}
#dial.visible { opacity: 1; }
#dial svg { display: block; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 5px 8px #1A233026); }
.dial-face { fill: var(--white); fill-opacity: 0.78; stroke: var(--ink); stroke-width: 1.5; }
.dial-tick { stroke: var(--ink); stroke-width: 0.65; }
.dial-tick.major { stroke-width: 1.5; }
.dial-label { fill: var(--ink); font: 400 11px var(--font-display); text-anchor: middle; dominant-baseline: central; }
.dial-label.minor { font-size: 7px; }
.dial-rose { fill: var(--green); fill-opacity: 0.35; stroke: var(--green); stroke-width: 0.9; }
.sweep-trail { fill: var(--green); fill-opacity: 0.12; }
.sweep-line { stroke: var(--green); stroke-width: 1.3; }
.needle-head { fill: var(--red); stroke: var(--white); stroke-width: 0.6; }
.needle-tail, .needle-hub { fill: var(--ink); }
#panel {
  position: fixed;
  bottom: calc(28px + env(safe-area-inset-bottom));
  left: 12px;
  right: 12px;
  width: auto;
  max-width: 440px;
  max-height: calc(100dvh - 126px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  margin-inline: auto;
  padding: 16px;
  z-index: 600;
  overflow: auto;
  overscroll-behavior: contain;
}
#panel.compact { max-height: 130px; padding: 8px 14px; }
#panel.compact .panel-heading { margin-bottom: 4px; line-height: 1.3; }
#panel.compact .readings { line-height: 1.3; }
#panel.compact .outside-note { font-size: 12px; line-height: 1.3; margin-top: 6px !important; }
#panel p { margin: 0 0 10px; }
#panel p:last-child { margin-bottom: 0; }
.panel-heading { margin: 0 0 8px; font-size: 16px; font-weight: 700; line-height: 1.5; text-align: center; }
.actions { display: grid; gap: 10px; }
.actions.pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.actions.pair .primary { grid-column: 1 / -1; }
.actions.pair > * { min-width: 0; white-space: normal; overflow-wrap: anywhere; }
.readings { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; margin: 0; text-align: center; }
.readings dt { font-size: 14px; }
.readings dd { margin: 0; font-size: 15px; font-weight: 900; font-variant-numeric: tabular-nums; }
.readings small { font-size: 11px; margin-left: 2px; }
.readings .passed dt { color: var(--green); }
.outside-note { font-size: 13px; line-height: 1.4; margin-top: 8px !important; }
.roulette-value { margin: 0 !important; font: 400 clamp(24px, 8vw, 36px)/1.6 var(--font-display); text-align: center; font-variant-numeric: tabular-nums; }
.station-card { text-align: center; margin: -3px -3px 12px; }
.station-kana, .station-roman, .station-pref { font-size: 14px; margin: 0 !important; }
.station-pref { font-size: 13px; color: var(--ink); }
.station-name { margin: 0 0 10px; font: 900 clamp(26px, 8vw, 38px)/1.25 var(--font-body); letter-spacing: 0.1em; }
.station-band { height: 13px; margin: 9px 0 5px; background: var(--green); display: grid; place-items: center; }
.station-band::after { content: ""; width: 8px; height: 8px; background: var(--white); }
.station-meta { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; font-size: 14px; font-weight: 700; text-align: left; }
.station-origin { flex: 1; min-width: 0; }
.station-direction { flex: 0 0 auto; text-align: right; }
.facts { padding: 0; margin: 0 0 14px; list-style: none; font-size: 14px; line-height: 1.7; }
#confetti { position: fixed; inset: 0; width: 100%; height: 100dvh; pointer-events: none; z-index: 800; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.noscript { position: fixed; z-index: 900; bottom: 24px; left: 12px; right: 12px; padding: 16px; }
.leaflet-top.leaflet-right { top: calc(76px + env(safe-area-inset-top)); }
.leaflet-touch .leaflet-bar a, .leaflet-bar a { min-width: 44px; min-height: 44px; line-height: 44px; }
.leaflet-control-attribution { max-width: calc(100vw - 10px); font-size: 9px; line-height: 1.4; padding-bottom: env(safe-area-inset-bottom) !important; }
.map-icon { background: none; border: 0; }
.origin-dot { display: block; width: 18px; height: 18px; position: relative; border: 3px solid var(--white); border-radius: 50%; background: var(--red); box-shadow: 0 0 0 1px var(--red); }
.origin-dot::after { content: ""; position: absolute; inset: -8px; border: 2px solid var(--red); border-radius: 50%; animation: pulse 2.6s ease-out infinite; }
.runner-dot { display: block; width: 22px; height: 22px; border: 3px solid var(--ink); border-radius: 50%; background: var(--yellow); }
.destination-wrap { display: block; width: 30px; height: 42px; position: relative; }
.destination-pin { display: block; width: 30px; height: 30px; border: 3px solid var(--ink); border-radius: 50% 50% 50% 0; background: var(--red); transform: rotate(-45deg); position: absolute; top: 2px; left: 0; }
.destination-pin::after { content: ""; width: 8px; height: 8px; background: var(--white); border-radius: 50%; position: absolute; top: 8px; left: 8px; }
.destination-wrap.landing .destination-pin { animation: pin-drop 0.6s ease-out both; }
.destination-wrap.searching::before { content: ""; position: absolute; left: -13px; bottom: -14px; width: 56px; height: 28px; border: 2px solid var(--red); border-radius: 50%; animation: sonar 1.6s ease-out infinite; }
.station-marker { display: grid; place-items: center; width: 44px; height: 44px; border: 3px solid var(--white); border-radius: 10px; background: var(--green); color: var(--white); font: 900 22px var(--font-body); box-shadow: 0 2px 0 var(--ink); animation: station-bounce 0.6s ease-out both; }
@keyframes pulse { from { opacity: 0.8; transform: scale(0.7); } to { opacity: 0; transform: scale(1.7); } }
@keyframes sonar { from { opacity: 0.8; transform: scale(0.3); } to { opacity: 0; transform: scale(2.7); } }
@keyframes pin-drop { 0% { transform: translateY(-90px) rotate(-45deg); opacity: 0; } 65% { transform: translateY(0) rotate(-45deg); opacity: 1; } 82% { transform: translateY(-10px) rotate(-45deg); } 100% { transform: translateY(0) rotate(-45deg); } }
@keyframes station-bounce { 0% { transform: translateY(-24px) scale(0.7); opacity: 0; } 65% { transform: translateY(0) scale(1.1); opacity: 1; } 100% { transform: translateY(0) scale(1); } }
@media (max-height: 700px) {
  #dial { top: 38dvh; width: min(74vw, 42dvh); }
}
@media (min-width: 900px) {
  #panel { left: 24px; right: auto; width: 440px; margin: 0; }
  .topbar { left: 24px; right: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .origin-dot::after, .destination-wrap.searching::before { display: none; }
}
