* {
  box-sizing: border-box;
}

html {
  height: 100%;
  /* Map page mobile: used for main.main height and profile sheet max-height (see @media 768 / 480). */
  --app-header-height: 3.5rem;
}

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  min-height: 100%;
  min-height: 100dvh;
}

/* Main map app: fill viewport without double scrollbars */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.honeypot-field {
  display: none !important;
  position: absolute !important;
  left: -9999px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0.5rem 1rem;
  background: #007cba;
  color: #eee;
  position: relative;
}

.header h1 {
  margin: 0;
  font-size: 1.25rem;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.header h1.header-brand-title {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.header-beta {
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.9;
  padding: 0.2em 0.45em;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.22);
  line-height: 1.2;
}

.header-nav-links {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  align-items: center;
  justify-content: flex-end;
  max-width: min(52%, 20rem);
}

.header-faq-link {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  color: #fff;
  text-decoration: none;
  font-size: 12px;
  white-space: nowrap;
}

.header-nav-links .header-faq-link {
  position: static;
  transform: none;
}

.header-faq-link:hover {
  background: rgba(255, 255, 255, 0.12);
}

#auth-area {
  margin-right: auto;
}

#auth-area button:not(.header-hero-profile-toggle) {
  margin-left: 0.5rem;
  padding: 0.35rem 0.75rem;
  border: none;
  border-radius: 4px;
  background: #007cba;
  color: #eee;
  cursor: pointer;
}

#auth-area button:not(.header-hero-profile-toggle):hover {
  background: #006ba8;
}

/* Hero name: opens/focuses profile (mobile sheet or desktop sidebar) */
.header-hero-profile-toggle {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: inherit;
  cursor: pointer;
  text-align: left;
  min-width: 0;
  max-width: 100%;
  pointer-events: auto;
}

.header-lang-select {
  margin-left: 0.5rem;
  padding: 0.2rem 0.35rem;
  border: none;
  border-radius: 4px;
  background: #007cba;
  color: #fff;
  font-size: 11px;
  height: 28px;
}

.header-lang-select:hover {
  background: #006ba8;
}

/* FAQ / changelog: bar stays at top while scrolling (below .modal z-index) */
body.page-sticky-header .header {
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}

.main {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  height: calc(100vh - 48px);
  height: calc(100dvh - 48px);
}

.map-wrapper {
  position: relative;
  flex: 1;
  min-height: 300px;
}

.map {
  width: 100%;
  height: 100%;
  min-height: 300px;
}

.guest-info-panel {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 1150;
  max-width: min(460px, calc(100% - 80px));
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #d9dee7;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  color: #1d2327;
  pointer-events: none;
}

.guest-info-panel h2 {
  margin: 0 0 6px 0;
  font-size: 16px;
  line-height: 1.3;
}

.guest-info-panel p {
  margin: 0;
  font-size: 13px;
  line-height: 1.35;
}

.guest-info-note {
  margin-top: 6px !important;
  font-weight: 600;
}

/* Move Leaflet zoom (+/-) boxes to the right side (keep Leaflet layout intact) */
.leaflet-top.leaflet-left {
  left: auto !important;
  right: 10px !important;
}

/* Ensure Leaflet zoom control stays above our overlays */
.leaflet-control-zoom {
  z-index: 2000 !important;
  pointer-events: auto !important;
}

/* Map overlays: same style as Leaflet zoom control (.leaflet-bar) */
.guest-hero-info {
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 1000;
  padding: 0.25rem 0.5rem;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  color: #333;
  font-size: 12px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.65);
  pointer-events: none;
}

/*
 * Logged-in UI layer over map: pass through except interactive children.
 * Must stack above #map (Leaflet panes/controls) and sibling HUD tiles (z-index 1000),
 * otherwise profile sheet and backdrop stay under them while still dimming the map.
 */
#auth-game-ui {
  position: absolute;
  inset: 0;
  z-index: 2100;
  pointer-events: none;
}

#auth-game-ui > * {
  pointer-events: auto;
}

.profile-sheet-backdrop {
  display: none;
}

.user-profile-wrap {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 1200;
  padding: 0;
  background-color: #f0f0f1;
  /* admin-ish light background */
  border: 1px solid #c3c4c7;
  border-left: none;
  border-radius: 0 0 4px 0;
  color: #1d2327;
  font-size: 13px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.12);
  pointer-events: auto;
  /* Fixed sidebar width: long journal lines must not expand over the map */
  width: 280px;
  max-width: min(280px, calc(100vw - 56px));
  min-width: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Mobile sheet peek handle (hidden on desktop) */
.user-profile-sheet-peek {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin: 0;
  padding: 8px 12px 6px;
  border: none;
  border-bottom: 1px solid #dcdcde;
  border-radius: 12px 12px 0 0;
  background: #e8e9eb;
  color: #1d2327;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  box-sizing: border-box;
  text-align: center;
}

.user-profile-sheet-peek:hover {
  background: #dfe0e3;
}

.user-profile-sheet-peek:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px #007cba;
}

.user-profile-sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: #8c8f94;
}

.user-profile-sheet-peek-label {
  line-height: 1.2;
}

.user-profile-back-bar {
  flex-shrink: 0;
  background: #fff;
  border-bottom: 1px solid #e5e5e5;
}

.user-profile-viewport {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.user-profile-pages {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
  width: 400%;
  box-sizing: border-box;
  transform: translate3d(0, 0, 0);
  transition: transform 0.28s ease-out;
  backface-visibility: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .user-profile-pages {
    transition: none;
  }
}

.user-profile-wrap--friends .user-profile-pages {
  transform: translate3d(-25%, 0, 0);
}

.user-profile-wrap--journal .user-profile-pages {
  transform: translate3d(-50%, 0, 0);
}

.user-profile-wrap--settings .user-profile-pages {
  transform: translate3d(-75%, 0, 0);
}

.user-profile-page {
  flex: 0 0 25%;
  width: 25%;
  max-width: 25%;
  min-width: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-profile-page--friends,
.user-profile-page--journal {
  background: #fff;
  box-sizing: border-box;
}

.user-journal-body {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-friends-body {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  background: #fff;
}

.user-friends-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid #e5e5e5;
}

.user-friends-section:last-child {
  border-bottom: none;
}

.user-friends-heading {
  margin: 0;
  padding: 10px 16px 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #50575e;
}

.user-friends-invite-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 0 16px 10px;
}

.user-friends-invite-input {
  flex: 1 1 160px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid #c3c4c7;
  border-radius: 4px;
  font-size: 14px;
  box-sizing: border-box;
}

.user-friends-list {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.user-friends-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid #f0f0f1;
}

.user-friends-item:first-child {
  border-top: none;
}

.user-friends-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.user-friends-name {
  font-weight: 600;
  color: #1d2327;
  overflow-wrap: anywhere;
}

.user-friends-meta,
.user-friends-route {
  font-size: 12px;
  line-height: 1.4;
  color: #50575e;
  overflow-wrap: anywhere;
}

.user-friends-status {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
}

.user-friends-status--declined {
  color: #b91c1c;
}

.user-friends-status--pending {
  color: #a16207;
}

.user-friends-actions {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

/* Match map control `.controls #btn-find-hero.btn-find-hero-icon` (see style.css). */
.user-friends-actions .btn-find-hero-icon {
  flex: 0 0 auto;
  min-width: 0;
  padding: 0.35rem 0.48rem;
  border: none;
  border-radius: 4px;
  background: #007cba;
  color: #eee;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.user-friends-actions .btn-find-hero-icon:hover:not(:disabled) {
  background: #e94560;
}

.user-friends-actions .btn-find-hero-icon .find-hero-glyph {
  display: inline-block;
  line-height: 1;
  transform: scale(1.28);
  transform-origin: center center;
}

.user-friends-remove-btn {
  flex: 0 0 auto;
  min-width: 0;
  /* Same box as `.user-friends-actions .btn-find-hero-icon` (padding + flex centering). */
  padding: 0.35rem 0.48rem;
  border: 1px solid #c3c4c7;
  border-radius: 4px;
  background: #f6f7f7;
  color: #6b7280;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.user-friends-remove-btn:hover {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fca5a5;
}

.user-friends-remove-btn .user-friends-remove-glyph {
  display: inline-block;
  line-height: 1;
  transform: scale(1.28);
  transform-origin: center center;
}

.user-friends-action-btn {
  padding: 6px 10px;
  border: 1px solid #c3c4c7;
  border-radius: 4px;
  background: #f6f7f7;
  color: #1d2327;
  font-size: 12px;
  cursor: pointer;
}

.user-friends-action-btn:hover {
  background: #f0f0f1;
}

.user-friends-empty {
  margin: 0;
  padding: 0 16px 10px;
  font-size: 12px;
  color: #6b7280;
}

.user-profile-page--settings {
  background: #f0f0f1;
  box-sizing: border-box;
}

.user-profile-back {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 12px 16px;
  border: none;
  border-radius: 0;
  background: #fff;
  color: #23282d;
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  line-height: 1.3;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  box-sizing: border-box;
}

.user-profile-back:hover {
  background: #f8f9fa;
}

.user-profile-back:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px #007cba;
}

.user-profile-back-icon {
  flex-shrink: 0;
  font-size: 16px;
  line-height: 1;
  color: #50575e;
  font-weight: 700;
}

.user-settings-body {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 16px 16px;
  box-sizing: border-box;
}

.user-profile-page--settings .user-settings-body {
  padding: 0;
  background: #f0f0f1;
}

.user-settings-field {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin: 0;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 4px;
  box-sizing: border-box;
}

.user-profile-page--settings .user-settings-field {
  padding: 12px 16px;
  border: none;
  border-radius: 0;
  border-bottom: 1px solid #e5e5e5;
  width: 100%;
  max-width: none;
}

.user-settings-field label {
  margin: 0;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #50575e;
  line-height: 1.2;
}

.user-profile-page--settings .user-settings-select {
  margin-left: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.user-settings-field-label {
  margin: 0;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #50575e;
  line-height: 1.2;
}

.user-settings-field--marker .user-marker-presets,
.user-settings-field--marker-shape .user-marker-shape-presets,
.user-settings-field--marker-kind .user-marker-kind-presets,
.user-settings-field--marker-emoji .user-marker-emoji-presets {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.user-marker-kind-preset {
  min-width: 88px;
  min-height: 36px;
  padding: 0.4rem 0.75rem;
  border: 1px solid #c3c4c7;
  border-radius: 999px;
  background: #fff;
  color: #1d2327;
  cursor: pointer;
}

.user-marker-kind-preset--active {
  background: #1d2327;
  border-color: #1d2327;
  color: #fff;
}

.user-marker-emoji-preset {
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 0;
  border: 1px solid #c3c4c7;
  border-radius: 7px;
  background: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.user-marker-emoji-preset--active {
  box-shadow: 0 0 0 2px #1d2327;
}

.user-marker-shape-preset {
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 7px;
  background: #f0f0f1;
  cursor: pointer;
  box-shadow: 0 0 0 1px #c3c4c7;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.user-marker-shape-preset svg {
  width: 20px;
  height: 20px;
  display: block;
}

.user-marker-shape-preset:hover {
  box-shadow: 0 0 0 2px #2271b1;
}

.user-marker-shape-preset--active {
  box-shadow: 0 0 0 2px #1d2327;
}

.user-marker-shape-preset:focus {
  outline: none;
  box-shadow: 0 0 0 2px #007cba, 0 0 0 4px #fff;
}

.user-marker-shape-preset--active:focus {
  box-shadow: 0 0 0 2px #007cba, 0 0 0 4px #fff;
}

.user-marker-preset {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 0 1px #c3c4c7;
  box-sizing: border-box;
}

.user-marker-preset:hover {
  box-shadow: 0 0 0 2px #2271b1;
}

.user-marker-preset--active {
  box-shadow: 0 0 0 2px #1d2327;
}

.user-marker-preset:focus {
  outline: none;
  box-shadow: 0 0 0 2px #007cba, 0 0 0 4px #fff;
}

.hero-appearance-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.hero-appearance-badge--emoji {
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 0 0 2px #fff, 0 1px 4px rgba(0, 0, 0, 0.25);
}

.hero-appearance-badge-emoji {
  line-height: 1;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.7);
}

.user-profile-row {
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #e5e5e5;
  line-height: 1.3;
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-profile-row:last-child {
  border-bottom: none;
}

.user-profile-day,
.user-profile-km {
  font-weight: 600;
  color: #23282d;
}

.user-profile-sep {
  color: #6b7280;
}

.user-journal {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
  background: #fff;
  border-bottom: none;
}

.user-journal-heading {
  margin: 0;
  padding: 10px 16px 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #50575e;
  flex-shrink: 0;
}

.user-journal-list {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 12px 8px;
  font-size: 12px;
  line-height: 1.45;
  color: #1d2327;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.user-journal-item {
  padding: 8px 4px;
  border-bottom: 1px solid #f0f0f1;
  min-width: 0;
}

.user-journal-item--system {
  color: #16a34a;
  font-weight: 600;
}

.user-journal-item:last-child {
  border-bottom: none;
}

.user-journal-empty {
  margin: 0;
  padding: 8px 16px 12px;
  font-size: 12px;
  color: #6b7280;
  flex-shrink: 0;
}

.user-journal-load-more {
  flex-shrink: 0;
  margin: 0 12px 10px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid #c3c4c7;
  border-radius: 4px;
  background: #f6f7f7;
  color: #1d2327;
}

.user-journal-load-more:hover {
  background: #f0f0f1;
}

/* Settings + route controls pinned to bottom of sidebar (no gap above buttons) */
.user-profile-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-height: 0;
}

.sidebar-route-controls-host {
  flex-shrink: 0;
  min-height: 0;
}

/* Filled on mobile when .controls is moved into #map-route-controls-anchor (see app.js placeRouteControls). */
.map-route-controls-anchor {
  display: none;
}

.leaflet-tooltip.guest-hero-tooltip {
  margin-top: -8px;
  padding: 0.35rem 0.6rem;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  color: #333;
  font-size: 12px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.65);
  white-space: normal;
  text-align: center;
  line-height: 1.25;
}

.guest-hero-tooltip-lines {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.guest-hero-tooltip-name,
.guest-hero-tooltip-meta {
  display: block;
  width: 100%;
}

.guest-hero-tooltip-name {
  font-weight: 600;
}

.guest-hero-tooltip-meta {
  opacity: 0.92;
  white-space: nowrap;
}

.map-hero-time-wrap {
  position: absolute;
  right: 114px;
  bottom: 10px;
  z-index: 1000;
  padding: 0 8px;
  height: 26px;
  min-width: 64px;
  line-height: 26px;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.65);
  color: #333;
  font-size: 12px;
  text-align: center;
  pointer-events: none;
}

.map-hero-speed-wrap {
  position: absolute;
  right: 42px;
  bottom: 10px;
  padding: 0 8px;
  height: 26px;
  min-width: 64px;
  line-height: 26px;
  background-color: #fff;
  border: 1px solid #ccc;
  color: #333;
  font-size: 12px;
  text-align: center;
  z-index: 1000;
  border-radius: 4px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.65);
  pointer-events: none;
}

.map-hero-eta-wrap {
  position: static;
  padding: 12px 16px;
  height: auto;
  line-height: 1.2;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  background: #fff;
  border: none;
  border-top: 1px solid #e5e5e5;
  border-bottom: 1px solid #e5e5e5;
  color: #333;
  font-size: 12px;
  z-index: 1;
  border-radius: 0;
  box-shadow: none;
  pointer-events: auto;
  margin: 0;
}

.map-hero-eta-label {
  font-weight: 600;
}

.map-hero-route-progress {
  margin-top: 4px;
}

.map-hero-route-progress-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.map-hero-route-progress-pct {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.map-hero-route-progress-track {
  height: 6px;
  border-radius: 3px;
  background: #e5e7eb;
  overflow: hidden;
}

.map-hero-route-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  /* Default until app.js runs; overridden from hero marker color (map.js). */
  background: linear-gradient(90deg, #3b82f6, #22c55e);
  transition: width 0.35s ease;
}

.map-zoom-wrap {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 1000;
  box-sizing: border-box;
  width: 26px;
  height: 26px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  color: #333;
  font-size: 12px;
  line-height: 1;
  pointer-events: none;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.65);
}

.map-zoom-wrap #map-zoom-value {
  line-height: 1;
}

/* Guest stats: to the left of zoom with a visible gap (two separate tiles) */
.map-heroes-stats-wrap {
  position: absolute;
  right: 44px;
  bottom: 10px;
  z-index: 1000;
  box-sizing: border-box;
  min-width: 180px;
  height: 26px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  color: #333;
  font-size: 12px;
  line-height: 1;
  pointer-events: none;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.65);
}

.map-heroes-stats-label {
  font-weight: 600;
}

/* Guest night / updating / offline — right column with zoom (not over stats tile) */
.map-guest-status-wrap {
  position: absolute;
  right: 10px;
  bottom: 44px;
  z-index: 1000;
  box-sizing: border-box;
  max-width: min(260px, calc(100vw - 20px));
  min-height: 26px;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  text-align: right;
  background-color: rgba(255, 255, 255, 0.95);
  border: 1px solid #ccc;
  border-radius: 4px;
  color: #333;
  font-size: 12px;
  line-height: 1.2;
  pointer-events: none;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.65);
}

.map-guest-hero-card {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 150px;
  max-width: min(280px, calc(100vw - 20px));
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #ccc;
  border-radius: 8px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.65);
  pointer-events: none;
}

.map-guest-hero-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.map-guest-hero-card-text {
  min-width: 0;
}

.map-guest-hero-card-name {
  font-weight: 600;
  color: #1d2327;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-guest-hero-card-meta {
  margin-top: 2px;
  color: #4b5563;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

.controls {
  padding: 0.75rem 1rem;
  background: #f0f0f1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: stretch;
  margin-top: 0;
  border-top: 1px solid #e5e5e5;
}

.controls-row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* Zoom tile + time/speed (in history row on mobile): visible only in fixed bar (see @media 768). */
.controls-inline-zoom {
  display: none;
}

.controls-history-hud {
  display: none;
}

.controls-history-buttons {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.controls-row-route-main {
  width: 100%;
}

.controls-route-main-buttons {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.controls-row-history {
  padding-top: 0.15rem;
  border-top: 1px solid #e0e0e0;
}

.controls button {
  padding: 0.35rem 0.55rem;
  border: none;
  border-radius: 4px;
  background: #007cba;
  color: #eee;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.1;
  min-width: 0;
}

.controls button:hover:not(:disabled) {
  background: #e94560;
}

.controls button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.controls #btn-find-hero.btn-find-hero-icon {
  flex: 0 0 auto;
  min-width: 0;
  padding: 0.35rem 0.48rem;
  font-size: 12px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.controls #btn-find-hero.btn-find-hero-icon .find-hero-glyph {
  display: inline-block;
  line-height: 1;
  transform: scale(1.28);
  transform-origin: center center;
}

.controls button.history-range-active {
  background: #e94560;
}

/* Same red as .controls button:hover (New route hover) */
.controls button.btn-finish-picking-cancel {
  background: #e94560;
  color: #eee;
}

.controls button.btn-finish-picking-cancel:hover:not(:disabled) {
  background: #d63652;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4000;
  padding: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right))
    max(0.75rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
  box-sizing: border-box;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-content {
  background: #007cba;
  color: #eee;
  padding: 1.5rem;
  border-radius: 8px;
  min-width: 280px;
  max-width: calc(100vw - 2rem);
  max-height: min(90dvh, calc(100dvh - 2rem));
  overflow-y: auto;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
}

/* Onboarding / language modals: ~30% viewport width; text wraps naturally */
.modal-content.onboarding-modal-content {
  min-width: 0;
  width: max(260px, min(30vw, calc(100vw - 2rem)));
  max-width: calc(100vw - 2rem);
  box-sizing: border-box;
}

.modal-content h2 {
  margin-top: 0;
}

.onboarding-modal-content .onboarding-text {
  margin: 0.65rem 0 0;
  line-height: 1.5;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.onboarding-modal-content .onboarding-copy-block {
  margin-top: 0.85rem;
  padding: 0.65rem 0.75rem;
  background: rgba(0, 0, 0, 0.12);
  border-radius: 6px;
  line-height: 1.5;
  font-size: 0.95rem;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.onboarding-modal-content .onboarding-copy-block p {
  margin: 0;
}

.onboarding-modal-content .onboarding-copy-block p + p {
  margin-top: 0.5rem;
}

.onboarding-modal-content .onboarding-copy-block + .controls-row {
  margin-top: 1.1rem;
}

#modal-onboarding-finish .onboarding-modal-content > .controls-row {
  margin-top: 1.1rem;
}

#modal-lang .onboarding-modal-content > .controls-row {
  margin-top: 1.1rem;
}

.modal-content input {
  display: block;
  width: 100%;
  margin-bottom: 0.75rem;
  padding: 0.5rem;
  border: 1px solid #9ec6e0;
  border-radius: 4px;
  background: #eef7ff;
  color: #293d6c;
}

.modal-content button {
  width: 100%;
  padding: 0.5rem;
  border: none;
  border-radius: 4px;
  background: #2b6aa8;
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
}

.modal-content form button[type="submit"] {
  background: #2b6aa8;
  color: #ffffff;
}

.modal-content form button[type="submit"]:hover {
  background: #245d95;
}

.auth-divider {
  height: 1px;
  margin: 0.75rem 0;
  background: rgba(255, 255, 255, 0.35);
}

.modal-link-btn {
  width: 100%;
  margin-bottom: 0.5rem;
  background: #2b6aa8;
  color: #ffffff;
}

.user-settings-toggle {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  margin: 0;
  padding: 12px 16px;
  border: none;
  border-top: 1px solid #e5e5e5;
  border-bottom: 1px solid #e5e5e5;
  border-radius: 0;
  background: #fff;
  color: #23282d;
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
}

.user-settings-toggle:hover {
  background: #f8f9fa;
}

.user-settings-toggle:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px #007cba;
}

.user-profile-footer .user-settings-toggle + .user-settings-toggle {
  border-top: none;
}

.user-settings-toggle-icon {
  flex-shrink: 0;
  font-size: 16px;
  line-height: 1;
  color: #50575e;
  font-weight: 700;
}

.user-settings-select {
  flex: 0 0 auto;
  width: auto;
  min-width: 4.25rem;
  margin: 0 0 0 auto;
  padding: 4px 8px;
  border: 1px solid #dcdcde;
  border-radius: 3px;
  background-color: #f0f0f1;
  color: #1d2327;
  font-size: 12px;
  font-family: inherit;
  line-height: 1.2;
  box-sizing: border-box;
  cursor: pointer;
  appearance: auto;
}

.user-settings-select:hover {
  border-color: #c3c4c7;
  background-color: #f6f7f7;
}

.user-settings-select:focus {
  border-color: #007cba;
  outline: none;
  box-shadow: 0 0 0 1px #007cba;
}

.modal-content button.modal-close {
  margin-top: 0.75rem;
  background: #2b6aa8;
  color: #ffffff;
  border: none;
}

.modal-content button.modal-close:hover {
  background: #245d95;
  color: #ffffff;
}

.error {
  color: #e94560;
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.faq-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px 28px;
}

.faq-page h2 {
  margin: 0 0 1.25rem 0;
  font-size: 24px;
}

.faq-list {
  margin: 0;
}

.faq-list dt {
  margin: 0;
  font-weight: 700;
  font-size: 1.05rem;
}

/* Separate each Q from the previous A (dl stays valid; no wrapper divs). */
.faq-list dd + dt {
  margin-top: 2rem;
  padding-top: 1.75rem;
  border-top: 1px solid #e2e8f0;
}

.faq-list dd {
  margin: 0.5rem 0 0 0;
  line-height: 1.45;
}

.faq-illustration-wrap {
  margin-top: 10px;
}

.faq-illustration {
  margin: 0;
  width: 100%;
  max-width: 700px;
}

.faq-illustration img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid #d3dbe6;
}

.faq-illustration figcaption {
  margin-top: 8px;
  font-size: 0.9rem;
  color: #555;
}

.faq-answer-lead {
  margin: 0 0 0.65rem 0;
  line-height: 1.45;
}

.faq-answer-note {
  margin: 0.65rem 0 0 0;
  font-size: 0.9rem;
  color: #555;
  line-height: 1.45;
}

.faq-table {
  width: 100%;
  max-width: 700px;
  border-collapse: collapse;
  font-size: 0.95rem;
  margin: 0;
}

.faq-table th,
.faq-table td {
  border: 1px solid #ccc;
  padding: 0.4rem 0.55rem;
  text-align: left;
  vertical-align: top;
}

.faq-table th {
  background: #f0f4f8;
  font-weight: 600;
}

.faq-table tbody tr:nth-child(even) {
  background: #fafbfc;
}

.faq-table tfoot th,
.faq-table tfoot td {
  border-top: 2px solid #b8c4d0;
}

.faq-table tfoot th {
  background: #e8eef5;
}

.faq-speed-table-chart {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.85rem;
}

.faq-speed-table-chart .faq-table {
  flex: 0 1 auto;
  margin: 0;
}

.faq-speed-tier-scroll {
  width: 100%;
  max-width: 100%;
}

.faq-speed-tier-table {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
  font-size: 0.68rem;
  line-height: 1.2;
}

.faq-speed-tier-table th,
.faq-speed-tier-table td {
  padding: 0.2rem 0.12rem;
  vertical-align: middle;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.faq-speed-tier-table thead th {
  font-weight: 600;
  text-align: center;
}

.faq-speed-tier-table thead th:first-child,
.faq-speed-tier-table tbody td:first-child,
.faq-speed-tier-table tfoot th {
  text-align: left;
}

.faq-speed-tier-table tbody td:not(:first-child),
.faq-speed-tier-table tfoot td {
  text-align: center;
}

.faq-speed-tier-table th:first-child,
.faq-speed-tier-table td:first-child {
  width: 11%;
}

.faq-table-caption {
  caption-side: bottom;
  font-size: 0.75rem;
  color: #555;
  line-height: 1.35;
  text-align: left;
  padding: 0.45rem 0 0 0;
}

.faq-speed-chart-wrap {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  width: 100%;
  max-width: 700px;
}

.faq-speed-chart {
  width: 100%;
  max-width: 700px;
  height: auto;
  display: block;
}

.faq-speed-chart-axis {
  stroke: #ccc;
  stroke-width: 1;
}

.faq-speed-chart-line {
  stroke: #007cba;
}

.faq-speed-chart-tick,
.faq-speed-chart-scale {
  fill: #555;
  font-size: 8px;
  font-family: system-ui, sans-serif;
}

.faq-speed-chart-caption {
  font-size: 0.85rem;
  color: #555;
  line-height: 1.35;
  text-align: left;
  max-width: 700px;
}

.faq-changelog-footer {
  margin: 28px 0 0 0;
  padding-top: 18px;
  border-top: 1px solid #e2e8f0;
}

.faq-changelog-footer a {
  color: #245d95;
  font-weight: 600;
  text-decoration: none;
}

.faq-changelog-footer a:hover {
  text-decoration: underline;
}

.faq-changelog-list {
  margin: 12px 0 0 0;
  padding-left: 1.25rem;
}

.faq-changelog-list li {
  margin: 0 0 8px 0;
  line-height: 1.45;
}

.faq-changelog-list li:last-child {
  margin-bottom: 0;
}

.changelog-page .faq-changelog-list {
  margin-top: 16px;
}

.changelog-back-faq {
  margin: 0 0 10px 0;
}

.changelog-back-faq a {
  color: #245d95;
  font-weight: 600;
  text-decoration: none;
  font-size: 0.95rem;
}

.changelog-back-faq a:hover {
  text-decoration: underline;
}

/* -------------------------------------------------------------------------- */
/* Mobile / narrow portrait: header grid, bottom profile sheet, modal tuning   */
/* -------------------------------------------------------------------------- */

@media (max-width: 768px) {
  /* One row: auth | WebWalks (+ Beta) | FAQ (guest and logged-in) */
  .header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    grid-template-rows: auto;
    align-items: center;
    column-gap: 0.35rem;
    row-gap: 0;
    padding: 0.4rem 0.6rem;
    padding-top: max(0.4rem, env(safe-area-inset-top));
  }

  .header > #auth-area {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    margin-right: 0;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    gap: 0.25rem 0.35rem;
    min-width: 0;
    max-width: 100%;
  }

  .header > h1,
  .header > .header-brand-title {
    grid-column: 2;
    grid-row: 1;
    justify-self: center;
    position: static;
    transform: none;
    font-size: clamp(0.95rem, 3.8vw, 1.05rem);
    text-align: center;
    white-space: nowrap;
    max-width: 42vw;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header > .header-faq-link {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    position: static;
    transform: none;
    align-self: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 0 0.5rem;
    line-height: 1.2;
    box-sizing: border-box;
    font-size: 12px;
  }

  #auth-area button:not(.header-hero-profile-toggle) {
    margin-left: 0;
    padding: 0 0.55rem;
    font-size: 12px;
    min-height: 32px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
  }

  .header-hero-profile-toggle {
    pointer-events: auto;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 0.15em;
  }

  .header-hero-profile-toggle:active {
    opacity: 0.88;
  }

  /* Logged-in row: name + logout share one flex line (no inline baseline drift vs FAQ) */
  #user-info {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: nowrap;
    min-width: 0;
    max-width: 100%;
  }

  #user-info #btn-logout {
    flex-shrink: 0;
  }

  #hero-name,
  .header-hero-profile-toggle #hero-name {
    max-width: min(42vw, 11rem);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
    line-height: 1.2;
    font-size: 12px;
  }

  .header-lang-select {
    margin-left: 0;
    min-height: 32px;
    height: 32px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
  }

  /* Map page only (FAQ uses main.faq-page); shorter one-line header */
  main.main {
    height: calc(100dvh - var(--app-header-height, 3.5rem));
    height: calc(100vh - var(--app-header-height, 3.5rem));
    min-height: 200px;
  }

  .modal-content.onboarding-modal-content {
    width: min(100%, 22rem);
    max-width: calc(100vw - 1.5rem);
  }

  /*
   * Fixed route footer (.map-route-controls-anchor) uses z-index 2200.
   * Keep logged-in layer above it and sit the sheet bottom above the footer band.
   */
  #auth-game-ui:not(.hidden) {
    z-index: 2300;
  }

  /* Bottom sheet profile: map stays primary */
  .profile-sheet-backdrop:not(.hidden) {
    display: block;
    position: absolute;
    inset: 0;
    z-index: 1180;
    background: rgba(0, 0, 0, 0.38);
    pointer-events: auto;
  }

  .user-profile-wrap:not(.hidden) {
    left: 0;
    right: 0;
    top: auto;
    /* Measured route footer: --mobile-route-footer-height (px) from app.js; fallback 5rem */
    bottom: var(--mobile-route-footer-height, 5rem);
    width: 100%;
    max-width: none;
    border-left: 1px solid #c3c4c7;
    border-radius: 12px 12px 0 0;
    max-height: min(
      70dvh,
      calc(100dvh - var(--app-header-height, 3.5rem) - var(--mobile-route-footer-height, 5rem))
    );
    transition: max-height 0.28s ease-out, height 0.28s ease-out;
  }

  /*
   * Expanded sheet (and settings): ~70% viewport from bottom, capped so flex column works
   * and the panel does not run under the header or route footer offset.
   */
  .user-profile-wrap:not(.hidden):not(.profile-sheet--collapsed) {
    height: min(
      70dvh,
      calc(100dvh - var(--app-header-height, 3.5rem) - var(--mobile-route-footer-height, 5rem))
    );
  }

  .user-profile-wrap.user-profile-wrap--settings:not(.hidden),
  .user-profile-wrap.user-profile-wrap--journal:not(.hidden) {
    height: min(
      70dvh,
      calc(100dvh - var(--app-header-height, 3.5rem) - var(--mobile-route-footer-height, 5rem))
    );
    max-height: min(
      70dvh,
      calc(100dvh - var(--app-header-height, 3.5rem) - var(--mobile-route-footer-height, 5rem))
    );
  }

  .user-profile-wrap.profile-sheet--collapsed:not(.user-profile-wrap--settings):not(.user-profile-wrap--journal):not(.user-profile-wrap--friends) {
    height: auto;
    max-height: min(52vh, 21rem);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Route ETA block is tall; hide in collapsed sheet so route buttons stay reachable */
  .user-profile-wrap.profile-sheet--collapsed:not(.user-profile-wrap--settings):not(.user-profile-wrap--journal):not(.user-profile-wrap--friends)
    .map-hero-eta-wrap {
    display: none !important;
  }

  /* Sheet open/close via hero name in header (peek bar was easy to miss) */
  .user-profile-sheet-peek {
    display: none !important;
  }

  .user-profile-footer {
    flex-shrink: 0;
  }

  .sidebar-route-controls-host:empty {
    display: none;
  }

  /* Logged-in: route bar as full-width footer flush to bottom (see placeRouteControls). */
  .map-route-controls-anchor.map-route-controls-anchor--active {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2200;
    pointer-events: none;
    padding: 0;
    box-sizing: border-box;
  }

  /* Footer strip: half the desktop .controls padding/gaps; edge-to-edge horizontally. */
  .map-route-controls-anchor.map-route-controls-anchor--active .controls {
    pointer-events: auto;
    margin-top: 0;
    width: 100%;
    border-radius: 6px 6px 0 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
    padding: 0.375rem 0.5rem;
    padding-bottom: calc(0.375rem + env(safe-area-inset-bottom, 0px));
    /* Extra space between route row and history / time / speed row */
    gap: 0.5rem;
    background: #f0f0f1;
    border: 1px solid #e5e5e5;
    border-bottom: none;
    box-sizing: border-box;
  }

  .map-route-controls-anchor.map-route-controls-anchor--active .controls button {
    min-height: 44px;
    padding: 0.175rem 0.275rem;
    box-sizing: border-box;
  }

  .map-route-controls-anchor.map-route-controls-anchor--active .controls #btn-find-hero.btn-find-hero-icon {
    min-height: 44px;
    min-width: 44px;
    padding: 0.175rem 0.24rem;
    box-sizing: border-box;
  }

  .map-route-controls-anchor.map-route-controls-anchor--active .controls .controls-row-route-main {
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.25rem;
  }

  .map-route-controls-anchor.map-route-controls-anchor--active .controls .controls-route-main-buttons {
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: wrap;
    gap: 0.25rem;
  }

  /* Tiles match desktop map HUD (.map-zoom-wrap / .map-hero-time-wrap): 26px-tall, 12px type. */
  .map-route-controls-anchor.map-route-controls-anchor--active .controls .controls-inline-zoom,
  .map-route-controls-anchor.map-route-controls-anchor--active .controls .controls-inline-hud {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.65);
    pointer-events: none;
    -webkit-user-select: none;
    user-select: none;
    color: #333;
    font-size: 12px;
    font-weight: 400;
  }

  .map-route-controls-anchor.map-route-controls-anchor--active .controls .controls-inline-zoom {
    flex: 0 0 auto;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
  }

  .map-route-controls-anchor.map-route-controls-anchor--active .controls .controls-inline-hud {
    flex: 0 0 auto;
    min-height: 44px;
    height: 44px;
    padding: 0 6px;
    max-width: min(48vw, 11rem);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .map-route-controls-anchor.map-route-controls-anchor--active .controls .controls-row-history {
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.25rem;
    width: 100%;
    padding-top: 0.3rem;
  }

  .map-route-controls-anchor.map-route-controls-anchor--active .controls .controls-history-buttons {
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: wrap;
    gap: 0.25rem;
  }

  .map-route-controls-anchor.map-route-controls-anchor--active .controls .controls-history-hud {
    display: flex;
    flex: 0 0 auto;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.25rem;
  }

  /* Logged-in mobile: HUD in route bar; hide duplicate corner tiles (class from updateAuthUI). */
  .map-wrapper.map-wrapper--logged-in #map-zoom-wrap,
  .map-wrapper.map-wrapper--logged-in #map-hero-time-wrap,
  .map-wrapper.map-wrapper--logged-in #map-hero-speed-wrap {
    display: none !important;
  }

  /*
   * Logged-in map HUD: one row at bottom; ~44px touch targets, 8px gaps (zoom 44px at right:10).
   */
  .map-zoom-wrap {
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .map-hero-speed-wrap {
    right: 62px;
    bottom: max(10px, env(safe-area-inset-bottom));
    font-size: 11px;
    height: 44px;
    line-height: 44px;
    min-width: 72px;
    padding: 0 8px;
    box-sizing: border-box;
  }

  .map-hero-time-wrap {
    right: 142px;
    bottom: max(10px, env(safe-area-inset-bottom));
    font-size: 11px;
    height: 44px;
    line-height: 44px;
    min-width: 64px;
    padding: 0 8px;
    box-sizing: border-box;
  }

  /*
   * Guest: stats next to zoom (right), 8px gap — zoom 44px at right:10 → stats right:62.
   */
  .map-heroes-stats-wrap {
    left: auto;
    right: 62px;
    bottom: max(10px, env(safe-area-inset-bottom));
    max-width: min(280px, calc(100vw - 78px));
    min-width: 0;
    height: auto;
    min-height: 44px;
    flex-wrap: wrap;
    font-size: 11px;
    justify-content: flex-start;
    align-items: center;
  }

  .map-guest-status-wrap {
    left: auto;
    right: 10px;
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 52px);
    max-width: min(240px, calc(100vw - 24px));
    justify-content: flex-end;
    text-align: right;
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  html {
    --app-header-height: 3.65rem;
  }

  main.main {
    height: calc(100dvh - var(--app-header-height, 3.65rem));
    height: calc(100vh - var(--app-header-height, 3.65rem));
  }

  .user-profile-wrap.profile-sheet--collapsed:not(.user-profile-wrap--settings):not(.user-profile-wrap--journal):not(.user-profile-wrap--friends) {
    max-height: min(56vh, 22rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  @media (max-width: 768px) {
    .user-profile-wrap:not(.hidden) {
      transition: none;
    }
  }
}
