/* netkeiba-like styling */
* { box-sizing: border-box; }
html { font-size: 13px; }
body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "ヒラギノ角ゴ ProN W3", Meiryo, "メイリオ", sans-serif;
  color: #333;
  background: #f4f4f0;
  line-height: 1.5;
}
a { color: #2c5aa0; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ----- header ----- */
.site-header {
  background: linear-gradient(180deg, #2c3e62 0%, #1a2747 100%);
  color: #fff;
  padding: 8px 0;
  border-bottom: 3px solid #c9a032;
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.logo {
  font-weight: bold;
  font-size: 18px;
  color: #fff;
}
.logo:hover { text-decoration: none; color: #ffd866; }
/* ----- nav (separate menu bar) ----- */
.site-nav {
  background: #fff;
  border-bottom: 1px solid #ddd;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.site-nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  gap: 4px;
}
.site-nav a {
  color: #555;
  font-size: 14px;
  padding: 12px 18px;
  text-decoration: none;
  border-bottom: 3px solid transparent;
  transition: all .15s;
}
.site-nav a:hover {
  color: #c9a032;
  background: #faf6e8;
  text-decoration: none;
}
.site-nav a.active {
  color: #c9a032;
  font-weight: bold;
  border-bottom-color: #c9a032;
  background: #faf6e8;
}

/* analysis page */
.kv-table { background: #fff; border: 1px solid #ddd; margin-bottom: 16px; }
.kv-table th, .kv-table td { padding: 6px 12px; border: 1px solid #eee; text-align: left; }
.kv-table th { background: #ebe5d2; min-width: 120px; }
.hint { font-size: 12px; color: #666; margin: 4px 0 8px; }
.roi-positive { color: #2a8; font-weight: bold; background: #e8f5ee; }
.reco-table tr.top-prob { background: #fff8d6; }
.reco-table tr.top-prob td { border-top: 2px solid #d9a900; border-bottom: 2px solid #d9a900; }
.reco-table tr.top-prob td:first-child { border-left: 2px solid #d9a900; }
.reco-table tr.top-prob td:last-child { border-right: 2px solid #d9a900; }
.reco-table td.prob-max { color: #b58000; }

/* Page loading bar (top of page) */
.page-loader {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  z-index: 9999;
  background: transparent;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.page-loader.active { opacity: 1; }
.page-loader-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #d9a900 0%, #ffd866 50%, #d9a900 100%);
  background-size: 200% 100%;
  animation: loader-shimmer 1.5s linear infinite;
  box-shadow: 0 0 8px rgba(217, 169, 0, 0.6);
  transition: width 0.2s ease-out;
}
@keyframes loader-shimmer {
  0% { background-position: 0% 0; }
  100% { background-position: 200% 0; }
}

/* Predict Not Ready (準備中) */
.not-ready-card {
  background: #fff;
  border: 2px solid #e0d8b8;
  border-radius: 10px;
  padding: 32px 24px;
  margin: 24px 0;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.not-ready-card.stage-no_race { border-color: #c44; background: #fff5f5; }
.not-ready-card.stage-no_entries { border-color: #d9a900; background: #fffbe8; }
.not-ready-card.stage-no_odds { border-color: #4a7fb8; background: #f0f6fc; }
.not-ready-card.stage-no_weight { border-color: #2a8859; background: #f0fbf5; }
.not-ready-card.stage-no_features { border-color: #888; background: #f7f7f7; }

.not-ready-icon { font-size: 56px; line-height: 1; margin-bottom: 16px; }
.not-ready-title { font-size: 22px; margin: 8px 0 16px; color: #333; }
.not-ready-detail { font-size: 14px; line-height: 1.7; color: #555; }
.not-ready-detail .next-time { font-size: 16px; margin-top: 12px; color: #c9a032; }
.not-ready-detail .hint { font-size: 12px; color: #888; margin-top: 8px; }

.not-ready-actions { margin-top: 24px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.reload-btn {
  background: #d9a900; color: #fff; border: none; padding: 10px 20px;
  border-radius: 6px; font-size: 14px; cursor: pointer; transition: background 0.15s;
}
.reload-btn:hover { background: #b58000; }
.back-link { padding: 10px 20px; color: #555; text-decoration: none; }
.back-link:hover { color: #c9a032; text-decoration: underline; }

.entry-preview { margin: 24px 0; padding: 12px 16px; border: 1px solid #ddd; border-radius: 6px; background: #fafafa; }
.entry-preview summary { cursor: pointer; font-weight: bold; padding: 4px 0; }

.schedule-info {
  margin: 24px 0; padding: 16px; background: #f7f5ee; border-left: 4px solid #c9a032;
  font-size: 13px; color: #666;
}
.schedule-info h3 { margin: 0 0 8px; font-size: 14px; }
.schedule-info ul { margin: 0; padding-left: 20px; }
.schedule-info li { margin: 4px 0; }

/* Half-donut gauge */
.gauge { display: block; width: 140px; height: 85px; margin: 0 auto; }
.predict-stats-gauges { display: flex; gap: 8px; justify-content: space-around; align-items: center; }
.predict-stats-gauges .predict-stat { text-align: center; flex: 1; }
.predict-stat-stars .label { font-size: 12px; color: #888; margin-bottom: 6px; }
.predict-stat-stars .stars-big { font-size: 26px; color: #d9a900; letter-spacing: 2px; }

/* glossary box */
.glossary {
  background: #fff;
  border: 1px solid #d4c79c;
  border-left: 4px solid #c9a032;
  padding: 8px 14px;
  margin-bottom: 18px;
  font-size: 12px;
}
.glossary summary {
  cursor: pointer;
  font-weight: bold;
  color: #2c3e62;
  padding: 4px 0;
}
.glossary dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 12px;
  margin: 8px 0 4px;
}
.glossary dt {
  font-weight: bold;
  color: #c9a032;
  white-space: nowrap;
}
.glossary dd { margin: 0; color: #444; }
.glossary-tip { margin: 8px 0 0; color: #666; font-style: italic; }

/* help icon (?) — inline tooltip */
.help {
  position: relative;
  display: inline-block;
  width: 14px;
  height: 14px;
  line-height: 14px;
  text-align: center;
  border-radius: 50%;
  background: #d4c79c;
  color: #fff;
  font-size: 10px;
  font-weight: bold;
  margin-left: 4px;
  cursor: help;
  vertical-align: middle;
}
.help:hover { background: #c9a032; }
.help[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #2c3e62;
  color: #fff;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: normal;
  line-height: 1.5;
  white-space: normal;
  width: max-content;
  max-width: 240px;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.help[data-tip]::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #2c3e62;
  z-index: 100;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.help[data-tip]:hover::after,
.help[data-tip]:hover::before { opacity: 1; }

/* prediction page */
.predict-top3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.predict-card {
  background: #fff;
  border: 2px solid #ddd;
  border-radius: 6px;
  padding: 14px;
  position: relative;
}
.predict-card.rank-1 { border-color: #c9a032; box-shadow: 0 2px 8px rgba(201,160,50,0.2); }
.predict-card.rank-2 { border-color: #999; }
.predict-card.rank-3 { border-color: #cd7f32; }
.predict-rank {
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 8px;
  color: #2c3e62;
}
.predict-horse {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 8px;
}
.predict-horse a { color: #2c3e62; }
.predict-meta { font-size: 12px; color: #555; margin-bottom: 10px; line-height: 1.6; }
.predict-stats { display: flex; gap: 16px; padding-top: 10px; border-top: 1px solid #eee; }
.predict-stat { flex: 1; text-align: center; }
.predict-stat .label { font-size: 11px; color: #888; }
.predict-stat .value-big { font-size: 22px; font-weight: bold; color: #c9a032; }
.predict-stat .value { font-size: 14px; color: #c9a032; }
.predict-stat .confidence-num { font-size: 10px; color: #999; }
.predict-actual {
  margin-top: 10px;
  padding: 6px 10px;
  background: #f0f0f0;
  border-radius: 3px;
  font-size: 12px;
  text-align: center;
}
.predict-actual.hit { background: #2a8; color: #fff; font-weight: bold; }
.predict-actual.near { background: #ffd866; color: #2c3e62; font-weight: bold; }

.predict-summary {
  background: #fffae0;
  border: 1px solid #c9a032;
  padding: 10px 14px;
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}
.badge-hit {
  display: inline-block;
  padding: 4px 10px;
  background: #2a8;
  color: #fff;
  border-radius: 3px;
  font-size: 12px;
  font-weight: bold;
}

.row-actual-1st { background: #fffae0 !important; font-weight: bold; }

@media (max-width: 720px) {
  .predict-top3 { grid-template-columns: 1fr; }
}

/* filter form */
.filter-block {
  background: #fff;
  border: 1px solid #c9a032;
  padding: 16px 18px;
  margin-bottom: 20px;
  border-radius: 4px;
}
.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px 18px;
}
.filter-cell { display: flex; flex-direction: column; gap: 4px; }
.filter-cell.wide { grid-column: span 2; }
.filter-cell label {
  font-weight: bold;
  font-size: 11px;
  color: #555;
  letter-spacing: 0.5px;
}
.filter-cell input, .filter-cell select {
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid #bbb;
  border-radius: 3px;
  font-family: inherit;
  width: 100%;
  background: #fff;
}
.filter-cell input:focus, .filter-cell select:focus {
  outline: none;
  border-color: #c9a032;
  box-shadow: 0 0 0 2px rgba(201,160,50,0.2);
}
.filter-input-row { display: flex; align-items: center; gap: 6px; }
.filter-input-row input { min-width: 0; }
.filter-input-row .dash { color: #888; flex-shrink: 0; }
.filter-actions {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #eee;
}
.filter-actions button {
  padding: 8px 24px;
  background: #c9a032;
  color: #fff;
  border: none;
  border-radius: 3px;
  font-weight: bold;
  cursor: pointer;
  font-size: 13px;
}
.filter-actions button:hover { background: #b08a25; }
.filter-reset {
  color: #888;
  font-size: 12px;
}
.filter-reset:hover { color: #c9a032; }

@media (max-width: 720px) {
  .filter-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-cell.wide { grid-column: span 2; }
}
.back-row {
  margin-top: 4px;
}
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 30px;
  padding: 8px 18px;
  background: linear-gradient(180deg, #fff 0%, #f0e8d0 100%);
  border: 1px solid #c9a032;
  border-radius: 4px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.8);
  color: #2c3e62;
  font-size: 13px;
  font-weight: bold;
  text-decoration: none;
  transition: all 0.1s ease;
  cursor: pointer;
}
.back-btn::before {
  content: "‹";
  font-size: 18px;
  font-weight: bold;
  line-height: 1;
  margin-right: 2px;
  color: #c9a032;
}
.back-btn:hover {
  background: linear-gradient(180deg, #fcf6e0 0%, #ebe0b8 100%);
  text-decoration: none;
  box-shadow: 0 2px 4px rgba(0,0,0,0.12), inset 0 1px 0 rgba(255,255,255,0.9);
  transform: translateY(-1px);
}
.back-btn:active {
  background: linear-gradient(180deg, #ebe0b8 0%, #fcf6e0 100%);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.15);
  transform: translateY(0);
}
.breadcrumb {
  font-size: 12px;
  color: #666;
  padding: 6px 10px;
  background: #f4f0e0;
  border-left: 3px solid #c9a032;
  margin-bottom: 12px;
}
.breadcrumb a { color: #2c5aa0; }

main {
  min-height: calc(100vh - 120px);
  padding: 16px 0;
}
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 16px;
}

.page-title {
  font-size: 18px;
  margin: 0 0 16px;
  padding: 8px 12px;
  background: #fff;
  border-left: 4px solid #c9a032;
}
.page-title small.mono { font-family: monospace; color: #888; font-size: 12px; margin-left: 8px; }
.horse-meta { font-size: 13px; color: #555; margin-left: 10px; font-weight: normal; }

.section-h {
  font-size: 14px;
  margin: 20px 0 6px;
  padding: 6px 10px;
  background: #2c3e62;
  color: #fff;
}
.bt-h {
  font-size: 13px;
  margin: 12px 0 4px;
  padding: 4px 8px;
  background: #ddd;
}

/* ----- search box ----- */
.search-block {
  background: #fff;
  border: 1px solid #c9a032;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.date-search {
  display: flex;
  align-items: center;
  gap: 8px;
}
.date-search label { font-weight: bold; }
.date-search input[type="date"] {
  padding: 6px 8px;
  border: 1px solid #bbb;
  font-size: 14px;
  font-family: inherit;
}
.date-search button {
  padding: 6px 16px;
  background: #c9a032;
  color: #fff;
  border: none;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
}
.date-search button:hover { background: #b08a25; }
.search-hint { margin: 6px 0 0; color: #888; font-size: 11px; }

/* pager */
.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 16px 0;
  justify-content: center;
}
.pager a, .pager span {
  display: inline-block;
  padding: 4px 12px;
  border: 1px solid #bbb;
  background: #fff;
  font-size: 13px;
  color: #333;
}
.pager a:hover { background: #fcf6e0; text-decoration: none; }
.pager .cur { background: #c9a032; color: #fff; border-color: #c9a032; font-weight: bold; }
.pager .disabled { color: #ccc; background: #f6f6f6; }

/* search highlight */
.date-block.highlight { border: 2px solid #c9a032; background: #fffbe8; }
.badge-target {
  display: inline-block;
  padding: 1px 8px;
  background: #c9a032;
  color: #fff;
  font-size: 11px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ----- index ----- */
.date-block {
  background: #fff;
  margin-bottom: 12px;
  padding: 10px 14px;
  border: 1px solid #ddd;
}
.date-heading {
  margin: 0 0 8px;
  font-size: 15px;
  border-bottom: 1px solid #ccc;
  padding-bottom: 4px;
}
.venue-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.venue-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 10px;
  background: #f8f4ea;
  border: 1px solid #d4c79c;
  border-radius: 3px;
  color: #333;
}
.venue-pill:hover { background: #fcf6e0; text-decoration: none; }
.v-name { font-weight: bold; }
.v-count { font-size: 11px; color: #666; }
.empty { padding: 20px; text-align: center; color: #888; }
.empty code { background: #eee; padding: 2px 6px; }

/* ----- date page ----- */
.venue-block {
  background: #fff;
  margin-bottom: 16px;
  border: 1px solid #ccc;
}
.venue-heading {
  margin: 0;
  padding: 6px 12px;
  font-size: 14px;
  background: #c9a032;
  color: #fff;
}
table.race-list, table.result-table, table.payout-table, table.odds-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 12px;
}
table.race-list th, table.race-list td,
table.result-table th, table.result-table td,
table.payout-table th, table.payout-table td,
table.odds-table th, table.odds-table td {
  border: 1px solid #d8d8d8;
  padding: 4px 6px;
  text-align: center;
}
table.race-list thead th, table.result-table thead th, table.odds-table thead th {
  background: #ebe5d2;
  color: #333;
  font-weight: normal;
  border-bottom: 2px solid #c9a032;
}
table.race-list tbody tr:nth-child(even),
table.result-table tbody tr:nth-child(even),
table.odds-table tbody tr:nth-child(even) { background: #fcfaf3; }
table.race-list tbody tr:hover,
table.result-table tbody tr:hover { background: #fff8d8; }
.r-no { font-weight: bold; }

/* ----- race header ----- */
.race-header {
  background: #fff;
  border: 1px solid #c9a032;
  padding: 10px 14px;
  margin-bottom: 12px;
}
.race-title { font-size: 18px; margin: 0 0 6px; }
.race-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: #555;
}
.race-meta span { white-space: nowrap; }
.race-pager {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 12px;
}
.race-pager a, .race-pager .cur {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid #bbb;
  background: #fafafa;
}
.race-pager .cur { background: #c9a032; color: #fff; border-color: #c9a032; }

/* surface badges */
.surface {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 2px;
  font-size: 11px;
  font-weight: bold;
}
.surface-芝 { background: #4a8a3a; color: #fff; }
.surface-dirt { background: #8b6230; color: #fff; }
.surface-jump { background: #884; color: #fff; }

/* grade badges */
.grade-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 2px;
  font-size: 10px;
  font-weight: bold;
  margin-left: 4px;
  vertical-align: middle;
}
.grade-g1 { background: #d22; color: #fff; }
.grade-g2 { background: #d72; color: #fff; }
.grade-g3 { background: #2c5aa0; color: #fff; }
.grade-l, .grade-op { background: #888; color: #fff; }

/* ----- result table ----- */
.result-table .finish { font-weight: bold; font-size: 13px; }
.result-table .horse { text-align: left; padding-left: 8px; }
.result-table .num { font-weight: bold; }
.result-table .odds { color: #c0392b; }
.result-table .pop { color: #555; }
.result-table .passing { font-family: monospace; }

/* 枠番 colors */
.frame { font-weight: bold; }
.frame-1 { background: #fff; color: #000; border: 1px solid #999 !important; }
.frame-2 { background: #000; color: #fff; }
.frame-3 { background: #c00; color: #fff; }
.frame-4 { background: #06c; color: #fff; }
.frame-5 { background: #fc0; color: #000; }
.frame-6 { background: #2a8; color: #fff; }
.frame-7 { background: #f80; color: #fff; }
.frame-8 { background: #f6a; color: #fff; }

/* ----- payout table ----- */
.payout-table { width: auto; min-width: 480px; }
.payout-table .bt {
  background: #ebe5d2;
  width: 80px;
  text-align: center;
  font-weight: bold;
}
.payout-table .combo { text-align: center; font-family: monospace; }
.payout-table .amt { color: #c0392b; font-weight: bold; text-align: right; }
.payout-table .pop2 { color: #888; font-size: 11px; }

/* ----- odds table ----- */
details { background: #fff; padding: 8px 12px; border: 1px solid #ddd; margin-top: 8px; }
summary { cursor: pointer; font-weight: bold; padding: 4px 0; }
.odds-table { margin-top: 4px; }
.odds-table .odds { color: #c0392b; font-weight: bold; }
.odds-table .more { color: #888; font-style: italic; }
.no-data {
  background: #fff;
  border: 1px dashed #ccc;
  padding: 16px 20px;
  margin: 4px 0 12px;
  color: #888;
  text-align: center;
}
.no-data code {
  background: #f0eee5;
  padding: 2px 6px;
  border-radius: 2px;
  color: #555;
  font-size: 12px;
}

/* ----- jockey stats ----- */
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-bottom: 16px;
  background: #fff;
  border: 1px solid #ccc;
}
.stat {
  flex: 1;
  min-width: 90px;
  padding: 8px;
  border-right: 1px solid #eee;
  text-align: center;
}
.stat:last-child { border-right: none; }
.stat-label { font-size: 11px; color: #777; }
.stat-value { font-size: 18px; font-weight: bold; color: #2c3e62; }

/* ----- footer ----- */
.site-footer {
  background: #2c3e62;
  color: #aab;
  padding: 10px 16px;
  font-size: 11px;
  text-align: center;
}
