:root {
  --bg1: #0b1626; --bg2: #13263f;
  --panel: rgba(16, 33, 58, .82); --panel-border: rgba(124, 196, 255, .22);
  --text: #e6edf5; --muted: #93a6bd; --accent: #7cc4ff; --gold: #ffd76a;
  --done: #4ade80; --doing: #fbbf24; --todo: #6b7a8f; --lock: #ff8a8a;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 600px at 50% -10%, #1d3c63 0%, transparent 60%), linear-gradient(180deg, var(--bg2), var(--bg1));
  background-attachment: fixed;
  padding: 24px 16px 40px;
  max-width: 1280px; margin: 0 auto;
}
button { font: inherit; color: inherit; cursor: pointer; }

body > header { text-align: center; margin-bottom: 18px; }
body > header .sub { font-size: 12px; letter-spacing: .25em; color: var(--accent); text-transform: uppercase; margin-bottom: 6px; }
body > header h1 { font-size: 20px; line-height: 1.45; margin: 0; text-shadow: 0 0 18px rgba(124, 196, 255, .35); }
body > header h1 small { display: block; font-size: 14px; font-weight: 500; color: var(--muted); margin-top: 2px; }

/* ---------- 共通（上）・3 ルート（列）・合流（下）。スマホはルートをタブで 1 列 ---------- */
.band, .route {
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 16px;
  padding: 12px 14px; box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
}
.band h2, .route h2 {
  font-size: 15px; color: var(--accent); margin: 0 0 10px;
  display: flex; align-items: baseline; gap: 6px;
}
.band.merge { border-color: rgba(255, 215, 106, .35); }
.band.merge h2 { color: var(--gold); }
.band-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
.band-row > .node { flex: 1 1 260px; max-width: 420px; }
.band-row > .exits.from { flex-basis: 100%; margin: 0; }

.routes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; margin: 14px 0; }
.route h2 .dir { font-size: 11px; color: var(--muted); font-weight: 500; margin-right: auto; }
.prog { font-size: 12px; color: var(--muted); font-weight: 500; }
.tabs { display: none; }
@media (max-width: 760px) {
  .routes { grid-template-columns: minmax(0, 1fr); }
  .route:not(.active) { display: none; }
  .tabs { display: flex; gap: 6px; margin: 14px 0 -4px; position: sticky; top: 0; z-index: 5; padding: 6px 0; background: var(--bg1); }
  .tab {
    flex: 1; padding: 8px 4px; border-radius: 10px; font-size: 14px; font-weight: 700;
    background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.14);
  }
  .tab.active { background: rgba(124, 196, 255, .2); border-color: var(--accent); color: #fff; }
}

/* ---------- マップ（ノード） ---------- */
.node {
  padding: 10px; border-radius: 12px;
  background: rgba(0, 0, 0, .22); border: 1px solid rgba(255,255,255,.1);
  transition: box-shadow .3s;
}
.node.cleared { border-color: rgba(74, 222, 128, .45); }
.node.cleared .name::after { content: " ✓"; color: var(--done); }
.node.unknown { border-style: dashed; color: var(--muted); }
.node.flash { box-shadow: 0 0 0 2px var(--gold), 0 0 18px rgba(255, 215, 106, .6); }
.node header { display: flex; align-items: center; gap: 8px; }
.node .no {
  flex: none; min-width: 26px; padding: 1px 6px; border-radius: 6px; text-align: center;
  font-size: 12px; font-weight: 700; background: rgba(124, 196, 255, .16); color: var(--accent);
}
.node .name { flex: 1; font-weight: 700; font-size: 15px; line-height: 1.35; }
.boss { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.boss-btn {
  font-size: 12px; padding: 2px 9px; border-radius: 999px;
  color: #ffc7a8; background: rgba(255, 140, 90, .1); border: 1px solid rgba(255, 140, 90, .45);
}
.boss-btn.down { color: #b8f5c8; background: rgba(74, 222, 128, .1); border-color: rgba(74, 222, 128, .45); }
.n-note { font-size: 12px; color: var(--muted); margin-top: 4px; }
.arrow { text-align: center; color: var(--muted); font-size: 13px; line-height: 1; margin: 3px 0; }
.empty { color: var(--muted); font-size: 13px; margin: 4px 0; }
.loading { color: var(--muted); text-align: center; }

/* ギミック（状態は左の丸ボタンで 未 → 進行中 → 完了） */
.gims { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.g {
  display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center;
  padding: 4px 6px; border-radius: 8px; background: rgba(255,255,255,.03);
}
.g.cross { background: rgba(255, 170, 80, .07); }
.g .g-note { grid-column: 2; }
.g.done .g-title { opacity: .55; text-decoration: line-through; text-decoration-color: rgba(255,255,255,.3); }
.g-title { font-size: 13.5px; line-height: 1.4; }
.g-note { display: block; font-size: 12px; color: var(--muted); line-height: 1.5; word-break: auto-phrase; }
.badge { font-size: 10px; font-weight: 700; padding: 0 6px; border-radius: 999px; vertical-align: 1px; white-space: nowrap; }
.badge.cross { color: #ffcf99; border: 1px solid rgba(255, 170, 80, .55); }

.st-btn, .help-btn {
  width: 26px; height: 26px; border-radius: 50%; padding: 0; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.18);
}
.help-btn { font-weight: 700; color: var(--accent); }
.st-icon { display: inline-block; width: 11px; height: 11px; border-radius: 50%; background: var(--todo); vertical-align: -1px; }
.st-icon.doing { background: var(--doing); box-shadow: 0 0 6px var(--doing); }
.st-icon.done { background: var(--done); box-shadow: 0 0 6px var(--done); }

/* 行き先・来る道のチップ（押すとそのマップへ移動） */
.exits { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.exits.col { flex-direction: column; align-items: flex-start; }
.exit {
  font-size: 12px; padding: 3px 9px; border-radius: 999px; text-align: left;
  background: rgba(124, 196, 255, .1); border: 1px solid rgba(124, 196, 255, .4); color: #cfe7ff;
}
.exit.dir { font-weight: 700; }
.exit.locked { background: rgba(255, 110, 110, .1); border-color: rgba(255, 138, 138, .5); color: #ffd2d2; }
.exit .lock { font-size: 11px; color: var(--lock); }

/* ---------- 分岐（レーンを色分け。分岐元の行き先チップも同じ色） ---------- */
.fork, .unordered { margin-top: 6px; }
.fork-head {
  font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .1em;
  display: flex; align-items: center; gap: 6px; margin: 2px 0 6px;
}
.fork-head::before, .fork-head::after { content: ""; flex: 1; border-top: 1px dashed rgba(255,255,255,.2); }
.lane { border-left: 3px solid var(--lane); padding-left: 8px; margin-bottom: 10px; }
.lane-head { font-size: 12px; font-weight: 700; color: var(--lane); margin-bottom: 4px; }
.lane-0 { --lane: #5eead4; }
.lane-1 { --lane: #c4a1ff; }
.lane-2 { --lane: #fca5a5; }
.lane-3 { --lane: #fde68a; }
.exit[class*="lane-"] { border-color: var(--lane); color: var(--lane); background: transparent; }
.unordered .node + .node { margin-top: 6px; }

/* ルート未確定のマップ */
.unassigned { margin-top: 14px; font-size: 13px; color: var(--muted); }
.unassigned summary { cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.18); }
.legend .badge { margin-left: 4px; }

/* ---------- 下部 ---------- */
.foot-tools { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-top: 16px; }
.legend { font-size: 12px; color: var(--muted); }
.legend .st-icon { margin-left: 8px; }
.reset {
  padding: 7px 14px; border-radius: 10px; font-size: 13px; font-weight: 600;
  border: 1px solid rgba(255, 140, 140, .45); background: rgba(255, 110, 110, .12); color: #ffd2d2;
}
footer { margin-top: 24px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; color: var(--muted); text-align: center; line-height: 1.6; }
footer p { margin: 0; }
footer .copy { font-size: 10.5px; opacity: .8; margin-top: 2px; }
.loading { color: var(--muted); text-align: center; grid-column: 1 / -1; }

/* ---------- ヘルプ ---------- */
dialog.help {
  width: min(600px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto;
  padding: 18px; border-radius: 16px; color: var(--text);
  background: #10213a; border: 1px solid var(--panel-border); box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
}
dialog.help::backdrop { background: rgba(3, 8, 16, .7); backdrop-filter: blur(2px); }
dialog.help h2 { font-size: 17px; margin: 0 0 8px; }
dialog.help h3 { font-size: 13px; color: var(--accent); margin: 14px 0 4px; }
dialog.help .route-name { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 6px; }
dialog.help .sum { font-size: 14px; color: var(--text); }
dialog.help ul { padding-left: 1.3em; font-size: 14px; line-height: 1.75; margin: 6px 0; }
dialog.help a { color: var(--accent); }
dialog.help figure { margin: 14px 0 0; text-align: center; }
dialog.help img { width: 100%; max-width: 420px; height: auto; image-rendering: pixelated; border-radius: 8px; }
dialog.help figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; }
.help-nav { display: flex; justify-content: center; margin-top: 16px; }
.help-nav button {
  min-width: 140px; padding: 8px 18px; border: 0; border-radius: 10px; font-weight: 700;
  color: #0b1a2c; background: var(--accent);
}

/* ---------- 情報募集の案内 ---------- */
.callout {
  margin: 0 0 14px; padding: 10px 14px; border-radius: 14px; font-size: 13px; line-height: 1.7; text-align: center;
  background: rgba(255, 215, 106, .08); border: 1px solid rgba(255, 215, 106, .35);
}
.callout a { color: var(--gold); font-weight: 700; }
.callout small { color: var(--muted); }

/* ---------- ワールド共有 ---------- */
.syncbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  margin: 0 0 14px; padding: 10px 14px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--panel-border); font-size: 13px;
}
.syncbar label { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--accent); }
.syncbar select {
  font: inherit; font-size: 13px; color: var(--text); min-width: 170px;
  background: rgba(0, 0, 0, .35); border: 1px solid rgba(255,255,255,.18); border-radius: 8px; padding: 5px 8px;
}
.syncbar option, .syncbar optgroup { background: #13263f; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700;
  padding: 3px 10px; border-radius: 999px; border: 1px solid rgba(255,255,255,.15); color: var(--muted);
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #6b7a8f; }
.pill.ok { color: #b8f5c8; border-color: rgba(90, 220, 130, .45); }
.pill.ok::before { background: #4ade80; box-shadow: 0 0 6px #4ade80; }
.pill.wait { color: #ffe1a3; border-color: rgba(255, 200, 90, .45); }
.pill.wait::before { background: #fbbf24; }
.sess { color: var(--muted); font-size: 12px; }
.sess b { color: var(--text); }
.sess .open { color: #b8f5c8; font-weight: 700; }
.sess .closed { color: #ffb4b4; font-weight: 700; }
.syncnote { flex-basis: 100%; font-size: 11px; color: var(--muted); line-height: 1.6; }
body.closed .st-btn, body.closed .boss-btn { cursor: not-allowed; }
body.synced .reset { opacity: .4; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  padding: 10px 16px; border-radius: 10px; font-size: 13px; z-index: 50;
  background: rgba(20, 30, 48, .96); border: 1px solid rgba(255, 170, 60, .5); color: #ffd79a;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
