:root {
  --bg: #0e1117; --panel: #171c26; --panel2: #1e2430;
  --text: #dce3f0; --muted: #8b96ab; --line: #2a3242;
  --accent: #4f8ef7; --green: #2ecc71; --red: #e74c3c; --gold: #f1c40f;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  font-size: 14px; line-height: 1.6;
}
header {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 12px 20px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
h1 {
  font-size: 20px; font-weight: 650; letter-spacing: .02em;
  display: flex; align-items: center; gap: 10px;
}
h1 .brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  box-shadow: 0 2px 10px rgba(52, 211, 153, .18);
}
#gen { margin-left: auto; color: var(--muted); font-size: 12px; }
nav#tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.banner {
  margin: 12px 20px 0; padding: 8px 14px; border-radius: 8px;
  background: #2a2416; border: 1px solid #6b5a1e; color: #e8d48b; font-size: 12px;
}
main.tabpane { display: none; padding: 16px 20px 60px; }
main.tabpane.active { display: block; }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px; margin-bottom: 16px;
}
h2 { font-size: 15px; margin-bottom: 10px; color: #b9c4d8; }
.controls { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-end; }
.ctl label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
input, select, button {
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; font-size: 14px;
}
input[type="number"] { width: 130px; text-align: right; }
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.quick button { margin-left: 4px; padding: 4px 8px; font-size: 12px; }
.chartbox { position: relative; height: 320px; }
.chartbox.tall { height: 420px; }
.tablebox { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; white-space: nowrap; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: right; }
th { color: var(--muted); font-weight: 600; cursor: pointer; position: sticky; top: 0; background: var(--panel); }
td:first-child, th:first-child { text-align: left; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--panel2); }
tr.reason td {
  text-align: left; background: var(--panel2); color: #b9c4d8;
  white-space: normal; font-size: 12px;
}
.pos { color: var(--green); } .neg { color: var(--red); }
.chips { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.chip {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 14px; font-size: 13px;
}
.chip b { display: block; font-size: 17px; margin-top: 2px; }
.desc { color: #b9c4d8; font-size: 13px; }
.fine { color: var(--muted); font-size: 12px; margin-top: 8px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.pcard {
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px;
}
.pcard h3 { font-size: 14px; margin-bottom: 6px; }
.pcard .eq { font-size: 20px; font-weight: 700; }
.pcard .pos-list { color: var(--muted); font-size: 12px; margin-top: 6px; }
label.pick {
  display: inline-flex; align-items: center; gap: 4px; margin: 2px 8px 2px 0;
  font-size: 13px; color: var(--text); cursor: pointer;
}
/* ===== 戦略アルゴリズム図鑑(カード型) ===== */
footer#algoNotes { padding: 8px 20px 64px; }
.algo-head { margin-bottom: 16px; }
.algo-head h2 { font-size: 21px; color: var(--text); margin-bottom: 6px; letter-spacing: .01em; }
.algo-sub { color: var(--muted); font-size: 12.5px; line-height: 1.75; max-width: 920px; }
.algo-sub b { color: #c3ccdb; font-weight: 600; }

.algo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
}

.algo-card {
  position: relative;
  background: linear-gradient(158deg, var(--panel) 0%, var(--panel2) 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 18px 16px;
  overflow: hidden;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.algo-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--c);
}
.algo-card::after {
  content: ""; position: absolute; top: -46px; right: -46px;
  width: 130px; height: 130px; border-radius: 50%;
  background: radial-gradient(circle, var(--c), transparent 68%);
  opacity: .13; pointer-events: none;
}
.algo-card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--c) 55%, var(--line));
  box-shadow: 0 10px 28px rgba(0, 0, 0, .38);
}

.algo-card-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 13px;
}
.algo-id {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px; font-weight: 600; color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 38%, transparent);
  padding: 3px 10px; border-radius: 999px; white-space: nowrap;
}
.algo-type {
  font-size: 11px; color: var(--muted); white-space: nowrap;
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px;
}
.algo-title {
  display: flex; align-items: center; gap: 9px;
  font-size: 16.5px; color: var(--text); margin-bottom: 10px; font-weight: 650;
}
.algo-icon { font-size: 20px; line-height: 1; }
.algo-title-sub { font-size: 12px; color: var(--muted); font-weight: 400; }

.algo-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.algo-badges .badge {
  font-size: 11px; color: #c3ccdb;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px;
}

.algo-body { display: grid; gap: 3px; }
.algo-body dt {
  font-size: 10.5px; font-weight: 700; letter-spacing: .08em;
  color: var(--c); margin-top: 8px;
}
.algo-body dt:first-child { margin-top: 0; }
.algo-body dd { font-size: 12.8px; color: #c3ccdb; line-height: 1.7; }

/* --- s6 全幅ハイライト --- */
.algo-card.featured {
  grid-column: 1 / -1;
  border-color: color-mix(in srgb, var(--c) 40%, var(--line));
}
.featured-tag {
  color: var(--c) !important;
  border-color: color-mix(in srgb, var(--c) 45%, transparent) !important;
  background: color-mix(in srgb, var(--c) 12%, transparent);
  font-weight: 600;
}
.algo-lead { font-size: 13px; color: #cbd4e2; line-height: 1.72; margin-bottom: 14px; max-width: 900px; }
.algo-lead b { color: var(--c); }
.algo-body-inline { font-size: 12.8px; color: #c3ccdb; line-height: 1.7; margin-top: 12px; }

.alloc { margin: 4px 0 4px; }
.alloc-label { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; color: var(--muted); margin-bottom: 6px; }
.alloc-bar {
  display: flex; height: 34px; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--line);
}
.alloc-bar span {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  color: #fff; font-size: 11.5px; font-weight: 500;
  min-width: 0; overflow: hidden; white-space: nowrap;
}
.alloc-bar span b { font-size: 13px; font-weight: 800; }

/* --- ベンチマーク説明 --- */
.algo-bench {
  margin-top: 14px; padding: 16px 18px;
  background: var(--panel); border: 1px dashed var(--line); border-radius: 12px;
}
.algo-bench h4 {
  display: flex; align-items: center; gap: 10px;
  font-size: 13.5px; color: #b9c4d8; margin-bottom: 8px; font-weight: 650;
}
.bench-line {
  display: inline-block; width: 26px; height: 0;
  border-top: 2px dashed var(--muted); flex: none;
}
.algo-bench p { font-size: 12.5px; color: var(--muted); line-height: 1.75; }
.algo-bench b { color: #c3ccdb; font-weight: 600; }

@media (max-width: 640px) {
  .alloc-bar span { font-size: 10px; }
  .alloc-bar span b { font-size: 11px; }
}
