:root {
  color-scheme: light;
  --ink: #16160f;
  --muted: #474a41;
  --paper: #f5f3ec;
  --line: #62655a;
  --card: #ffffff;
  --walker: #0072b2;
  --bike: #a8420f;
  --other: #41443c;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--paper); color: var(--ink); line-height: 1.75;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}
.site-head, main { max-width: 900px; margin: auto; padding: 0 24px; }
.site-head { padding-top: 48px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .12em; margin: 0 0 6px; }
h1, h2, h3, p, ol { margin: 0 0 12px; }
h1 {
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(32px, 6.4vw, 54px); letter-spacing: .04em; line-height: 1.3;
  word-break: keep-all; overflow-wrap: anywhere;
}
h2 { font-size: 19px; line-height: 1.6; word-break: keep-all; overflow-wrap: anywhere; }
.lede { font-size: 16px; margin: 0; }
button {
  min-height: 44px; padding: 10px 18px; border: 2px solid var(--line); border-radius: 4px;
  background: var(--card); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
}
button:hover { background: #e8e5db; }
a { color: #1f3f57; text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
#answer-text, .spot-text, .band-axis, .intro-note, #hours-peak, #hours-unknown { font-variant-numeric: tabular-nums; }

/* 場所を決める */
#picker { padding-top: 28px; }
#picker h2 { font-size: 16px; }
#locate { width: 100%; background: #1c3f56; color: #ffffff; border-color: #1c3f56; }
#locate:hover { background: #142e3f; }
.address-form { margin: 12px 0 0; }
.address-label { display: block; font-size: 13px; font-weight: 700; }
.address-row { display: flex; gap: 8px; margin-top: 4px; }
#address {
  flex: 1; min-width: 0; min-height: 44px; padding: 8px 12px; font: inherit;
  border: 2px solid var(--line); border-radius: 4px; background: var(--card); color: var(--ink);
}
#candidates { margin: 10px 0 0; }
.candidates-head, .candidates-message { font-size: 14px; margin: 0 0 6px; }
.candidate { display: block; width: 100%; text-align: left; margin-bottom: 6px; font-weight: 400; }
.candidate strong { font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
#place-name { font-size: 15px; font-weight: 700; margin: 12px 0 0; }

/* 答え。中身が全部隠れているときは枠ごと消す */
.answer-area:not(:has(> :not([hidden]))) { display: none; }
.answer-area { padding: 24px 0 4px; }
#answer-text {
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(22px, 3.6vw, 32px); max-width: 24em; margin-bottom: 8px;
}
#answer-text .count { font-size: 1.35em; font-weight: 700; letter-spacing: .01em; }
#answer-sub { font-size: 17px; font-weight: 700; max-width: 34em; word-break: keep-all; overflow-wrap: anywhere; }
#failure { border-left: 4px solid #8a3a12; padding-left: 20px; }
#none { border-left: 4px solid var(--line); padding-left: 20px; }
#none-text { font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; font-size: clamp(20px, 3.2vw, 26px); }
#none-sub, #status { font-size: 15px; max-width: 40em; }

/* 「多い＝危ない」ではない。答えのすぐ下に、たたまずに置く */
.caveat {
  font-size: 15px; color: var(--muted); max-width: 44em;
  padding-top: 12px; margin: 12px 0 0;
}
/* 罫線は「答えとの仕切り」なので、上に答え（0件・エラーを含む）が出ているときだけ引く。
   場所を決める前は仕切るものが無く、住所欄の下に短い線が1本浮いて見える */
.answer-area:has(> :not([hidden])) + .caveat { border-top: 1px solid var(--line); }

/* 使い方 */
#intro { padding-top: 24px; }
.steps { padding-left: 1.4em; }
.steps li { margin-bottom: 6px; }
.intro-note { font-size: 15px; color: var(--muted); max-width: 42em; margin-bottom: 0; }

/* 絞り込み */
.controls { display: grid; gap: 12px; margin: 24px 0 0; grid-template-columns: 1fr; }
fieldset { border: 1px solid var(--line); border-radius: 4px; padding: 6px 14px 14px; margin: 0; min-width: 0; }
legend { font-size: 15px; font-weight: 700; padding: 0 6px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 14px;
  border: 2px solid var(--line); border-radius: 4px; background: var(--card); cursor: pointer; font-size: 16px;
}
.chip:hover { background: #eeebe1; }
.chip input { width: 20px; height: 20px; flex-shrink: 0; accent-color: #1c3f56; margin: 0; }
.chip:has(:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); font-weight: 700; }

/* 地図 */
#map-area { padding-top: 28px; }
#map { height: 360px; background: #e6e6e0; border: 1px solid var(--line); }
.pin-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; font-size: 14px; margin: 8px 0 0; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.map-tail { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; margin-top: 8px; }
.map-tail p { font-size: 14px; margin: 0; }
.map-tail button { font-size: 14px; flex-shrink: 0; }
.privacy { font-size: 14px; color: var(--muted); margin: 12px 0 0; max-width: 44em; }
.maplibregl-ctrl-attrib { color: var(--ink); background: var(--card) !important; }
.maplibregl-ctrl-attrib a { color: var(--ink) !important; }
.maplibregl-ctrl-group { border: 2px solid var(--line); }
.maplibregl-ctrl-group button { width: 44px; height: 44px; }

/* ピン（凡例と、選んだ場所の目印）。地図の事故ピンは canvas で描いて記号レイヤーに載せている */
.pin { width: 44px; height: 44px; display: grid; place-items: center; cursor: default; }
.pin-face { display: block; flex-shrink: 0; }
.pin-walker { width: 14px; height: 14px; border-radius: 50%; background: var(--walker); border: 2px solid #ffffff; box-shadow: 0 0 0 1px #9a9d93; }
.pin-bike { width: 12px; height: 12px; background: var(--bike); border: 2px solid #ffffff; transform: rotate(45deg); box-shadow: 0 0 0 1px #9a9d93; }
.pin-other { width: 8px; height: 8px; border-radius: 50%; background: var(--other); border: 1px solid #ffffff; box-shadow: 0 0 0 1px #9a9d93; }
.pin-death { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--ink); background: #ffffff; }
.pin-self { width: 20px; height: 20px; background: var(--ink); border: 3px solid #ffffff; transform: rotate(45deg); box-shadow: 0 0 0 1px #6c6f65; }

/* 読み取り欄 */
.readouts { display: grid; gap: 28px; grid-template-columns: 1fr; padding-top: 28px; }
#spots-list { list-style: none; padding: 0; margin: 0; counter-reset: spot; }
.spot {
  position: relative; counter-increment: spot; padding: 12px 0 12px 44px;
  border-top: 1px solid var(--line); font-size: 16px;
}
.spot::before {
  content: counter(spot); position: absolute; left: 0; top: 14px; width: 30px; height: 30px;
  border-radius: 50%; background: #1c3f56; color: #ffffff; display: grid; place-items: center;
  font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums;
}
.spot-text { word-break: keep-all; overflow-wrap: anywhere; }
.note { font-size: 14px; color: var(--muted); margin-top: 12px; max-width: 42em; }

/* 時刻の帯。0〜23時の24本。時刻不明は混ぜない */
.band {
  list-style: none; display: grid; grid-template-columns: repeat(24, 1fr); gap: 2px;
  align-items: end; height: 140px; padding: 0; margin: 0 0 4px;
  border-bottom: 2px solid var(--line);
}
.band-cell { display: flex; align-items: flex-end; height: 100%; }
.band-cell .bar { display: block; width: 100%; background: #6d7d8c; }
.band-cell[data-peak="1"] .bar { background: #1c3f56; }
/* 目盛りは帯と同じ24分割の上に置く。flexで等間隔に並べると、棒とずれて読み違える */
.band-axis { display: grid; grid-template-columns: repeat(24, 1fr); font-size: 13px; color: var(--muted); }
.band-axis span { grid-row: 1; }
.band-axis span:nth-child(1) { grid-column: 1 / 7; }
.band-axis span:nth-child(2) { grid-column: 7 / 13; }
.band-axis span:nth-child(3) { grid-column: 13 / 19; }
.band-axis span:nth-child(4) { grid-column: 19 / 25; }
.band-axis span:nth-child(5) { grid-column: 19 / 25; justify-self: end; }
#hours-peak { font-size: 16px; font-weight: 700; margin: 8px 0 0; }
#hours-unknown { font-size: 14px; color: var(--muted); margin: 4px 0 0; }

#skeleton { padding: 28px 0 0; }
#skeleton div {
  height: 88px; background: #e6e3d8; border-left: 18px solid #d2cfc2; margin: 12px 0;
  animation: pulse 1.5s ease-in-out infinite alternate;
}
@keyframes pulse { to { opacity: .5; } }

/* 限界と出典 */
.limits { border-top: 1px solid var(--line); margin-top: 32px; padding-top: 24px; }
.limit-list { padding-left: 1.4em; font-size: 16px; max-width: 46em; }
.limit-list li { margin-bottom: 8px; }
.sources { padding: 8px 0 32px; font-size: 13px; }
.sources p { margin-bottom: 4px; max-width: 48em; }
.source-line { font-size: 14px; }

@media (max-width: 600px) {
  .site-head, main { padding-left: 18px; padding-right: 18px; }
  .site-head { padding-top: 28px; }
  .map-tail { flex-direction: column; align-items: flex-start; gap: 10px; }
  #map { height: 300px; }
  .band { height: 110px; gap: 1px; }
}
@media (min-width: 760px) {
  .controls { grid-template-columns: auto 1fr; align-items: start; }
}
@media (min-width: 900px) {
  .site-head, main { max-width: 1040px; }
  .readouts { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 40px; }
}
@media (prefers-reduced-motion: reduce) { #skeleton div { animation: none; } }
