:root {
  --bg: #eef1f5;
  --card-bg: #ffffff;
  --text: #1a1d24;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --accent-bg: #eff6ff;
  --pill-bg: #f1f3f6;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding-block: 32px;
  padding-inline: 16px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Segoe UI", sans-serif;
}

.app {
  max-width: 820px;
  margin: 0 auto;
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.app-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 28px 16px;
}
.app-icon { font-size: 22px; }
.app-header h1 { font-size: 20px; margin: 0; }

.venue-tabs {
  display: flex;
  gap: 4px;
  margin: 0 28px 16px;
  padding: 4px;
  background: var(--pill-bg);
  border-radius: 10px;
}
.venue-tab {
  flex: 1;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}
.venue-tab.active {
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow);
}

.date-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.date-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 18px;
  cursor: pointer;
  color: var(--text);
}
.date-btn:hover { background: var(--pill-bg); }
.date-label { font-size: 17px; font-weight: 700; min-width: 200px; text-align: center; }

main { padding: 20px 28px 28px; }

.race-list { display: flex; flex-direction: column; gap: 12px; }

.race-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  background: #fff;
}
.race-card:hover { border-color: var(--accent); background: var(--accent-bg); }

.race-num-badge {
  flex: none;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 800;
  font-size: 15px;
  border-radius: 10px;
}
.race-card-body { flex: 1; min-width: 0; }
.race-card-title { font-weight: 700; font-size: 16px; margin-bottom: 2px; }
.race-card-meta { color: var(--text-muted); font-size: 13.5px; }
.race-card-chevron { color: #c4c9d2; font-size: 20px; }

.empty-msg { color: var(--text-muted); text-align: center; padding: 40px 0; }

.back-btn {
  border: none; background: none; color: var(--accent);
  font-size: 15px; font-weight: 600; cursor: pointer; padding: 0 0 16px;
}

.race-header h2 { margin: 0 0 6px; font-size: 21px; }
.race-header .race-meta-line {
  color: var(--text-muted);
  font-size: 14px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--pill-bg);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}

.race-num-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin: 16px 0;
  padding-bottom: 4px;
}
.race-num-tab {
  flex: none;
  min-width: 44px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
}
.race-num-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.shape-box {
  background: var(--accent-bg);
  border: 1px solid #dbeafe;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 20px;
}
.shape-title { color: var(--accent); font-weight: 800; font-size: 15px; margin-bottom: 8px; }
.shape-note { font-size: 14px; line-height: 1.6; margin-bottom: 10px; }
.shape-course-note { font-size: 13.5px; color: #1e40af; margin-bottom: 8px; }
.shape-counts { font-size: 13px; color: var(--text-muted); }

.horse-table-wrap { overflow-x: auto; }
.horse-table { width: 100%; min-width: 620px; border-collapse: collapse; font-size: 14px; }
.horse-table th {
  text-align: left;
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.horse-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.col-prob, .col-prev, .col-odds { text-align: right; white-space: nowrap; }
.col-num { text-align: center; }

.waku-chip {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 13px;
  border: 1px solid rgba(0,0,0,0.08);
}
.waku-1 { background: #ffffff; color: #111; }
.waku-2 { background: #1a1a1a; color: #fff; }
.waku-3 { background: #d92626; color: #fff; }
.waku-4 { background: #1e5fd9; color: #fff; }
.waku-5 { background: #f2c200; color: #111; }
.waku-6 { background: #189a4e; color: #fff; }
.waku-7 { background: #ef7e1a; color: #fff; }
.waku-8 { background: #ea6fb0; color: #111; }

.horse-name-cell { display: flex; flex-direction: column; gap: 2px; min-width: 140px; }
.horse-name { font-weight: 700; white-space: nowrap; }
.horse-weight { font-weight: 500; font-size: 12.5px; color: var(--text-muted); }
.horse-sub { font-size: 12.5px; color: var(--text-muted); display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.style-tag {
  display: inline-block;
  flex: none;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--pill-bg);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.prob-cell { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.prob-value { font-weight: 800; font-size: 15px; }
.prob-bar { width: 90px; height: 6px; background: var(--pill-bg); border-radius: 999px; overflow: hidden; }
.prob-bar-fill { height: 100%; background: var(--accent); border-radius: 999px; }

.prev-cell { color: var(--text-muted); font-size: 13px; line-height: 1.5; }
.prev-cell .prev-rank { color: var(--text); font-weight: 700; }

.disclaimer {
  margin-top: 20px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.7;
}

.hidden { display: none !important; }

@media (max-width: 480px) {
  body { padding-block: 0; padding-inline: 0; }
  .app { border-radius: 0; }
  .app-header, main { padding-left: 16px; padding-right: 16px; }
  .venue-tabs { margin-left: 16px; margin-right: 16px; }
  .prob-bar { width: 60px; }
}
