:root {
  --bg: rgba(10, 12, 20, 0.78);
  --fg: #e8ecf4;
  --muted: #8a93a8;
  --line: rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #05060a;
  color: var(--fg);
  font-family: "Noto Sans JP", system-ui, sans-serif;
  overflow: hidden;
}

#map { position: absolute; inset: 0; }

.panel {
  position: absolute;
  background: var(--bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 12px;
  z-index: 2;
}
.panel.hidden { display: none; }

.panel-close {
  position: absolute; top: 6px; right: 6px;
  width: 24px; height: 24px;
  border: none; border-radius: 50%;
  background: rgba(255, 255, 255, 0.06); color: var(--muted);
  font-size: 15px; line-height: 1; cursor: pointer;
}
.panel-close:hover { background: rgba(255, 255, 255, 0.16); color: var(--fg); }

/* パネルの表示切り替えバー */
#panel-bar {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 4;
  display: flex; gap: 4px;
  padding: 4px;
  background: var(--bg); backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 999px;
}
#panel-bar button {
  border: none; border-radius: 999px;
  padding: 5px 12px;
  background: transparent; color: var(--muted);
  font: inherit; font-size: 12px; white-space: nowrap; cursor: pointer;
}
#panel-bar button.on { background: rgba(255, 255, 255, 0.14); color: var(--fg); }
#panel-bar #toggle-all { color: #ffd34d; }
body.export #panel-bar, body.export .panel-close { display: none; }

#title { top: 16px; left: 16px; padding: 12px 40px 12px 18px; }
#title h1 { margin: 0; font-size: 20px; font-weight: 900; letter-spacing: 0.04em; }
#title p { margin: 2px 0 0; font-size: 11px; color: var(--muted); letter-spacing: 0.12em; }

#clock-panel {
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 20px 10px;
  text-align: center;
  min-width: 460px;
}
#clock {
  font-size: 56px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: 0.02em;
}
#clock-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
#controls { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
#controls button {
  width: 34px; height: 30px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #1b2030; color: var(--fg); cursor: pointer; font-size: 13px;
}
#scrub { flex: 1; accent-color: #ffd34d; }
#controls select {
  background: #1b2030; color: var(--fg);
  border: 1px solid var(--line); border-radius: 8px; height: 30px;
}
#toggles {
  display: flex; gap: 16px; justify-content: center; align-items: center;
  margin-top: 8px; font-size: 11px; color: var(--muted);
}
#toggles input[type="range"] { width: 80px; vertical-align: middle; }

#lines-panel {
  top: 16px; right: 16px;
  width: 290px;
  max-height: calc(100% - 32px);
  overflow-y: auto;
  padding: 12px 14px;
}
h2 { margin: 0 0 8px; font-size: 12px; color: var(--muted); font-weight: 700; letter-spacing: 0.1em; }

.line-card {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: 2px 10px;
  align-items: center;
  padding: 7px 0;
  border-top: 1px solid var(--line);
  transition: opacity 0.6s;
}
.line-card.done { opacity: 0.38; }
.line-badge {
  grid-row: span 2;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 900; font-size: 14px; color: #fff;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.12);
}
.line-name { font-weight: 700; font-size: 13px; }
.line-status { font-size: 11px; text-align: right; font-variant-numeric: tabular-nums; }
.line-detail { grid-column: 2 / span 2; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.line-status.running { color: #7dffa8; }
.line-status.done { color: var(--muted); }

#ticker {
  top: 100px; left: 16px;
  width: 300px;
  max-height: calc(100% - 330px);
  overflow: hidden;
  padding: 12px 14px;
}
#events { list-style: none; margin: 0; padding: 0; }
#events li {
  display: grid;
  grid-template-columns: 42px 8px 1fr;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  padding: 4px 0;
  border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
body.export #controls, body.export #toggles { display: none; }
#events li .dot { width: 8px; height: 8px; border-radius: 50%; }
#events li.past { opacity: 0.4; }
#events li.now { background: rgba(255, 211, 77, 0.12); }
#events li small { color: var(--muted); }
@keyframes fadein { from { opacity: 0; transform: translateY(-4px); } }

#finale {
  position: absolute; inset: 0; z-index: 3;
  display: grid; place-items: center;
  pointer-events: none;
}
#finale[hidden] { display: none; }
.finale-inner {
  text-align: center;
  background: rgba(0, 0, 0, 0.55);
  padding: 24px 48px;
  border-radius: 16px;
  animation: fadein 1.2s;
}
.finale-time { font-size: 64px; font-weight: 900; font-variant-numeric: tabular-nums; }
.finale-text { font-size: 20px; letter-spacing: 0.2em; color: #ffd34d; }

#credits {
  position: absolute; bottom: 6px; left: 0; right: 0;
  text-align: center; font-size: 10px; color: var(--muted); z-index: 2;
  text-shadow: 0 0 4px #000;
}

.maplibregl-popup-content {
  background: #11141f; color: var(--fg);
  border-radius: 10px; padding: 10px 14px;
  font-family: "Noto Sans JP", sans-serif;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
}
.maplibregl-popup-tip { border-top-color: #11141f !important; border-bottom-color: #11141f !important; }
.pop h3 { margin: 0 0 6px; font-size: 15px; }
.pop table { border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.pop td { padding: 2px 6px 2px 0; }
.pop td.t { font-weight: 700; }
.pop .gone { opacity: 0.45; text-decoration: line-through; }
.maplibregl-ctrl-attrib { display: none; }

/* ---------- スマホ ---------- */
@media (max-width: 700px) {
  #panel-bar {
    top: max(8px, env(safe-area-inset-top));
    left: 8px; right: 8px; transform: none;
    overflow-x: auto; scrollbar-width: none;
    justify-content: space-between;
  }
  #panel-bar::-webkit-scrollbar { display: none; }
  #panel-bar button { padding: 6px 10px; font-size: 12px; }

  #title { top: 56px; left: 8px; padding: 8px 36px 8px 12px; }
  #title h1 { font-size: 16px; }
  #title p { font-size: 9px; }

  /* 一覧・路線は時計の上に出るシート（同時に 1 つだけ） */
  #ticker, #lines-panel {
    top: auto; left: 8px; right: 8px; width: auto;
    bottom: calc(var(--clock-h, 120px) + 16px);
    max-height: 42vh;
    overflow-y: auto;
    padding: 10px 12px;
  }
  #events li { font-size: 11px; grid-template-columns: 36px 8px 1fr; }
  .line-card { padding: 5px 0; }
  .line-badge { width: 24px; height: 24px; font-size: 12px; }
  .line-name { font-size: 12px; }

  #clock-panel {
    left: 8px; right: 8px;
    bottom: max(18px, env(safe-area-inset-bottom));
    transform: none;
    min-width: 0;
    padding: 8px 12px 8px;
  }
  #clock { font-size: 34px; }
  #clock-sub { font-size: 11px; margin-top: 2px; }
  #controls { margin-top: 6px; gap: 8px; }
  #toggles { flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; }
  #toggles input[type="range"] { width: 70px; }

  .finale-inner { padding: 16px 24px; }
  .finale-time { font-size: 44px; }
  .finale-text { font-size: 15px; }

  #credits { font-size: 7px; bottom: 2px; padding: 0 8px; }
}
