/* ============================================================
   胸スポンサー図鑑 — 欧州5大リーグ + Jリーグ
   スコアブック風のエディトリアルなライトテーマ(CSS変数でダーク対応)
   ============================================================ */

:root {
  --bg: #F7F5F0;
  --panel: #FFFFFF;
  --ink: #26241F;
  --muted: #7C786E;
  --line: #E3DFD6;
  --line-strong: #C9C4B8;
  --accent: #1A7A4A;          /* ピッチグリーン */
  --accent-ink: #0E5C36;
  --gamble: #D4537E;

  /* ゾーン行背景(薄い色) */
  --zone-ucl: #EAF2FB;
  --zone-uel: #E9F6EE;
  --zone-uecl: #FCF1E1;
  --zone-po: #F0F6E6;
  --zone-relpo: #FBEFEC;
  --zone-rel: #F9E4E2;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(38, 36, 31, 0.06), 0 4px 16px rgba(38, 36, 31, 0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1C1B18;
    --panel: #26241F;
    --ink: #ECE9E1;
    --muted: #A29D90;
    --line: #3A382F;
    --line-strong: #4C4A40;
    --accent: #4CBB85;
    --accent-ink: #7AD2A6;

    --zone-ucl: rgba(72, 130, 200, 0.16);
    --zone-uel: rgba(64, 168, 110, 0.16);
    --zone-uecl: rgba(220, 160, 70, 0.16);
    --zone-po: rgba(140, 180, 80, 0.14);
    --zone-relpo: rgba(200, 90, 80, 0.12);
    --zone-rel: rgba(210, 70, 60, 0.18);

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  }
  .jersey path[stroke="rgba(0,0,0,0.1)"] { stroke: rgba(255, 255, 255, 0.18); }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(rgba(38, 36, 31, 0.035) 1px, transparent 1px);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-ink); }

/* ---------- ヘッダー ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--panel);
  border-bottom: 2px solid var(--ink);
}

.site-header .header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 20px 0;
}

.site-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.04em;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.site-title .ball { color: var(--accent); }

.site-title small {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.12em;
}

.nav-tabs {
  display: flex;
  gap: 2px;
  margin-top: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-tabs::-webkit-scrollbar { display: none; }

.nav-tabs .tab {
  flex-shrink: 0;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
}

.nav-tabs .tab:hover { color: var(--ink); background: var(--bg); }

.nav-tabs .tab.active {
  color: var(--ink);
  background: var(--bg);
  border-color: var(--ink);
  position: relative;
}
.nav-tabs .tab.active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 2px;
  background: var(--bg);
}

/* ---------- レイアウト ---------- */

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.loading {
  padding: 60px 0;
  text-align: center;
  color: var(--muted);
}

.error-box {
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-left: 4px solid #C0392B;
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
}
.error-hint { color: var(--muted); font-size: 13px; }

/* ---------- トップ(全体集計) ---------- */

.hero h2 {
  margin: 4px 0 10px;
  font-size: clamp(24px, 4.5vw, 36px);
  line-height: 1.3;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.hero-sub {
  max-width: 620px;
  color: var(--muted);
  margin: 0 0 14px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  margin: 26px 0 10px;
}

.league-card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, border-color 0.15s ease;
  position: relative;
  overflow: hidden;
}
.league-card[class*="flag-bg-"]::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.06;
  z-index: 0;
  pointer-events: none;
  border-radius: var(--radius);
}
.league-card[class*="flag-bg-"] > * { position: relative; z-index: 1; }

.league-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.lc-name { font-size: 17px; font-weight: 700; }
.lc-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.lc-top { font-size: 13px; margin-top: 10px; font-weight: 600; }
.lc-gamble { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; align-items: center; gap: 5px; }
.lc-gamble.none { opacity: 0.7; }

/* ミニ順位表(トップページカード内) */
.mini-standings {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin: 10px 0 6px;
  line-height: 1.3;
}
.mini-standings thead th {
  font-weight: 600;
  color: var(--muted);
  text-align: left;
  padding: 0 4px 4px;
  border-bottom: 1px solid var(--line);
  font-size: 10px;
}
.mini-standings thead th:first-child,
.mini-standings thead th:last-child { text-align: center; }
.mini-standings tbody tr { border-bottom: 1px solid color-mix(in srgb, var(--line) 50%, transparent); }
.mini-standings tbody tr:last-child { border-bottom: none; }
.mini-standings td { padding: 3px 4px; vertical-align: middle; }
.mini-rank { text-align: center; font-weight: 700; color: var(--muted); width: 20px; }
.mini-kit { width: 22px; text-align: center; padding: 2px 2px !important; }
.mini-kit .jersey { display: block; margin: 0 auto; }
.mini-club { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.mini-sponsor { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 90px; }
.mini-pts { text-align: center; font-weight: 700; width: 30px; }

/* ---------- リーグページ見出し ---------- */

.league-head { margin-bottom: 18px; }
.league-head[class*="flag-bg-"] { margin-bottom: 0; }

.league-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.league-head h2 {
  margin: 0;
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 800;
  letter-spacing: 0.02em;
}

.league-head .country {
  margin-left: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.season-label { font-size: 13px; color: var(--muted); }

.season-label select {
  margin-left: 6px;
  font: inherit;
  font-size: 13px;
  padding: 5px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
}

.reload-btn {
  font: inherit;
  font-size: 11px;
  font-weight: 400;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.reload-btn:hover { opacity: 1; border-color: var(--line-strong); color: var(--ink); }

.season-name {
  margin-top: 10px;
  font-size: 15px;
  font-weight: 700;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  font-size: 12px;
}

.status-chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.04em;
}
.status-chip.final { background: var(--zone-uel); color: var(--accent-ink); }
.status-chip.ongoing { background: var(--zone-uecl); color: #9A6010; }

.updated-at { color: var(--muted); }

.format-note {
  margin-top: 12px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
}

/* ---------- 国旗透かし背景 ---------- */

.league-head[class*="flag-bg-"] {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  padding: 18px 20px 16px;
  margin-bottom: 18px;
}
.league-head[class*="flag-bg-"]::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.07;
  z-index: 0;
  pointer-events: none;
}
.league-head[class*="flag-bg-"] > * { position: relative; z-index: 1; }

/* イングランド — 白地に赤十字(セント・ジョージ旗) */
.flag-bg-epl::before {
  background:
    linear-gradient(to right, transparent calc(50% - 4px), #CE1124 calc(50% - 4px), #CE1124 calc(50% + 4px), transparent calc(50% + 4px)),
    linear-gradient(to bottom, transparent calc(50% - 4px), #CE1124 calc(50% - 4px), #CE1124 calc(50% + 4px), transparent calc(50% + 4px));
  opacity: 0.10;
}
/* イタリア — 緑白赤の縦三色旗 */
.flag-bg-seriea::before {
  background: linear-gradient(to right, #009246 33.3%, #FFFFFF 33.3%, #FFFFFF 66.6%, #CE2B37 66.6%);
}
/* スペイン — 赤黄赤の横三色旗 */
.flag-bg-laliga::before {
  background: linear-gradient(to bottom, #AA151B 25%, #F1BF00 25%, #F1BF00 75%, #AA151B 75%);
}
/* ドイツ — 黒赤金の横三色旗 */
.flag-bg-bundesliga::before {
  background: linear-gradient(to bottom, #000000 33.3%, #DD0000 33.3%, #DD0000 66.6%, #FFCC00 66.6%);
}
/* フランス — 青白赤の縦三色旗 */
.flag-bg-ligue1::before {
  background: linear-gradient(to right, #002395 33.3%, #FFFFFF 33.3%, #FFFFFF 66.6%, #ED2939 66.6%);
}
/* オランダ — 赤白青の横三色旗 */
.flag-bg-eredivisie::before {
  background: linear-gradient(to bottom, #AE1C28 33.3%, #FFFFFF 33.3%, #FFFFFF 66.6%, #21468B 66.6%);
}
/* ポルトガル — 緑赤の縦二色旗 */
.flag-bg-primeiraliga::before {
  background: linear-gradient(to right, #006600 40%, #FF0000 40%);
}
/* 日本 — 白地に赤丸(日の丸) */
.flag-bg-j1::before {
  background:
    radial-gradient(circle at 50% 50%, #BC002D 22%, transparent 22%),
    linear-gradient(#FFFFFF, #FFFFFF);
  opacity: 0.10;
}

@media (prefers-color-scheme: dark) {
  .league-head[class*="flag-bg-"]::before { opacity: 0.05; }
  .flag-bg-epl::before { opacity: 0.07; }
  .flag-bg-j1::before { opacity: 0.07; }
}

/* ---------- 順位表 ---------- */

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

table.standings {
  width: 100%;
  min-width: 700px;
  border-collapse: collapse;
  font-size: 14px;
}

.standings thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 2px solid var(--ink);
  white-space: nowrap;
}

.standings tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.standings tbody tr:last-child td { border-bottom: none; }

/* ゾーン別の薄い行背景 */
tr.zone-ucl  { background: var(--zone-ucl); }
tr.zone-uel  { background: var(--zone-uel); }
tr.zone-uecl { background: var(--zone-uecl); }
tr.zone-po   { background: var(--zone-po); }
tr.zone-relpo{ background: var(--zone-relpo); }
tr.zone-rel  { background: var(--zone-rel); }

.col-rank { white-space: nowrap; width: 86px; }
.rank-num {
  display: inline-block;
  min-width: 24px;
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.zone-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 4px;
  letter-spacing: 0.03em;
  vertical-align: 2px;
  white-space: nowrap;
}
.zb-ucl  { background: #3D74C4; color: #fff; }
.zb-uel  { background: #2E9E63; color: #fff; }
.zb-uecl { background: #D98C26; color: #fff; }
.zb-po   { background: #7FA33C; color: #fff; }
.zb-relpo{ background: #C97B6E; color: #fff; }
.zb-rel  { background: #C0392B; color: #fff; }

.group-tag {
  margin-top: 2px;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.col-club { min-width: 170px; }
.club-ja { font-weight: 700; }
.club-en { font-size: 11px; color: var(--muted); }

.col-kit { width: 72px; text-align: center; }
.jersey { display: inline-block; vertical-align: middle; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.12)); }

.col-sponsor { min-width: 220px; }

.sponsor-main { display: flex; align-items: center; gap: 6px; font-weight: 600; }

.sponsor-link { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.sponsor-link:hover { text-decoration-thickness: 2px; }

.sponsor-name-plain { color: var(--ink); }

.sponsor-none { color: var(--muted); font-weight: 600; }

.sponsor-industry {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}

.ind-swatch {
  width: 8px; height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}

.sponsor-note {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  max-width: 360px;
}

/* ギャンブル系マーカー(小さなドット) */
.dot-gambling {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--gamble);
  flex-shrink: 0;
}

/* イニシャルバッジ試作(現在フラグでオフ) */
.sponsor-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  border-radius: 50%;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
}

/* 消化試合数(進行中シーズンのみ表示)。勝点より控えめに見せる */
.col-played {
  width: 46px;
  text-align: right;
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.col-points {
  width: 64px;
  text-align: right;
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.zone-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 12px 4px 0;
  font-size: 12px;
  color: var(--muted);
}

.legend-item { display: inline-flex; align-items: center; gap: 6px; }

.legend-chip {
  width: 10px; height: 10px;
  border-radius: 3px;
  display: inline-block;
}

/* ---------- グラフ ---------- */

.charts { margin-top: 34px; }

.charts h3, .sources h3 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.03em;
  border-left: 4px solid var(--accent);
  padding-left: 10px;
  margin: 0 0 14px;
}

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.chart-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  height: 320px;
  position: relative;
}

.chart-box.tall { height: 360px; }

@media (max-width: 760px) {
  .chart-grid { grid-template-columns: 1fr; }
  .chart-box { height: 300px; }
}

/* ---------- モバイル順位表(横スクロール不要に) ---------- */

@media (max-width: 640px) {
  table.standings {
    min-width: 0;
    font-size: 13px;
  }
  .standings thead th,
  .standings tbody td {
    padding: 7px 5px;
  }
  .col-rank { width: auto; }
  .rank-num { font-size: 14px; min-width: 20px; }
  .zone-badge { font-size: 8px; padding: 1px 4px; margin-left: 3px; }
  .col-club { min-width: 0; }
  .club-en { display: none; }
  .col-kit { width: 40px; }
  .jersey svg { width: 26px !important; height: 28px !important; }
  .col-sponsor { min-width: 0; }
  .sponsor-main { font-size: 13px; }
  .sponsor-industry { display: none; }
  .sponsor-note { display: none; }
  .col-played { width: auto; min-width: 26px; font-size: 12px; }
  .col-points { width: auto; min-width: 32px; font-size: 14px; }
}

@media (max-width: 440px) {
  table.standings { font-size: 12px; }
  .standings thead th,
  .standings tbody td {
    padding: 6px 4px;
  }
  .col-kit { display: none; }
  .rank-num { font-size: 13px; min-width: 18px; }
  .zone-badge { font-size: 7px; padding: 0 3px; margin-left: 2px; letter-spacing: 0; }
  .col-played { font-size: 11px; min-width: 20px; }
  .col-points { font-size: 13px; }
}

/* ---------- 広告 ---------- */

.ad-container {
  max-width: 900px;
  margin: 24px auto 0;
  padding: 0 16px;
  text-align: center;
}

/* ---------- 出典・フッター ---------- */

.sources { margin-top: 30px; }

.source-links { display: flex; flex-direction: column; gap: 4px; font-size: 12px; word-break: break-all; }
.source-links a { color: var(--muted); }
.source-links a:hover { color: var(--accent-ink); }

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--panel);
}

.site-footer .footer-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 22px 20px 30px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.8;
}

.site-footer p { margin: 0 0 6px; }
.site-footer .dot-gambling { vertical-align: 1px; margin-right: 4px; }

.footer-links { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--accent-ink); text-decoration: underline; }

/* ---------- noscript ---------- */

.noscript-content {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 0;
  line-height: 1.9;
}
.noscript-content h2 { font-size: 22px; font-weight: 800; margin: 0 0 16px; }
.noscript-content h3 { font-size: 16px; font-weight: 700; margin: 24px 0 10px; color: var(--accent-ink); }
.noscript-content p { margin: 0 0 12px; }
.noscript-content ul { margin: 0 0 12px; padding-left: 20px; }
.noscript-content li { margin-bottom: 6px; }

/* ---------- 記事ページ ---------- */

.article-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 24px 60px;
  line-height: 1.9;
  color: var(--ink);
}
@media (max-width: 480px) {
  .article-page { padding: 28px 16px 48px; }
}
.article-page h1 { font-size: 22px; margin-bottom: 8px; }
.article-page .article-meta { font-size: 12px; color: var(--muted); margin-bottom: 28px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.article-page h2 { font-size: 17px; margin: 32px 0 12px; padding-left: 12px; border-left: 4px solid var(--accent); }
.article-page p { font-size: 14px; margin: 0 0 14px; }
.article-page ul, .article-page ol { font-size: 14px; margin: 0 0 14px; padding-left: 22px; }
.article-page li { margin-bottom: 4px; }
.article-page .highlight-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; margin: 18px 0; font-size: 14px; }
.article-page .back-link { display: inline-block; margin-top: 32px; font-size: 14px; }
.article-page table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 14px 0; }
.article-page th, .article-page td { padding: 8px 12px; border: 1px solid var(--line); text-align: left; }
.article-page th { background: var(--bg); font-weight: 700; font-size: 12px; }
.article-page .related-links { margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--line); }
.article-page .related-links h3 { font-size: 14px; margin: 0 0 10px; color: var(--muted); }
.article-page .related-links ul { list-style: none; padding: 0; }
.article-page .related-links li { margin-bottom: 6px; }
