/* BOATRACE ANALYZER */
:root {
  --bg: #f3f5f9; --card: #ffffff; --ink: #1b2433; --sub: #5d6878; --line: #dfe4ec; --soft: #eef2f8;
  --navy: #0d2a4f; --navy2: #163d70; --accent: #0a84d6; --accent2: #e8f3fc; --warn: #d9480f; --good: #1f8a4c;
  --hot: #d7263d; --hot-bg: #fdecee; --cool: #1c64c8; --cool-bg: #e9f1fd; --gold: #b7860b;
  --l1: #ffffff; --l1t: #222; --l2: #222222; --l2t: #fff; --l3: #e0262e; --l3t: #fff;
  --l4: #1d5fd1; --l4t: #fff; --l5: #f2cf1d; --l5t: #222; --l6: #1f9d55; --l6t: #fff;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 36, 70, .06), 0 2px 8px rgba(16, 36, 70, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141c; --card: #171e29; --ink: #e6ebf2; --sub: #98a4b5; --line: #2a3443; --soft: #1d2633;
    --navy: #0a1a30; --navy2: #12294a; --accent: #4fb0ff; --accent2: #16314d; --warn: #ff8a50; --good: #4cc27f;
    --hot: #ff6b7d; --hot-bg: #3a1a20; --cool: #6aa7ff; --cool-bg: #172a45; --gold: #e3b341;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141c; --card: #171e29; --ink: #e6ebf2; --sub: #98a4b5; --line: #2a3443; --soft: #1d2633;
  --navy: #0a1a30; --navy2: #12294a; --accent: #4fb0ff; --accent2: #16314d; --warn: #ff8a50; --good: #4cc27f;
  --hot: #ff6b7d; --hot-bg: #3a1a20; --cool: #6aa7ff; --cool-bg: #172a45; --gold: #e3b341;
  --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.6 "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.35; margin: 0; }
.num, td.n, th.n { font-variant-numeric: tabular-nums; }

/* ヘッダー */
.hd { background: linear-gradient(90deg, var(--navy), var(--navy2)); color: #fff; position: sticky; top: 0; z-index: 30; }
.hd-in { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 18px; padding: 0 16px; height: 54px; }
.logo { color: #fff; font-weight: 800; letter-spacing: .06em; font-size: 17px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.logo:hover { text-decoration: none; }
.logo svg { width: 26px; height: 26px; }
.logo small { font-weight: 500; font-size: 10px; letter-spacing: .02em; opacity: .7; display: block; line-height: 1; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: #cfdcf0; padding: 7px 11px; border-radius: 7px; white-space: nowrap; font-size: 13.5px; }
.nav a:hover, .nav a.on { background: rgba(255, 255, 255, .12); color: #fff; text-decoration: none; }
.theme-btn { background: none; border: 1px solid rgba(255,255,255,.25); color: #fff; border-radius: 7px; padding: 4px 8px; cursor: pointer; font-size: 13px; }
@media (max-width: 760px) {
  .hd-in { height: auto; flex-wrap: wrap; padding: 8px 16px 0; gap: 6px; }
  .nav { order: 3; flex-basis: 100%; padding-bottom: 6px; }
  .theme-btn { margin-left: auto; }
}

.wrap { max-width: 1240px; margin: 0 auto; padding: 18px 16px 40px; }
.crumb { font-size: 12.5px; color: var(--sub); margin-bottom: 10px; }
.crumb a { color: var(--sub); }
.page-title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-title h1 { font-size: 22px; }
.page-title .meta { color: var(--sub); font-size: 13px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card > h2, .sec-h { font-size: 15.5px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card > h2::before, .sec-h::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--accent); }
.card > h2 .note, .sec-h .note { font-weight: 400; color: var(--sub); font-size: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 960px) { .grid3, .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); } }
.grid2 > .card, .grid3 > .card { margin-bottom: 0; }
.mb { margin-bottom: 16px; }
.muted { color: var(--sub); }
.small { font-size: 12px; }
.loading { padding: 40px; text-align: center; color: var(--sub); }
.err { padding: 24px; color: var(--warn); }

/* 表 */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -2px; }
table.t { border-collapse: collapse; width: 100%; font-size: 13px; }
table.t th, table.t td { border-bottom: 1px solid var(--line); padding: 6px 7px; text-align: center; white-space: nowrap; }
table.t th { background: var(--soft); color: var(--sub); font-weight: 600; font-size: 12px; position: sticky; top: 0; }
table.t td.l, table.t th.l { text-align: left; }
table.t td.r, table.t th.r { text-align: right; }
table.t tr:hover td { background: color-mix(in srgb, var(--accent) 5%, transparent); }
table.t.sort th { cursor: pointer; user-select: none; }
table.t.sort th.asc::after { content: " ▲"; font-size: 9px; }
table.t.sort th.desc::after { content: " ▼"; font-size: 9px; }
table.t.compact td, table.t.compact th { padding: 4px 5px; }
td.best { font-weight: 800; color: var(--hot); }
td.worst { color: var(--cool); }
.cell-bar { position: relative; }
.cell-bar i { position: absolute; left: 0; top: 3px; bottom: 3px; background: color-mix(in srgb, var(--accent) 16%, transparent); border-radius: 2px; z-index: 0; }
.cell-bar span { position: relative; z-index: 1; }

/* 艇番 */
.lane { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 5px; font-weight: 800; font-size: 13px; border: 1px solid rgba(0,0,0,.25); }
.lane.s { width: 19px; height: 19px; font-size: 11.5px; border-radius: 4px; }
.lane1 { background: var(--l1); color: var(--l1t); } .lane2 { background: var(--l2); color: var(--l2t); }
.lane3 { background: var(--l3); color: var(--l3t); } .lane4 { background: var(--l4); color: var(--l4t); }
.lane5 { background: var(--l5); color: var(--l5t); } .lane6 { background: var(--l6); color: var(--l6t); }
tr.row-l1 td:first-child { box-shadow: inset 4px 0 var(--l1); } tr.row-l2 td:first-child { box-shadow: inset 4px 0 var(--l2); }
tr.row-l3 td:first-child { box-shadow: inset 4px 0 var(--l3); } tr.row-l4 td:first-child { box-shadow: inset 4px 0 var(--l4); }
tr.row-l5 td:first-child { box-shadow: inset 4px 0 var(--l5); } tr.row-l6 td:first-child { box-shadow: inset 4px 0 var(--l6); }
.combo { display: inline-flex; gap: 2px; align-items: center; }

/* バッジ */
.b { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 11px; font-weight: 700; line-height: 1.6; white-space: nowrap; }
.b-SG { background: #c4161c; color: #fff; } .b-G1 { background: #0a5bb5; color: #fff; } .b-G2 { background: #14808c; color: #fff; }
.b-G3 { background: #2c8d3c; color: #fff; } .b-一般 { background: var(--soft); color: var(--sub); }
.b-night { background: #3d2a7a; color: #fff; } .b-morning { background: #f39c12; color: #fff; } .b-midnight { background: #111; color: #fff; }
.b-lady { background: #e5559c; color: #fff; } .b-final { background: var(--gold); color: #fff; }
.b-A1 { background: #d7263d; color: #fff; } .b-A2 { background: #f08c00; color: #fff; } .b-B1 { background: #1c64c8; color: #fff; } .b-B2 { background: #8a94a3; color: #fff; }
.b-alert { background: var(--hot-bg); color: var(--hot); border: 1px solid color-mix(in srgb, var(--hot) 40%, transparent); }
.b-info { background: var(--accent2); color: var(--accent); }
.tag-row { display: flex; gap: 4px; flex-wrap: wrap; }

/* タブ */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { background: none; border: none; padding: 9px 14px; font: inherit; font-weight: 600; color: var(--sub); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pills button, .pills a { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: 4px 12px; font: inherit; font-size: 12.5px; cursor: pointer; }
.pills .on { background: var(--accent); color: #fff; border-color: var(--accent); }
.pills a:hover { text-decoration: none; border-color: var(--accent); }

/* トップ：場カード */
.venues { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.vcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.vcard-h { padding: 10px 12px 8px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.vcard-h .vn { font-weight: 800; font-size: 17px; color: var(--ink); }
.vcard-h .day { color: var(--sub); font-size: 12px; margin-left: auto; white-space: nowrap; }
.vcard .title { font-size: 11.5px; color: var(--sub); padding: 4px 12px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rgrid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; padding: 8px 10px 10px; }
.rbtn { border: 1px solid var(--line); border-radius: 6px; padding: 3px 0 2px; text-align: center; color: var(--ink); background: var(--card); line-height: 1.25; position: relative; }
.rbtn:hover { border-color: var(--accent); text-decoration: none; }
.rbtn b { display: block; font-size: 13px; }
.rbtn small { font-size: 10.5px; color: var(--sub); }
.rbtn.done { background: var(--soft); }
.rbtn.done small { color: var(--ink); font-weight: 700; }
.rbtn.next { border-color: var(--hot); box-shadow: 0 0 0 1px var(--hot) inset; }
.rbtn .dot { position: absolute; top: 2px; right: 3px; width: 6px; height: 6px; border-radius: 50%; background: var(--hot); }
.vstat { display: flex; gap: 10px; padding: 0 12px 10px; font-size: 11.5px; color: var(--sub); flex-wrap: wrap; }
.vstat b { color: var(--ink); }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.kpi { background: var(--soft); border-radius: 8px; padding: 10px 12px; }
.kpi .k { font-size: 11.5px; color: var(--sub); }
.kpi .v { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi .v small { font-size: 12px; font-weight: 600; color: var(--sub); margin-left: 2px; }
.kpi .d { font-size: 11px; color: var(--sub); }

/* ランキング */
.rank-list { list-style: none; margin: 0; padding: 0; }
.rank-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.rank-list li:last-child { border-bottom: none; }
.rank-list .no { width: 22px; height: 22px; border-radius: 50%; background: var(--soft); display: inline-flex; align-items: center; justify-content: center; font-size: 11.5px; font-weight: 700; flex: none; }
.rank-list li:nth-child(1) .no { background: #f5c518; color: #222; }
.rank-list li:nth-child(2) .no { background: #c9ced6; color: #222; }
.rank-list li:nth-child(3) .no { background: #d9a066; color: #222; }
.rank-list .val { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; }

/* レース見出し */
.race-hd { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.race-hd .rno { font-size: 30px; font-weight: 900; color: var(--navy2); line-height: 1; }
:root[data-theme="dark"] .race-hd .rno { color: var(--accent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .race-hd .rno { color: var(--accent); } }
.race-hd .rinfo { display: flex; flex-direction: column; gap: 2px; }
.race-hd .rname { font-weight: 800; font-size: 17px; }
.race-hd .wx { margin-left: auto; display: flex; gap: 12px; font-size: 12.5px; color: var(--sub); flex-wrap: wrap; }
.race-hd .wx b { color: var(--ink); }
.rsel { display: flex; gap: 4px; flex-wrap: wrap; margin: 12px 0 4px; }
.rsel a { width: 38px; text-align: center; border: 1px solid var(--line); border-radius: 6px; padding: 3px 0; color: var(--ink); background: var(--card); font-size: 12.5px; }
.rsel a.on { background: var(--navy2); color: #fff; border-color: var(--navy2); }
.rsel a:hover { text-decoration: none; border-color: var(--accent); }

/* 出走表の選手セル */
.pl { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.3; }
.pl .nm { font-weight: 800; font-size: 14px; color: var(--ink); }
.pl .sb { font-size: 11px; color: var(--sub); }

/* 予測・確率バー */
.pbar { height: 8px; background: var(--soft); border-radius: 4px; overflow: hidden; min-width: 60px; }
.pbar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.pbar.hot i { background: var(--hot); }
.heat { font-variant-numeric: tabular-nums; }

/* 展開図 */
.tenkai { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.tenkai .tk { text-align: center; padding: 8px 4px; border-radius: 8px; background: var(--soft); }
.tenkai .tk .p { font-size: 18px; font-weight: 800; }
.tenkai .tk .w { font-size: 11px; color: var(--sub); }

/* 検索 */
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.filter { background: var(--soft); border-radius: 8px; padding: 10px 12px; }
.filter label { display: block; font-size: 12px; color: var(--sub); margin-bottom: 4px; }
.filter select, .filter input { width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--ink); font: inherit; }
.preset { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.preset button { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 8px; padding: 6px 12px; font: inherit; font-weight: 700; cursor: pointer; }
.preset button:hover { border-color: var(--accent); color: var(--accent); }
.preset button.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* 検索ボックス */
.search-box { display: flex; gap: 8px; }
.search-box input { flex: 1; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: var(--card); color: var(--ink); }
.search-box button { padding: 9px 16px; border-radius: 8px; border: none; background: var(--accent); color: #fff; font: inherit; font-weight: 700; cursor: pointer; }

.ft { border-top: 1px solid var(--line); color: var(--sub); font-size: 12px; padding: 22px 16px 40px; text-align: center; }
.ft a { color: var(--sub); margin: 0 6px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--sub); font-size: 10.5px; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--sub); flex-wrap: wrap; margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.tip { position: fixed; pointer-events: none; background: var(--ink); color: var(--bg); padding: 5px 8px; border-radius: 6px; font-size: 12px; z-index: 99; display: none; white-space: nowrap; }
.note-box { background: var(--accent2); border-radius: 8px; padding: 10px 12px; font-size: 12.5px; color: var(--ink); }
.foot-note { font-size: 11.5px; color: var(--sub); margin-top: 8px; }
.hidden { display: none !important; }

/* 集計期間の帯 */
.period-bar { background: var(--accent2); border-bottom: 1px solid var(--line); font-size: 12px; color: var(--sub); }
.period-in { max-width: 1240px; margin: 0 auto; padding: 5px 16px; }
.period-bar b { color: var(--ink); }
.period-bar a { margin-left: 6px; }

/* 展開アニメ */
.anim-ctrl { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.anim-btns { display: flex; gap: 6px; align-items: center; }
.anim-btns .ab { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 8px; padding: 5px 12px; font: inherit; font-weight: 700; cursor: pointer; }
.anim-btns .ab:hover { border-color: var(--accent); color: var(--accent); }
.anim-btns select { padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); color: var(--ink); font: inherit; }
.anim-box { position: relative; }
.anim-svg { display: block; width: 100%; height: auto; border-radius: 14px; }
.anim-cap { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(8, 20, 36, .62); color: #fff; font-weight: 800; padding: 6px 16px; border-radius: 999px; font-size: clamp(12px, 2.2vw, 16px); white-space: nowrap; pointer-events: none; }
.anim-order { margin-top: 8px; font-size: 13px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
