:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #dfe4ea;
  --text: #1e293b;
  --text-muted: #64748b;
  --primary: #0f4c81;
  --primary-light: #e6f0fa;
  --accent: #0284c7;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.breadcrumb a {
  color: var(--text-muted);
}

.breadcrumb a:hover {
  color: var(--primary);
}

.breadcrumb-sep {
  opacity: 0.6;
}

/* Header & Nav */
.site-header {
  background: var(--primary);
  color: #fff;
  padding: 10px 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.site-header-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.site-brand {
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.02em;
}

.site-brand:hover {
  text-decoration: none;
  opacity: 0.9;
}

.site-nav {
  display: flex;
  gap: 12px;
  font-size: 13px;
}

.site-nav a {
  color: rgba(255, 255, 255, 0.92);
  padding: 4px 6px;
  border-radius: 4px;
}

.site-nav a:hover {
  background: rgba(255, 255, 255, 0.15);
  text-decoration: none;
}

/* Main Container */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
}

.card-title {
  margin: 0 0 8px 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-header {
  margin-bottom: 12px;
}

.page-header h1 {
  margin: 0 0 4px 0;
  font-size: 18px;
  line-height: 1.3;
}

.page-meta {
  font-size: 12px;
  color: var(--text-muted);
}

/* Official Boat Colors (Waku 1-6) */
.waku-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
}

.waku-1 { background: #ffffff; color: #111111; border: 1px solid #94a3b8; }
.waku-2 { background: #1e293b; color: #ffffff; border: 1px solid #1e293b; }
.waku-3 { background: #dc2626; color: #ffffff; border: 1px solid #dc2626; }
.waku-4 { background: #2563eb; color: #ffffff; border: 1px solid #2563eb; }
.waku-5 { background: #eab308; color: #111111; border: 1px solid #a16207; }
.waku-6 { background: #16a34a; color: #ffffff; border: 1px solid #16a34a; }

/* Tables */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

th, td {
  padding: 6px 5px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11.5px;
}

td.num, th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

td.center, th.center {
  text-align: center;
}

/* Class badges */
.class-badge {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
}

.class-A1 { background: #fef3c7; color: #92400e; }
.class-A2 { background: #dbeafe; color: #1e40af; }
.class-B1 { background: #f1f5f9; color: #475569; }
.class-B2 { background: #f8fafc; color: #94a3b8; }

/* Race buttons */
.race-btn-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.race-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 2px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.race-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  text-decoration: none;
}

.race-btn.finished {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.race-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.race-btn .payout-mini {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 400;
}

.race-btn.active .payout-mini {
  color: rgba(255, 255, 255, 0.85);
}

/* Charts */
.chart-caption {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 8px;
}

.chart-box {
  width: 100%;
  height: 260px;
}

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

.chart-note {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Stadium Grid */
.stadium-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

@media (min-width: 640px) {
  .stadium-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.stadium-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--text);
}

.stadium-card:hover {
  border-color: var(--primary);
  text-decoration: none;
}

.stadium-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.stadium-name {
  font-weight: 700;
  font-size: 15px;
}

.grade-tag {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  background: #e2e8f0;
  color: #334155;
  font-weight: 600;
}

.grade-SG { background: #fee2e2; color: #991b1b; }
.grade-G1 { background: #fef3c7; color: #92400e; }
.grade-G2 { background: #dbeafe; color: #1e40af; }
.grade-G3 { background: #dcfce7; color: #166534; }

/* Search & Filters */
.search-form {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.search-form input[type="text"],
.search-form input[type="date"] {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}

.btn {
  display: inline-block;
  padding: 8px 14px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-outline {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.nav-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.nav-pills a {
  padding: 4px 10px;
  border-radius: 999px;
  background: #e2e8f0;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.nav-pills a.active {
  background: var(--primary);
  color: #fff;
}

/* Footer */
.site-footer {
  margin-top: 24px;
  padding: 16px 12px;
  background: #e2e8f0;
  color: #475569;
  font-size: 12px;
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 8px;
}

.footer-notice {
  margin: 4px 0;
  font-size: 11px;
}

.muted {
  color: var(--text-muted);
}

.small {
  font-size: 11.5px;
}

/* Summary KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

@media (min-width: 640px) {
  .kpi-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

.kpi-item {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  text-align: center;
}

.kpi-label {
  font-size: 10.5px;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.kpi-value.warn {
  color: #dc2626;
}

.tab-pills {
  display: inline-flex;
  gap: 4px;
}

.tab-btn {
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.pickup-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pickup-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--text);
}

.pickup-item:hover {
  border-color: var(--primary);
  text-decoration: none;
}

/* Favorites & Marks & Bet Calc */
.fav-btn {
  display: inline-block;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.fav-btn.active {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
}

.fav-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.fav-chip {
  display: inline-block;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  color: #92400e;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
}

.mark-btn {
  min-width: 28px;
  height: 26px;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text-muted);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.mark-btn.marked {
  background: #fef3c7;
  border-color: #d97706;
  color: #b45309;
}

.alert-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12.5px;
  margin-bottom: 10px;
}

.bet-calc-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.bet-calc-col {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
}

.bet-calc-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.bet-calc-checks label {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 12.5px;
  cursor: pointer;
}

/* Search Filters & Suggest */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  align-items: center;
}

.filter-row select,
.filter-row input[type="text"],
.filter-row input[type="number"] {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}

.suggest-wrap {
  position: relative;
  display: inline-block;
  flex: 1;
  min-width: 180px;
}

.suggest-wrap input {
  width: 100%;
}

.suggest-list {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 50;
  max-height: 220px;
  overflow-y: auto;
}

.suggest-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  border: none;
  border-bottom: 1px solid #f1f5f9;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
}

.suggest-item:hover {
  background: var(--primary-light);
}

.trend-up {
  color: #16a34a;
  font-weight: 700;
}

.trend-down {
  color: #dc2626;
  font-weight: 700;
}




/* 節間日程タブ & 1R〜12R横並びバー */
.race-hub-nav {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  margin-bottom: 10px;
}
.day-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.day-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 68px;
  padding: 5px 8px;
  border-radius: 6px;
  background: #eff6ff;
  color: var(--primary);
  font-size: 11px;
  line-height: 1.3;
  text-decoration: none;
  flex-shrink: 0;
}
.day-tab.active {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}
.race-strip {
  display: grid;
  grid-template-columns: repeat(12, minmax(52px, 1fr));
  gap: 4px;
  overflow-x: auto;
}
.race-strip-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 2px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #f8fafc;
  color: var(--text);
  font-size: 11px;
  line-height: 1.25;
  text-decoration: none;
}
.race-strip-item.finished {
  background: #f0fdf4;
}
.race-strip-item.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 700;
}
.race-strip-sub {
  font-size: 10px;
  opacity: 0.85;
}

/* スタートスリット隊形図 */
.slit-board {
  position: relative;
  background: linear-gradient(90deg, #e0f2fe 0%, #bae6fd 100%);
  border: 1px solid #7dd3fc;
  border-radius: 8px;
  padding: 6px 10px;
  margin: 8px 0 12px;
  overflow: hidden;
}
.slit-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 20%;
  width: 2px;
  background: #eab308;
  box-shadow: 0 0 4px rgba(234, 179, 8, 0.7);
  z-index: 1;
}
.slit-lane {
  position: relative;
  display: flex;
  align-items: center;
  height: 28px;
  border-bottom: 1px dashed rgba(14, 116, 144, 0.2);
  z-index: 2;
}
.slit-lane:last-child {
  border-bottom: none;
}
.slit-course {
  width: 24px;
  font-size: 11px;
  font-weight: 700;
  color: #0c4a6e;
  flex-shrink: 0;
}
.slit-track {
  position: relative;
  flex: 1;
  height: 100%;
}
.slit-boat {
  position: absolute;
  top: 4px;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  white-space: nowrap;
}
.slit-st {
  width: 110px;
  text-align: right;
  font-size: 11px;
  color: #0c4a6e;
  flex-shrink: 0;
}

/* サイクル1追加: レース特徴タグ・展開リスト・H2H */
.race-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.race-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
}
.race-tag-good { background: #dcfce7; color: #166534; border-color: #86efac; }
.race-tag-warn { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.race-tag-info { background: #e0f2fe; color: #075985; border-color: #7dd3fc; }

.insight-list {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 12.5px;
  color: var(--text);
}
.insight-list li {
  margin-bottom: 3px;
}

.h2h-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 6px;
}
.h2h-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  flex-wrap: wrap;
}
.h2h-item .waku-badge {
  width: 18px;
  height: 18px;
  font-size: 11px;
}

/* 収益化・SEOガイド・注目レポート・広告枠 */
.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.guide-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  color: var(--text);
}
.guide-card:hover {
  border-color: var(--primary);
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(15, 76, 129, 0.08);
}
.guide-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.guide-title {
  margin: 0;
  font-size: 15px;
  line-height: 1.4;
}
.guide-summary {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
  flex: 1;
}
.guide-article h2 {
  font-size: 15.5px;
  margin: 16px 0 6px;
  border-left: 3px solid var(--primary);
  padding-left: 8px;
}
.guide-article p {
  margin: 0 0 10px;
  line-height: 1.75;
}
.guide-related {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.guide-related h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.major-banner {
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #78350f;
  padding: 8px 12px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 13px;
}
.major-banner a {
  color: #78350f;
  font-weight: 600;
}

.contact-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  margin-top: 8px;
}

.ad-slot-wrap {
  margin: 14px 0;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  min-height: 90px;
}
.ad-slot-label {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* ダークモード・CSVコピーボタン */
.theme-toggle-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 12px;
  cursor: pointer;
}
.theme-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

.csv-copy-btn {
  padding: 2px 7px;
  font-size: 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
}
.csv-copy-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

html[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --border: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #38bdf8;
  --primary-light: #0c4a6e;
}
html[data-theme="dark"] th {
  background: #0f172a;
  color: #cbd5e1;
}
html[data-theme="dark"] .kpi-item,
html[data-theme="dark"] .h2h-item,
html[data-theme="dark"] .contact-box,
html[data-theme="dark"] .pickup-item,
html[data-theme="dark"] .race-btn,
html[data-theme="dark"] .day-tab,
html[data-theme="dark"] .race-strip-item {
  background: #0f172a;
  color: var(--text);
}
html[data-theme="dark"] input,
html[data-theme="dark"] select {
  background: #0f172a;
  color: var(--text);
  border-color: var(--border);
}
html[data-theme="dark"] .site-header {
  background: #020617;
}

.upset-meter-wrap {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.upset-meter-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  margin-bottom: 5px;
}
.upset-meter-bar {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.upset-meter-fill {
  height: 100%;
  border-radius: 999px;
}
.upset-tone-good { background: #16a34a; }
.upset-tone-info { background: #0284c7; }
.upset-tone-warn { background: #dc2626; }
