:root {
  font-size: 16px;
  color-scheme: dark light;
  --bg: #020617;
  --bg-alt: #0f172a;
  --card: rgba(15, 23, 42, 0.75);
  --card-border: rgba(148, 163, 184, 0.2);
  --muted: rgba(148, 163, 184, 0.8);
  --text: #e2e8f0;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --success: #22c55e;
  --error: #f87171;
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.3) transparent;
}
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.3);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(99, 102, 241, 0.55); }
::-webkit-scrollbar-corner { background: transparent; }

body {
  margin: 0;
  font-family: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, rgba(99, 102, 241, 0.12), transparent 55%), var(--bg);
  color: var(--text);
  min-height: 100vh;
}

html,
body {
  height: 100%;
}

a {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  background: linear-gradient(135deg, rgba(2, 8, 23, 0.95), rgba(15, 23, 42, 0.85));
  height: 100vh;
}

.sidebar {
  width: min(360px, 100%);
  border-right: 1px solid rgba(148, 163, 184, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(10, 15, 28, 0.8);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  pointer-events: none;
  z-index: 0;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  padding: 1.8rem 1.5rem 2.4rem;
  width: 100%;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  position: relative;
  z-index: 1;
}

.sidebar-header h1 {
  margin: 0 0 0.5rem;
  font-size: 1.45rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-logo {
  width: 1.75rem;
  height: 1.75rem;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-header p {
  margin: 0;
  color: rgba(148, 163, 184, 0.85);
  line-height: 1.4;
  font-size: 0.9rem;
}

.planner-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.form-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.uid-input-row {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.uid-input-row input {
  flex: 1;
  min-width: 0;
}

.uid-clear-btn {
  flex-shrink: 0;
  padding: 0 0.5rem;
  height: 2.1rem;
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 6px;
  color: #94a3b8;
  cursor: pointer;
  font-size: 0.75rem;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s;
}

.uid-clear-btn:hover {
  color: #f87171;
  border-color: #f87171;
}

.location-grid {
  display: grid;
  gap: 0.85rem;
}

.location-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.45rem 0;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.18);
}

.location-group:last-of-type {
  border-bottom: none;
}

.strategy-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.5rem 0;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 500;
}

.checkbox-inline input[type="checkbox"] {
  width: auto;
  height: auto;
}

.strategy-group label {
  font-weight: 600;
}

.strategy-group select {
  width: 100%;
}

.strategy-description {
  margin: 0;
  font-size: 0.8rem;
  color: rgba(148, 163, 184, 0.75);
}

.location-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.location-title {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.location-meta {
  font-size: 0.8rem;
  color: rgba(148, 163, 184, 0.75);
}

.location-row {
  display: flex;
  gap: 0.5rem;
}

.location-row input {
  flex: 1 1 auto;
}

.location-feedback {
  margin: 0;
  font-size: 0.85rem;
  color: rgba(148, 163, 184, 0.75);
}

.location-feedback.success {
  color: var(--success);
}

.location-feedback.error {
  color: var(--error);
}

label {
  font-size: 0.9rem;
  font-weight: 500;
  color: rgba(226, 232, 240, 0.85);
}

.hint {
  font-weight: 400;
  color: rgba(148, 163, 184, 0.8);
}

input,
button,
select {
  font-size: 1rem;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.55);
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: rgba(99, 102, 241, 0.65);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

.primary-button {
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: white;
  border: none;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.primary-button:hover,
.primary-button:focus {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(99, 102, 241, 0.35);
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: var(--text)!important;
  cursor: pointer;
  font-weight: 500;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.ghost-button:hover,
.ghost-button:focus {
  border-color: rgba(148, 163, 184, 0.55);
  background: rgba(148, 163, 184, 0.18);
}

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.35);
}

.loading,
.alert {
  padding: 1rem 1.25rem;
  font-size: 0.95rem;
}

.loading {
  text-align: center;
  font-weight: 600;
  color: rgba(226, 232, 240, 0.85);
}

.alert {
  color: var(--error);
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(248, 113, 113, 0.35);
}

.map-panel {
  position: relative;
  flex: 1;
  min-height: 100vh;
  overflow: hidden;
  background: radial-gradient(circle at center, rgba(99, 102, 241, 0.18), rgba(2, 6, 23, 0.7));
}

.map-surface {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 0;
  border: none;
  background: none;
  overflow: hidden;
}

.map-surface[hidden] {
  display: none;
}

.map-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* Direction arrows for final route */
.route-arrow {
  pointer-events: none;
}
.route-arrow-body {
  color: rgba(255,255,255,0.9);
  text-shadow: 0 0 6px rgba(37, 99, 235, 0.9), 0 0 2px rgba(2, 6, 23, 0.9);
  transform: translate(-50%, -50%);
}

/* Desktop: loading panel covers the full sidebar, terminal fills remaining space */
.map-progress-overlay[hidden] { display: none !important; }
.map-progress-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: rgba(10, 15, 28, 0.97);
  overflow: hidden;
  pointer-events: auto;
}

@keyframes map-spin {
  to { transform: rotate(360deg); }
}
@keyframes map-pill-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.5); }
  50%       { box-shadow: 0 0 0 4px rgba(99, 102, 241, 0); }
}
@keyframes map-log-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes map-shimmer {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

/* Invader type filter bar */
.map-filter-controls {
  position: absolute;
  top: calc(20px + env(safe-area-inset-top, 0px));
  left: 20px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.5rem;
}
.map-filter-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.3rem;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 8px;
  cursor: pointer;
  transition: opacity 0.15s ease, background 0.15s ease, border-color 0.15s ease, filter 0.15s ease;
  opacity: 1;
  position: relative;
}
.map-filter-btn img {
  display: block;
  width: 29px;
  height: 20px;
  image-rendering: pixelated;
}
.map-filter-btn:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.55);
}
.map-filter-btn--hidden {
  opacity: 0.55;
  background: none;
  border-color: transparent;
}
.map-filter-btn--hidden::after {
  content: '';
  position: absolute;
  inset: 4px;
  background: linear-gradient(to bottom right, transparent calc(50% - 1px), rgba(148, 163, 184, 0.7) calc(50% - 1px), rgba(148, 163, 184, 0.7) calc(50% + 1px), transparent calc(50% + 1px));
  pointer-events: none;
  border-radius: 4px;
}
.map-filter-btn--hidden:hover {
  opacity: 0.65;
  background: rgba(148, 163, 184, 0.08);
  border-color: rgba(148, 163, 184, 0.2);
}

.map-filter-combo {
  position: relative;
  display: inline-flex;
}
.map-filter-combo .map-filter-btn[data-type="flashed"] {
  padding-right: 0.6rem;
  padding-bottom: 0.6rem;
}
.map-filter-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  padding: 0;
  z-index: 1;
  pointer-events: none;
  background: none;
  border: none;
  line-height: 0;
  transition: opacity 0.15s ease;
}
.map-filter-badge img {
  display: block;
  width: 15px;
  height: 10px;
  image-rendering: pixelated;
}
.map-filter-badge--hidden {
  opacity: 0.35;
}

/* Top-right floating control cluster: profile (transport) selector and the
   field-mode toggle live here. Wrapping them in a flex row keeps the toggle
   aligned even when the select grows to fit "🚶 Piéton". */
.map-top-right-controls {
  position: fixed;
  top: calc(20px + env(safe-area-inset-top, 0px));
  right: 16px;
  z-index: 402;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.map-top-right-controls > * {
  pointer-events: auto;
}

.mobile-profile-select {
  display: block;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.35);
  color: var(--text);
  font-size: 1rem;
  line-height: 1;
  padding: 0.2rem 0.3rem;
  cursor: pointer;
  width: auto;
  min-width: 46px;
  height: 46px;
  touch-action: manipulation;
}
.mobile-profile-select:focus {
  outline: none;
  border-color: rgba(99, 102, 241, 0.7);
}

/* Field-mode toggle (desktop): pop the emoji-driven mobile UX into the
   desktop layout, useful for the Tesla browser where native form selects
   misbehave. Hidden on real mobile — that flow already is the mobile flow. */
.field-mode-toggle {
  display: none;
  width: 46px;
  height: 46px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.35);
  color: var(--text);
  cursor: pointer;
  padding: 0;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}
.field-mode-toggle svg {
  width: 22px;
  height: 22px;
}
.field-mode-toggle.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
@media (min-width: 1101px) {
  .field-mode-toggle {
    display: flex;
  }
}

/* Field-mode active on desktop: hide the planning sidebar so the map gets
   the full viewport, and surface the mobile-only chrome. */
body.force-mobile-ui .sidebar {
  display: none !important;
}
body.force-mobile-ui .app-shell {
  flex-direction: column;
}
body.force-mobile-ui .map-overlay {
  position: static;
  margin: 1rem;
  max-width: none;
}
body.force-mobile-ui .mobile-result-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  left: 12px;
  right: 12px;
  z-index: 401;
}
body.force-mobile-ui .mobile-result-bar[hidden] {
  display: none !important;
}
body.force-mobile-ui.hunt-active .mobile-result-bar {
  display: none !important;
}
body.force-mobile-ui .mobile-result-bar-secondary {
  display: flex;
  gap: 8px;
}
body.force-mobile-ui .mobile-result-bar-sec-btn {
  flex: 1;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
body.force-mobile-ui .mobile-result-bar-primary {
  display: flex;
  gap: 8px;
}
body.force-mobile-ui .hunt-start-fab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #15803d, #166534);
  color: white;
  border: none;
  border-radius: 12px;
  padding: 13px 20px;
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(21, 128, 61, 0.45);
  cursor: pointer;
}
body.force-mobile-ui .mobile-cancel-route-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: var(--muted);
  border-radius: 12px;
  width: 48px;
  font-size: 1.1rem;
  cursor: pointer;
}
body.force-mobile-ui .mobile-invader-sheet {
  position: fixed;
  left: auto;
  right: 16px;
  bottom: 16px;
  width: min(420px, calc(100vw - 32px));
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.55);
  z-index: 401;
  overflow: hidden;
  visibility: hidden;
  transform: translateY(calc(100% + 20px));
  transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s 0.26s;
}
body.force-mobile-ui .mobile-invader-sheet.open {
  visibility: visible;
  transform: translateY(0);
  transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s;
}
body.force-mobile-ui .mobile-invader-sheet-handle {
  width: 36px;
  height: 4px;
  background: rgba(148, 163, 184, 0.3);
  border-radius: 2px;
  margin: 10px auto 6px;
  cursor: pointer;
}
body.force-mobile-ui .mobile-invader-sheet-body {
  padding: 0 0.85rem 0.85rem;
}
body.force-mobile-ui .mobile-invader-sheet-body .invader-popup {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  width: auto;
  padding: 0;
}
body.force-mobile-ui .mobile-invader-sheet-body .invader-popup-img {
  width: 70px;
  min-width: 70px;
  height: 70px;
  border-radius: 9px;
  margin-bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
body.force-mobile-ui .mobile-invader-sheet-body .invader-popup-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
body.force-mobile-ui .mobile-invader-sheet-body .invader-popup-content {
  flex: 1;
  min-width: 0;
}
body.force-mobile-ui .mobile-invader-sheet-body .invader-popup-header {
  margin-bottom: 0.1rem;
}
body.force-mobile-ui .mobile-invader-sheet-body .invader-status {
  font-size: 0.78rem;
  margin: 0.1rem 0 0;
}
/* In field mode the floating field-mode toggle sits next to the emoji
   dropdown — keep it highlighted so the user can find their way back. */
body.force-mobile-ui .field-mode-toggle {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Cluster counter (low zoom) */
#cluster-counter {
  position: absolute;
  top: calc(62px + env(safe-area-inset-top, 0px));
  left: 20px;
  z-index: 3;
  pointer-events: none;
  padding: 0.5rem 0.7rem;
}
#cluster-counter .cluster-counter-inner {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
}
#cluster-counter .label {
  font-size: 0.8rem;
  color: rgba(148, 163, 184, 0.85);
}
#cluster-counter .value {
  font-weight: 700;
}

.map-progress-card {
  pointer-events: auto;
  padding: 1.5rem 1.5rem 1.2rem;
  color: var(--text);
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex-shrink: 0;
}

/* Header: spinner + real phase message */
.map-progress-header {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.map-progress-spinner {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(148, 163, 184, 0.25);
  border-top-color: var(--accent);
  animation: map-spin 0.75s linear infinite;
}
.map-progress-status {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  flex: 1;
}
.map-elapsed {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  opacity: 0.85;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Step stepper */
.map-progress-steps {
  display: flex;
  gap: 0.3rem;
}
.map-step {
  flex: 1;
  text-align: center;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.2rem 0.25rem;
  border-radius: 6px;
  background: rgba(148, 163, 184, 0.1);
  color: rgba(148, 163, 184, 0.45);
  transition: background 0.2s, color 0.2s;
}
.map-step.active {
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent);
}
.map-step.done {
  background: rgba(34, 197, 94, 0.12);
  color: rgba(34, 197, 94, 0.7);
}

/* Terminal log — fills remaining space inside the progress overlay */
.map-terminal {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  padding: 0.5rem 0.6rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0;
  box-sizing: border-box;
}

.map-log-entry {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.67rem;
  line-height: 1.55;
  display: flex;
  gap: 0.5rem;
  overflow: hidden;
  flex-shrink: 0;
}
.map-log-entry-new {
  animation: map-log-in 0.15s ease-out both;
}
.map-log-ts   { color: rgba(148, 163, 184, 0.35); flex-shrink: 0; width: 4.5ch; text-align: right; white-space: nowrap; }
.map-log-tag  { flex-shrink: 0; width: 6ch; font-weight: 700; white-space: nowrap; }
.map-log-msg  { color: rgba(226, 232, 240, 0.75); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.map-log-tag.tag-init    { color: rgba(148, 163, 184, 0.55); }
.map-log-tag.tag-data    { color: rgba(148, 163, 184, 0.55); }
.map-log-tag.tag-osrm    { color: #38bdf8; }
.map-log-tag.tag-algo    { color: #a78bfa; }
.map-log-tag.tag-step    { color: #4ade80; }
.map-log-tag.tag-opt     { color: #fb923c; }
.map-log-tag.tag-best    { color: #facc15; }
.map-log-tag.tag-done    { color: #34d399; }
.map-log-tag.tag-err     { color: #f87171; }

/* Algorithm pills */
.map-algo-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.map-algo-pill {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(148, 163, 184, 0.07);
  color: rgba(148, 163, 184, 0.45);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.map-algo-pill.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(99, 102, 241, 0.12);
  animation: map-pill-pulse 1s ease infinite;
}
.map-algo-pill.done {
  border-color: rgba(34, 197, 94, 0.45);
  color: rgba(34, 197, 94, 0.8);
  background: rgba(34, 197, 94, 0.08);
}

/* Best score */
.map-best-score {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.2);
}
.map-best-label {
  font-size: 0.68rem;
  opacity: 0.7;
  font-weight: 500;
}
.map-best-value {
  font-size: 0.78rem;
  font-weight: 700;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  color: var(--accent);
}

/* OSRM matrix info */
.map-matrix-info {
  font-size: 0.68rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  color: rgba(148, 163, 184, 0.6);
  text-align: center;
}

/* Joke message */
.map-progress-joke {
  font-style: italic;
  font-size: 0.72rem;
  opacity: 0.55;
  text-align: center;
  line-height: 1.3;
}

.map-progress-bar {
  margin-top: 0.5rem;
  height: 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.25);
  overflow: hidden;
}

.map-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #7c3aed, var(--accent));
  background-size: 200% 100%;
  animation: map-shimmer 1.8s linear infinite;
  transition: width 0.3s ease, box-shadow 0.2s ease;
  position: relative;
}

.map-overlay {
  position: absolute;
  top: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: min(420px, 45%);
  z-index: 2;
  pointer-events: none;
}

@media (min-width: 1101px) {
  /* Make room for the floating top-right controls (mobile-profile-select +
     field-mode-toggle) so they don't sit on top of the stats card. */
  .map-overlay {
    top: calc(20px + 46px + 14px);
  }
}

.stats {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.stats.card {
  padding: 1rem;
  pointer-events: auto;
}
.stats-placeholder {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 0.8rem;
  opacity: 0.5;
  margin: 0;
  padding: 0.25rem 0;
}

.stat-card {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 12px;
  padding: 0.9rem;
  text-align: left;
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.stat-card h2 {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.85);
}

.stat-card p {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 600;
}

.actions {
  display: flex;
  gap: 0.5rem;
  justify-content: stretch;
  align-items: center;
  flex-wrap: wrap;
}

.actions.card {
  padding: 0.75rem;
  pointer-events: auto;
}

.export-btns {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-left: auto;
  flex: 0 0 auto;
}
#download-csv,
#download-gpx {
  flex: none;
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  text-align: center;
}

.mission-action-btn {
  flex-direction: column;
  gap: 0.1rem;
}
.mission-btn-hint {
  font-size: 0.65rem;
  opacity: 0.5;
  font-weight: 400;
  line-height: 1;
}

/* Advanced stats button + modal */
.advanced-stats-btn {
  position: absolute;
  bottom: 14px;
  right: 14px;
  z-index: 4;
  background: rgba(2,6,23,0.65);
  border: 1px solid rgba(148,163,184,0.35);
  color: var(--text);
  padding: 0.55rem 0.85rem;
  border-radius: 10px;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.2s ease, border-color 0.2s ease;
}
.advanced-stats-btn:hover { background: rgba(2,6,23,0.82); border-color: rgba(148,163,184,0.55); }

.advanced-stats-modal {
  position: absolute;
  inset: 0;
  background: rgba(2,6,23,0.65);
  backdrop-filter: blur(4px);
  z-index: 40;
  padding: 1.5rem;
  display: none;
}
.advanced-stats-modal[hidden] { display: none !important; }
.advanced-stats-modal:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: center;
}
.advanced-stats-content {
  background: rgba(15,23,42,0.92);
  border: 1px solid rgba(148,163,184,0.25);
  border-radius: 18px;
  padding: 1.5rem 1.75rem 1.75rem;
  width: min(820px, 100%);
  max-height: 80vh;
  overflow: auto;
  box-shadow: 0 22px 48px -8px rgba(2,6,23,0.75);
}
.advanced-stats-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.advanced-stats-header h2 { margin: 0; font-size: 1.1rem; font-weight: 600; letter-spacing: 0.02em; }
.advanced-stats-body table { width: 100%; border-collapse: collapse; font-size: 0.75rem; margin: 0 0 1.25rem; }
.advanced-stats-body th, .advanced-stats-body td { padding: 0.45rem 0.6rem; text-align: left; border-bottom: 1px solid rgba(148,163,184,0.22); }
.advanced-stats-body th { background: rgba(2,6,23,0.55); position: sticky; top: 0; z-index: 1; }
.advanced-meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: 0.6rem 0.8rem; margin-bottom: 0.75rem; }
.advanced-meta-item { background: rgba(2,6,23,0.55); border: 1px solid rgba(148,163,184,0.18); border-radius: 10px; padding: 0.55rem 0.65rem; font-size: 0.65rem; line-height: 1.3; }
.advanced-meta-item .k { display: block; opacity: 0.65; font-weight: 500; }
.advanced-meta-item .v { display: block; font-weight: 600; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; }

.actions button,
.actions a {
  flex: 1;
  text-align: center;
  text-decoration: none;
}

.compass-fab {
  display: none;
}

.refresh-flash-fab {
  display: none;
}

.locate-me-fab {
  display: none;
}

@media (min-width: 1101px) {
  .locate-me-fab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 14px;
    bottom: 80px;
    z-index: 10;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--card);
    border: 1px solid var(--card-border);
    color: var(--text);
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    padding: 0;
    touch-action: manipulation;
    transition: background 0.15s ease, transform 0.15s ease;
  }
  .locate-me-fab:active {
    transform: scale(0.92);
  }
  .locate-me-fab svg {
    width: 22px;
    height: 22px;
  }
  .locate-me-fab.locating {
    color: var(--accent);
    border-color: rgba(99, 102, 241, 0.55);
  }
  .locate-me-fab.following {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.5);
  }
}

@media (max-width: 1100px) {
  .locate-me-fab,
  .compass-fab,
  .refresh-flash-fab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 16px;
    z-index: 10;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--card);
    border: 1px solid var(--card-border);
    color: var(--text);
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    padding: 0;
    transition: background 0.15s ease, transform 0.15s ease, bottom 0.26s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .locate-me-fab {
    bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 14px);
    transition: bottom 0.2s ease;
  }
  .compass-fab {
    bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 14px + 46px + 10px);
    transition: bottom 0.2s ease;
  }
  .refresh-flash-fab {
    bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 14px + 46px + 10px + 46px + 10px);
    transition: bottom 0.2s ease;
  }
  /* Lift controls above result bar when it's visible */
  body:has(#mobile-result-bar:not([hidden])) .locate-me-fab {
    bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 100px + 14px);
  }
  body:has(#mobile-result-bar:not([hidden])) .compass-fab {
    bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 100px + 14px + 46px + 10px);
  }
  body:has(#mobile-result-bar:not([hidden])) .refresh-flash-fab {
    bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 100px + 14px + 46px + 10px + 46px + 10px);
  }
  body:has(#mobile-result-bar:not([hidden])) .leaflet-bottom.leaflet-left {
    bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 100px + 14px);
  }
  .locate-me-fab:active,
  .compass-fab:active,
  .refresh-flash-fab:active {
    transform: scale(0.92);
  }
  .locate-me-fab svg,
  .compass-fab svg,
  .refresh-flash-fab svg {
    width: 22px;
    height: 22px;
  }
  .locate-me-fab.locating {
    color: var(--accent);
    border-color: rgba(99, 102, 241, 0.55);
  }
  .locate-me-fab.following {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.5);
  }
  .compass-fab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.5);
  }
  .refresh-flash-fab.refreshing {
    color: var(--accent);
    border-color: rgba(99, 102, 241, 0.55);
  }
  .refresh-flash-fab.refreshing .refresh-flash-icon {
    animation: refresh-spin 0.8s linear infinite;
  }
  .refresh-flash-fab.success {
    background: var(--success, #22c55e);
    border-color: var(--success, #22c55e);
    color: #fff;
    box-shadow: 0 4px 20px rgba(34, 197, 94, 0.5);
  }
  .refresh-flash-fab.error {
    background: #ef4444;
    border-color: #ef4444;
    color: #fff;
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.5);
  }
  #compass-svg {
    transition: transform 0.15s ease;
  }
}

@keyframes refresh-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@media (max-width: 1100px) {
  .app-shell {
    flex-direction: column;
    height: calc(100dvh - 56px - env(safe-area-inset-bottom, 0px));
    min-height: unset;
  }

  /* Tab bar */
  .mobile-tabs {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: rgba(10, 15, 28, 0.97);
    backdrop-filter: blur(12px);
    border-top: 1px solid rgba(148, 163, 184, 0.15);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    height: calc(56px + env(safe-area-inset-bottom, 0px));
  }

  .mobile-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(148, 163, 184, 0.6);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    min-height: unset;
    border-radius: 0;
    transition: color 0.2s ease;
  }

  .mobile-tab.active {
    color: var(--accent);
  }

  .mobile-tab svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }

  /* Hide inactive panel */
  .sidebar[data-hidden],
  .map-panel[data-hidden] {
    display: none !important;
  }

  /* On mobile, loading panel floats above the map at the bottom */
  .map-progress-overlay {
    position: fixed;
    inset: auto 12px calc(56px + env(safe-area-inset-bottom, 0px) + 10px) 12px;
    background: transparent;
    padding: 0;
    overflow-y: visible;
    gap: 0.5rem;
  }
  .map-progress-card {
    background: rgba(2, 6, 23, 0.93);
    border: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: 0 8px 32px rgba(2, 6, 23, 0.8);
  }
  .map-terminal {
    display: none !important;
  }

  .sidebar {
    width: 100%;
    height: 100%;
    border-right: none;
    border-bottom: none;
    overflow: hidden;
  }

  .sidebar-inner {
    padding-top: max(1.8rem, env(safe-area-inset-top, 0px));
    overflow-y: auto;
    flex: 1;
    min-height: 0;
  }

  .map-panel {
    height: 100%;
    min-height: unset;
  }

  .map-overlay {
    position: static;
    margin: 1.5rem;
    max-width: none;
  }

  /* Mobile invader bottom sheet */
  .mobile-invader-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    background: var(--card);
    border: 1px solid var(--card-border);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.55);
    z-index: 401;
    overflow: hidden;
    visibility: hidden;
    transform: translateY(calc(100% + 20px));
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s 0.26s;
  }
  .mobile-invader-sheet.open {
    visibility: visible;
    transform: translateY(0);
    transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s;
  }
  .mobile-invader-sheet-handle {
    width: 36px;
    height: 4px;
    background: rgba(148, 163, 184, 0.3);
    border-radius: 2px;
    margin: 10px auto 6px;
    flex-shrink: 0;
    cursor: pointer;
  }
  .mobile-invader-sheet-handle:active {
    background: rgba(148, 163, 184, 0.55);
  }
  .mobile-invader-sheet-body {
    padding: 0 0.85rem 0.85rem;
  }
  .mobile-invader-sheet-body .invader-popup {
    display: flex;
    gap: 0.7rem;
    align-items: center;
    width: auto;
    padding: 0;
  }
  .mobile-invader-sheet-body .invader-popup-img {
    width: 70px;
    min-width: 70px;
    height: 70px;
    border-radius: 9px;
    margin-bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }
  .mobile-invader-sheet-body .invader-popup-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }
  .mobile-invader-sheet-body .invader-popup-content {
    flex: 1;
    min-width: 0;
  }
  .mobile-invader-sheet-body .invader-popup-header {
    margin-bottom: 0.1rem;
  }
  .mobile-invader-sheet-body .invader-status {
    font-size: 0.78rem;
    margin: 0.1rem 0 0;
  }
}

/* Compact stats chips (mobile sheet) */
.invader-stats-compact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
  margin-top: 0.35rem;
  align-items: center;
}
.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 6px;
  padding: 0.17rem 0.38rem;
  font-size: 0.69rem;
  white-space: nowrap;
  color: var(--text);
  text-decoration: none;
  line-height: 1.4;
}
.stat-chip-label {
  color: rgba(148, 163, 184, 0.65);
}
.stat-chip-ig {
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.stat-chip-ig:hover { border-color: rgba(225, 48, 108, 0.5); color: #e1306c; }

/* Highlight ring on selected invader */
@keyframes invader-ring-pulse {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 0.3; }
}
.invader-highlight-ring {
  animation: invader-ring-pulse 1.6s ease-in-out infinite;
}

@media (max-width: 700px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .sidebar-inner {
    padding: 1.75rem 1.25rem;
    padding-top: max(1.75rem, env(safe-area-inset-top, 0px));
  }

  .map-overlay {
    margin: 1rem;
  }

  /* Touch targets */
  input,
  button,
  select {
    min-height: 44px;
  }

  /* Location header : stack on narrow screens */
  .location-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  #use-geolocation {
    width: 100%;
  }
}

/* Leaflet popup theming */
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--card-border);
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.45);
}
.leaflet-popup-content {
  margin: 0;
}

/* Invader popup card */
.invader-popup {
  width: 240px;
  padding: 0.7rem;
}
.invader-popup-img {
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  margin-bottom: 0.5rem;
  display: block;
}
.invader-popup-img--link {
  cursor: pointer;
}
.invader-popup-img--link:active {
  opacity: 0.8;
}
.invader-popup-img img {
  display: block;
  width: 100%;
  height: 140px;
  object-fit: cover;
}
.invader-popup-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}
.invader-title {
  font-weight: 700;
  letter-spacing: 0.01em;
}
.invader-badges {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(148, 163, 184, 0.12);
}
.badge-destroyed {
  color: #fecaca;
  border-color: rgba(248, 113, 113, 0.45);
  background: rgba(239, 68, 68, 0.12);
}
.badge-flashed {
  color: #bbf7d0;
  border-color: rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.12);
}
.badge-reactivated {
  color: #fed7aa;
  border-color: rgba(249, 115, 22, 0.45);
  background: rgba(249, 115, 22, 0.12);
}
.invader-stats-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin: 0.5rem 0 0.35rem;
}
.invader-stat {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 10px;
  padding: 0.5rem 0.6rem;
}
.invader-stat .label {
  display: block;
  font-size: 0.75rem;
  color: rgba(148, 163, 184, 0.85);
}
.invader-stat .value {
  font-size: 1.1rem;
  font-weight: 700;
}
.invader-status {
  font-size: 0.9rem;
  color: rgba(226, 232, 240, 0.9);
  margin: 0.25rem 0 0.4rem;
}
.invader-meta-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 0.4rem;
}
.invader-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  background: rgba(15, 23, 42, 0.5);
  border: 1px dashed rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
}
.invader-meta .meta {
  color: rgba(148, 163, 184, 0.85);
}
.invader-actions {
  margin-top: 0.6rem;
  display: flex;
  gap: 0.5rem;
}
.invader-action {
  padding: 0.55rem 0.75rem;
}

/* City stats floating button */
.city-stats-btn {
  position: absolute;
  bottom: 14px;
  left: 14px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(2, 6, 23, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: var(--text);
  padding: 0.55rem 0.85rem;
  border-radius: 10px;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.2s ease, border-color 0.2s ease;
}
.city-stats-btn:hover { background: rgba(2, 6, 23, 0.82); border-color: rgba(148, 163, 184, 0.55); }
.timeline-visible .city-stats-btn { bottom: calc(62px + 14px); }

/* City stats modal */
.city-stats-modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.city-stats-modal[hidden] { display: none !important; }
.city-stats-modal:not([hidden]) { display: flex; }

.city-stats-content {
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 18px;
  padding: 1.5rem 1.75rem 1.75rem;
  width: min(860px, 100%);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 24px 56px -8px rgba(2, 6, 23, 0.8);
}

.city-stats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.city-stats-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.city-stats-body {
  overflow-y: auto;
  flex: 1;
}

.city-stats-loading {
  text-align: center;
  padding: 2rem;
  color: rgba(148, 163, 184, 0.75);
}

.city-stats-note {
  font-size: 0.78rem;
  color: rgba(148, 163, 184, 0.65);
  margin: 0 0 0.75rem;
}

.city-stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.city-stats-table th {
  background: rgba(2, 6, 23, 0.6);
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-weight: 600;
  color: rgba(148, 163, 184, 0.85);
  border-bottom: 1px solid rgba(148, 163, 184, 0.22);
  white-space: nowrap;
}
.city-stats-table td {
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  white-space: nowrap;
}
.city-stats-table tr:last-child td { border-bottom: none; }
.city-stats-table tr:hover td { background: rgba(99, 102, 241, 0.07); }
.city-stats-table .td-city { font-weight: 600; color: var(--text); }
.city-stats-table .td-num { text-align: right; font-variant-numeric: tabular-nums; }
.city-stats-table .td-remaining { color: #86efac; font-weight: 600; }
.city-stats-table .td-captured { color: #a5b4fc; }

/* City stats modal — tabs */
.city-stats-tabs {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  padding-bottom: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.city-stats-tabs::-webkit-scrollbar { display: none; }

.city-stats-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.45rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: rgba(148, 163, 184, 0.65);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
  margin-bottom: -1px;
}
.city-stats-tab:hover { color: rgba(148, 163, 184, 0.9); }
.city-stats-tab--active {
  color: #a5b4fc;
  border-bottom-color: #a5b4fc;
}

.city-stats-tab-panel { display: none; }
.city-stats-tab-panel--active { display: block; }
.city-stats-tab-panel[hidden] { display: none !important; }

/* Sessions list */
.sessions-list { display: flex; flex-direction: column; gap: 1.5rem; padding: 0.25rem 0 0.5rem; }

.sessions-month-group {}
.sessions-month-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: rgba(148, 163, 184, 0.5);
  margin-bottom: 0.65rem;
}
.sessions-month-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(148, 163, 184, 0.12);
}
.sessions-month-count {
  font-weight: 500;
  color: rgba(148, 163, 184, 0.35);
  text-transform: none;
  letter-spacing: 0;
}

.sessions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}

.session-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  transition: border-color 0.15s, background 0.15s;
  min-width: 0;
}
.session-card:hover {
  border-color: rgba(99, 102, 241, 0.35);
  background: rgba(99, 102, 241, 0.06);
}
.session-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}
.session-card-heading {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.session-card-day {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}
.session-card-city {
  font-size: 0.72rem;
  color: #a5b4fc;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.session-card-time {
  font-size: 0.73rem;
  color: rgba(148, 163, 184, 0.45);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}
.session-card-pts {
  font-size: 1.35rem;
  font-weight: 800;
  color: #86efac;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.session-card-pts span {
  font-size: 0.75rem;
  font-weight: 500;
  color: rgba(134, 239, 172, 0.6);
  margin-left: 2px;
}
.session-card-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.session-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 20px;
  padding: 0.18rem 0.5rem;
  font-size: 0.72rem;
  color: rgba(148, 163, 184, 0.75);
  white-space: nowrap;
}
.session-pill--inv { border-color: rgba(165, 180, 252, 0.25); color: #a5b4fc; }
.session-pill--ppm { border-color: rgba(134, 239, 172, 0.2); color: #86efac; }

@media (max-width: 720px) {
  .sessions-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .sessions-grid { grid-template-columns: 1fr; }
}

/* Global stats */
.global-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.65rem;
  padding: 0.25rem 0 1rem;
}
.global-stat-card {
  background: rgba(2, 6, 23, 0.45);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 10px;
  padding: 0.75rem 1rem;
}
.global-stat-card .stat-label {
  font-size: 0.73rem;
  color: rgba(148, 163, 184, 0.6);
  margin-bottom: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.global-stat-card .stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.1;
}
.global-stat-card .stat-value.accent-green { color: #86efac; }
.global-stat-card .stat-value.accent-violet { color: #a5b4fc; }
.global-stat-card .stat-sub {
  font-size: 0.73rem;
  color: rgba(148, 163, 184, 0.5);
  margin-top: 0.2rem;
}
.global-stats-section-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(148, 163, 184, 0.55);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0.75rem 0 0.4rem;
}

/* City stats — responsive */
@media (max-width: 600px) {
  .city-stats-table .td-hide-mobile { display: none; }
  .city-stats-table td, .city-stats-table th { padding: 0.4rem 0.5rem; font-size: 0.78rem; }
  .global-stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1100px) {
  .city-stats-btn { display: none; }
  #session-panel-toggle { display: none !important; }
  #advanced-stats-btn { display: none !important; }

  .city-stats-modal:not([hidden]) {
    position: static !important;
    inset: unset;
    display: flex !important;
    flex-direction: column;
    flex: 1;
    background: var(--bg);
    backdrop-filter: none;
    padding: 0;
    align-items: stretch;
    justify-content: flex-start;
    z-index: auto;
    overflow-y: auto;
  }
  .city-stats-content {
    border-radius: 0;
    border: none;
    max-height: none;
    max-width: none;
    width: 100%;
    flex: 1;
    overflow-y: auto;
    padding: 1.2rem 1rem 1.5rem;
    background: transparent;
  }
  .city-stats-header .ghost-button { display: none; }
}

/* Mobile tab bar — hidden on desktop */
@media (min-width: 1101px) {
  .mobile-tabs {
    display: none;
  }
}

/* Session numbered markers */
.session-marker {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  border: 2px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

/* Missed invader markers */
.missed-marker {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(234, 179, 8, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1a1200;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  border: 2px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

/* Session panel toggle button */
.session-panel-toggle {
  position: absolute;
  bottom: 50px;
  right: 14px;
  z-index: 4;
  background: rgba(2, 6, 23, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: var(--text);
  padding: 0.55rem 0.85rem;
  border-radius: 10px;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.2s ease, border-color 0.2s ease;
}
.session-panel-toggle:hover { background: rgba(2, 6, 23, 0.82); border-color: rgba(148, 163, 184, 0.55); }

/* Session panel drawer */
.session-panel {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 260px;
  background: rgba(10, 15, 28, 0.93);
  backdrop-filter: blur(14px);
  border-left: 1px solid rgba(148, 163, 184, 0.14);
  z-index: 10;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}
.session-panel.open { transform: translateX(0); }

.session-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  flex-shrink: 0;
  font-size: 0.82rem;
  font-weight: 500;
  color: rgba(148, 163, 184, 0.85);
}
.session-panel-header strong { color: var(--text); }

.session-panel-close {
  background: none;
  border: none;
  color: rgba(148, 163, 184, 0.6);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.1rem 0.35rem;
  line-height: 1;
  border-radius: 4px;
}
.session-panel-close:hover { color: var(--text); background: rgba(148, 163, 184, 0.1); }

.session-panel-options {
  padding: 0.5rem 0.85rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.1);
  flex-shrink: 0;
  font-size: 0.8rem;
}

.session-panel-list {
  overflow-y: auto;
  flex: 1;
  padding: 0.2rem 0;
}

.session-panel-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(148, 163, 184, 0.06);
  font-size: 0.8rem;
  transition: background 0.1s ease;
}
.session-panel-item:hover { background: rgba(99, 102, 241, 0.12); }

.session-item-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #6366f1;
  color: white;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.session-item-id {
  flex: 1;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.session-item-pts {
  color: rgba(148, 163, 184, 0.7);
  font-size: 0.72rem;
  white-space: nowrap;
}
.session-badge {
  font-size: 0.62rem;
  padding: 0.1rem 0.28rem;
  border-radius: 4px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.session-badge-destroyed { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.session-badge-reactivated { background: rgba(249, 115, 22, 0.2); color: #fdba74; }

/* Cluster markers */
.cluster-div-icon { }
.cluster-marker {
  position: relative;
  width: 54px;
  height: 54px;
  border-radius: 999px;
  border: 3px solid #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45), 0 0 0 1.5px rgba(0,0,0,0.15);
  overflow: hidden;
  background: #1e293b;
}
.cluster-pie {
  position: absolute;
  inset: 0;
}
.cluster-inner-ring {
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: #0f172a;
}
.cluster-count {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 14px;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

@media (max-width: 1100px) {
  .leaflet-bottom.leaflet-left {
    bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 14px);
    left: 16px;
  }
}

.live-dot {
  width: 18px;
  height: 18px;
  background: #6366f1;
  border: 2.5px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 0 4px rgba(99,102,241,0.22);
}

/* ── History Timeline (desktop only) ──────────────────────────── */
.history-timeline { display: none; }

@media (min-width: 1101px) {
  .history-timeline {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    height: 62px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 18px;
    background: rgba(8, 13, 26, 0.9);
    backdrop-filter: blur(14px);
    border-top: 1px solid rgba(148, 163, 184, 0.13);
  }

  .history-timeline[hidden] { display: none !important; }

  .history-timeline-info {
    flex: 0 0 190px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
  }

  .history-timeline-date {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .history-timeline-meta {
    font-size: 0.7rem;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .history-timeline-track-wrap {
    flex: 1;
    position: relative;
    height: 100%;
    min-width: 0;
  }

  .history-timeline-axis {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 2px;
    background: rgba(148, 163, 184, 0.18);
    border-radius: 2px;
    pointer-events: none;
  }

  .history-timeline-track {
    position: absolute;
    inset: 0;
  }

  .history-tick {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: rgba(148, 163, 184, 0.35);
    border: 1.5px solid rgba(148, 163, 184, 0.45);
    cursor: pointer;
    padding: 0;
    transition: background 0.15s, border-color 0.15s, width 0.15s, height 0.15s, box-shadow 0.15s;
  }

  .history-tick:hover {
    background: var(--accent);
    border-color: var(--accent);
    width: 12px;
    height: 12px;
  }

  .history-tick--past {
    background: rgba(99, 102, 241, 0.45);
    border-color: rgba(99, 102, 241, 0.55);
  }

  .history-tick--active {
    background: var(--accent);
    border-color: var(--accent);
    width: 13px;
    height: 13px;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.28), 0 0 10px rgba(99, 102, 241, 0.5);
  }

  .history-timeline-controls {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 5px;
  }

  .history-ctrl-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: rgba(148, 163, 184, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.18);
    color: var(--text);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    min-height: unset;
  }

  .history-ctrl-btn:hover {
    background: rgba(148, 163, 184, 0.18);
    border-color: rgba(148, 163, 184, 0.35);
  }

  .history-ctrl-btn:disabled {
    opacity: 0.3;
    cursor: default;
  }

  .history-ctrl-btn--close {
    font-size: 0.72rem;
    color: var(--muted);
    margin-left: 6px;
  }

  .history-ctrl-btn--playing {
    background: rgba(99, 102, 241, 0.18);
    border-color: rgba(99, 102, 241, 0.5);
    color: var(--accent);
  }
}

/* ── Hunt Mode ──────────────────────────────────────────────────────────────── */

.hunt-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 500;
  height: calc(48px + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  background: rgba(8, 13, 26, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(148, 163, 184, 0.13);
}

.hunt-topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 12px;
  gap: 8px;
}

.hunt-exit-btn,
.hunt-list-btn {
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid rgba(148, 163, 184, 0.18);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.hunt-exit-btn:hover,
.hunt-list-btn:hover {
  background: rgba(148, 163, 184, 0.2);
}

.hunt-topbar-progress {
  flex: 1;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.hunt-active #map-container {
  padding-top: 48px;
}

/* Shift absolute/fixed elements down to clear the hunt topbar */
body.hunt-active .map-filter-controls {
  top: calc(68px + env(safe-area-inset-top, 0px));
}

body.hunt-active .map-top-right-controls {
  top: calc(68px + env(safe-area-inset-top, 0px));
}

/* Lift map controls above the hunt card */
body.hunt-active .locate-me-fab {
  bottom: calc(var(--hunt-card-h, 180px) + 14px);
}
body.hunt-active .compass-fab {
  bottom: calc(var(--hunt-card-h, 180px) + 14px + 46px + 10px);
}
body.hunt-active .refresh-flash-fab {
  bottom: calc(var(--hunt-card-h, 180px) + 14px + 46px + 10px + 46px + 10px);
}
body.hunt-active .leaflet-bottom.leaflet-left {
  bottom: calc(var(--hunt-card-h, 180px) + 14px);
}

/* Slidein sheet appears above hunt card in hunt mode, fully opaque */
body.hunt-active .mobile-invader-sheet {
  z-index: 404;
  bottom: 0;
  background: rgba(15, 23, 42, 0.98);
}

.hunt-card {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 402;
  background: rgba(8, 13, 26, 0.97);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  padding: 0 16px calc(16px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
}

.hunt-progress-bar {
  height: 3px;
  background: rgba(148, 163, 184, 0.15);
  border-radius: 2px;
  margin: 10px 0 12px;
  overflow: hidden;
}

.hunt-progress-fill {
  height: 100%;
  background: var(--success);
  border-radius: 2px;
  transition: width 0.4s ease;
  width: 0%;
}

.hunt-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.hunt-counter {
  font-weight: 600;
  color: var(--text);
}

.hunt-pts {
  color: var(--success);
  font-weight: 600;
}

.hunt-distance {
  margin-left: auto;
  font-weight: 500;
}

.hunt-card-main {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.hunt-invader-img {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.15);
}

.hunt-invader-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hunt-card-invader-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.hunt-invader-id {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}

.hunt-invader-pts {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
}

.hunt-invader-instagram {
  font-size: 0.75rem;
  color: var(--muted);
  text-decoration: none;
}

.hunt-invader-instagram:hover {
  color: var(--text);
}

/* Undo button */
.hunt-btn-undo {
  margin-left: auto;
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: var(--muted);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.hunt-btn-undo:hover {
  background: rgba(148, 163, 184, 0.2);
  color: var(--text);
}

.hunt-card-actions {
  display: flex;
  gap: 8px;
}

.hunt-btn {
  flex: 1;
  min-height: 52px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.hunt-btn-captured {
  background: #15803d;
  color: white;
}

.hunt-btn-captured:active {
  background: #166534;
  transform: scale(0.97);
}

.hunt-btn-blocked {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.28);
  flex: 0 0 auto;
  padding: 0 14px;
  font-size: 0.82rem;
}

.hunt-btn-blocked:active {
  background: rgba(239, 68, 68, 0.22);
}

.hunt-btn-navigate {
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent);
  border: 1px solid rgba(99, 102, 241, 0.28);
  flex: 0 0 auto;
  padding: 0 14px;
  font-size: 0.82rem;
}

.hunt-btn-navigate:active {
  background: rgba(99, 102, 241, 0.22);
}

/* Proximity highlight when < 30 m from target */
.hunt-card--near .hunt-btn-captured {
  background: #16a34a;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.35), 0 0 20px rgba(34, 197, 94, 0.2);
}

/* Captured flash animation */
@keyframes hunt-flash {
  0%   { background: rgba(34, 197, 94, 0.25); }
  100% { background: transparent; }
}

.hunt-card--flash {
  animation: hunt-flash 0.35s ease-out;
}

/* All done state */
.hunt-card--done .hunt-invader-id {
  font-size: 1rem;
  color: var(--success);
}

.hunt-card--done .hunt-card-actions {
  display: none;
}

/* Target pulse ring on map */
@keyframes hunt-pulse {
  0%   { transform: scale(1); opacity: 0.85; }
  50%  { transform: scale(1.55); opacity: 0.2; }
  100% { transform: scale(1); opacity: 0.85; }
}

.hunt-target-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid #f97316;
  animation: hunt-pulse 1.8s ease-in-out infinite;
  pointer-events: none;
  transform-origin: center;
}

.hunt-current-wrapper {
  position: relative;
  width: 44px;
  height: 44px;
}

/* Blocked marker on map */
.hunt-blocked-marker {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.35);
  border: 2px solid rgba(239, 68, 68, 0.6);
  color: #fca5a5;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Completed stop marker on map */
.hunt-done-marker {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid rgba(255, 255, 255, 0.65);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* Hunt list panel */
.hunt-list-panel {
  position: fixed;
  top: 48px;
  bottom: 0;
  right: 0;
  width: min(320px, 100%);
  z-index: 450;
  background: rgba(8, 13, 26, 0.97);
  border-left: 1px solid rgba(148, 163, 184, 0.15);
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transform: translateX(100%);
  transition: transform 0.24s ease;
}

.hunt-list-panel:not([hidden]) {
  transform: translateX(0);
}

.hunt-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  font-weight: 600;
  font-size: 0.9rem;
  position: sticky;
  top: 0;
  background: rgba(8, 13, 26, 0.97);
  z-index: 1;
}

.hunt-list-body {
  padding: 8px 0;
}

.hunt-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.07);
  font-size: 0.85rem;
  transition: background 0.1s;
}

.hunt-list-item--current {
  background: rgba(249, 115, 22, 0.08);
  border-left: 3px solid #f97316;
}

.hunt-list-item--done {
  opacity: 0.45;
}

.hunt-list-item--blocked {
  opacity: 0.5;
}

.hunt-list-item-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
  color: var(--muted);
}

.hunt-list-item--current .hunt-list-item-num {
  background: #f97316;
  color: white;
}

.hunt-list-item--done .hunt-list-item-num {
  background: rgba(34, 197, 94, 0.25);
  color: var(--success);
}

.hunt-list-item-id {
  flex: 1;
  font-weight: 500;
  color: var(--text);
}

.hunt-list-item-pts {
  color: var(--muted);
  font-size: 0.78rem;
}

.hunt-list-item-status {
  font-size: 0.8rem;
  width: 16px;
  text-align: center;
}

/* Hunt list: pending items highlight on hover/tap */
.hunt-list-item--pending:hover,
.hunt-list-item--current:hover {
  background: rgba(99, 102, 241, 0.08);
}

/* Hunt action sheet buttons (add/remove/jump) */
.hunt-sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 0 4px;
  border-top: 1px solid var(--card-border);
  margin-top: 8px;
}

/* Inside Leaflet popup the actions need horizontal padding */
.invader-leaflet-popup .hunt-sheet-actions {
  padding: 10px 4px 2px;
}

.hunt-sheet-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}

.hunt-sheet-btn:active { transform: scale(0.97); }
.hunt-sheet-btn:disabled { opacity: 0.45; cursor: default; }

.hunt-sheet-btn--jump {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border-color: rgba(99, 102, 241, 0.3);
}

.hunt-sheet-btn--add {
  background: rgba(21, 128, 61, 0.15);
  color: #4ade80;
  border-color: rgba(21, 128, 61, 0.3);
}

.hunt-sheet-btn--remove {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.25);
}

/* Mobile result action bar (above tab bar, shown after planning) */
.mobile-result-bar {
  display: none;
}

@media (max-width: 1100px) {
  .mobile-result-bar {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: fixed;
    bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 8px);
    left: 12px;
    right: 12px;
    z-index: 401;
  }

  .mobile-result-bar[hidden] {
    display: none !important;
  }

  body.hunt-active .mobile-result-bar {
    display: none !important;
  }

  .mobile-result-bar-secondary {
    display: flex;
    gap: 8px;
  }

  .mobile-result-bar-sec-btn {
    flex: 1;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(148, 163, 184, 0.2);
    color: var(--text);
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
    white-space: nowrap;
  }

  .mobile-result-bar-sec-btn:active {
    background: rgba(99, 102, 241, 0.2);
  }

  .mobile-result-bar-primary {
    display: flex;
    gap: 8px;
  }

  .hunt-start-fab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #15803d, #166534);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 13px 20px;
    font-size: 0.95rem;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 4px 20px rgba(21, 128, 61, 0.45);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.15s, transform 0.1s;
  }

  .hunt-start-fab:active {
    transform: scale(0.97);
  }

  .mobile-cancel-route-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(148, 163, 184, 0.2);
    color: var(--muted);
    border-radius: 12px;
    width: 48px;
    font-size: 1.1rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
  }

  .mobile-cancel-route-btn:active {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
  }
}

/* "Commencer la chasse" primary button */
.start-hunt-btn {
  background: linear-gradient(135deg, #15803d, #166534);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.start-hunt-btn:hover {
  opacity: 0.9;
}

.start-hunt-btn:active {
  transform: scale(0.97);
}

/* Save mission modal */
.mission-save-modal {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgba(0, 0, 0, 0.75);
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.mission-save-modal[hidden] { display: none !important; }
.mission-save-modal:not([hidden]) { display: flex; }

.mission-save-content {
  background: var(--bg-alt);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.5rem;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
}

.mission-save-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.mission-save-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.mission-save-hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0 0 14px;
}

.mission-url-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
}

.mission-url-input {
  flex: 1;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.78rem;
  font-family: monospace;
  min-width: 0;
}

.mission-qr {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.mission-qr img {
  border-radius: 8px;
  width: 180px;
  height: 180px;
  background: white;
}

.mission-save-expiry {
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
  margin: 0;
}

.mission-save-error {
  color: var(--error);
  font-size: 0.82rem;
  margin-top: 10px;
}

/* Hunt loading state */
.hunt-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.hunt-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(148, 163, 184, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
