:root {
  --bg: #f4f7fb;
  --panel: rgba(255, 255, 255, 0.8);
  --panel-strong: #ffffff;
  --primary: #0f766e;
  --primary-strong: #115e59;
  --accent: #f59e0b;
  --accent-2: #ff6a3d;
  --sport-blue: #1d4ed8;
  --ink: #10233a;
  --muted: #5a6b82;
  --outline: rgba(148, 163, 184, 0.26);
  --success: #1b9c65;
  --danger: #d93025;
  --shadow: 0 20px 50px rgba(15, 23, 42, 0.14);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  font-family: "Segoe UI", "Hiragino Sans", "Yu Gothic", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(34, 197, 94, 0.18), transparent 25%),
    radial-gradient(circle at top right, rgba(249, 115, 22, 0.18), transparent 28%),
    linear-gradient(180deg, #ecfeff 0%, #f7fafc 30%, #eef4ff 100%);
  color: var(--ink);
}

body {
  min-height: 100vh;
}

button, select {
  font: inherit;
}

.splash-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at center, rgba(255,255,255,0.92), rgba(240,248,255,0.9) 38%, rgba(13, 59, 92, 0.88));
  z-index: 2000;
  transition: opacity 0.7s ease, visibility 0.7s ease;
}

.splash-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-inner {
  display: grid;
  place-items: center;
  gap: 12px;
  padding: 24px 28px;
  border-radius: 28px;
  background: rgba(255,255,255,0.3);
  backdrop-filter: blur(6px);
  box-shadow: 0 24px 50px rgba(15, 23, 42, 0.18);
  animation: splashFlash 1.4s ease-in-out infinite alternate;
}

.splash-logo {
  width: 270px;
  height: auto;
  filter: drop-shadow(0 14px 26px rgba(15, 118, 110, 0.22));
}

.splash-text {
  letter-spacing: 0.24em;
  font-weight: 900;
  font-size: 0.74rem;
  color: rgba(17, 94, 89, 0.9);
}

@keyframes splashFlash {
  0% {
    transform: scale(0.9) translateY(10px);
    opacity: 0.7;
  }
  50% {
    transform: scale(1.04) translateY(0);
    opacity: 1;
  }
  100% {
    transform: scale(0.96) translateY(-8px);
    opacity: 0.9;
  }
}

.error-banner {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  min-width: min(92vw, 640px);
  max-width: calc(100vw - 32px);
  padding: 12px 16px;
  background: rgba(217, 48, 37, 0.96);
  color: #ffffff;
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(146, 24, 24, 0.25);
  border: 1px solid rgba(255,255,255,0.2);
  z-index: 1000;
  display: none;
  font-weight: 700;
  line-height: 1.5;
}

.error-banner.visible {
  display: block;
}

.success-toast {
  position: fixed;
  right: 20px;
  bottom: 24px;
  padding: 12px 16px;
  background: rgba(27, 156, 101, 0.96);
  color: white;
  border-radius: 12px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 900;
  font-weight: 700;
}

.success-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(7, 105, 114, 0.92), rgba(30, 64, 175, 0.9));
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  width: 135px;
  height: 45px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: transparent;
  box-shadow: none;
}

.logo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-text h1 {
  margin: 0;
  font-size: clamp(1.2rem, 1.6vw, 1.8rem);
  color: #f8fbff;
  letter-spacing: 0.04em;
}

.brand-text p {
  margin: 2px 0 0;
  color: rgba(240, 249, 255, 0.8);
  font-size: 0.82rem;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.pill {
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.14);
  color: #f8fbff;
  border-radius: 999px;
  padding: 9px 14px;
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
}

.primary {
  background: linear-gradient(135deg, #f59e0b, #f97316);
  border-color: rgba(255,255,255,0.2);
  color: white;
  box-shadow: 0 10px 18px rgba(249, 115, 22, 0.25);
}

.header-filter {
  min-width: 142px;
  gap: 3px;
}

.header-filter label {
  color: rgba(240, 249, 255, 0.82);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.header-filter select {
  min-width: 142px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  padding: 9px 30px 9px 13px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  font-weight: 700;
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.1);
}

.app-shell {
  max-width: 1320px;
  margin: 20px auto 40px;
  padding: 0 18px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  margin-bottom: 20px;
  background: linear-gradient(135deg, rgba(255,255,255,0.82), rgba(233,247,255,0.9));
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
}

.filter-group label {
  font-size: 0.72rem;
  color: rgba(16, 35, 58, 0.7);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.filter-group select {
  border: 1px solid rgba(148, 163, 184, 0.38);
  border-radius: 14px;
  padding: 12px 14px;
  background: linear-gradient(180deg, #ffffff, #f6fbff);
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(30, 64, 175, 0.08);
  font-weight: 700;
}

.toolbar button {
  margin-left: auto;
}

.ghost-button {
  border: 1px solid var(--outline);
  background: white;
  color: var(--ink);
  border-radius: 12px;
  padding: 11px 14px;
  font-weight: 700;
  cursor: pointer;
}

.facility-candidate-marker {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(99, 102, 106, 0.9);
  border: 3px solid rgba(255, 255, 255, 0.98);
  box-shadow: 0 0 0 6px rgba(107, 114, 128, 0.18), 0 10px 18px rgba(31, 41, 55, 0.2);
}

.sport-event-marker {
position: absolute;
  display: grid;
  width: 38px;
  height: 46px;
  place-items: start center;
  filter: drop-shadow(0 7px 7px rgba(15, 23, 42, 0.28));
  cursor: pointer;
  /* MapLibreがDOM要素を正しく地理座標に追従させるための設定 */
  transform: translate(-50%, -100%);
}

.sport-event-marker::after {
  position: absolute;
  bottom: 0;
  width: 23px;
  height: 19px;
  content: '';
  background: var(--marker-color);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  z-index: -1;
}

.sport-event-marker span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: var(--marker-color);
  font-size: 1.18rem;
  line-height: 1;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.28);
}

.facility-popup {
  min-width: 170px;
  padding: 12px 12px 10px;
}

.facility-popup .tag {
  display: inline-block;
  margin-bottom: 8px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(107, 114, 128, 0.12);
  color: #4b5563;
  font-size: 0.72rem;
  font-weight: 800;
}

.facility-popup h3 {
  margin: 0 0 7px;
  font-size: 1.04rem;
  line-height: 1.4;
}

.facility-popup p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.6;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) minmax(300px, 0.9fr);
  gap: 20px;
}

.map-panel,
.event-panel {
  background: rgba(255,255,255,0.9);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.map-panel {
  position: relative;
  overflow: hidden;
}

.map-location-button {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 5;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  padding: 11px 16px;
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #ffffff;
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.25);
  cursor: pointer;
}

.map-location-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.3);
}

.map-event-list-button {
  display: none;
}

#map {
  width: 100%;
  height: 640px;
  background: #dfeef9;
}

.event-panel {
  padding: 18px 16px 12px;
}

.event-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.event-panel-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.event-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.12);
  color: var(--primary-strong);
  font-weight: 800;
}

.event-list {
  display: grid;
  gap: 12px;
  max-height: 610px;
  overflow: auto;
  padding-right: 4px;
}

.event-card {
  padding: 14px 12px;
  border-radius: 18px;
  border: 1px solid rgba(130, 146, 175, 0.2);
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(240,248,255,0.94));
  display: grid;
  gap: 9px;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 10px 18px rgba(15, 23, 42, 0.04);
}

.event-card:hover {
  transform: translateY(-2px);
  border-color: rgba(10, 132, 181, 0.34);
  box-shadow: 0 12px 20px rgba(30, 64, 175, 0.08);
}

.event-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sport-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(15, 118, 110, 0.1);
  color: var(--primary-strong);
}

.date-pill {
  font-size: 0.74rem;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.12);
  color: #9a6700;
  font-weight: 700;
}

.event-card h3 {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.42;
  color: #10233a;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.meta-row span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
}

.price {
  color: var(--primary-strong);
  font-weight: 800;
}

.join-inline {
  border: none;
  background: linear-gradient(135deg, #0f766e, #14b8a6, #22c55e);
  color: white;
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(20, 184, 166, 0.2);
}

.maplibregl-popup-content {
  padding: 0;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.15);
  margin: 0 auto;
}

.maplibregl-popup {
  max-width: none;
}

.popup-card {
  padding: 18px 18px 14px;
  min-width: 280px;
  width: 280px;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.popup-card .tag {
  display: inline-flex;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.12);
  color: var(--primary-strong);
  font-weight: 800;
  font-size: 0.74rem;
  margin-bottom: 8px;
}

.popup-card h3 {
  margin: 0 0 6px;
  font-size: 1.08rem;
  line-height: 1.4;
}

.popup-card p {
  margin: 4px 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.6;
}

.popup-card strong {
  color: var(--ink);
}

.join-button {
  display: block;
  width: 230px;
  max-width: 100%;
  margin: 12px auto 0;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #0f766e, #14b8a6);
  color: #fff;
  padding: 11px 12px;
  font-weight: 800;
  cursor: pointer;
}

.empty-state {
  border: 1px dashed var(--outline);
  border-radius: 16px;
  padding: 20px 16px;
  background: rgba(255,255,255,0.6);
  color: var(--muted);
  line-height: 1.7;
}

@media (max-width: 980px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  #map {
    height: 460px;
  }

  .toolbar {
    align-items: stretch;
  }

  .toolbar button {
    margin-left: 0;
  }
}

@media (max-width: 560px) {
  .topbar {
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
  }

  .brand {
    flex: 0 0 auto;
    gap: 0;
  }

  .logo {
    width: 88px;
    height: 30px;
  }

  .brand-text {
    display: none;
  }

  .header-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    justify-content: initial;
    gap: 6px;
  }

  .header-filter {
    width: 100%;
    min-width: 0;
  }

  .header-filter label {
    font-size: 0.56rem;
    line-height: 1;
  }

  .header-filter select {
    width: 100%;
    min-width: 0;
    padding: 7px 22px 7px 9px;
    font-size: 0.72rem;
  }

  .app-shell {
    margin: 0 0 24px;
    padding: 0;
  }

  .content-grid {
    gap: 10px;
  }

  .map-panel {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  #map {
    height: calc(100svh - 62px);
    min-height: 500px;
  }

  .map-location-button {
    left: 12px;
    bottom: 12px;
    padding: 9px 13px;
    font-size: 0.8rem;
  }

  .map-event-list-button {
    display: block;
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 5;
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 999px;
    padding: 9px 13px;
    background: rgba(255, 255, 255, 0.96);
    color: var(--primary-strong);
    font-size: 0.8rem;
    font-weight: 800;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.22);
    cursor: pointer;
  }

  .event-panel {
    border-radius: 18px;
    margin: 0 10px;
  }

  .maplibregl-popup-content {
    max-width: calc(100vw - 24px);
  }

  .popup-card {
    width: min(280px, calc(100vw - 24px));
    min-width: 0;
    padding: 15px 15px 12px;
  }
}
