:root {
  --bg: #0f1720;
  --panel: #17222e;
  --panel-2: #1e2c3a;
  --line: #2c3d4e;
  --text: #e8eef4;
  --muted: #93a5b6;
  --accent: #ff8c42;
  --accent-2: #4ec9a5;
  --star: #ffd24a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  line-height: 1.6;
}

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

/* ---- ヘッダー ---- */
.header {
  background: linear-gradient(135deg, #123 0%, #1d3446 60%, #23485c 100%);
  border-bottom: 1px solid var(--line);
  padding: 22px 16px 18px;
}
.header-inner { max-width: 1080px; margin: 0 auto; }
.header h1 { margin: 0 0 4px; font-size: 25px; }
.subtitle { margin: 0; font-size: 13px; color: var(--muted); }
.stats { margin-top: 12px; display: flex; gap: 10px; flex-wrap: wrap; }
.stat {
  background: rgba(255, 255, 255, .08);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 13px;
}
.stat b { color: var(--accent); font-size: 16px; }

/* ---- タブ ---- */
.tabs {
  display: flex;
  gap: 6px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 16px 0;
  flex-wrap: wrap;
}
.tab {
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  padding: 9px 18px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.is-active {
  background: var(--panel-2);
  color: var(--text);
  border-bottom-color: var(--panel-2);
  font-weight: 700;
}

main { max-width: 1080px; margin: 0 auto; padding: 0 16px 40px; }

.view { display: none; background: var(--panel-2); border: 1px solid var(--line); border-radius: 0 10px 10px 10px; padding: 18px; }
.view.is-active { display: block; }

.hint { margin: 0 0 14px; font-size: 13px; color: var(--muted); }

/* ---- 月ナビ ---- */
.month-nav { display: flex; align-items: center; justify-content: center; gap: 18px; }
.month-nav h2 { margin: 0; font-size: 21px; min-width: 170px; text-align: center; }
.nav-btn {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 40px; height: 36px;
  cursor: pointer;
  font-size: 14px;
}
.nav-btn:hover { border-color: var(--accent); color: var(--accent); }

.month-jump { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; margin: 14px 0 18px; }
.month-jump button {
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 9px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
.month-jump button.has-race { color: var(--text); border-color: #46607a; }
.month-jump button.is-current { background: var(--accent); color: #16232e; border-color: var(--accent); font-weight: 700; }

/* ---- カレンダー ---- */
.calendar-wrap { overflow-x: auto; }
.calendar { width: 100%; border-collapse: collapse; min-width: 620px; }
.calendar th {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 7px;
  font-size: 13px;
  color: var(--muted);
}
.calendar th.sun, .calendar td.sun .day-num { color: #ff7b7b; }
.calendar th.sat, .calendar td.sat .day-num { color: #7bb6ff; }
.calendar td {
  border: 1px solid var(--line);
  vertical-align: top;
  height: 92px;
  width: 14.28%;
  padding: 4px;
  background: var(--panel);
}
.calendar td.empty { background: #14202b; }
.calendar td.today { outline: 2px solid var(--accent-2); outline-offset: -2px; }
.day-num { font-size: 12px; color: var(--muted); }

.cal-race {
  display: block;
  width: 100%;
  text-align: left;
  margin-top: 3px;
  padding: 3px 5px;
  font-size: 11px;
  line-height: 1.3;
  background: #2b4256;
  border: 1px solid #3a5a74;
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  overflow: hidden;
}
.cal-race:hover { background: #35526b; }
.cal-race.is-fav { border-left-color: var(--star); background: #4a3f22; }

.cal-race-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cal-race-deadline {
  display: block;
  font-size: 10px;
  color: #a9c0d4;
  white-space: nowrap;
}
.cal-race.is-fav .cal-race-deadline { color: #d8c88f; }

/* ---- レースカード ---- */
.section-title { margin: 26px 0 10px; font-size: 15px; color: var(--accent-2); border-left: 4px solid var(--accent-2); padding-left: 8px; }

.race-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 10px; }

.race-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px 14px;
  position: relative;
}
.race-card.is-fav { border-color: var(--star); }
.race-card h4 { margin: 0 8px 6px 0; font-size: 15px; padding-right: 34px; }
.race-card h4 a { color: var(--text); text-decoration: none; }
.race-card h4 a:hover { color: var(--accent); text-decoration: underline; }
.race-meta { font-size: 12.5px; color: var(--muted); margin: 2px 0; }
.race-meta b { color: var(--text); font-weight: 600; }
.badge {
  display: inline-block;
  background: #2b4256;
  color: #bcd3e6;
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 11px;
  margin-bottom: 6px;
}
.fav-btn {
  position: absolute;
  top: 10px; right: 10px;
  background: transparent;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: #55697c;
  padding: 0;
}
.fav-btn:hover { transform: scale(1.15); }
.fav-btn.is-fav { color: var(--star); }

.empty-msg { color: var(--muted); font-size: 13px; grid-column: 1 / -1; }

/* ---- MAP ---- */
#map { height: 620px; border-radius: 9px; border: 1px solid var(--line); background: #22303d; }
.leaflet-popup-content { font-family: inherit; font-size: 13px; min-width: 210px; }
.leaflet-popup-content h4 { margin: 0 0 6px; font-size: 14px; }
.popup-fav {
  margin-top: 8px;
  width: 100%;
  background: #f4f6f8;
  border: 1px solid #c6ced6;
  border-radius: 6px;
  padding: 5px;
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.popup-fav.is-fav { background: #fff3cd; border-color: #e3c463; }

.pin {
  width: 22px; height: 22px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid #fff;
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(0,0,0,.5);
}
.pin.is-fav { background: var(--star); }

.footer { text-align: center; font-size: 12px; color: var(--muted); padding: 0 16px 30px; }

@media (max-width: 600px) {
  .calendar td { height: 74px; }
  #map { height: 460px; }
}
