:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #eef0f5;
  --border: #dde1ea;
  --text: #151a26;
  --muted: #5d6679;
  --accent: #a8822c;
  --accent-strong: #8a6a1f;
  --accent-ink: #ffffff;
  --win: #1f8a5b;
  --win-soft: #e3f4ec;
  --lose: #c24536;
  --lose-soft: #fbe9e6;
  --blue: #2f6fd6;
  --red: #d2453b;
  --lock: rgba(244, 245, 248, 0.82);
  --shadow: 0 1px 2px rgba(20, 26, 38, 0.06), 0 4px 16px rgba(20, 26, 38, 0.06);
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117;
    --surface: #151b25;
    --surface-2: #1c2431;
    --border: #273142;
    --text: #e8ecf3;
    --muted: #97a2b6;
    --accent: #d4ad55;
    --accent-strong: #e6c475;
    --accent-ink: #151a26;
    --win: #3fbf86;
    --win-soft: #13291f;
    --lose: #ef6b5b;
    --lose-soft: #2c1714;
    --blue: #5b93ee;
    --red: #ef6b5b;
    --lock: rgba(13, 17, 23, 0.82);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { display: block; }
h1, h2, h3 { line-height: 1.3; margin: 0; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

/* ---- 上部バー ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 20px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; white-space: nowrap; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-weight: 800;
}
.nav { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); white-space: nowrap; font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { color: var(--text); background: var(--surface-2); }
.account { display: flex; align-items: center; gap: 8px; white-space: nowrap; }

@media (max-width: 720px) {
  .topbar-inner { flex-wrap: wrap; gap: 8px 12px; }
  .nav { order: 3; flex-basis: 100%; }
}

/* ---- レイアウト ---- */
.page { max-width: 1080px; margin: 0 auto; padding: 24px 16px 64px; display: grid; gap: 20px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 820px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.card.flat { box-shadow: none; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---- ボタン・入力 ---- */
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; font-size: 14px; padding: 8px 14px; border-radius: 9px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--lose); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.lg { padding: 11px 20px; font-size: 15px; }

input, textarea, select {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 12px; width: 100%;
}
input:focus, textarea:focus, select:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { min-height: 96px; resize: vertical; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab {
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600;
}
.tab.active { background: var(--text); color: var(--bg); border-color: var(--text); }

.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge.gold { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent-strong); }
.badge.win { background: var(--win-soft); color: var(--win); }
.badge.lose { background: var(--lose-soft); color: var(--lose); }

.error { color: var(--lose); font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 32px 16px; }

/* ---- ヒーロー（検索） ---- */
.hero { display: grid; gap: 14px; padding: 28px; }
.hero h1 { font-size: 26px; }
.search { display: flex; gap: 8px; }
.search input { font-size: 16px; padding: 12px 14px; }
@media (max-width: 560px) { .search { flex-direction: column; } }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 14px; font-weight: 600; cursor: pointer;
}
.chip:hover { border-color: var(--accent); }

/* ---- 試合カード ---- */
.match-list { display: grid; gap: 8px; }
.match {
  display: grid; grid-template-columns: 6px 48px 1fr auto; gap: 14px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px 10px 0; overflow: hidden; cursor: pointer;
}
.match:hover { border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); }
.match .bar { align-self: stretch; margin: -10px 0; background: var(--muted); }
.match.win .bar { background: var(--win); }
.match.lose .bar { background: var(--lose); }
.match .icon { width: 48px; height: 48px; border-radius: 10px; background: var(--surface-2); }
.match-main { display: grid; gap: 2px; min-width: 0; }
.match-main .top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.match-stats { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.match-stats b { color: var(--text); font-weight: 700; }
.match-side { text-align: right; font-size: 13px; color: var(--muted); display: grid; gap: 4px; justify-items: end; }
.aug-row { display: flex; gap: 4px; }
.aug-row img { width: 22px; height: 22px; border-radius: 5px; background: var(--surface-2); }
@media (max-width: 560px) {
  .match { grid-template-columns: 6px 40px 1fr; }
  .match .icon { width: 40px; height: 40px; }
  .match-side { grid-column: 3; justify-items: start; text-align: left; }
}

/* ---- 試合詳細 ---- */
.match-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.match-head .icon { width: 64px; height: 64px; border-radius: 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.kpi { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .value.pos { color: var(--win); }
.kpi .value.neg { color: var(--lose); }

.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 28px; gap: 10px; align-items: center; font-size: 13px; }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--lose); border-radius: 999px; }

.coach { border-left: 3px solid var(--accent); }
.coach-text { white-space: pre-wrap; }
.task {
  margin-top: 12px; padding: 12px 14px; border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 14%, transparent); font-weight: 600;
}
.upsell {
  display: grid; gap: 10px; padding: 16px; border-radius: 10px; border: 1px dashed var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}

.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 720px) { .teams { grid-template-columns: 1fr; } }
.team h3 { margin-bottom: 6px; }
.team.blue h3 { color: var(--blue); }
.team.red h3 { color: var(--red); }
.plist { display: grid; gap: 4px; }
.prow { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center; font-size: 13px; padding: 4px 6px; border-radius: 8px; }
.prow.me { background: color-mix(in srgb, var(--accent) 14%, transparent); font-weight: 700; }
.prow img { width: 28px; height: 28px; border-radius: 6px; }
.prow .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- オーグメント ---- */
.aug-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.aug {
  display: grid; grid-template-columns: 40px 1fr; gap: 10px; align-items: start;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
}
.aug img { width: 40px; height: 40px; border-radius: 8px; background: var(--surface-2); }
.aug .name { font-weight: 700; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.aug .desc { font-size: 13px; color: var(--muted); white-space: pre-wrap; }
.aug.pickable { cursor: pointer; }
.aug.pickable:hover { border-color: var(--accent); }
.aug.picked { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--surface)); }
.rarity-プリズム { background: color-mix(in srgb, #b16cea 18%, transparent); color: #a55ee0; }
.rarity-ゴールド { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent-strong); }
.rarity-シルバー { background: color-mix(in srgb, #8a95a8 20%, transparent); color: var(--muted); }

/* ---- ビルド ---- */
.build-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.build { position: relative; display: grid; gap: 10px; cursor: pointer; }
.build:hover { border-color: var(--accent); }
.build-head { display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: center; }
.build-head img { width: 44px; height: 44px; border-radius: 10px; }
.build .icons { display: flex; gap: 4px; flex-wrap: wrap; }
.build .icons img { width: 30px; height: 30px; border-radius: 7px; background: var(--surface-2); }
.build.locked { cursor: default; }
.build.locked .lock-cover {
  position: absolute; inset: 0; border-radius: var(--radius); background: var(--lock); backdrop-filter: blur(3px);
  display: grid; place-content: center; text-align: center; gap: 6px; padding: 16px;
}
.lock-icon { font-size: 22px; }

.banner {
  display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}

.picker { display: grid; gap: 10px; }
.picker-results { max-height: 420px; overflow: auto; padding-right: 4px; }
.champ-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.champ {
  display: grid; justify-items: center; gap: 2px; padding: 6px 2px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent; font-size: 11px; text-align: center; background: none; color: inherit; font-family: inherit;
}
.champ img { width: 44px; height: 44px; border-radius: 8px; }
.champ:hover { background: var(--surface-2); }
.champ.picked { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.selected-list { display: flex; gap: 8px; flex-wrap: wrap; }
.selected {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 4px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; font-weight: 600;
}
.selected img { width: 24px; height: 24px; border-radius: 5px; }
.selected button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px; }
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.item-opt {
  display: grid; grid-template-columns: 28px 1fr; gap: 8px; align-items: center; padding: 6px; border-radius: 8px;
  cursor: pointer; font-size: 12px; border: 1px solid transparent; background: none; color: inherit; text-align: left; font-family: inherit;
}
.item-opt img { width: 28px; height: 28px; border-radius: 6px; }
.item-opt:hover { background: var(--surface-2); }
.item-opt.picked { border-color: var(--accent); }

/* ---- プラン ---- */
.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 820px) { .plans { grid-template-columns: 1fr; } }
.plan { display: grid; gap: 12px; align-content: start; }
.plan.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.plan .price { font-size: 28px; font-weight: 800; }
.plan .price small { font-size: 14px; font-weight: 600; color: var(--muted); }
.plan ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 14px; }
.dev { border-style: dashed; }

/* ---- その他 ---- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600;
  box-shadow: var(--shadow); max-width: calc(100% - 32px);
}
.modal {
  border: 1px solid var(--border); border-radius: 14px; padding: 0; width: min(420px, calc(100% - 32px));
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(0, 0, 0, 0.45); }
.modal form { padding: 20px; display: grid; gap: 14px; }
.loading { display: grid; place-items: center; padding: 48px; color: var(--muted); }
.spinner {
  width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--surface-2); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite; margin-bottom: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius); height: 70px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---- 時間帯別 ---- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table thead th { color: var(--muted); font-weight: 600; font-size: 12px; }
.table tbody th { font-weight: 700; }
.pos { color: var(--win); }
.neg { color: var(--lose); }
.gchart { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(40px, 1fr); gap: 6px; overflow-x: auto; }
.gcol { display: grid; justify-items: center; gap: 2px; }
.gplot {
  position: relative; width: 100%; height: 120px; display: flex; justify-content: center; gap: 3px;
  background: linear-gradient(var(--border), var(--border)) center / 100% 1px no-repeat;
}
.gbar { width: 10px; position: absolute; border-radius: 3px; }
.gbar.up { bottom: 50%; }
.gbar.down { top: 50%; }
.gbar.team { left: calc(50% - 11px); background: var(--accent); }
.gbar.lane { left: calc(50% + 1px); background: var(--blue); }
.gplot:not(:has(.lane)) .gbar.team { left: calc(50% - 5px); }
.legend { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-left: 8px; }
.legend.team { background: var(--accent); }
.legend.lane { background: var(--blue); }
.death-log { display: grid; gap: 4px; }
.death { display: grid; grid-template-columns: 52px 1fr 1fr auto auto; gap: 10px; align-items: center; font-size: 13px; padding: 6px 8px; border-radius: 8px; background: var(--surface-2); }
.death .time { font-weight: 700; }
@media (max-width: 560px) { .death { grid-template-columns: 46px 1fr auto auto; } .death > :nth-child(3) { display: none; } }
.coach-h { color: var(--accent-strong); }
.btn.fable { background: linear-gradient(135deg, #7c4dde, #b16cea); border-color: transparent; color: #fff; }
.btn.fable:hover { filter: brightness(1.08); }

/* ---- 上位プレイヤーとの比較 ---- */
.cmp-row { display: grid; grid-template-columns: 230px 1fr 200px 64px; gap: 12px; align-items: center; font-size: 13px; padding: 4px 0; }
.cmp-track { position: relative; height: 18px; border-radius: 999px; background: var(--surface-2); }
.cmp-band { position: absolute; top: 4px; bottom: 4px; border-radius: 999px; background: color-mix(in srgb, var(--muted) 35%, transparent); }
.cmp-median { position: absolute; top: 1px; bottom: 1px; width: 2px; margin-left: -1px; background: var(--muted); }
.cmp-you { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--surface); }
.cmp-you.win { background: var(--win); }
.cmp-you.lose { background: var(--lose); }
.cmp-val { white-space: nowrap; }
.legend-band, .legend-median, .legend-you { display: inline-block; margin-left: 10px; }
.legend-band { width: 18px; height: 8px; border-radius: 999px; background: color-mix(in srgb, var(--muted) 35%, transparent); }
.legend-median { width: 2px; height: 12px; background: var(--muted); }
.legend-you { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
@media (max-width: 760px) {
  .cmp-row { grid-template-columns: 1fr auto; row-gap: 4px; }
  .cmp-track { grid-column: 1 / -1; grid-row: 2; }
  .cmp-val { grid-column: 1; grid-row: 3; }
  .cmp-row .badge { grid-column: 2; grid-row: 1; }
}

/* ---- ルーン図鑑 ---- */
.tree-tab { display: inline-flex; align-items: center; gap: 6px; }
.tree-tab img { width: 18px; height: 18px; }
.rune-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.rune { display: grid; gap: 10px; align-content: start; }
.rune.focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); }
.rune-head { display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: center; }
.rune-head img { width: 44px; height: 44px; border-radius: 50%; background: var(--surface-2); }
.rune-summary { font-weight: 600; }
.rune-dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; margin: 0; font-size: 13px; }
.rune-dl dt { color: var(--accent-strong); font-weight: 700; white-space: nowrap; }
.rune-dl dd { margin: 0; }
.rune-desc { white-space: pre-wrap; margin-top: 6px; }
details summary { cursor: pointer; }
.rune-cmp { display: grid; gap: 4px; }
.rune-opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
@media (max-width: 720px) { .rune-opts { grid-template-columns: 1fr; } }
.rune-opt { display: grid; grid-template-columns: 1fr 60px 36px; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 8px; background: var(--surface-2); border: 1px solid transparent; font-size: 13px; }
.rune-opt:hover { border-color: var(--accent); }
.rune-opt.mine { border-color: var(--accent); font-weight: 700; }
.rune-opt .name { overflow-wrap: anywhere; line-height: 1.3; }
.rbar { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.rbar span { display: block; height: 100%; background: var(--accent); }

/* ---- ボット相性 ---- */
.champ .small { font-size: 10px; }
.duo-list { display: grid; gap: 6px; }
.duo-row { display: grid; grid-template-columns: 32px 130px 1fr 190px 200px; gap: 12px; align-items: center; padding: 6px 10px; border-radius: 10px; background: var(--surface-2); }
.syn { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.duo-row img { width: 32px; height: 32px; border-radius: 8px; }
.duo-rate { display: grid; grid-template-columns: 1fr 44px auto; gap: 8px; align-items: center; }
@media (max-width: 720px) {
  .duo-row { grid-template-columns: 32px 1fr; }
  .duo-row > :nth-child(3), .duo-row > :nth-child(4), .duo-row > :nth-child(5) { grid-column: 2; }
}

/* ---- フッター・法律ページ ---- */
.site-footer { max-width: 1080px; margin: 0 auto; padding: 24px 16px 40px; border-top: 1px solid var(--border); display: grid; gap: 10px; font-size: 12px; color: var(--muted); }
.site-footer nav { gap: 16px; }
.site-footer a { text-decoration: underline; }
.legal { max-width: 760px; }
.legal h2 { font-size: 16px; margin-top: 8px; }
.legal p, .legal li { max-width: 68ch; }
.legal ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.legal-table th { width: 180px; white-space: normal; vertical-align: top; }
.legal-table td { white-space: normal; }
