html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
}

/* 進行方向が上になるように JS が回す。大きさ (画面の対角線) と回転角は app.js が入れる */
#map {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #e8e8e8;
}

#credit {
  position: fixed;
  right: 0;
  bottom: 0;
  z-index: 1000;
  padding: 1px 6px;
  background: rgba(255, 255, 255, 0.8);
  color: #333;
  font-size: 11px;
}

#credit a {
  color: #0078a8;
  text-decoration: none;
}

#hud {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1000;
  max-width: calc(100vw - 24px);
  box-sizing: border-box;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.25);
  color: #222;
  font-size: 13px;
  line-height: 1.7;
  pointer-events: none;
}

#speed {
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

#speed-value {
  display: inline-block;
  min-width: 3ch;
  font-size: 26px;
  font-weight: 700;
  text-align: right;
}

#speed .unit {
  margin-left: 4px;
  color: #666;
}

/* いま走っている道と、近くの地名・駅 */
#where {
  max-width: 340px;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#where:empty {
  display: none;
}

#status {
  color: #c0392b;
  font-weight: 600;
}

#status:empty {
  display: none;
}

/* 速度とボタン類を1行に並べる。操作説明は ? で開く */
#hud-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

#help[hidden] {
  display: none;
}

/* このサイトについて (説明・作者・出典)。? で操作説明といっしょに開く */
#about[hidden] {
  display: none;
}

#about {
  max-width: 340px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #ddd;
  line-height: 1.6;
  pointer-events: auto;
}

#about h1 {
  margin: 0;
  font-size: 15px;
}

#about p {
  margin: 2px 0 6px;
}

#about .disclaimer {
  padding: 4px 8px;
  border-radius: 6px;
  background: #fff6e0;
  font-size: 12px;
}

#about .links a {
  margin-right: 12px;
}

#about .sources {
  margin: 0;
  color: #666;
  font-size: 11px;
}

#help {
  margin: 6px 0 2px;
  padding: 0;
  list-style: none;
}

kbd {
  display: inline-block;
  min-width: 1.4em;
  padding: 0 4px;
  border: 1px solid #bbb;
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #f7f7f7;
  font-family: inherit;
  font-size: 12px;
  text-align: center;
}

.next-swatch {
  display: inline-block;
  width: 22px;
  height: 6px;
  margin: 0 4px 2px 2px;
  border-radius: 3px;
  background: #1e88e5;
  vertical-align: middle;
}

/* 車アイコン。上 (北) 向きに描いておき、進行方向の角度だけ回転させる */
.car {
  background: none;
  border: none;
}

.car-body {
  position: relative;
  width: 16px;
  height: 30px;
  margin: 2px;
  border-radius: 6px 6px 4px 4px;
  background: #e53935;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  box-sizing: border-box;
}

.car-body::before {
  /* フロントガラス */
  content: "";
  position: absolute;
  top: 5px;
  left: 1px;
  right: 1px;
  height: 6px;
  border-radius: 2px 2px 0 0;
  background: #263238;
}

/* 拡大縮小・地図の種類・開始位置のボタン。HUD 自体はクリックを素通しするので、ここだけ受け取る */
#controls {
  display: flex;
  align-items: center;
  gap: 4px;
  pointer-events: auto;
}

#controls button,
#controls select,
#picker-bar button,
#picker-results button {
  padding: 3px 9px;
  border: 1px solid #bbb;
  border-radius: 6px;
  background: #fff;
  color: #222;
  font: inherit;
  cursor: pointer;
}

#controls button,
#controls select {
  height: 26px;
  padding: 0 7px;
  font-size: 12px;
  line-height: 1;
}

#controls select {
  width: 9.5em;
}

#help-toggle[aria-expanded="true"] {
  background: #e3f0fc;
}

/* 開始位置を選ぶ画面。走行中の地図の上に全面で重ねる */
#picker {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  background: #fff;
  font-size: 14px;
}

#picker[hidden] {
  display: none;
}

#picker-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid #ddd;
}

#picker-search {
  display: flex;
  gap: 6px;
}

#picker-query {
  width: 260px;
  max-width: 50vw;
  padding: 4px 8px;
  border: 1px solid #bbb;
  border-radius: 6px;
  font: inherit;
}

#picker-hint {
  flex: 1;
  color: #555;
}

#picker-results {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0 12px;
  list-style: none;
  color: #555;
}

#picker-results:not(:empty) {
  padding: 8px 12px;
  border-bottom: 1px solid #ddd;
}

#picker-results button {
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#picker-map {
  flex: 1;
  cursor: crosshair;
}
