:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, Helvetica, sans-serif;
  --bg: #f3f3f3;
  --panel: #ffffff;
  --text: #1a1a1a;
  --muted: #71777a;
  --line: #e7e7e7;
  --line-strong: #c0c0c0;
  --accent: #eb1923;
  --accent-strong: #c81420;
  --accent-soft: #fdeceb;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-btn: 8px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.12);
  --gap: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 88px;
  padding: 14px 20px;
  border-bottom: 3px solid var(--accent);
  background: var(--panel);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.15;
  font-weight: 700;
}

#summary {
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
}

.filters {
  display: flex;
  align-items: end;
  gap: var(--gap);
  flex-wrap: wrap;
}

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

.search-label-text {
  padding-left: 2px;
}

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.icon-search {
  position: absolute;
  left: 12px;
  color: var(--muted);
  pointer-events: none;
}

input,
button {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-btn);
  background: #fff;
  color: var(--text);
  font: inherit;
}

input {
  min-width: 220px;
  padding: 0 14px;
}

.search-input-wrap input {
  width: 100%;
  padding-left: 36px;
}

button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-ghost {
  border-color: var(--accent);
  color: var(--accent-strong);
  font-weight: 700;
}

.btn-ghost:hover,
.btn-ghost:focus-visible {
  background: var(--accent);
  color: #fff;
}

.filter-dropdown {
  position: relative;
  display: grid;
  gap: 5px;
}

.filter-dropdown-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.filter-dropdown-toggle {
  min-width: 150px;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-btn);
  background: #fff;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.filter-dropdown-toggle:hover,
.filter-dropdown-toggle:focus-visible {
  border-color: var(--accent);
}

.filter-dropdown-toggle--active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.filter-dropdown-menu {
  position: absolute;
  z-index: 1200;
  top: calc(100% + 6px);
  left: 0;
  min-width: 190px;
  max-height: 260px;
  overflow: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  box-shadow: var(--shadow-md);
}

.filter-dropdown-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
}

.filter-dropdown-option:hover {
  background: var(--accent-soft);
}

.filter-dropdown-option input {
  min-height: 0;
  min-width: 0;
  width: auto;
  padding: 0;
  margin: 0;
  border-radius: 4px;
}

main {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  height: calc(100vh - 91px);
  min-height: 520px;
}

#map {
  position: relative;
  width: 100%;
  height: 100%;
}

.region-group {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 6px 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-btn);
  background: var(--bg);
}

.region-group-label {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-right: 6px;
  border-right: 1px solid var(--line-strong);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.region-group-label .icon {
  width: 13px;
  height: 13px;
  color: #d4a017;
}

.help-toggle {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  min-height: 0;
  padding: 0;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.help-toggle:hover,
.help-toggle:focus-visible {
  background: var(--line);
  color: var(--text);
}

.help-panel {
  position: absolute;
  z-index: 1300;
  top: calc(100% + 8px);
  left: 0;
  width: 260px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--panel);
  box-shadow: var(--shadow-md);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  font-weight: 400;
}

.help-panel .icon {
  width: 13px;
  height: 13px;
  vertical-align: -1px;
  color: #d4a017;
}

.legend {
  position: absolute;
  z-index: 1000;
  left: 12px;
  bottom: 24px;
}

.legend-toggle {
  border-radius: var(--radius-btn);
  border-color: var(--line-strong);
  background: var(--panel);
  box-shadow: var(--shadow-md);
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
}

.icon-chevron {
  transition: transform 0.15s ease;
}

.legend-toggle[aria-expanded="true"] .icon-chevron {
  transform: rotate(180deg);
}

.legend-panel {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  display: grid;
  gap: 10px;
  width: max-content;
  min-width: 210px;
  padding: 12px 14px;
  background: var(--panel);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.legend-panel[hidden] {
  display: none;
}

.color-mode {
  display: flex;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-btn);
  overflow: hidden;
}

.color-mode-option {
  flex: 1;
  min-height: 30px;
  padding: 0 6px;
  border: none;
  border-radius: 0;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  justify-content: center;
}

.color-mode-option + .color-mode-option {
  border-left: 1px solid var(--line-strong);
}

.color-mode-option[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}

.legend-items {
  display: grid;
  gap: 6px;
}

.legend-item {
  display: flex;
  align-items: center;
  font-size: 13px;
  color: var(--text);
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.list-panel {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: var(--panel);
}

.list-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.list-header h2 {
  font-size: 18px;
}

#result-count {
  color: var(--muted);
  font-size: 13px;
}

#team-list {
  overflow: auto;
  padding: 8px;
}

.team-item {
  display: flex;
  align-items: stretch;
  gap: 4px;
  border-bottom: 1px solid var(--line);
}

.team-item:hover {
  background: var(--bg);
}

.team-item-main {
  flex: 1;
  min-width: 0;
  display: block;
  padding: 12px 10px;
  border: none;
  border-radius: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.team-item-main:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.team-region-toggle {
  flex-shrink: 0;
  align-self: center;
  width: 32px;
  height: 32px;
  margin-right: 4px;
  padding: 0;
  justify-content: center;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--line-strong);
  cursor: pointer;
}

.team-region-toggle .icon {
  width: 18px;
  height: 18px;
}

.team-region-toggle:hover {
  color: #d4a017;
}

.team-region-toggle[aria-pressed="true"] {
  color: #d4a017;
}

.team-region-toggle[aria-pressed="true"] .icon {
  fill: currentColor;
}

.region-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.region-group .btn-ghost {
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

.region-toggle input[type="checkbox"] {
  width: 16px;
  min-width: 0;
  height: 16px;
  min-height: 0;
  padding: 0;
  border-radius: 4px;
}

.team-marker span {
  display: block;
  width: 18px;
  height: 18px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.35);
}

/* Stacked layout inside a list entry: name, then attribute tags, then venue address. */
.team-name {
  display: block;
  font-weight: 700;
}

.team-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin-top: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  white-space: nowrap;
}

.team-venue {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.popup-title {
  margin-bottom: 6px;
  font-weight: 700;
}

.popup-row {
  margin: 2px 0;
}

.popup-label {
  color: var(--muted);
  font-weight: 700;
}

@media (max-width: 860px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .filters {
    align-items: stretch;
  }

  label,
  input,
  button {
    width: 100%;
  }

  .filter-dropdown,
  .filter-dropdown-toggle {
    width: 100%;
  }

  main {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(420px, 58vh) minmax(220px, 42vh);
    height: auto;
    min-height: 0;
  }

  .list-panel {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .legend {
    left: 8px;
    bottom: 8px;
  }
}
