* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #05060f; }
body {
  font-family: "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  color: #e8e4d8;
}
#map { position: absolute; inset: 0; }

/* ===== 地名検索（左上・タイムラインの右） ===== */
#search-panel {
  position: absolute; left: 176px; top: 14px; z-index: 11; width: 300px;
  display: flex; flex-wrap: wrap;
}
#search-panel input {
  flex: 1; min-width: 0; padding: 7px 10px; font-size: 13px;
  background: rgba(8, 10, 22, 0.78); color: #e8e4d8;
  border: 1px solid rgba(255,255,255,0.18); border-radius: 8px 0 0 8px;
  backdrop-filter: blur(6px); outline: none;
}
#search-panel input:focus { border-color: #2e6fd1; }
#search-btn {
  width: 36px; padding: 7px 0; font-size: 13px; cursor: pointer;
  background: #2e6fd1; color: #fff; border: 1px solid #2e6fd1;
  border-radius: 0 8px 8px 0;
}
#search-btn:hover { background: #3d80e4; }
#search-results { display: none; margin-top: 4px; flex-basis: 100%; }
.search-result {
  display: block; width: 100%; text-align: left; cursor: pointer;
  padding: 7px 10px; font-size: 12px; color: #e8e4d8;
  background: rgba(8, 10, 22, 0.88); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px; margin-bottom: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.search-result:hover:not(:disabled) { background: rgba(46, 111, 209, 0.5); }
.search-result:disabled { color: rgba(232,228,216,0.5); cursor: default; }

/* ===== 年代ティント（キャンバスモードに追従） ===== */
#era-tint {
  position: absolute; inset: 0; pointer-events: none; z-index: 5;
  opacity: 0; transition: opacity 0.6s ease, background 0.6s ease;
}
body[data-canvas="dusk"] #era-tint {
  opacity: 1;
  background: radial-gradient(ellipse at center, rgba(70,60,40,0) 55%, rgba(30,24,12,0.35) 100%);
}
body[data-canvas="sepia"] #era-tint {
  opacity: 1;
  background:
    radial-gradient(ellipse at center, rgba(0,0,0,0) 50%, rgba(28,18,6,0.5) 100%),
    linear-gradient(rgba(112,76,30,0.16), rgba(112,76,30,0.16));
}
body[data-canvas="parchment"] #era-tint {
  opacity: 1;
  background:
    radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(46,30,10,0.4) 100%),
    linear-gradient(rgba(198,162,96,0.18), rgba(198,162,96,0.18));
}

/* ===== 左サイド タイムライン ===== */
#timeline {
  position: absolute; left: 14px; top: 14px; bottom: 14px; width: 148px; z-index: 10;
  display: flex; flex-direction: column;
  background: rgba(8, 10, 22, 0.78);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  backdrop-filter: blur(6px);
  overflow: hidden;
}
.tl-header { padding: 8px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.tl-home {
  width: 100%; padding: 5px 0; cursor: pointer;
  background: #2e6fd1; color: #fff; border: 0; border-radius: 6px; font-size: 12px;
}
.tl-home:hover { background: #3d80e4; }
.tl-viewport { position: relative; flex: 1; min-height: 0; }
.tl-scroll {
  position: absolute; inset: 0; overflow-y: scroll; scrollbar-width: none;
}
.tl-scroll::-webkit-scrollbar { display: none; }
.tl-strip { position: relative; }
.tl-band {
  position: absolute; left: 0; width: 26px; cursor: pointer;
  background: linear-gradient(90deg, var(--band-color), transparent);
  border-top: 1px solid rgba(255,255,255,0.25);
}
.tl-band span {
  position: sticky; top: 4px;
  display: inline-block; padding: 2px 0 2px 4px;
  writing-mode: vertical-rl; font-size: 10px; letter-spacing: 2px;
  color: rgba(255,255,255,0.85); text-shadow: 0 0 4px #000;
  max-height: 100%;
}
.tl-tick {
  position: absolute; left: 30px; right: 6px; transform: translateY(-50%);
  font-size: 10px; color: rgba(232,228,216,0.75);
  border-top: 1px solid rgba(255,255,255,0.16);
  padding-top: 1px; pointer-events: none;
}
.tl-marker {
  position: absolute; left: 0; right: 0; top: 90px; z-index: 2; pointer-events: none;
  border-top: 2px solid #ffb84d;
}
.tl-marker-year {
  position: absolute; right: 4px; top: -22px;
  font-size: 13px; font-weight: 700; color: #ffb84d; text-shadow: 0 0 6px #000;
}

/* ===== HUD（右上） ===== */
#hud {
  position: absolute; top: 14px; right: 74px; z-index: 10; text-align: right;
  background: rgba(8, 10, 22, 0.72); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px; padding: 10px 14px; max-width: 380px;
  backdrop-filter: blur(6px);
}
#hud-year { font-size: 30px; font-weight: 800; letter-spacing: 1px; line-height: 1.1; }
#hud-era { font-size: 12px; color: #9fc3ff; margin-top: 2px; }
#hud-note { font-size: 11px; color: rgba(232,228,216,0.75); margin-top: 4px; }

/* ===== 高度パネル（右側） ===== */
#alt-panel {
  position: absolute; right: 14px; top: 40%; transform: translateY(-50%); z-index: 10;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: rgba(8, 10, 22, 0.72); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px; padding: 12px 8px; width: 76px;
  backdrop-filter: blur(6px);
}
#alt-readout { font-size: 10px; font-weight: 700; color: #ffb84d; white-space: nowrap; }
#alt-slider {
  writing-mode: vertical-lr; direction: rtl;
  height: 22vh; width: 22px; cursor: pointer; accent-color: #2e6fd1;
}
#alt-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; width: 100%; }
#alt-presets button {
  font-size: 9px; padding: 3px 4px; cursor: pointer;
  background: rgba(255,255,255,0.1); color: #e8e4d8;
  border: 1px solid rgba(255,255,255,0.15); border-radius: 5px;
}
#alt-presets button:hover { background: rgba(255,255,255,0.22); }

/* ===== 操作ヘルプ（左下） / クレジット（右下） ===== */
#help {
  position: absolute; left: 176px; bottom: 14px; z-index: 10;
  font-size: 11px; color: rgba(232,228,216,0.8);
  background: rgba(8, 10, 22, 0.6); border-radius: 8px; padding: 6px 10px;
}
#help kbd {
  background: rgba(255,255,255,0.15); border-radius: 3px; padding: 0 4px;
  font-family: inherit; font-size: 10px;
}
/* ===== 位置情報パネル（右下: ミニマップ + 住所 + 緯度経度） ===== */
#geo-panel {
  position: absolute; right: 14px; bottom: 76px; z-index: 10; width: 190px;
  background: rgba(8, 10, 22, 0.72); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px; padding: 5px; text-align: right;
  backdrop-filter: blur(6px);
}
#minimap-wrap { position: relative; }
#minimap {
  width: 180px; height: 130px; border-radius: 6px; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.18); display: none;
}
#minimap-arrow {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  color: #ffb84d; font-size: 14px; text-shadow: 0 0 4px #000;
  pointer-events: none; display: none;
}
#geo-addr { font-size: 11px; color: #cfe0ff; margin-top: 4px; min-height: 13px; }
#geo-coords { font-size: 10px; color: rgba(232,228,216,0.8); font-variant-numeric: tabular-nums; }
#geo-credit { font-size: 8px; color: rgba(232,228,216,0.45); margin-top: 2px; }

#quality-toggle {
  position: absolute; right: 14px; bottom: 44px; z-index: 10;
  font-size: 11px; padding: 4px 10px; cursor: pointer;
  background: rgba(8, 10, 22, 0.72); color: #e8e4d8;
  border: 1px solid rgba(255,255,255,0.18); border-radius: 8px;
}
#quality-toggle:hover { background: rgba(30, 36, 60, 0.85); }

#attribution {
  position: absolute; right: 14px; bottom: 14px; z-index: 10; max-width: 60vw;
  font-size: 10px; color: rgba(232,228,216,0.85); text-align: right;
  background: rgba(8, 10, 22, 0.6); border-radius: 8px; padding: 4px 8px;
}

@media (max-width: 720px) {
  #timeline { width: 110px; }
  #hud { right: 66px; max-width: 55vw; }
  #hud-year { font-size: 22px; }
  #help { display: none; }
}
