/* Look and feel shared with Satisfactory Map Renderer: Inter + Space Grotesk, light and dark theme; the accent is Factorio's orange. */
@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url("fonts/Inter-Regular.otf") format("opentype"); }
@font-face { font-family: "Inter"; font-weight: 500; font-display: swap; src: url("fonts/Inter-Medium.ttf") format("truetype"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url("fonts/Inter-SemiBold.ttf") format("truetype"); }
@font-face { font-family: "Space Grotesk"; font-weight: 500; font-display: swap; src: url("fonts/SpaceGrotesk-Medium.ttf") format("truetype"); }
@font-face { font-family: "Space Grotesk"; font-weight: 600; font-display: swap; src: url("fonts/SpaceGrotesk-SemiBold.ttf") format("truetype"); }
@font-face { font-family: "Space Grotesk"; font-weight: 700; font-display: swap; src: url("fonts/SpaceGrotesk-Bold.ttf") format("truetype"); }

:root {
  color-scheme: light;

  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-heading: "Space Grotesk", var(--font-body);
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, monospace;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-full: 999px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --dur: 0.35s;

  --color-bg: #f5f6f8;
  --color-bg-elevated: #ffffff;
  --color-bg-header: #12161f;
  --color-bg-header-text: #ffffff;
  --color-bg-subtle: #eef0f4;
  --color-text: #14181f;
  --color-text-muted: #62697a;
  --color-border: #e4e7ec;
  --color-input-border: #d7dbe3;
  --color-primary: #c96f12;
  --color-primary-ii: #e8a23a;
  --color-primary-soft: rgba(201, 111, 18, 0.12);
  --color-primary-text: #ffffff;
  --color-overlay: rgba(255, 255, 255, 0.88);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 12px 28px -14px rgba(15, 23, 42, 0.22);
  --shadow-lg: 0 24px 56px -22px rgba(15, 23, 42, 0.3);

  --sidebar-width: 340px;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --color-bg: #0a0c11;
  --color-bg-elevated: #12151d;
  --color-bg-header: #05070a;
  --color-bg-header-text: #f3f4f6;
  --color-bg-subtle: #161a23;
  --color-text: #e7eaf0;
  --color-text-muted: #8b93a5;
  --color-border: #232833;
  --color-input-border: #2c323f;
  --color-primary: #f0a03c;
  --color-primary-ii: #ffc56b;
  --color-primary-soft: rgba(240, 160, 60, 0.16);
  --color-primary-text: #06101f;
  --color-overlay: rgba(18, 21, 29, 0.88);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 16px 34px -16px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 32px 70px -26px rgba(0, 0, 0, 0.72);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme: dark;

    --color-bg: #0a0c11;
    --color-bg-elevated: #12151d;
    --color-bg-header: #05070a;
    --color-bg-header-text: #f3f4f6;
    --color-bg-subtle: #161a23;
    --color-text: #e7eaf0;
    --color-text-muted: #8b93a5;
    --color-border: #232833;
    --color-input-border: #2c323f;
    --color-primary: #f0a03c;
    --color-primary-ii: #ffc56b;
    --color-primary-soft: rgba(240, 160, 60, 0.16);
    --color-primary-text: #06101f;
    --color-overlay: rgba(18, 21, 29, 0.88);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 16px 34px -16px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 32px 70px -26px rgba(0, 0, 0, 0.72);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  font: 400 13.5px/1.5 var(--font-body);
}

::selection { background: var(--color-primary); color: var(--color-primary-text); }

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

#map {
  position: absolute;
  inset: 0 0 0 var(--sidebar-width);
  background: var(--color-bg);
}

body.collapsed #map { left: 0; }
body.collapsed #sidebar { transform: translateX(-100%); }

#sidebar {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  background: var(--color-bg-elevated);
  border-right: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  z-index: 1000;
  transition: transform var(--dur) var(--ease);
}

#sidebar header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  padding: 12px 16px;
  background: var(--color-bg-header);
  color: var(--color-bg-header-text);
}

#sidebar header::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 2px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-ii));
}

#sidebar h1 {
  flex: 1;
  margin: 0;
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 24px;
  background: var(--color-bg);
}

h2, summary {
  margin: 20px 0 8px;
  font-family: var(--font-heading);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  cursor: default;
}
summary { cursor: pointer; transition: color var(--dur) var(--ease); }
summary:hover { color: var(--color-primary); }

button {
  background: var(--color-bg-elevated);
  color: var(--color-text);
  border: 1px solid var(--color-input-border);
  border-radius: var(--r-full);
  cursor: pointer;
  font: 500 inherit;
  font-family: var(--font-heading);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
    border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
button:hover {
  transform: translateY(-1px);
  border-color: var(--color-primary);
  color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

#toggle-sidebar {
  width: 32px;
  height: 32px;
  font-size: 17px;
  background: none;
  border-color: rgba(255, 255, 255, 0.18);
  border-radius: var(--r-md);
  color: var(--color-bg-header-text);
}
#toggle-sidebar:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--color-primary-ii);
  color: var(--color-primary-ii);
}

#show-sidebar {
  display: none;
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1000;
  width: 40px;
  height: 40px;
  font-size: 18px;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
}
body.collapsed #show-sidebar { display: block; }

input[type=search], select {
  font: inherit;
  color: var(--color-text);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-input-border);
  border-radius: var(--r-sm);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
input[type=search] { width: 100%; padding: 8px 10px; }
select { padding: 5px 8px; }
input[type=search]:focus, select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}
input[type=checkbox] { accent-color: var(--color-primary); }

#search-results {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
}
#search-results li {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 8px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background-color var(--dur) var(--ease);
}
#search-results li:hover { background: var(--color-bg-subtle); }
#search-results .layer { margin-left: auto; color: var(--color-text-muted); font-size: 11px; white-space: nowrap; }

.layer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background-color var(--dur) var(--ease);
}
.group-body > .layer-row:hover { background: var(--color-bg-subtle); }
.layer-row label { flex: 1; display: flex; align-items: center; gap: 8px; cursor: pointer; min-width: 0; }
.layer-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-row .count { color: var(--color-text-muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.layer-row.empty { opacity: .45; }

.select-row { gap: 8px; }
.select-row label { flex: none; color: var(--color-text-muted); }
.select-row select { flex: 1; min-width: 0; }

.expand {
  width: 20px;
  height: 20px;
  padding: 0;
  font-size: 11px;
  line-height: 1;
  border: none;
  background: none;
  color: var(--color-text-muted);
}
.expand:hover { transform: none; box-shadow: none; }

.swatch {
  flex: none;
  width: 11px;
  height: 11px;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25);
}
.swatch.dot { border-radius: 50%; }

.legend-icon {
  flex: none;
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.legend {
  margin: 2px 6px 6px 30px;
  padding-left: 8px;
  border-left: 2px solid var(--color-border);
}
.legend[hidden] { display: none; }
.legend .layer-row { padding: 1px 0; font-size: 12px; }

.option { display: flex; gap: 8px; align-items: center; margin-top: 8px; color: var(--color-text-muted); cursor: pointer; }

table { width: 100%; border-collapse: collapse; }
td { padding: 4px 0; vertical-align: top; border-bottom: 1px solid var(--color-border); }
tr:last-child td { border-bottom: none; }
td:first-child { color: var(--color-text-muted); padding-right: 12px; white-space: nowrap; }
td:last-child { text-align: right; font-variant-numeric: tabular-nums; word-break: break-word; }
#counts { margin-top: 8px; }
/* Names can be long (unknown buildables show their class name): they wrap, the number never does. */
#counts td:first-child { white-space: normal; overflow-wrap: anywhere; }
#counts td:last-child { white-space: nowrap; word-break: normal; }

.hint { margin-top: 20px; color: var(--color-text-muted); font-size: 12px; }

#cursor {
  position: absolute;
  right: 12px;
  bottom: 24px;
  z-index: 1000;
  padding: 4px 10px;
  border-radius: var(--r-full);
  background: var(--color-overlay);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font: 12px var(--font-mono);
  pointer-events: none;
}

/* Leaflet overrides */
.leaflet-container { background: var(--color-bg); font: inherit; }
.leaflet-container a { color: var(--color-primary); }
.leaflet-popup-content-wrapper {
  background: var(--color-bg-elevated);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
}
.leaflet-popup-tip {
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  box-shadow: none;
}
.leaflet-popup-content { margin: 14px 16px; min-width: 200px; }
.leaflet-popup-content h3 {
  margin: 0 0 2px;
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--color-primary);
}
.leaflet-popup-content .sub { margin-bottom: 8px; color: var(--color-text-muted); font-size: 12px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--color-text-muted); }
.popup-icon { float: right; width: 44px; height: 44px; margin: 0 0 6px 10px; }

.leaflet-bar { border: 1px solid var(--color-border) !important; border-radius: var(--r-md); overflow: hidden; box-shadow: var(--shadow-md); }
.leaflet-bar a { background: var(--color-bg-elevated); color: var(--color-text); border-color: var(--color-border); transition: color var(--dur) var(--ease); }
.leaflet-bar a:hover { background: var(--color-bg-subtle); color: var(--color-primary); }
.leaflet-bar a.leaflet-disabled { background: var(--color-bg-subtle); color: var(--color-text-muted); }
.leaflet-control-attribution { background: var(--color-overlay) !important; color: var(--color-text-muted); border-top-left-radius: var(--r-sm); }
.leaflet-control-attribution a { color: var(--color-text-muted); }
.leaflet-tooltip.map-label {
  background: var(--color-overlay);
  border: 1px solid var(--color-border);
  border-radius: var(--r-full);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
  font: 500 11px var(--font-heading);
  padding: 1px 8px;
}
.leaflet-tooltip.map-label::before { display: none; }
.no-labels .leaflet-tooltip.map-label.permanent { display: none; }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; }
}

@media (max-width: 700px), (max-height: 500px) {
  :root { --sidebar-width: 100vw; }
  #map { left: 0; }
  body:not(.collapsed) #map { visibility: hidden; }
}

/* ---- Save game source */
#source details summary { margin: 12px 0 6px; }
.muted { color: var(--color-text-muted); }
.source-current { word-break: break-word; }
code { font: 12px var(--font-mono); background: var(--color-bg-subtle); padding: 1px 5px; border-radius: 5px; }

.drop-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  padding: 14px 10px;
  border: 1.5px dashed var(--color-input-border);
  border-radius: var(--r-md);
  color: var(--color-text-muted);
  background: var(--color-bg-subtle);
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}
body.dragging-file .drop-zone { border-color: var(--color-primary); background: var(--color-primary-soft); color: var(--color-text); }
body.dragging-file #map::after {
  content: "Drop the save file to load it";
  position: absolute;
  inset: 12px;
  z-index: 2000;
  display: grid;
  place-items: center;
  border: 2px dashed var(--color-primary);
  border-radius: var(--r-lg);
  background: var(--color-overlay);
  font: 600 18px var(--font-heading);
  pointer-events: none;
}

#source button { padding: 6px 14px; font-size: 12.5px; }
button.primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-ii));
  border-color: transparent;
  color: var(--color-primary-text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
button.primary:hover { color: var(--color-primary-text); border-color: transparent; box-shadow: var(--shadow-md); }
button.wide { width: 100%; margin-top: 12px; padding: 8px 14px !important; }

.source-form { display: flex; flex-direction: column; gap: 8px; }
.source-form label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--color-text-muted); min-width: 0; }
.source-form label.check { flex-direction: row; align-items: center; gap: 8px; font-size: inherit; color: var(--color-text); cursor: pointer; }
.source-form input:not([type=checkbox]) {
  width: 100%;
  padding: 6px 8px;
  font: inherit;
  color: var(--color-text);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-input-border);
  border-radius: var(--r-sm);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.source-form input:not([type=checkbox]):focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-soft); }
.field-row { display: flex; gap: 8px; }
.field-row label { flex: 1; }
.field-row label.narrow { flex: 0 0 84px; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.source-form .hint { margin: 2px 0 0; }

.server-info { padding: 8px 10px; border-radius: var(--r-sm); background: var(--color-bg-subtle); font-size: 12.5px; display: flex; flex-direction: column; gap: 4px; }
.pill { align-self: flex-start; padding: 1px 10px; border-radius: var(--r-full); font: 600 11.5px var(--font-heading); background: var(--color-border); color: var(--color-text); }
.server-info[data-state=ok] .pill { background: #dcfce7; color: #166534; }
.server-info[data-state=untested] .pill { background: #fef3c7; color: #92400e; }
.server-info[data-state=unsupported] .pill { background: #fee2e2; color: #991b1b; }

.source-status { margin-top: 10px; padding: 8px 10px; border-radius: var(--r-sm); background: var(--color-bg-subtle); font-size: 12.5px; }
.source-status[data-kind=error] { background: #fee2e2; color: #991b1b; }
.source-status[data-kind=ok] { background: #dcfce7; color: #166534; }

/* ---- Admin */
.admin-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.admin-head h2 { margin: 0 0 2px; }
.admin-head p { margin: 0; color: var(--color-text-muted); font-size: 12.5px; }
.admin-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--r-md);
  background: var(--color-primary-soft);
  color: var(--color-primary);
}
.admin-card > form > label { font-size: 12px; color: var(--color-text-muted); margin-bottom: -4px; }
.password-field { position: relative; }
.password-field input { padding-right: 38px !important; }
.password-field button {
  position: absolute;
  top: 50%;
  right: 4px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0 !important;
  transform: translateY(-50%);
  border: none;
  border-radius: var(--r-sm);
  background: none;
  color: var(--color-text-muted);
}
.password-field button:hover { transform: translateY(-50%); box-shadow: none; color: var(--color-primary); background: var(--color-primary-soft); }
.password-field button[aria-pressed=true] { color: var(--color-primary); }
.admin-card button.wide { margin-top: 4px; }
button:disabled { opacity: .6; cursor: default; transform: none !important; }
.admin-card.shake { animation: admin-shake .35s var(--ease); }
@keyframes admin-shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

/* Signed-in bar above the save game source */
.admin-session {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 8px 7px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--r-full);
  background: var(--color-bg-elevated);
  box-shadow: var(--shadow-sm);
}
.admin-badge { display: inline-flex; align-items: center; gap: 7px; font: 600 12.5px var(--font-heading); color: #166534; }
:root[data-theme="dark"] .admin-badge { color: #86efac; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .admin-badge { color: #86efac; } }
button.logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 10px;
  font-size: 12.5px;
  color: var(--color-text-muted);
}
button.logout svg { width: 15px; height: 15px; }
button.logout:hover { border-color: #dc2626; color: #dc2626; background: rgba(220, 38, 38, 0.08); }
@media (prefers-reduced-motion: reduce) { .admin-card.shake { animation: none; } }

#sidebar header .logo { flex: none; display: block; filter: drop-shadow(0 4px 10px rgba(37, 99, 235, 0.45)); }

/* ---- Nothing loaded yet */
#placeholder {
  position: absolute;
  inset: 0 0 0 var(--sidebar-width);
  z-index: 900;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(60% 50% at 50% 38%, var(--color-primary-soft), transparent 70%),
    linear-gradient(var(--color-border) 1px, transparent 1px) 0 0 / 48px 48px,
    linear-gradient(90deg, var(--color-border) 1px, transparent 1px) 0 0 / 48px 48px,
    var(--color-bg);
}
#placeholder[hidden] { display: none; }
body.collapsed #placeholder { left: 0; }
.placeholder-card {
  max-width: 440px;
  padding: 36px 36px 30px;
  text-align: center;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  animation: placeholder-in .45s var(--ease) both;
}
.placeholder-logo { display: block; margin: 0 auto 18px; border-radius: 20px; filter: drop-shadow(0 10px 22px rgba(37, 99, 235, 0.35)); }
.placeholder-card h2 {
  margin: 0 0 8px;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--color-text);
}
.placeholder-card p { margin: 0 0 20px; color: var(--color-text-muted); font-size: 14.5px; }
.placeholder-card button.primary { padding: 10px 22px; font-size: 14px; }
.placeholder-card ul { margin: 20px 0 0; padding: 16px 0 0; list-style: none; border-top: 1px solid var(--color-border); color: var(--color-text-muted); font-size: 13px; }
.placeholder-card li + li { margin-top: 6px; }
.placeholder-card b { color: var(--color-text); font-weight: 600; }
@keyframes placeholder-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Without a map the layer list, search and statistics have nothing to show. */
body.empty #tabs, body.empty #save-details, body.empty #cursor { display: none; }
@media (prefers-reduced-motion: reduce) { .placeholder-card { animation: none; } }
@media (max-width: 700px), (max-height: 500px) { #placeholder { left: 0; } body:not(.collapsed) #placeholder { visibility: hidden; } }

/* The hidden attribute must win over the display values set above. */
[hidden] { display: none !important; }
body.empty .leaflet-control-container { display: none; }

/* ---- Status bar: which save is shown */
#statusbar {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 950;
  max-width: min(420px, calc(100vw - var(--sidebar-width) - 90px));
  padding: 9px 14px 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  background: var(--color-overlay);
  backdrop-filter: blur(8px);
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
}
.status-name { display: flex; align-items: baseline; gap: 8px; min-width: 0; font: 600 14px var(--font-heading); letter-spacing: -0.01em; }
.status-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-name #status-session { flex: none; max-width: 100%; }
.status-name .muted { font: 400 12.5px var(--font-body); letter-spacing: 0; }
.status-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--color-text-muted); white-space: nowrap; }
#status-source { align-self: center; background: var(--color-primary-soft); color: var(--color-primary); }
#status-untested { align-self: center; background: #fef3c7; color: #92400e; cursor: help; }
:root[data-theme="dark"] #status-untested { background: #422006; color: #fcd34d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #status-untested { background: #422006; color: #fcd34d; } }
#status-source::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: currentColor; vertical-align: 1px; }
body.collapsed #statusbar { max-width: min(420px, calc(100vw - 80px)); }
@media (max-width: 700px), (max-height: 500px) { #statusbar { max-width: calc(100vw - 70px); } body:not(.collapsed) #statusbar { display: none; } }

/* ---- Progress of a save game being fetched and rendered */
.progress-track {
  height: 10px;
  border-radius: var(--r-full);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-ii));
  transition: width 0.25s var(--ease);
}
.progress-track.running .progress-bar { width: 35%; animation: progress-running 1.2s ease-in-out infinite; }
@keyframes progress-running { from { transform: translateX(-100%); } to { transform: translateX(290%); } }
@media (prefers-reduced-motion: reduce) {
  .progress-bar { transition: none; }
  .progress-track.running .progress-bar { animation: none; width: 100%; opacity: 0.5; }
}

/* ---- Side panel: tabs and cards */
#tabs {
  display: flex;
  padding: 0 6px;
  background: var(--color-bg-elevated);
  border-bottom: 1px solid var(--color-border);
}
#tabs button {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 2px 8px;
  border: none;
  border-radius: 0;
  background: none;
  color: var(--color-text-muted);
  font: 500 11.5px var(--font-heading);
  white-space: nowrap;
}
#tabs button:hover { transform: none; box-shadow: none; color: var(--color-text); }
#tabs button[aria-selected=true] { color: var(--color-primary); font-weight: 600; }
#tabs button::after {
  content: "";
  position: absolute;
  inset: auto 10px -1px 10px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-ii));
  transform: scaleX(0);
  transition: transform var(--dur) var(--ease);
}
#tabs button[aria-selected=true]::after { transform: scaleX(1); }

.tab-panel { display: flex; flex-direction: column; gap: 12px; }
.tab-panel > .hint { margin: 2px 4px 0; }
.card {
  padding: 12px 14px 14px;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
.card > h2:first-child { margin-top: 0; }
.card .hint { margin: 10px 0 0; }
.card .option:first-of-type { margin-top: 0; }
#layers { display: flex; flex-direction: column; gap: 10px; }

/* Layer groups fold; the header shows how many of the group's layers are on. */
.group {
  position: relative;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
.group-all {
  position: absolute;
  top: 18px;
  left: 14px;
  margin: 0;
  transform: translateY(-50%);
}
.group-fold > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 9px 12px 9px 40px;
  list-style: none;
  font: 600 13.5px var(--font-heading);
  letter-spacing: 0;
  text-transform: none;
  color: var(--color-text);
}
.group-fold > summary::-webkit-details-marker { display: none; }
.group-fold > summary::after {
  content: "▸";
  width: 20px;
  text-align: center;
  font-size: 11px;
  color: var(--color-text-muted);
  transition: transform var(--dur) var(--ease);
}
.group-fold[open] > summary::after { transform: rotate(90deg); }
.group-count {
  margin-left: auto;
  padding: 0 8px;
  border-radius: var(--r-full);
  background: var(--color-bg-subtle);
  color: var(--color-text-muted);
  font: 500 11.5px var(--font-body);
  font-variant-numeric: tabular-nums;
}
.group-body { padding: 4px 6px 8px 8px; border-top: 1px solid var(--color-border); }
.group-body .select-row { padding: 6px; }

#status-refresh {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  font-size: 16px;
}

.group-count:empty { display: none; }
.group-fold > summary .group-name { margin-right: auto; }
#search-results:empty { display: none; }

.load-logo { display: block; margin: 0 auto 16px; border-radius: 16px; filter: drop-shadow(0 10px 22px rgba(37, 99, 235, 0.35)); }
@keyframes load-fade { from { opacity: 0; } to { opacity: 1; } }

/* ---- Footer and update notice */
#sidebar-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
  color: var(--color-text-muted);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}
#sidebar-footer a { color: inherit; font-weight: 600; text-decoration: none; transition: color var(--dur) var(--ease); }
#sidebar-footer a:hover { color: var(--color-primary); }

#update-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-ii));
  color: var(--color-primary-text);
  font-size: 12.5px;
  text-decoration: none;
}
#update-banner b { font-family: var(--font-heading); font-weight: 600; }
.update-banner-link { margin-left: auto; white-space: nowrap; font: 600 12px var(--font-heading); opacity: .9; }
#update-banner:hover .update-banner-link { opacity: 1; text-decoration: underline; }
.update-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: update-pulse 2.4s infinite; }
@keyframes update-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }
#tabs button.has-update::before {
  content: "";
  position: absolute;
  top: 7px;
  left: calc(50% + 8px);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-primary-ii);
  box-shadow: 0 0 0 2px var(--color-bg-elevated);
}

.update-status { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-bottom: 12px; font-size: 13px; }
.update-status[data-state=ok] .pill { background: #dcfce7; color: #166534; }
.update-status[data-state=update] .pill { background: var(--color-primary-soft); color: var(--color-primary); }
.update-status[data-state=error] .pill { background: #fef3c7; color: #92400e; }
#about .button-row { margin-top: 12px; }
#about button { padding: 6px 14px; font-size: 12.5px; }
@media (prefers-reduced-motion: reduce) { .update-dot { animation: none; } }

/* Error boxes in the dark theme: dark red instead of the light theme's pink */
:root[data-theme="dark"] .source-status[data-kind=error], :root[data-theme="dark"] #render-modal.failed .render-done { background: #3a1414; color: #fca5a5; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .source-status[data-kind=error], :root:not([data-theme="light"]) #render-modal.failed .render-done { background: #3a1414; color: #fca5a5; }
}

/* What is new: shown once after an update */
#news-modal {
  position: fixed;
  inset: 0;
  z-index: 4900;
  display: grid;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--color-bg) 55%, transparent);
  backdrop-filter: blur(10px) saturate(0.9);
  -webkit-backdrop-filter: blur(10px) saturate(0.9);
  animation: load-fade .3s var(--ease) both;
}
#news-modal[hidden] { display: none; }
.news-card {
  display: flex;
  flex-direction: column;
  width: min(620px, 100%);
  max-height: min(760px, 100%);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: placeholder-in .45s var(--ease) both;
}
.news-card header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 26px 18px;
  background: linear-gradient(135deg, var(--color-primary-soft), transparent 70%);
  border-bottom: 1px solid var(--color-border);
}
.news-card header .load-logo { margin: 0; flex: none; }
.news-card header > div { flex: 1; min-width: 0; }
.news-kicker { margin: 0 0 2px; font: 700 11px var(--font-heading); letter-spacing: 0.12em; text-transform: uppercase; color: var(--color-primary); }
.news-card h2 { margin: 0; font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; text-transform: none; color: var(--color-text); }
.news-x { flex: none; align-self: flex-start; border: 0; background: none; color: var(--color-text-muted); font-size: 22px; line-height: 1; cursor: pointer; padding: 2px 6px; }
.news-x:hover { color: var(--color-text); }
.news-render {
  margin: 18px 26px 0;
  padding: 11px 14px;
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-primary);
  border-radius: var(--r-md);
  background: var(--color-bg-subtle);
  color: var(--color-text-muted);
  font-size: 13.5px;
  line-height: 1.5;
}
.news-render.stale { border-left-color: #f59e0b; background: color-mix(in srgb, #f59e0b 12%, var(--color-bg-elevated)); color: var(--color-text); }
.news-body { padding: 8px 26px 18px; overflow-y: auto; font-size: 14px; line-height: 1.55; }
.news-body h3 { margin: 18px 0 6px; font: 700 12px var(--font-heading); letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-text-muted); }
.news-body ul { margin: 10px 0 0; padding-left: 20px; }
.news-body li { margin: 0 0 8px; }
.news-body li::marker { color: var(--color-primary); }
.news-body code { padding: 1px 5px; border-radius: 4px; background: var(--color-bg-subtle); font-size: 12.5px; }
.news-card footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 26px; border-top: 1px solid var(--color-border); }
.news-card footer a { color: var(--color-primary); font-size: 13px; text-decoration: none; }
.news-card footer a:hover { text-decoration: underline; }
.news-card footer button.primary { padding: 9px 22px; font-size: 14px; }
.news-body h3.news-version { margin: 22px 0 0; padding-bottom: 6px; border-bottom: 1px solid var(--color-border); font-size: 14px; letter-spacing: 0; text-transform: none; color: var(--color-text); }
.news-body h3.news-version:first-child { margin-top: 12px; }

/* Server tab */
.server-name { margin: -4px 0 10px; color: var(--color-text-muted); font-size: 12.5px; }
.server-error { margin: 0 0 10px; padding: 9px 12px; border-radius: var(--r-md); background: color-mix(in srgb, #ef4444 12%, var(--color-bg-elevated)); border: 1px solid color-mix(in srgb, #ef4444 40%, var(--color-border)); font-size: 13px; }
.server-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.server-table td { padding: 5px 0; border-bottom: 1px solid var(--color-border); vertical-align: top; }
.server-table tr:last-child td { border-bottom: 0; }
.server-table td:first-child { padding-right: 12px; color: var(--color-text-muted); }
.server-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
#server-health[data-state="ok"] { background: color-mix(in srgb, #22c55e 22%, transparent); color: #15803d; }
#server-health[data-state="slow"] { background: color-mix(in srgb, #f59e0b 25%, transparent); color: #b45309; }
#server-health[data-state="down"] { background: color-mix(in srgb, #ef4444 22%, transparent); color: #b91c1c; }
:root[data-theme="dark"] #server-health[data-state="ok"] { color: #86efac; }
:root[data-theme="dark"] #server-health[data-state="slow"] { color: #fcd34d; }
:root[data-theme="dark"] #server-health[data-state="down"] { color: #fca5a5; }
.card h2 .pill { margin-left: 8px; vertical-align: middle; }
.server-command-row { display: flex; gap: 8px; margin-top: 6px; }
.server-command-row input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  background: var(--color-bg);
  color: var(--color-text);
  font: 12.5px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.server-command-row input:focus { outline: 2px solid var(--color-primary); outline-offset: 1px; }
.server-output { margin: 10px 0 0; padding: 10px 12px; max-height: 240px; overflow: auto; border-radius: var(--r-md); background: var(--color-bg-subtle); border: 1px solid var(--color-border); font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.server-buttons { display: flex; gap: 8px; margin-top: 14px; }
.server-buttons button { flex: 1; }
button.danger { border-color: color-mix(in srgb, #ef4444 55%, var(--color-border)); color: #dc2626; }
button.danger:hover { background: #dc2626; border-color: #dc2626; color: #fff; }
#tabs button[hidden] { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #server-health[data-state="ok"] { color: #86efac; }
  :root:not([data-theme="light"]) #server-health[data-state="slow"] { color: #fcd34d; }
  :root:not([data-theme="light"]) #server-health[data-state="down"] { color: #fca5a5; }
}
.server-list { margin-top: 12px; }
.server-list summary { cursor: pointer; font: 600 13px var(--font-heading); color: var(--color-primary); }
#server-list-items { list-style: none; margin: 10px 0 0; padding: 0; max-height: 340px; overflow-y: auto; border: 1px solid var(--color-border); border-radius: var(--r-md); }
#server-list-items li + li { border-top: 1px solid var(--color-border); }
#server-list-items li.none { padding: 10px; color: var(--color-text-muted); font-size: 12.5px; }
#server-list-items button {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  width: 100%; padding: 5px 9px; border: 0; border-radius: 0; background: none; box-shadow: none;
  font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--color-text); text-align: left; cursor: pointer;
}
#server-list-items button:hover { background: var(--color-primary-soft); transform: none; }
#server-list-items button span { overflow-wrap: anywhere; }
#server-list-items button b { font-weight: 500; }
#server-list-items button small { display: block; margin-top: 1px; font: 11.5px/1.35 var(--font-body, inherit); color: var(--color-text-muted); }
#server-list-items button em { flex: none; font: 500 10.5px var(--font-heading); color: var(--color-text-muted); }
#server-list-items button code { flex: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--color-text-muted); }

/* ---- The map being rendered: over the blurred map, for everybody, until it is done */
#render-modal {
  position: fixed;
  inset: 0;
  z-index: 6000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--color-bg) 40%, transparent);
  backdrop-filter: blur(14px) saturate(0.8);
  -webkit-backdrop-filter: blur(14px) saturate(0.8);
  animation: load-fade .3s var(--ease) both;
}
.render-card {
  display: flex;
  flex-direction: column;
  width: min(640px, 100%);
  max-height: min(860px, 100%);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: placeholder-in .45s var(--ease) both;
}
.render-card header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 26px 18px;
  background: linear-gradient(135deg, var(--color-primary-soft), transparent 70%);
  border-bottom: 1px solid var(--color-border);
}
.render-card header .load-logo { margin: 0; flex: none; }
.render-card h2 { margin: 0; font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; text-transform: none; color: var(--color-text); }
.render-save { margin: 3px 0 0; color: var(--color-text-muted); font-size: 13px; overflow-wrap: anywhere; }
.render-save:empty { display: none; }
.render-body { display: flex; flex-direction: column; min-height: 0; padding: 18px 26px 8px; overflow: auto; }
.render-intro { margin: 0 0 16px; color: var(--color-text-muted); font-size: 14px; line-height: 1.5; }
.render-now { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.render-percent { flex: none; font: 700 28px/1 var(--font-heading); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--color-text); }
.render-stage { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--color-text); font-weight: 600; font-size: 14px; }
.render-body .progress-track { height: 12px; margin: 12px 0 7px; }
.render-times { display: flex; justify-content: space-between; gap: 12px; color: var(--color-text-muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }

.render-steps { margin: 18px 0 0; padding: 6px 0 0; list-style: none; border-top: 1px solid var(--color-border); }
.render-steps li {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  column-gap: 12px;
  align-items: center;
  padding: 9px 0;
  color: var(--color-text-muted);
  transition: color var(--dur) var(--ease);
}
.render-steps li::before {
  content: "";
  grid-row: 1 / span 2;
  width: 22px;
  height: 22px;
  margin: 0 auto;
  box-sizing: border-box;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1.5px solid var(--color-input-border);
  font: 700 12px var(--font-heading);
}
.render-step-title { font: 600 13.5px var(--font-heading); }
.render-step-detail { grid-column: 2; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.render-step-detail:empty { display: none; }
.render-step-time { grid-column: 3; grid-row: 1; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.render-steps li[data-state=active] { color: var(--color-text); }
.render-steps li[data-state=active] .render-step-title { color: var(--color-primary); }
.render-steps li[data-state=active]::before {
  border-color: var(--color-primary-soft);
  border-top-color: var(--color-primary);
  border-width: 2.5px;
  animation: render-spin .9s linear infinite;
}
.render-steps li[data-state=done] { color: var(--color-text); }
.render-steps li[data-state=done]::before {
  content: "✓";
  border-color: transparent;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-ii));
  color: var(--color-primary-text);
}
.render-steps li[data-state=failed] { color: #b91c1c; }
.render-steps li[data-state=failed]::before { content: "✕"; border-color: transparent; background: #dc2626; color: #fff; }
@keyframes render-spin { to { transform: rotate(360deg); } }

.render-console { margin: 14px 0 10px; }
.render-console summary { cursor: pointer; width: fit-content; color: var(--color-text-muted); font: 600 13px var(--font-heading); }
.render-console summary span { font-weight: 400; }
.render-console pre {
  max-height: 260px;
  margin: 10px 0 0;
  padding: 12px 14px;
  overflow: auto;
  border-radius: var(--r-sm);
  border: 1px solid #1f2937;
  background: #0b0f14;
  color: #d1d5db;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.render-card footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 26px; border-top: 1px solid var(--color-border); }
.render-done { margin: 0; color: var(--color-text-muted); font-size: 13.5px; overflow-wrap: anywhere; }
#render-ok { flex: none; padding: 9px 26px; font-size: 14px; }
#render-ok:disabled { opacity: 0.45; cursor: progress; }
#render-modal.failed .progress-bar { background: #dc2626; }
#render-modal.failed .render-done { padding: 8px 12px; border-radius: var(--r-sm); background: #fee2e2; color: #991b1b; }
@media (prefers-reduced-motion: reduce) {
  #render-modal, .render-card { animation: none; }
  .render-steps li[data-state=active]::before { animation: none; border-color: var(--color-primary); }
}
@media (max-width: 600px) { .render-card header, .render-body, .render-card footer { padding-left: 16px; padding-right: 16px; } }

/* ---- Surfaces: planets as chips, space platforms in a list */
.surface-picker { margin-bottom: 12px; }
.planet-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.planet-chips button, #platform-items button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 5px;
  border: 1px solid var(--color-border);
  border-radius: var(--r-full);
  background: var(--color-bg-subtle);
  color: var(--color-text);
  font: 500 12.5px var(--font-body);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.planet-chips button:hover, #platform-items button:hover { border-color: var(--color-primary); }
.planet-chips button[aria-checked=true], #platform-items button[aria-checked=true] {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-weight: 600;
}
.planet-chips img, #platform-items img { width: 22px; height: 22px; }
.surface-dot { width: 22px; height: 22px; border-radius: 50%; background: var(--color-text-muted); opacity: 0.4; }
.platform-list { margin-top: 10px; }
#platform-items { display: flex; flex-direction: column; gap: 4px; padding: 0 8px 8px; }
#platform-items button { width: 100%; border-radius: var(--r-sm); background: var(--color-bg-elevated); text-align: left; }
#platform-items .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#platform-items .muted { font-size: 11.5px; }

/* Icons in names ("[item=iron-plate]") and in the statistics */
.rich-icon { width: 1.25em; height: 1.25em; vertical-align: -0.28em; margin: 0 1px; }
.icon-table { width: 100%; table-layout: fixed; border-collapse: collapse; margin-top: 8px; }
.icon-table td { padding: 3px 0; border-bottom: 1px solid var(--color-border); }
.icon-table td:last-child { width: 7.5em; padding-left: 8px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.with-icon { display: flex; align-items: center; gap: 8px; min-width: 0; }
.with-icon > span:last-child { overflow-wrap: anywhere; }
.table-icon { flex: none; width: 20px; height: 20px; }
#production-filter, #count-filter { width: 100%; }

/* One colour per game tile, enlarged without smoothing: the blocks stay sharp at every zoom */
.tiles-terrain img, .tiles-resources img, .tiles-nature img { image-rendering: pixelated; }

/* Uncharted ground is black in the game's map, whatever the page's theme */
#map.leaflet-container { background: #121417; }

/* Zoomed far out, train stops and tags would only cover each other: their names show on hover then */
.labels-far .leaflet-tooltip.map-label.permanent.minor { display: none; }

/* ---- The solar system: a star map instead of a surface */
body.space-view #map.leaflet-container {
  background:
    radial-gradient(1px 1px at 12% 18%, rgba(255, 255, 255, 0.7), transparent 60%),
    radial-gradient(1px 1px at 63% 42%, rgba(255, 255, 255, 0.55), transparent 60%),
    radial-gradient(1.5px 1.5px at 81% 77%, rgba(255, 255, 255, 0.6), transparent 60%),
    radial-gradient(1px 1px at 33% 71%, rgba(255, 255, 255, 0.5), transparent 60%),
    radial-gradient(ellipse at 50% 50%, #141a2a 0%, #07090f 70%);
  background-size: 180px 180px, 230px 230px, 310px 310px, 140px 140px, 100% 100%;
}
body.space-view #layers, body.space-view #layers + .hint { display: none; }
.space-planet.visited { cursor: pointer; transition: filter var(--dur) var(--ease); }
.space-planet.visited:hover { filter: brightness(1.25) drop-shadow(0 0 12px rgba(255, 210, 140, 0.6)); }
.space-label { width: auto !important; height: auto !important; }
.space-label span {
  display: inline-block;
  transform: translate(-50%, 4px);
  padding: 2px 10px;
  border-radius: var(--r-full);
  background: rgba(10, 12, 18, 0.75);
  color: #f3f4f6;
  font: 600 13px var(--font-heading);
  white-space: nowrap;
}
.space-platform { cursor: pointer; }
.space-platform img {
  width: 30px;
  height: 30px;
  padding: 3px;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  background: rgba(16, 20, 26, 0.85);
}
.space-platform.moving img { border-color: #f0a03c; box-shadow: 0 0 8px rgba(240, 160, 60, 0.7); }
.space-platform:hover img { filter: drop-shadow(0 0 6px rgba(255, 200, 120, 0.9)); }

/* ---- Phones and touch screens */
/* With the panel closed, its button sits where the zoom buttons are: they move below it. */
body.collapsed .leaflet-top.leaflet-left { top: 52px; }
/* the corners of a phone with a notch or a home bar */
#show-sidebar { top: calc(12px + env(safe-area-inset-top, 0px)); left: calc(12px + env(safe-area-inset-left, 0px)); }
#statusbar { top: calc(12px + env(safe-area-inset-top, 0px)); }
.leaflet-top { margin-top: env(safe-area-inset-top, 0px); }
.leaflet-left { margin-left: env(safe-area-inset-left, 0px); }
.leaflet-bottom { margin-bottom: env(safe-area-inset-bottom, 0px); }
.leaflet-right { margin-right: env(safe-area-inset-right, 0px); }
#sidebar header { padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
#sidebar-footer { padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }

/* Where there is little room next to the panel: the status bar on two lines, the save's name in full */
@media (max-width: 1100px) {
  .status-name { grid-column: 1; font-size: 13.5px; }
  .status-meta { grid-column: 1; grid-row: 2; font-size: 11.5px; }
  #status-refresh { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
}

/* The planets along the bottom of the map: only on a phone, with the panel closed */
#surface-bar { display: none; }

@media (max-width: 700px), (max-height: 500px) {
  body.collapsed #surface-bar:not([hidden]) {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    z-index: 900;
    display: flex;
    gap: 6px;
    padding: 6px calc(10px + env(safe-area-inset-right, 0px)) 6px calc(10px + env(safe-area-inset-left, 0px));
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  #surface-bar::-webkit-scrollbar { display: none; }
  #surface-bar button {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 4px 12px 4px 6px;
    border: 1px solid var(--color-border);
    border-radius: var(--r-full);
    background: var(--color-overlay);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: var(--shadow-md);
    color: var(--color-text);
    font: 500 13px var(--font-body);
    white-space: nowrap;
  }
  #surface-bar button:hover { transform: none; }
  #surface-bar button[aria-checked=true] { border-color: transparent; background: linear-gradient(135deg, var(--color-primary), var(--color-primary-ii)); color: var(--color-primary-text); font-weight: 600; }
  #surface-bar img, #surface-bar .surface-dot { width: 26px; height: 26px; }
  #surface-bar .muted { font-size: 12px; }

  /* the status bar between the panel button and the edge */
  #statusbar, body.collapsed #statusbar { left: calc(62px + env(safe-area-inset-left, 0px)); right: calc(10px + env(safe-area-inset-right, 0px)); max-width: none; padding: 7px 12px 8px; }

  .leaflet-control-attribution { max-width: calc(100vw - 20px); font-size: 10px; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .leaflet-popup-content { margin: 12px 14px; min-width: 0; }
  .space-label span { padding: 1px 8px; font-size: 11.5px; }

  /* windows over the map use the whole width */
  #render-modal, #news-modal { padding: 10px; }
}

/* Without a mouse the pointer's position means nothing; fingers need larger things to tap */
@media (hover: none) { #cursor { display: none; } }
@media (pointer: coarse) {
  .leaflet-touch .leaflet-bar a { width: 40px; height: 40px; line-height: 40px; font-size: 20px; }
  body.collapsed .leaflet-top.leaflet-left { top: 56px; }
  #show-sidebar { width: 44px; height: 44px; }
  #toggle-sidebar { width: 40px; height: 40px; }
  #tabs button { min-height: 48px; }
  .layer-row label { min-height: 36px; }
  .layer-row .expand { min-width: 36px; min-height: 36px; }
  input[type=checkbox] { width: 18px; height: 18px; }
  .planet-chips button, #platform-items button { min-height: 38px; }
  #search-results li { min-height: 40px; }
  input[type=search], select { min-height: 40px; font-size: 16px; } /* 16 px: iOS does not zoom into the field */
}
