html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

#map {
  position: absolute;
  inset: 0;
}

.mode-menu {
  position: absolute;
  z-index: 1000;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 2px;
  background: rgba(255, 255, 255, 0.92);
  padding: 4px;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, sans-serif;
}

.mode-menu button {
  border: none;
  background: none;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  font: inherit;
  color: #333;
}

.mode-menu button:hover {
  background: rgba(0, 0, 0, 0.06);
}

.mode-menu button.active {
  background: #3498db;
  color: #fff;
}

.legend {
  position: absolute;
  z-index: 1000;
  bottom: 12px;
  right: 12px;
  background: rgba(255, 255, 255, 0.92);
  padding: 10px 12px;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, sans-serif;
  max-width: 200px;
}

.legend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.legend-header h1 {
  font-size: 13px;
  margin: 0;
}

.legend-toggle {
  flex: none;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  color: #333;
  font: 14px/1 -apple-system, BlinkMacSystemFont, sans-serif;
  cursor: pointer;
}

.legend-toggle:hover {
  background: #f0f0f0;
}

.legend-body {
  margin-top: 6px;
}

.legend.collapsed .legend-body {
  display: none;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}

.legend-count {
  margin-top: 6px;
  color: #555;
  font-size: 12px;
}

.popup-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.popup-row {
  font-size: 13px;
}

.instagram-btn {
  display: block;
  margin-top: 6px;
  margin-bottom: 10px;
  font-size: 13px;
  color: #333;
  text-decoration: none;
}

.instagram-btn:hover {
  text-decoration: underline;
}

.leaflet-bar a.geolocation-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
}

.leaflet-bar a.geolocation-toggle.active {
  color: #3498db;
}

.legend-manage-link {
  display: block;
  margin-bottom: 8px;
  padding: 6px 10px;
  background: #3498db;
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
  text-align: center;
  font-weight: 600;
}

.legend-manage-link:hover {
  background: #2980b9;
}

.manage {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, sans-serif;
  color: #222;
}

.manage-nav {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  font-size: 13px;
  margin-bottom: 8px;
}

.manage-nav a {
  color: #3498db;
  text-decoration: none;
}

.manage-nav a:hover {
  text-decoration: underline;
}

.manage-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 12px;
}

.manage-header h1 {
  font-size: 20px;
  margin: 0;
}

#summary {
  color: #555;
  font-size: 13px;
}

.search-box {
  font-size: 13px;
  padding: 4px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  min-width: 0;
}

.found-only-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #333;
  cursor: pointer;
}

.filters-indicator {
  font-size: 13px;
  color: #555;
  margin: -4px 0 12px;
}

.filters-indicator a {
  color: #3498db;
  text-decoration: none;
}

.filters-indicator a:hover {
  text-decoration: underline;
}

/* Below the header's own max-width: 900px container, not a device-class
   breakpoint - just where "title, filter, summary" stops fitting on one
   line comfortably. Reorders onto separate lines: title, found-only,
   then the found-count summary. */
@media (max-width: 480px) {
  .manage-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .manage-header h1 {
    order: 1;
  }

  .manage-header .search-box {
    order: 2;
  }

  .manage-header .found-only-toggle {
    order: 3;
  }

  .manage-header #summary {
    order: 4;
  }

  /* Only the 404 page has a bare link as a .manage-header child (the
     "Back to map" link); with no order of its own it would default to 0
     and jump above the "404" heading in this reordered mobile layout. */
  .manage-header a {
    order: 5;
  }
}

/* A horizontal scrollbar on its own box, rather than squeezing cell text
   onto multiple lines when a column's content (namely city names) is
   wide - table.invaders' own overflow-x:auto would also make it the
   nearest scroll container for its sticky thead, breaking the "stays put
   while the page scrolls" behavior below. */
.table-scroll {
  overflow-x: auto;
}

table.invaders {
  width: 100%;
  border-collapse: collapse;
}

table.invaders thead th {
  position: sticky;
  top: 0;
  background: #fff;
  text-align: left;
  padding: 6px 8px;
  border-bottom: 2px solid #ddd;
  font-size: 12px;
  text-transform: uppercase;
  color: #666;
  white-space: nowrap;
}

table.invaders thead th.sortable {
  cursor: pointer;
  user-select: none;
}

table.invaders thead th.sortable:hover {
  color: #3498db;
}

table.invaders td {
  padding: 6px 8px;
  border-bottom: 1px solid #eee;
  white-space: nowrap;
}

table.invaders tr.found td {
  color: #999;
}

table.invaders td a {
  color: #3498db;
  text-decoration: none;
}

table.invaders td a:hover {
  text-decoration: underline;
}

.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 28px 0;
  font-size: 13px;
  color: #555;
}

.pagination button {
  padding: 6px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  font: inherit;
  cursor: pointer;
}

.pagination button:hover:not(:disabled) {
  background: #f0f0f0;
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: default;
}

/* #cities-list's own trailing space, via padding rather than a margin
   on its last .cities-section child - a child's bottom margin collapses
   through a parent with no bottom border/padding of its own, so it
   wouldn't actually create visible space past #cities-list's edge.
   Padding doesn't have that problem. */
#cities-list {
  padding-bottom: 40px;
}

/* Sections (one per country) are plain block <section>s, so they stack
   as rows one under another; only the city cards *within* a section
   use the grid/column layout below. Spacing between them (this doesn't
   need the #cities-list padding-bottom trick above, since it's between
   siblings, not against the parent's edge). */
.cities-section {
  margin-bottom: 20px;
}

.cities-section h2 {
  font-size: 14px;
  margin: 0 0 8px;
  color: #333;
}

.cities-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.cities-list a {
  display: block;
  padding: 8px 10px;
  background: #f4f4f4;
  border-radius: 4px;
  color: #222;
  text-decoration: none;
  font-size: 14px;
}

.cities-list a:hover {
  background: #e8e8e8;
}

.cities-list .city-name {
  display: block;
  font-weight: 600;
}

.cities-list .city-counts {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: normal;
  color: #555;
}

/* Pending cities use the plain grey above. These two are lighter tints
   at roughly the same lightness as that grey (#f4f4f4), not saturated
   colors, so the grid still reads as one calm system. */
.cities-list a.city-in-progress {
  background: #e3f4e6;
}

.cities-list a.city-in-progress:hover {
  background: #d3ebd7;
}

.cities-list a.city-destroyed {
  background: #fbe6e4;
}

.cities-list a.city-destroyed:hover {
  background: #f5d5d2;
}

.login {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f4f4f4;
}

.login-box {
  background: #fff;
  padding: 24px 28px;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  max-width: 320px;
  width: 90%;
  text-align: center;
}

.login-box h1 {
  font-size: 18px;
  margin: 0 0 8px;
}

.login-box p {
  margin: 0 0 12px;
  color: #555;
}

#login-form {
  display: flex;
  gap: 6px;
}

#login-email {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font: inherit;
}

#login-form button {
  padding: 8px 14px;
  border: none;
  border-radius: 4px;
  background: #3498db;
  color: #fff;
  font: inherit;
  cursor: pointer;
}

#login-form button:hover {
  background: #2980b9;
}

#login-form button:disabled {
  opacity: 0.6;
  cursor: default;
}

.login-message {
  margin: 10px 0 0;
  color: #2c7a2c;
  min-height: 1.2em;
}
