:root {
  --bg: #0b1020;
  --bg-2: #111832;
  --panel: rgba(20, 28, 56, 0.86);
  --line: rgba(148, 170, 255, 0.16);
  --text: #e8ecff;
  --muted: #94a0c8;
  --accent: #6c8cff;
  --accent-2: #36d6c3;
  --ok: #3ddc97;
  --ng: #ff5d6c;
  --warn: #ffb547;
  --road: #ff7a59;
  --adjacent: #ffb547;
  --north: #4dabf7;
  --absolute: #b197fc;
  --shadow: #8f7cff;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 70% -10%, #1b2552 0%, var(--bg) 55%) fixed, var(--bg);
  color: var(--text);
  font-family: "Noto Sans JP", "Yu Gothic UI", "Hiragino Sans", "Meiryo", system-ui, sans-serif;
  font-size: 14px;
  display: flex; flex-direction: column;
}
button { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; font-weight: 400; }
.tag { font-size: 11px; margin-left: 8px; padding: 2px 8px; border-radius: 999px; background: rgba(108, 140, 255, 0.18); color: #b9c6ff; vertical-align: middle; font-weight: 600; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 18px; border-bottom: 1px solid var(--line);
  background: rgba(11, 16, 32, 0.7); backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand > div { min-width: 0; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: conic-gradient(from 210deg, var(--accent), var(--accent-2), var(--warn), var(--accent)); box-shadow: 0 0 18px rgba(108, 140, 255, 0.5); flex: none; }
.brand-name { font-weight: 800; letter-spacing: 0.02em; }
.brand-sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.btn { border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); padding: 8px 14px; border-radius: 10px; cursor: pointer; transition: 0.15s; white-space: nowrap; }
.btn:hover { border-color: rgba(148, 170, 255, 0.45); background: rgba(255, 255, 255, 0.08); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #8a6cff); border-color: transparent; font-weight: 700; box-shadow: 0 6px 20px rgba(108, 140, 255, 0.35); }
.btn.primary:hover { filter: brightness(1.1); }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 300px 1fr 290px; gap: 12px; padding: 12px; }
.panel { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; min-height: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); }
.card h2 { margin: 0 0 10px; font-size: 13px; letter-spacing: 0.06em; color: #c5cffa; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; }
.facts dt { color: var(--muted); font-size: 12px; }
.facts dd { margin: 0; font-weight: 600; }
.facts dd .art { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }

.bosses { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.boss { display: grid; grid-template-columns: 6px 1fr auto; gap: 10px; align-items: center; padding: 10px 10px 10px 0; border-radius: 12px; background: rgba(255, 255, 255, 0.03); border: 1px solid transparent; cursor: pointer; transition: 0.15s; }
.boss:hover { border-color: var(--line); }
.boss.focus { border-color: rgba(255, 255, 255, 0.35); background: rgba(255, 255, 255, 0.07); }
.boss .stripe { align-self: stretch; border-radius: 0 6px 6px 0; }
.boss .name { font-weight: 700; }
.boss .art { font-size: 11px; color: var(--muted); }
.boss .detail { font-size: 11px; color: #b6bfdf; margin-top: 2px; }
.pill { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: rgba(61, 220, 151, 0.16); color: var(--ok); }
.pill.ng { background: rgba(255, 93, 108, 0.18); color: var(--ng); animation: pulse 1.4s infinite; }
.pill.na { background: rgba(148, 160, 200, 0.12); color: var(--muted); }
.pill.wait { background: rgba(255, 181, 71, 0.15); color: var(--warn); }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(255, 93, 108, 0.12); } }

.stage-view { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #0d1430; min-height: 360px; }
#view { width: 100%; height: 100%; display: block; touch-action: none; }
.view-hud { position: absolute; left: 12px; top: 12px; display: flex; gap: 8px; flex-wrap: wrap; pointer-events: none; }
.hud-chip { background: rgba(11, 16, 32, 0.75); border: 1px solid var(--line); padding: 6px 10px; border-radius: 999px; font-size: 12px; backdrop-filter: blur(6px); }
.hud-chip.warn { color: var(--warn); }
.cams { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 6px; }

.chip { border: 1px solid var(--line); background: rgba(11, 16, 32, 0.7); padding: 5px 10px; border-radius: 999px; cursor: pointer; font-size: 12px; }
.chip.active, .chip:hover { border-color: var(--accent); color: #fff; background: rgba(108, 140, 255, 0.2); }

.score .big { font-size: 34px; font-weight: 800; letter-spacing: 0.01em; font-variant-numeric: tabular-nums; }
.score .big small { font-size: 14px; margin-left: 4px; color: var(--muted); }
.bar { height: 8px; background: rgba(255, 255, 255, 0.07); border-radius: 99px; overflow: hidden; margin: 6px 0; }
.bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width 0.25s; }
.bar-fill.over { background: var(--ng); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0 6px; }
.num { font-weight: 700; font-variant-numeric: tabular-nums; }
.num.ng { color: var(--ng); }

.tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tool { position: relative; text-align: left; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); padding: 9px 10px; border-radius: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.tool span { font-size: 11px; color: var(--muted); }
.tool kbd { position: absolute; right: 8px; top: 8px; font-size: 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; }
.tool.active { border-color: var(--accent); background: rgba(108, 140, 255, 0.16); box-shadow: inset 0 0 0 1px rgba(108, 140, 255, 0.35); }
.slider { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; margin-top: 10px; font-size: 12px; color: var(--muted); }
.slider input { width: 100%; accent-color: var(--accent); }
.slider output { color: var(--text); font-weight: 700; min-width: 3em; text-align: right; }
.seg { display: flex; gap: 6px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.toggle { display: flex; gap: 8px; align-items: center; padding: 4px 0; cursor: pointer; }
.toggle input { accent-color: var(--accent); }
.hint { font-size: 12px; line-height: 1.7; color: #c9d1f5; border-left: 3px solid var(--accent-2); }
.hint-list { margin: 0 0 10px; padding-left: 1.4em; display: flex; flex-direction: column; gap: 8px; }
.hint-list:empty { display: none; }
.hint-more { width: 100%; font-size: 12px; }
.hint-more:disabled { opacity: 0.5; cursor: default; }

/* クリアまで（3D 画面の左上） */
.todo { position: absolute; left: 12px; top: 52px; width: min(330px, calc(100% - 24px)); background: rgba(11, 16, 32, 0.82); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(8px); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); overflow: hidden; }
.todo-head { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; background: none; border: 0; cursor: pointer; font-weight: 800; font-size: 13px; letter-spacing: 0.03em; }
.todo.done .todo-head { color: var(--ok); }
.todo-caret { color: var(--muted); transition: transform 0.15s; }
.todo.collapsed .todo-caret { transform: rotate(-90deg); }
.todo.collapsed .todo-list, .todo.collapsed .todo-foot { display: none; }
.todo-list { list-style: none; margin: 0; padding: 0 12px 6px; display: flex; flex-direction: column; gap: 5px; }
.todo-list li { display: grid; grid-template-columns: 8px 1fr; column-gap: 8px; row-gap: 1px; align-items: center; font-size: 12px; }
.todo-list .dot { width: 8px; height: 8px; border-radius: 50%; }
.todo-list .nm { font-weight: 700; }
.todo-list .tx { grid-column: 2; color: var(--ng); font-variant-numeric: tabular-nums; }
.todo-list li.ok { grid-template-columns: 8px auto 1fr; }
.todo-list li.ok .tx { grid-column: auto; text-align: right; }
.todo-list li.ok .nm { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(148, 160, 200, 0.6); }
.todo-list li.ok .tx { color: var(--ok); }
.todo-list li.wait .tx { color: var(--warn); }
.todo-foot { font-size: 11px; color: #c9d1f5; padding: 7px 12px 9px; border-top: 1px solid var(--line); line-height: 1.6; }
.todo.done .todo-foot { color: var(--ok); }

/* 課題カード */
.mission-sheet { width: min(640px, 100%); }
.mission-no { font-size: 12px; color: var(--accent-2); font-weight: 800; letter-spacing: 0.1em; margin-bottom: 4px; }
.mission-sheet h1 { font-size: 21px; }
.goal { background: rgba(108, 140, 255, 0.1); border: 1px solid rgba(108, 140, 255, 0.35); border-radius: 14px; padding: 12px 14px; margin: 12px 0 16px; }
.goal-label { font-size: 12px; font-weight: 800; color: #b9c6ff; letter-spacing: 0.06em; margin-bottom: 6px; }
.goal-steps { margin: 0; padding-left: 1.4em; line-height: 1.9; }
.mission-bosses { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.mission-bosses li { display: grid; grid-template-columns: 10px 9em 1fr; gap: 10px; align-items: baseline; font-size: 13px; padding: 7px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); }
.mission-bosses .dot { width: 10px; height: 10px; border-radius: 50%; align-self: center; }
.mission-bosses span:last-child { color: #c9d1f5; }
.mission-bosses .rule { grid-column: 2 / -1; font-size: 12px; color: var(--muted); line-height: 1.6; }
.mission-bosses .rule .art { display: block; color: #b9c6ff; font-weight: 700; }
@media (max-width: 560px) {
  .mission-bosses li { grid-template-columns: 10px 1fr; }
  .mission-bosses li > span:last-of-type { grid-column: 2; }
}
a { color: #9db2ff; }
a:hover { color: #c5d1ff; }
.premise { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; margin: 0 0 10px; background: rgba(255, 255, 255, 0.03); }
.premise summary { cursor: pointer; font-weight: 700; font-size: 13px; color: #c5cffa; }
.premise ul { margin: 8px 0 4px; padding-left: 1.3em; font-size: 12px; line-height: 1.7; color: #c9d1f5; }
#termsNote a { color: #9db2ff; }
.linkbtn { background: none; border: 0; padding: 0; color: #9db2ff; text-decoration: underline; cursor: pointer; font-size: 12px; }

/* 出典・参考資料 */
.sources-sheet { width: min(860px, 100%); }
.sources-sheet h2 { font-size: 14px; margin: 18px 0 8px; color: #c5cffa; }
.basis { margin: 8px 0 0; padding-left: 1.3em; line-height: 1.8; color: #c9d1f5; }
.src-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.src-table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px; border-bottom: 1px solid var(--line); }
.src-table td { padding: 7px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.src-list { margin: 0; padding-left: 1.3em; line-height: 1.8; font-size: 13px; }
@media (max-width: 560px) {
  .src-table th:nth-child(3), .src-table td:nth-child(3) { display: none; }
}

.disclaimer { text-align: center; font-size: 12px; color: var(--muted); padding: 6px 16px 10px; }
.disclaimer b { color: var(--warn); }

.overlay { position: fixed; inset: 0; background: rgba(5, 8, 18, 0.72); backdrop-filter: blur(8px); display: grid; place-items: center; z-index: 10; padding: 16px; overflow-y: auto; }
.sheet { width: min(980px, 100%); background: linear-gradient(180deg, #151e42, #10173a); border: 1px solid var(--line); border-radius: 20px; padding: 26px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5); }
.sheet h1 { margin: 0 0 6px; font-size: 24px; }
.lead { color: #c9d1f5; line-height: 1.8; }
.stage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin: 16px 0; }
.stage-card { text-align: left; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); border-radius: 16px; padding: 14px; cursor: pointer; transition: 0.18s; display: flex; flex-direction: column; gap: 6px; }
.stage-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 10px 30px rgba(108, 140, 255, 0.2); }
.stage-card .no { font-size: 11px; color: var(--accent-2); font-weight: 800; letter-spacing: 0.1em; }
.stage-card .t { font-size: 17px; font-weight: 800; }
.stage-card .s { font-size: 12px; color: var(--muted); line-height: 1.6; }
.stage-card .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.stage-card .meta span { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: rgba(255, 255, 255, 0.06); }
.stage-card .best { margin-top: auto; font-size: 12px; color: var(--warn); font-weight: 700; }
.result-sheet { width: min(560px, 100%); text-align: center; }
.rank { font-size: 76px; font-weight: 900; line-height: 1; background: linear-gradient(135deg, var(--warn), #ff6bd6, var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.rank.fail { background: none; color: var(--ng); font-size: 40px; }
.result-sheet table { width: 100%; border-collapse: collapse; margin: 12px 0; text-align: left; font-size: 13px; }
.result-sheet td { padding: 6px 4px; border-bottom: 1px solid var(--line); }
.result-sheet td:last-child { text-align: right; }
.sheet-actions { display: flex; gap: 10px; justify-content: center; margin-top: 14px; }

@media (max-width: 980px) {
  body { height: auto; }
  .layout { grid-template-columns: 1fr; }
  .stage-view { height: 62vh; order: -1; }
  .topbar { flex-direction: column; align-items: stretch; }
  .top-actions { justify-content: flex-start; }
}

/* 結果の共有と導線 */
.result-sheet .share { margin-top: 14px; text-align: left; }
.result-sheet .share h3, .result-sheet .cta h3 { margin: 0 0 8px; font-size: 15px; }
.share-text { white-space: pre-wrap; word-break: break-all; margin: 0 0 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); font: 13px/1.6 inherit; font-family: inherit; }
.share-actions, .cta-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn.x { background: #000; border-color: #333; color: #fff; font-weight: 700; }
.result-sheet .cta { margin-top: 14px; padding: 14px; text-align: left; border-radius: 12px; border: 1px solid rgba(108, 140, 255, 0.35); background: linear-gradient(135deg, rgba(108, 140, 255, 0.12), rgba(54, 214, 195, 0.08)); }
.result-sheet .cta p { margin: 0 0 8px; font-size: 13px; }
.cta-eyebrow { color: var(--accent-2); font-size: 12px !important; font-weight: 700; letter-spacing: 0.04em; }
.cta-actions a { text-decoration: none; color: var(--text, #e8ecff); }
.cta-actions a.btn.primary { color: #fff; }
.result-sheet { max-height: calc(100vh - 32px); overflow-y: auto; }
.disclaimer a { color: inherit; margin-left: 6px; }
