:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-soft: #f9fbfb;
  --line: #d8e2e0;
  --text: #182321;
  --muted: #667572;
  --brand: #007a68;
  --brand-dark: #00594c;
  --blue: #2368d1;
  --red: #d92f35;
  --yellow: #f2b735;
  --green: #00895f;
  --shadow: 0 10px 30px rgba(20, 38, 35, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(0, 122, 104, 0.10), transparent 32rem),
    linear-gradient(315deg, rgba(242, 183, 53, 0.16), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
  line-height: 1.45;
}

button,
select {
  font: inherit;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 460px);
  gap: 18px;
  align-items: stretch;
  margin-bottom: 18px;
}

.hero-copy,
.hero-panel,
.left-pane,
.detail-pane {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.hero-copy {
  min-height: 178px;
  padding: 26px;
  border-radius: 18px;
  position: relative;
  overflow: hidden;
}

.hero-copy::after {
  content: "";
  position: absolute;
  inset: auto 22px 18px auto;
  width: 138px;
  height: 54px;
  border-bottom: 10px solid rgba(0, 122, 104, 0.17);
  border-radius: 50%;
  transform: rotate(-8deg);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.08;
}

.lead {
  max-width: 720px;
  margin-bottom: 0;
  color: #33433f;
  font-size: 16px;
}

.hero-panel {
  border-radius: 18px;
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric-value {
  display: block;
  margin-top: 4px;
  font-size: 24px;
  font-weight: 800;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(330px, 430px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.left-pane,
.detail-pane {
  border-radius: 18px;
}

.left-pane {
  padding: 14px;
  position: sticky;
  top: 14px;
}

.detail-pane {
  min-width: 0;
  overflow: hidden;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.select-label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select,
.icon-button {
  min-height: 42px;
  border: 1px solid #c8d6d3;
  border-radius: 12px;
  background: #fff;
  color: var(--text);
}

select {
  width: 100%;
  padding: 0 12px;
}

.icon-button {
  padding: 0 14px;
  color: #fff;
  background: var(--brand);
  border-color: var(--brand);
  font-weight: 800;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.mini-metric {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.mini-metric strong {
  display: block;
  margin-top: 2px;
  font-size: 18px;
}

.race-list {
  display: grid;
  gap: 8px;
}

.race-card {
  width: 100%;
  padding: 12px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
}

.race-card:hover,
.race-card.active {
  border-color: rgba(0, 122, 104, 0.62);
  box-shadow: 0 0 0 3px rgba(0, 122, 104, 0.10);
}

.race-card-top {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: flex-start;
}

.race-title {
  font-weight: 900;
}

.race-meta,
.muted {
  color: var(--muted);
}

.race-meta {
  margin-top: 2px;
  font-size: 12px;
}

.axis-line {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.horse-chip,
.frame-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border-radius: 9px;
  border: 1px solid rgba(0, 0, 0, 0.22);
  font-weight: 900;
}

.frame-white {
  background: #fff;
  color: #111;
}

.frame-black {
  background: #111;
  color: #fff;
}

.frame-red {
  background: #e42b2d;
  color: #fff;
}

.frame-blue {
  background: #2265d1;
  color: #fff;
}

.frame-yellow {
  background: #ffd33d;
  color: #111;
}

.frame-green {
  background: #168a55;
  color: #fff;
}

.frame-orange {
  background: #f57f20;
  color: #111;
}

.frame-pink {
  background: #ef8aac;
  color: #111;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid transparent;
}

.tag-blue {
  color: #114f9c;
  background: #e7f0ff;
  border-color: #bfd7ff;
}

.tag-red {
  color: #9c1f25;
  background: #ffe9e9;
  border-color: #ffc5c7;
}

.tag-yellow {
  color: #6e4b00;
  background: #fff5d6;
  border-color: #ffe09b;
}

.tag-gray {
  color: #3d4a47;
  background: #eef2f1;
  border-color: #d9e2df;
}

.race-detail {
  padding: 18px;
}

.empty-state {
  min-height: 360px;
  display: grid;
  align-content: center;
}

.detail-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.detail-header h2 {
  margin-bottom: 6px;
  font-size: 24px;
}

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

.summary-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.summary-card h3 {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.summary-main {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 900;
}

.section-title {
  margin: 20px 0 10px;
  font-size: 16px;
}

.horse-grid {
  display: grid;
  gap: 8px;
}

.horse-row {
  display: grid;
  grid-template-columns: auto minmax(160px, 1.15fr) repeat(5, minmax(72px, 0.7fr));
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.horse-name {
  min-width: 0;
}

.horse-name strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.horse-sub {
  color: var(--muted);
  font-size: 12px;
}

.num-cell {
  min-width: 0;
}

.num-cell span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.num-cell strong {
  font-size: 15px;
}

.bar {
  width: 100%;
  height: 7px;
  margin-top: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5ecea;
}

.bar > i {
  display: block;
  height: 100%;
  width: var(--w, 0%);
  background: linear-gradient(90deg, var(--brand), #2d8cdf);
}

.result-order {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.result-order .ranked {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 980px) {
  .app-shell {
    padding: 12px;
  }

  .hero,
  .main-grid {
    grid-template-columns: 1fr;
  }

  .left-pane {
    position: static;
  }

  .summary-cards {
    grid-template-columns: 1fr;
  }

  .horse-row {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .horse-row .num-cell {
    display: grid;
    grid-template-columns: 70px minmax(0, 1fr);
    grid-column: 1 / -1;
    align-items: center;
  }

  .hero-panel,
  .summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .hero-copy {
    min-height: auto;
    padding: 18px;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .icon-button {
    width: 100%;
  }

  .hero-panel,
  .summary-strip {
    grid-template-columns: 1fr;
  }

  .detail-header {
    grid-template-columns: 1fr;
  }

  .race-detail {
    padding: 12px;
  }
}
