.kb-map-page {
  --map-ink: #171b26;
  --map-muted: #646b7a;
  --map-border: #dfe3ec;
  --map-surface: #fff;
  --map-race: #d9342b;
  --map-circuit: #202b45;
  --map-user: #1677ff;
}

.kb-map-intro {
  max-width: 760px;
  margin: 18px auto 0;
  color: rgba(255, 255, 255, .9);
  font-size: 17px;
  line-height: 1.7;
}

.kb-map-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 14px;
  border: 1px solid rgba(255, 255, 255, .42);
  border-radius: 999px;
  background: rgba(10, 17, 35, .44);
  color: #fff;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .09em;
}

.kb-map-content {
  padding: 72px 0 96px;
}

.kb-map-notice {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
  padding: 20px 22px;
  border: 1px solid #cfe0ff;
  border-left: 5px solid var(--map-user);
  border-radius: 8px;
  background: #f5f9ff;
  color: var(--map-ink);
}

.kb-map-notice.is-action {
  border-color: #f0d7a7;
  border-left-color: #dc8a00;
  background: #fffaf0;
}

.kb-map-notice-icon {
  flex: 0 0 auto;
  color: var(--map-user);
  font-size: 24px;
}

.kb-map-notice.is-action .kb-map-notice-icon { color: #b36b00; }
.kb-map-notice p { margin: 0; line-height: 1.65; }
.kb-map-notice strong { display: block; margin-bottom: 3px; }
.kb-map-notice a { font-weight: 700; text-decoration: underline; }

.kb-map-shell {
  overflow: hidden;
  border: 1px solid var(--map-border);
  border-radius: 12px;
  background: var(--map-surface);
  box-shadow: 0 18px 46px rgba(17, 30, 58, .1);
}

.kb-map-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--map-border);
}

.kb-map-toolbar h2 {
  margin: 0;
  color: var(--map-ink);
  font-size: 22px;
}

.kb-map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--map-muted);
  font-size: 13px;
}

.kb-map-legend span { display: inline-flex; align-items: center; gap: 7px; }
.kb-map-key { width: 12px; height: 12px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, .2); }
.kb-map-key.is-circuit { background: var(--map-circuit); }
.kb-map-key.is-race { background: var(--map-race); }
.kb-map-key.is-user { background: var(--map-user); }

#karting-map {
  width: 100%;
  height: min(68vh, 720px);
  min-height: 480px;
  background: #e9edf4;
}

.kb-map-error {
  display: none;
  padding: 22px;
  color: #8b1e19;
  background: #fff0ef;
}

.kb-map-error.is-visible { display: block; }

.kb-map-popup { display: flex; min-width: 220px; flex-direction: column; color: var(--map-ink); }
.kb-map-popup h3 { margin: 0 0 7px; font-size: 17px; line-height: 1.25; }
.kb-map-popup-address { margin: 0 0 10px; color: var(--map-muted); line-height: 1.45; }
.kb-map-distance { display: inline-flex; align-items: center; gap: 7px; margin: 0 0 10px; padding: 6px 10px; border-radius: 999px; color: #115cb8; background: #edf5ff; font-size: 12px; font-weight: 800; line-height: 1.35; }
.kb-map-popup-races { margin: 11px 0; padding: 10px 12px; border-left: 3px solid var(--map-race); background: #fff4f3; }
.kb-map-popup-races strong { display: block; margin-bottom: 5px; color: #a5231d; }
.kb-map-popup-races ul { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; }
.kb-map-popup-races li { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 7px; align-items: start; line-height: 1.35; }
.kb-map-popup-race-date { color: #9e2721; font-weight: 800; white-space: nowrap; }
.kb-map-popup-race-name { min-width: 0; overflow-wrap: anywhere; }
.kb-map-popup-more { display: block; margin-top: 6px; color: #7b312d; font-size: 12px; font-weight: 800; }
.kb-map-popup-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--map-border); }
.kb-map-popup-actions .kb-map-action { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 8px 12px; border: 2px solid transparent; border-radius: 7px; font-weight: 800; line-height: 1.2; text-align: center; text-decoration: none; transition: background-color .15s ease, border-color .15s ease, color .15s ease; }
.kb-map-popup-actions .kb-map-action.is-circuit { border-color: var(--map-circuit); color: var(--map-circuit); background: #fff; }
.kb-map-popup-actions .kb-map-action.is-circuit:hover { color: #fff; background: var(--map-circuit); }
.kb-map-popup-actions .kb-map-action.is-races { border-color: var(--map-race); color: #fff; background: var(--map-race); }
.kb-map-popup-actions .kb-map-action.is-races:hover { border-color: #a9231d; color: #fff; background: #a9231d; }
.kb-map-popup-actions .kb-map-action:focus-visible { outline: 3px solid rgba(22, 119, 255, .35); outline-offset: 2px; }

.kb-map-user-marker { animation: kb-map-user-pulse 1.9s ease-out infinite; }
@keyframes kb-map-user-pulse {
  0%, 100% { stroke-opacity: 1; fill-opacity: .85; }
  50% { stroke-opacity: .55; fill-opacity: .45; }
}

.kb-map-race-section { margin-top: 46px; }
.kb-map-race-header { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.kb-map-race-header h2 { margin: 0; color: var(--map-ink); font-size: 28px; }
.kb-map-race-header p { margin: 0; color: var(--map-muted); }
.kb-map-race-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.kb-map-race-card { padding: 22px; border: 1px solid var(--map-border); border-top: 4px solid var(--map-race); border-radius: 8px; background: #fff; box-shadow: 0 8px 25px rgba(17, 30, 58, .06); }
.kb-map-race-card-button { display: block; width: 100%; padding: 0; border: 0; color: var(--map-ink); background: transparent; text-align: left; cursor: pointer; }
.kb-map-race-card-button h3 { margin: 0 0 6px; font-size: 18px; }
.kb-map-race-card-address { display: block; color: var(--map-muted); line-height: 1.45; }
.kb-map-race-card-button .kb-map-distance { margin: 11px 0 0; }
.kb-map-date-list { display: grid; gap: 7px; margin: 16px 0 0; padding: 0; list-style: none; }
.kb-map-date-list li { border-radius: 8px; background: #fff0ef; font-size: 12px; }
.kb-map-date-list a { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 9px; align-items: baseline; padding: 8px 10px; color: var(--map-ink); }
.kb-map-date-list time { color: #8f1c17; font-weight: 800; }
.kb-map-date-list span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-map-race-card details { margin-top: 12px; }
.kb-map-race-card summary { color: #414a5d; cursor: pointer; font-weight: 700; }
.kb-map-race-card-link { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; margin-top: 16px; padding: 9px 14px; border: 2px solid var(--map-race); border-radius: 7px; color: #fff; background: var(--map-race); font-weight: 800; text-decoration: none; }
.kb-map-race-card-link:hover { border-color: #a9231d; color: #fff; background: #a9231d; }

.kb-map-empty { padding: 26px; border: 1px dashed #c8cedb; border-radius: 8px; color: var(--map-muted); background: #fff; }

@media (max-width: 991px) {
  .kb-map-race-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 767px) {
  .kb-map-content { padding: 48px 0 72px; }
  #karting-map { height: 62vh; min-height: 400px; }
  .kb-map-toolbar { align-items: flex-start; }
  .kb-map-race-grid { grid-template-columns: 1fr; }
  .kb-map-notice { padding: 17px; }
  .kb-map-page .kb-map-leaflet-popup .leaflet-popup-content-wrapper { border-radius: 11px; }
  .kb-map-page .kb-map-leaflet-popup .leaflet-popup-content { margin: 14px 15px 15px; }
  .kb-map-page .kb-map-leaflet-popup .leaflet-popup-content.leaflet-popup-scrolled {
    overscroll-behavior: contain;
    border-top: 0;
    border-bottom: 0;
    padding-right: 7px;
    scrollbar-color: #aab4bf transparent;
    scrollbar-width: thin;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
  }
  .kb-map-page .kb-map-leaflet-popup .leaflet-popup-close-button {
    width: 36px;
    height: 36px;
    border-radius: 0 10px 0 10px;
    background: rgba(255, 255, 255, .94);
    font-size: 22px;
    line-height: 34px;
  }
  .kb-map-popup { min-width: 0; }
  .kb-map-popup h3 { padding-right: 22px; font-size: 16px; }
  .kb-map-popup-address { font-size: 12px; line-height: 1.35; }
  .kb-map-popup-actions {
    order: 1;
    grid-template-columns: 1fr;
    margin: 2px 0 10px;
    padding: 10px 0;
    border-top: 1px solid var(--map-border);
    border-bottom: 1px solid var(--map-border);
  }
  .kb-map-popup-actions .kb-map-action { min-height: 42px; }
  .kb-map-popup-races { order: 2; margin: 0; padding: 9px 10px; }
  .kb-map-popup-races strong { margin-bottom: 7px; }
  .kb-map-popup-races li { grid-template-columns: 70px minmax(0, 1fr); gap: 6px; font-size: 12px; }
  #karting-map .leaflet-control-zoom { transition: opacity .15s ease; }
  #karting-map.has-open-popup .leaflet-control-zoom { opacity: 0; pointer-events: none; }
}

@media (prefers-reduced-motion: reduce) {
  .kb-map-user-marker { animation: none; }
}
