:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --text: #1f1d1a;
  --muted: #6b665e;
  --line: #e4dfd5;
  --accent: #8a2c1d;
  --accent-soft: #f6e9e6;
  --head: #f1ede4;
  --gold: #b8901c;
  --silver: #7d848c;
  --bronze: #9a5b2e;
  --up: #2c7a3f;
  --down: #a23a2a;
  --men: #1f5f8b;
  --women: #8a2c1d;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1000px; margin: 0 auto; padding: 0 16px; }

/* ヘッダー */
header { background: var(--surface); border-bottom: 3px solid var(--accent); position: sticky; top: 0; z-index: 10; }
.header-inner { display: flex; align-items: center; gap: 8px 24px; flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
.logo { font-weight: 700; font-size: 17px; color: var(--text); white-space: nowrap; }
.logo-mark { color: var(--accent); margin-right: 6px; }
nav { display: flex; gap: 16px; }
nav a { color: var(--text); padding: 2px 0; border-bottom: 2px solid transparent; }
nav a.active { color: var(--accent); font-weight: 700; border-bottom-color: var(--accent); }
.search { margin-left: auto; }
.search input {
  font-size: 15px; padding: 6px 10px; width: 200px; max-width: 100%;
  border: 1px solid var(--line); border-radius: 20px; background: var(--bg);
}

main { padding-top: 20px; padding-bottom: 48px; }
h1 { font-size: 26px; margin: 4px 0 6px; line-height: 1.3; }
h2 { font-size: 18px; margin: 36px 0 10px; border-left: 4px solid var(--accent); padding-left: 10px; }
h3 { font-size: 15px; margin: 20px 0 6px; color: var(--muted); }
.note { color: var(--muted); font-size: 13px; margin: 6px 0; }
.lead { color: var(--muted); margin: 0 0 8px; }

/* 操作部品 */
.controls { display: flex; gap: 10px 16px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
select {
  font-size: 15px; padding: 6px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface); color: var(--text); max-width: 100%;
}
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.segmented button {
  font: inherit; font-size: 14px; padding: 6px 16px; border: 0; background: transparent; cursor: pointer; color: var(--text);
}
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button.on { background: var(--accent); color: #fff; }

/* 表 */
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: center; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
th { background: var(--head); font-weight: 600; font-size: 13px; }
tbody tr:hover { background: #fbfaf7; }
td.name, td.left { text-align: left; }
td.num { font-variant-numeric: tabular-nums; }
.rank-badge {
  display: inline-block; min-width: 26px; height: 26px; line-height: 26px; border-radius: 13px;
  font-weight: 700; font-size: 13px;
}
.rank-1 .rank-badge { background: var(--gold); color: #fff; }
.rank-2 .rank-badge { background: var(--silver); color: #fff; }
.rank-3 .rank-badge { background: var(--bronze); color: #fff; }
.bar { display: inline-block; height: 8px; background: var(--accent); border-radius: 4px; vertical-align: middle; margin-left: 8px; opacity: .65; }
.delta { font-size: 12px; margin-left: 4px; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.wins { font-size: 13px; color: var(--muted); white-space: normal; min-width: 180px; text-align: left; line-height: 1.5; }

/* カード */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 12px 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.card .num { font-size: 26px; font-weight: 700; color: var(--accent); line-height: 1.3; }
.card .label { font-size: 13px; color: var(--muted); }
.card .num.small { font-size: 20px; }

/* トップページの最新大会 */
.latest { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.latest a.card { color: var(--text); display: block; }
.latest a.card:hover { border-color: var(--accent); text-decoration: none; }
.latest .t-name { font-weight: 700; }
.latest .t-date { font-size: 12px; color: var(--muted); }
.latest .winner { margin-top: 6px; font-size: 14px; }
.latest .winner b { color: var(--accent); }

.hero { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 8px; }
.hero h1 { margin-top: 0; }

.chart-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; height: 280px; }
table.overview { width: auto; min-width: 320px; }
table.overview td { text-align: left; white-space: normal; }
table.overview td:first-child { background: var(--head); font-weight: 600; white-space: nowrap; }

footer { color: var(--muted); font-size: 12px; text-align: center; padding: 24px 0 32px; border-top: 1px solid var(--line); line-height: 1.8; }

/* スマホ */
@media (max-width: 640px) {
  header { position: static; }
  .header-inner { gap: 6px 16px; padding-top: 8px; padding-bottom: 8px; }
  .logo { font-size: 15px; }
  nav { gap: 12px; font-size: 14px; }
  h1 { font-size: 21px; }
  h2 { margin-top: 28px; }
  .hero { padding: 14px 16px; }
  .hero .lead { font-size: 14px; }
  .latest { grid-template-columns: 1fr 1fr; gap: 8px; }
  .latest .card { padding: 10px 12px; }
  .latest .t-name { font-size: 14px; }
  .latest .winner { font-size: 13px; margin-top: 2px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .card .num { font-size: 22px; }
  .card .num.small { font-size: 18px; }
  .search { margin-left: 0; width: 100%; }
  .search input { width: 100%; font-size: 16px; padding: 5px 10px; }
  .sub { display: none; }
  th, td { padding: 7px 6px; font-size: 13px; }
  .bar { display: none; }
  .chart-box { height: 230px; }
}

/* このサイトについて・プライバシーポリシーなど、文章のページ */
.prose { max-width: 760px; line-height: 1.85; }
.prose p, .prose li { font-size: 15px; }
.prose ul { padding-left: 1.4em; margin: 8px 0; }
.prose li { margin: 4px 0; }
.prose a, footer a { color: var(--accent); }
footer a { margin: 0 6px; white-space: nowrap; }
.button { display: inline-block; background: var(--accent); color: #fff !important; padding: 10px 18px; border-radius: 8px; text-decoration: none; font-weight: bold; }

/* トップページの大きな検索欄 */
.hero-search { display: flex; gap: 8px; margin-top: 14px; max-width: 560px; }
.hero-search input {
  flex: 1; min-width: 0; font-size: 16px; padding: 11px 16px;
  border: 1px solid var(--line); border-radius: 24px; background: var(--bg); color: var(--text);
}
.hero-search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.hero-search button {
  font-size: 16px; font-weight: 700; padding: 0 22px; border: none; border-radius: 24px;
  background: var(--accent); color: #fff; cursor: pointer;
}
/* トップページは大きな検索欄があるので、ヘッダーの検索欄は出さない */
body.home header .search { display: none; }

/* 読み込み中の仮のカード（画面のガタつき＝CLSを防ぐため、本物と同じ大きさで場所を空けておく） */
.latest .card.placeholder { background: var(--head); border-color: transparent; }
/* メニューは JavaScript で後から入るので、入る前から同じ高さを空けておく */
header:empty { height: 55px; }
@media (max-width: 640px) {
  header:empty { height: 84px; }
  body.home header:empty { height: 48px; }
}
tr.placeholder td, tr.placeholder td * { color: transparent !important; }
tr.placeholder .bar { background: var(--head) !important; }

/* 読み物（記事） */
.guide-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-top: 16px; }
.guide-card { display: block; color: var(--text); }
.guide-card:hover { border-color: var(--accent); text-decoration: none; }
.guide-card .t-name { font-weight: 700; line-height: 1.5; margin-bottom: 4px; }
.guide-card.planned { opacity: .55; }
.wrap-article h1 { font-size: 26px; line-height: 1.4; }
.wrap-article h2 { margin-top: 32px; }
.wrap-article ol { padding-left: 1.4em; }
.wrap-article .table-scroll { margin: 10px 0; }
.guide-card .t-date { font-size: 12px; color: var(--muted); margin-top: 6px; }
.guide-list { margin-bottom: 32px; }
.terms dt { font-weight: 700; margin-top: 12px; }
.terms dd { margin: 2px 0 0 1em; }
.summary { line-height: 1.9; margin: 8px 0 16px; }

/* 学校どうしの比較 */
.compare-pick { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 12px 0 4px; }
.compare-pick select { font-size: 16px; font-weight: 600; min-width: 0; flex: 1 1 160px; }
.compare-pick .pick-a { border: 2px solid #1f5f8b; }
.compare-pick .pick-b { border: 2px solid #b8701c; }
.compare-pick .vs { color: var(--muted); }
.swap { font-size: 18px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 4px 10px; cursor: pointer; color: var(--text); }
.compare-table th.col-a, .compare-table th.col-b, th.col-a, th.col-b { white-space: normal; min-width: 90px; }
th.col-a { color: #1f5f8b; border-bottom: 3px solid #1f5f8b; }
th.col-b { color: #b8701c; border-bottom: 3px solid #b8701c; }
.compare-table td.label-cell { background: var(--head); font-weight: 600; font-size: 13px; }
.compare-table td { width: 36%; }
.compare-table td.label-cell { width: 28%; }
td.better { font-weight: 700; }
td.col-a.better { color: #1f5f8b; background: #eef4f9; }
td.col-b.better { color: #9a5c12; background: #fbf3e6; }
.of { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 2px; }
.txt-a { color: #1f5f8b; }
.txt-b { color: #9a5c12; }
@media (max-width: 640px) {
  .compare-pick select { flex-basis: 100%; }
  .compare-pick .vs { display: none; }
  .swap { margin-left: auto; }
}

/* 学校を選ぶ部品（学校ページ・比較ページ） */
.picker { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin: 12px 0; }
.picker-label { font-size: 12px; color: var(--muted); }
.picker-current { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.picker-name { font-size: 17px; }
.picker-toggle { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 4px 12px; cursor: pointer; color: var(--accent); font-size: 14px; }
.picker-body .controls { margin: 10px 0 8px; }
.picker-text { font-size: 16px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; flex: 1 1 200px; min-width: 0; }
.picker-list { display: flex; flex-wrap: wrap; gap: 6px; }
.picker-list .note { width: 100%; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: 14px; color: var(--text); }
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.picker.pick-a { border: 2px solid #1f5f8b; }
.picker.pick-b { border: 2px solid #b8701c; }
.picker.pick-a .picker-name { color: #1f5f8b; }
.picker.pick-b .picker-name { color: #9a5c12; }
.compare-pickers { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: start; }
.compare-pickers .swap { margin-top: 24px; }
@media (max-width: 640px) {
  .compare-pickers { grid-template-columns: 1fr; }
  .compare-pickers .swap { margin: 0 auto; }
}
.guide-search { display: flex; align-items: center; gap: 12px; margin: 12px 0 0; max-width: 560px; }
.guide-search input { flex: 1; font-size: 16px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; }
.guide-card .snippet { background: #fdf6e3; border-radius: 4px; padding: 2px 6px; margin-top: 4px; }
.guide-card[hidden] { display: none; }

/* JavaScript が中身を入れる場所は、先に高さを取っておく（読み込み中に画面がずれないように＝CLS 対策） */
.picker:empty { min-height: 52px; }
.compare-pickers .picker:empty { min-height: 73px; }
h1#title:empty { min-height: 34px; }
p#district:empty { min-height: 21px; }
#cards:empty { min-height: 94px; }
.table-scroll:has(#summary:empty) { min-height: 360px; }
@media (max-width: 640px) {
  h1#title:empty { min-height: 27px; }
  #cards:empty { min-height: 258px; }
  .table-scroll:has(#summary:empty) { min-height: 325px; }
}
.tournament-pick + h1#title:empty { min-height: 34px; }
#cards:empty:has(+ .table-scroll #overview) { min-height: 149px; }
.table-scroll:has(#overview:empty) { min-height: 196px; }
@media (max-width: 640px) {
  .table-scroll:has(#overview:empty) { min-height: 178px; }
}
.tournament-pick select { min-width: 9em; }
@media (max-width: 640px) {
  .tournament-pick select { flex: 1 1 40%; min-width: 0; }
}
#sections:empty, #results:empty { min-height: 100vh; }

/* 共有ボタン（学校・大会・コラムのページ） */
.share { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.share-x, .share-copy { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; padding: 6px 14px; border-radius: 999px; cursor: pointer; text-decoration: none; line-height: 1.4; }
.share-x { background: #000; color: #fff; border: 1px solid #000; }
.share-x:hover { opacity: .85; }
.share-copy { background: var(--surface); color: var(--text); border: 1px solid var(--line); font-family: inherit; }
.share-copy:hover { border-color: var(--accent); }
#wins-head { text-align: left; }

/* フッターの X・Instagram（フォローのボタン） */
footer .sns { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; margin: 0 0 18px; font-size: 13px; color: var(--text, #222); }
footer .sns-btn { display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 8px 16px; border-radius: 999px; color: #fff; font-weight: 700; text-decoration: none; font-size: 14px; }
footer .sns-btn svg { width: 16px; height: 16px; }
footer .sns-x { background: #000; }
footer .sns-ig { background: linear-gradient(45deg, #f58529, #dd2a7b 50%, #8134af); }
footer .sns-btn:hover { opacity: .85; }

/* ヘッダーの X・Instagram の小さいアイコン（どのページからもすぐ行けるように） */
.head-sns { display: inline-flex; gap: 6px; align-items: center; }
.head-sns a { display: inline-flex; width: 28px; height: 28px; border-radius: 50%; align-items: center; justify-content: center; color: #fff; }
.head-sns a:first-child { background: #000; }
.head-sns a:last-child { background: linear-gradient(45deg, #f58529, #dd2a7b 50%, #8134af); }
.head-sns svg { width: 15px; height: 15px; }
/* ランキングの「もっと見る」 */
.more-box { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 12px 0 4px; }
.more-btn { font-size: 15px; padding: 9px 20px; border-radius: 999px; border: 1px solid var(--accent); background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; }
.more-btn.sub-btn { background: var(--surface); color: var(--accent); }

/* 大会のデータ予想（site/yosou/、tools/predict.py） */
table.yosou td.mark { font-size: 18px; color: var(--accent); font-weight: 700; }
table.yosou td.prob { text-align: left; min-width: 90px; }
table.yosou .bar { margin-right: 6px; }
.tag-est { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; margin-left: 6px; }
.vote-cell { white-space: nowrap; }
.vote-btn { font: inherit; font-size: 13px; padding: 4px 12px; border: 1px solid var(--accent); color: var(--accent); background: var(--surface); border-radius: 999px; cursor: pointer; }
.vote-btn.on { background: var(--accent); color: #fff; }
.vote-btn:disabled { opacity: .5; cursor: default; }
.vote-share { display: inline-block; min-width: 3em; margin-left: 6px; font-variant-numeric: tabular-nums; }
table.yosou .pref-sub { font-size: 11px; color: var(--muted); }
table.yosou td.wins { min-width: 260px; }

/* 長い表・一覧の「もっと見る」（more.js。ボタンの見た目はトップのランキングと同じ .more-box・.more-btn） */
table[data-more] tr.x { display: none; }
.guide-list:not(.open) .guide-card.x { display: none; }
details.year { margin: 8px 0; }
details.year > summary { cursor: pointer; font-weight: 700; font-size: 17px; padding: 8px 0; }
details.year > summary .note { font-weight: 400; margin-left: 6px; }
/* ページ内の目次（学校・大会の静的ページ） */
.jump { display: flex; flex-wrap: wrap; gap: 6px 8px; margin: 10px 0; }
.jump a { font-size: 13px; padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
h2[id] { scroll-margin-top: 70px; }
/* コラム一覧のページ切り替え（tools/build_guide.py） */
.pager { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 16px 0; }
.pager a, .pager span { min-width: 40px; text-align: center; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.pager span.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.vote-line { margin-top: 4px; display: flex; align-items: center; gap: 6px; }
table.yosou .vote-share { min-width: 0; margin-left: 0; font-size: 13px; color: var(--accent); font-weight: 700; }

/* 左上の「≡」：高校・中学の切りかえ（build_pages.py の level_menu()） */
.level-menu { position: relative; }
.level-menu > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }
.level-menu > summary::-webkit-details-marker { display: none; }
.level-menu .burger { display: grid; gap: 4px; }
.level-menu .burger i { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 1px; }
.level-nav { position: absolute; top: 44px; left: 0; z-index: 20; min-width: 200px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 8px; display: grid; gap: 4px; }
.level-nav .level-title { font-size: 12px; color: var(--muted); padding: 4px 8px; }
.level-nav a { padding: 10px 12px; border-radius: 8px; color: var(--text); font-weight: 600; }
.level-nav a.on { background: var(--accent); color: #fff; }
.level-nav a:hover { text-decoration: none; background: var(--head); }
.level-nav a.on:hover { background: var(--accent); }

/* ソフトテニスの学校一覧の絞り込み欄（tools/build_softtennis.py） */
.st-filter { border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; font-size: 14px; background: var(--surface); min-width: 200px; }
.st-filter:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ソフトテニスのトーナメント表（tools/build_softtennis.py の bracket_html()）。横に長いので、はみ出す分は横にスクロール */
.bracket-scroll { overflow-x: auto; margin: 12px 0 8px; -webkit-overflow-scrolling: touch; }
.bracket { display: flex; gap: 14px; min-width: 860px; }
.bt-col { flex: 1 1 0; display: flex; flex-direction: column; min-width: 150px; }
.bt-head { font-size: 12px; font-weight: 700; color: var(--muted); text-align: center; padding: 4px 0 8px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.bt-body { flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 6px; }
.bt-match { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; font-size: 13px; }
.bt-team { display: flex; gap: 6px; align-items: baseline; padding: 4px 8px; color: var(--muted); }
.bt-team + .bt-team { border-top: 1px solid var(--line); }
.bt-team.win { color: inherit; font-weight: 700; background: #faf3f1; box-shadow: inset 3px 0 0 var(--accent); }
.bt-team a { color: inherit; }
.bt-mark { flex: none; width: 1.2em; text-align: center; }
.bt-name { min-width: 0; }
.bt-champ .bt-match { border-color: var(--accent); }
.st-area { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.st-pre { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
.cards.wide { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
@media (min-width: 900px) { .bt-hint { display: none; } }

/* ランキング：絞り込んだときの「全体N位」（2026-11-07） */
.rank-cell { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; }
.rank-all { font-size: 10px; color: var(--muted, #6e655e); white-space: nowrap; line-height: 1; }
