:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --border: #dfe6f1;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #1d8f5f;
  --accent: #f59e0b;
  --danger: #d6336c;
  --shadow: 0 12px 28px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

@keyframes location-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Yu Gothic", "Hiragino Kaku Gothic ProN", sans-serif;
}

body {
  min-height: 100vh;
}

button, input, select, textarea {
  font: inherit;
}

button {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: var(--primary);
  color: #fff;
  padding: 0.8rem 1.2rem;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

button:disabled {
  cursor: not-allowed;
}

button:hover {
  opacity: 0.92;
}

button.secondary {
  background: #eef4ff;
  color: var(--text);
}

button.event-grid-action {
  padding: 4px 8px;
}

#routeStartBtn:focus,
#routeRegisterBtn:focus,
#routeMoveModeBtn:focus,
#routeDeleteModeBtn:focus {
  outline: none;
}

#routeStartBtn:focus-visible,
#routeRegisterBtn:focus-visible,
#routeMoveModeBtn:focus-visible,
#routeDeleteModeBtn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

#routeMoveModeBtn.is-active {
  background: var(--primary);
  color: #fff;
}

#routeDeleteModeBtn.is-active {
  background: var(--danger);
  color: #fff;
}

#routeStartBtn.is-active,
#routeRegisterBtn.is-active {
  background: var(--primary);
  color: #fff;
}

#routeRegisterBtn.is-focus-blue {
  background: #2563eb;
  color: #fff;
}

#routeEndBtn.is-drawing-active {
  background: rgba(29, 143, 95, 0.18);
  color: var(--primary);
}

#routeDeletePointBtn.is-drawing-active {
  background: rgba(214, 51, 108, 0.14);
  color: var(--danger);
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
}

input[type="color"] {
  width: 3.2rem;
  height: 2.6rem;
  padding: 0.2rem;
  cursor: pointer;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-weight: 600;
  font-size: 0.92rem;
}

.app-layout {
  display: grid;
  grid-template-columns: minmax(0, 2.4fr) minmax(300px, 1fr);
  min-height: 100vh;
}

.map-panel {
  position: relative;
  padding: 1rem;
}

.map-frame-wrap {
  position: relative;
  height: 100%;
  min-height: 760px;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #dfe9f2;
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.map-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.side-panel {
  background: rgba(248, 250, 252, 0.96);
  padding: 1.5rem 1.2rem;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.brand-block h1,
.page-header h1 {
  margin: 0.2rem 0 0;
  font-size: clamp(1.7rem, 2vw, 2.4rem);
}

.eyebrow {
  margin: 0;
  color: var(--primary);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
}

.info-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.03);
}

.status-row {
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  margin: 0.6rem 0;
}

.status-row label {
  flex: 0 0 auto;
  white-space: nowrap;
}

.status-row select {
  width: auto;
  flex: 0 0 auto;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.35rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
}

.status-on {
  background: rgba(29, 143, 95, 0.12);
  color: var(--primary);
}

.status-off {
  background: rgba(214, 51, 108, 0.1);
  color: var(--danger);
}

.event-name {
  font-weight: 700;
}

.location-status-row {
  margin-top: 0.7rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}

.location-label {
  font-weight: 700;
  color: var(--muted);
}

.location-accuracy {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
}

.location-loading {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: #0f766e;
  background: rgba(13, 148, 136, 0.1);
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
}

.location-loading::before {
  content: "";
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  border: 2px solid rgba(15, 118, 110, 0.35);
  border-top-color: #0f766e;
  animation: location-spin 0.8s linear infinite;
}

.location-loading.hidden,
.location-message.hidden {
  display: none;
}

.location-message {
  margin: 0.35rem 0 0;
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  background: rgba(29, 143, 95, 0.08);
  color: var(--text);
  font-size: 0.8rem;
  line-height: 1.5;
}

.location-message.warning {
  background: rgba(214, 51, 108, 0.08);
  color: var(--danger);
}

.route-list,
.amenity-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.route-list li,
.amenity-list li {
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  background: #f9fbff;
}

.route-list li {
  padding: 0;
  border: none;
  background: transparent;
  display: block;
}

.route-card {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.94), rgba(245,248,255,0.96));
  overflow: hidden;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
}

.route-card.selected {
  border-color: rgba(29, 143, 95, 0.5);
  box-shadow: 0 10px 24px rgba(29, 143, 95, 0.08);
}

.route-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  list-style: none;
  cursor: pointer;
  padding: 0.8rem 0.85rem;
}

.route-summary::-webkit-details-marker {
  display: none;
}

.route-summary-main {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex: 1;
  min-width: 0;
}

.route-icon {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.1rem;
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.35), 0 6px 14px rgba(15, 23, 42, 0.12);
  flex-shrink: 0;
}

.route-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.2rem;
}

.route-name {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.route-road,
.route-description {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.5;
}

.route-road {
  display: block;
  overflow-wrap: anywhere;
}

.route-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.route-select-button {
  border: 1px solid rgba(29, 143, 95, 0.18);
  background: #ecfdf5;
  color: var(--primary);
  padding: 0.45rem 0.7rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 5.3rem;
}

.route-select-button.active {
  background: var(--primary);
  color: #fff;
}

.route-toggle {
  width: 1.7rem;
  height: 1.7rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e9f0ff;
  color: var(--text);
  font-weight: 700;
  transition: transform 0.2s ease;
}

.route-card[open] .route-toggle {
  transform: rotate(45deg);
}

.route-line-dimmed,
.route-label-dimmed,
.route-road-label-dimmed {
  opacity: 0.35;
}

.route-body {
  border-top: 1px solid var(--border);
  padding: 0.7rem 0.85rem 0.85rem;
  background: rgba(255, 255, 255, 0.5);
}

.route-description {
  margin: 0;
  color: #374151;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
}

.color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.route-name,
.amenity-name {
  font-weight: 700;
}

.amenity-name {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.amenity-type {
  font-size: 0.62rem;
  color: var(--muted);
  font-weight: 700;
  padding: 0.18rem 0.48rem;
  border-radius: 999px;
  letter-spacing: 0.04em;
  line-height: 1.5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.4rem;
}

.amenity-icon {
  width: 1.5rem;
  height: 1.5rem;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  font-size: 0.9rem;
  flex-shrink: 0;
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.35);
}

.popup-kind {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.25rem 0.55rem;
  margin-bottom: 0.55rem;
}

.popup-close {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: white;
  font-size: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  cursor: pointer;
}

.popup-map-link {
  display: inline-block;
  margin-top: 0.8rem;
  color: #dbeafe;
  text-decoration: underline;
  font-weight: 600;
}

.sponsor-list {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.amenity-list li {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.amenity-name {
  font-size: 0.68rem;
}

.sponsor-item {
  border: 1px solid rgba(214, 51, 108, 0.18);
  border-left: 4px solid #d6336c;
  border-radius: 12px;
  background: linear-gradient(180deg, #fff6f8, #fff);
  padding: 0.7rem 0.75rem;
  cursor: pointer;
}

.sponsor-item strong {
  display: block;
  margin-bottom: 0.25rem;
}

.sponsor-popup {
  position: fixed;
  right: 2rem;
  bottom: 2rem;
  width: min(360px, calc(100vw - 2rem));
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(30, 41, 59, 0.96));
  color: #fff;
  padding: 1rem 1.1rem;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: 0 25px 40px rgba(15, 23, 42, 0.25);
  z-index: 50;
  backdrop-filter: blur(8px);
  padding-top: 2.4rem;
}

@media (max-width: 640px) {
  .sponsor-popup {
    right: 0.75rem;
    left: 0.75rem;
    bottom: 0.75rem;
    width: auto;
    max-width: none;
  }
}

.sponsor-popup.hidden,
.user-location.hidden {
  display: none;
}

.sponsor-popup h3 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}

.sponsor-popup dl {
  margin: 0;
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 0.5rem 0.8rem;
  font-size: 0.88rem;
}

.sponsor-popup dt {
  color: rgba(255, 255, 255, 0.72);
  font-weight: 600;
}

.sponsor-popup dd {
  margin: 0;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.96);
}

.page-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.2rem 3rem;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.top-nav {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.top-nav a {
  text-decoration: none;
  color: var(--text);
  padding: 0.7rem 1rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.admin-landing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.admin-link-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.9rem;
  padding: 1.2rem;
  border-radius: 18px;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.03);
  text-decoration: none;
  color: var(--text);
}

.admin-link-card h3 {
  margin: 0;
  font-size: 1.1rem;
}

.admin-link-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.9rem;
}

.admin-link-card span {
  color: var(--primary);
  font-weight: 700;
}

.admin-actions {
  margin-top: 1rem;
}

button.danger {
  background: #d6336c;
}

.map-picker-toggle {
  display: inline-flex;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
  padding: 0.25rem;
  border-radius: 999px;
  background: #eef4ff;
  border: 1px solid var(--border);
}

.map-size-toggle {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  font-weight: 700;
}

.map-size-toggle.is-active {
  background: var(--primary);
  color: #fff;
}

.map-picker-surface {
  position: relative;
  min-height: 320px;
  height: 320px;
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  background: #eaf0f7;
  box-shadow: var(--shadow);
  transition: height 0.2s ease;
}

.map-picker-surface.is-large {
  height: 640px;
}

.map-picker-surface.is-drawing .map-canvas {
  cursor: crosshair;
}

.map-picker-note {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.admin-grid,
.register-wrap {
  display: grid;
  gap: 1.2rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 1rem;
}

.wide-field {
  grid-column: 1 / -1;
}

.checkbox-row {
  flex-direction: row !important;
  align-items: center;
  gap: 0.7rem;
  margin-top: 0.2rem;
}

.checkbox-row input {
  width: auto;
}

.table-wrap {
  margin-top: 1rem;
  overflow-x: auto;
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
}

.table-wrap th,
.table-wrap td {
  padding: 0.75rem 0.55rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  font-size: 0.9rem;
}

.table-wrap th {
  background: #f5f8fc;
}

.table-wrap button {
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.primary-action {
  background: linear-gradient(135deg, #2f80ed, #2563eb);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0.7rem 1rem;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.22);
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
}

.modal-dialog {
  position: relative;
  width: min(640px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow: auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
  padding: 1.2rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.modal-header h3 {
  margin: 0;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 1.6rem;
  cursor: pointer;
  color: #334155;
}

.modal-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 1rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 980px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .map-frame-wrap {
    min-height: 500px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 720px) {
  .map-panel {
    padding: 0.75rem 0.75rem 0;
  }

  .side-panel {
    padding: 1rem 0.75rem 2rem;
  }

  .info-card,
  .panel {
    padding: 0.85rem;
    border-radius: 14px;
  }

  .route-list,
  .amenity-list {
    gap: 0.75rem;
  }

  .route-summary {
    align-items: flex-start;
    padding: 0.8rem 0.75rem;
  }

  .route-summary-main {
    align-items: flex-start;
  }

  .route-text {
    gap: 0.25rem;
  }

  .route-body {
    padding: 0.65rem 0.75rem 0.75rem;
  }

  .route-description {
    font-size: 0.74rem;
  }
}

@media (max-width: 560px) {
  .map-frame-wrap {
    min-height: 360px;
    border-radius: 14px;
  }

  .route-card {
    border-radius: 14px;
  }

  .route-summary-main {
    gap: 0.6rem;
  }

  .route-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 10px;
  }

  .route-name {
    font-size: 0.95rem;
  }
}
  }
}

@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .side-panel {
    padding-top: 0.5rem;
  }
}
