:root {
  --bg:        #0b0e14;
  --panel:     #11151d;
  --panel-2:   #181d27;
  --border:    #232a36;
  --text:      #e7ecf3;
  --muted:     #8893a4;
  --accent:    #00c2ff;
  --accent-2:  #1bd6a4;
  --warn:      #f0a000;
  --start:     #1bd6a4;
  --end:       #ff5577;
  --portal:    #00c2ff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

body {
  display: grid;
  grid-template-columns: 320px 1fr;
  grid-template-rows: 100%;
}

#sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#sidebar header {
  padding: 16px 18px 10px;
  border-bottom: 1px solid var(--border);
}

#sidebar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

#sidebar #set-meta {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

#sidebar .controls {
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
}

#sidebar button {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
}

#sidebar button:hover { border-color: var(--accent); color: var(--accent); }

#mission-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  overflow-y: auto;
  flex: 1;
}

#mission-list li {
  padding: 8px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  cursor: pointer;
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: center;
}

#mission-list li:hover { background: var(--panel-2); }

#mission-list li.active {
  background: linear-gradient(90deg, rgba(0,194,255,0.12), transparent);
  border-left: 3px solid var(--accent);
  padding-left: 15px;
}

.mission-num {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

.mission-title {
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mission-count {
  font-size: 11px;
  color: var(--muted);
}

#sidebar footer {
  padding: 10px 18px 14px;
  border-top: 1px solid var(--border);
}

.note {
  margin: 0;
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted);
}

#map {
  width: 100%;
  height: 100%;
  background: var(--panel-2);
}

#detail {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 320px;
  max-height: calc(100% - 28px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px 16px;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

#detail h2 { margin: 0 0 8px; font-size: 15px; padding-right: 24px; }

.detail-actions {
  margin: 4px 0 12px;
}
.btn-primary {
  display: block;
  text-align: center;
  text-decoration: none;
  background: var(--accent);
  color: #061015;
  font-weight: 600;
  font-size: 13px;
  padding: 9px 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: background 0.15s ease, transform 0.05s ease;
}
.btn-primary:hover { background: #4dd6ff; }
.btn-primary:active { transform: translateY(1px); }
.hint {
  margin: 6px 2px 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}
#detail-close {
  position: absolute;
  right: 6px; top: 4px;
  width: 28px; height: 28px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
}
#detail-portals { list-style: none; margin: 0; padding: 0; }
#detail-portals li {
  display: grid;
  grid-template-columns: 22px 44px 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 12.5px;
}
#detail-portals .ix { color: var(--accent); font-weight: 600; }
#detail-portals img {
  width: 44px; height: 44px; border-radius: 6px;
  background: var(--panel-2);
  object-fit: cover;
}
#detail-portals .portal-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#detail-portals .portal-nav {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 700;
  border: 1px solid transparent;
  transition: background 0.12s ease;
  font-variant-numeric: tabular-nums;
}
#detail-portals .portal-nav--maps {
  color: var(--accent);
  font-size: 16px;
  background: rgba(0,194,255,0.10);
  border-color: rgba(0,194,255,0.25);
}
#detail-portals .portal-nav--maps:hover  { background: rgba(0,194,255,0.22); }
#detail-portals .portal-nav--maps:active { background: rgba(0,194,255,0.35); }
#detail-portals .portal-nav--ingress {
  color: var(--accent-2);
  font-size: 14px;
  background: rgba(27,214,164,0.10);
  border-color: rgba(27,214,164,0.28);
}
#detail-portals .portal-nav--ingress:hover  { background: rgba(27,214,164,0.22); }
#detail-portals .portal-nav--ingress:active { background: rgba(27,214,164,0.35); }

/* Custom MapKit annotations */
.portal-pin {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--portal);
  color: #061015;
  font-weight: 700;
  font-size: 12px;
  border: 2px solid #061015;
  box-shadow: 0 1px 4px rgba(0,0,0,0.6);
  font-variant-numeric: tabular-nums;
}
.portal-pin.start { background: var(--start); }
.portal-pin.end   { background: var(--end); color: #fff; }

.banner-pin {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: var(--accent);
  color: #061015;
  font-weight: 700;
  font-size: 11px;
  border: 1px solid #061015;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  background: rgba(11, 14, 20, 0.96);
  color: var(--accent-2);
  border: 1px solid rgba(27, 214, 164, 0.35);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.2px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.5);
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 720px) {
  body {
    grid-template-columns: 1fr;
    grid-template-rows: 55vh 1fr;
    grid-template-areas: "map" "sidebar";
  }
  #map {
    grid-area: map;
    min-height: 0;
  }
  #sidebar {
    grid-area: sidebar;
    min-height: 0;
    border-right: none;
    border-top: 1px solid var(--border);
  }
  #sidebar header { padding: 12px 16px 8px; }
  #sidebar h1 { font-size: 16px; }
  #sidebar .controls { padding: 8px 16px; }
  #sidebar footer {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
  #mission-list li { padding: 10px 16px; }
  #mission-list li.active { padding-left: 13px; }

  /* Detail panel becomes a full-screen overlay on mobile */
  #detail {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
    padding: 14px 18px calc(20px + env(safe-area-inset-bottom));
    overflow-y: auto;
    z-index: 100;
  }
  #detail-close {
    width: 36px; height: 36px;
    font-size: 24px;
    top: 6px; right: 8px;
  }
  #detail h2 { font-size: 17px; padding-right: 36px; }
  #detail-portals li { padding: 9px 0; font-size: 14px; gap: 6px; }
  #detail-portals img { width: 48px; height: 48px; }
  #detail-portals .portal-nav { width: 38px; height: 38px; }
  #detail-portals .portal-nav--maps { font-size: 18px; }
  #detail-portals .portal-nav--ingress { font-size: 16px; }
  .btn-primary { padding: 12px 14px; font-size: 14px; }
}

/* Very short landscape phones — keep a usable sidebar */
@media (max-width: 720px) and (max-height: 480px) {
  body { grid-template-rows: 60vh 1fr; }
}
