/* PlaceCity in the app layout (phones and touch tablets, html.gt-app). Shared frame: assets/css/mode-app.css.
   Same HTML as on PC: the heading, the fullscreen bar (.gt-fsbar) and the map are re-laid out in CSS, the
   difficulty block (.gt-place-command) becomes the "⋯" sheet on phones and a card of the side panel on tablets.
   Every rule is under .gt-app, so the PC layout never changes. The existing fullscreen mode
   (#placecity-container.geotrainer-fullscreen) keeps its own layout: the frame rules skip it. */

.gt-app .gt-place-page {
  --gtm-accent: #3b82f6;
  --gtm-accent-ink: color-mix(in srgb, #3b82f6 72%, #101820);
  min-height: 0;
  isolation: auto; /* the "⋯" sheet must stack above its backdrop, at the page level */
}
.gt-app[data-bs-theme="dark"] .gt-place-page { --gtm-accent-ink: #3b82f6; }
.gt-app .gt-place-page .gt-page-grid,
.gt-app .gt-place-page .gt-page-glow { display: none; }
.gt-app .gt-place-page .gt-game-section { padding: 0; }
.gt-app .gt-place-page .gt-game-section > .container { max-width: none; padding: 0; }

/* ------------------------------------------------------------ game frame (phone) */
.gt-app #placecity-container:not(.geotrainer-fullscreen) {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--gt-bg);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
.gt-app #placecity-container:not(.geotrainer-fullscreen)::before { display: none; }
.gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-place-game-body {
  z-index: auto;
  display: flex;
  flex-direction: column;
  height: var(--gtm-game-h);
  min-height: 0;
}

/* Mode banner: kicker + the real h1, fullscreen and "⋯" buttons. */
.gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-game-topbar {
  flex: none;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 10px var(--gtm-gutter, 16px);
  border-bottom: 1px solid var(--gt-border-soft);
}
.gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-game-heading {
  flex: 1;
  min-width: 0;
  max-width: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-game-heading .gt-kicker {
  gap: 6px;
  color: var(--gtm-accent-ink);
  font-size: .69rem;
  font-weight: 800;
}
.gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-game-heading h1 {
  margin: 0;
  font-size: 1.19rem;
  font-weight: 850;
  letter-spacing: -.02em;
  line-height: 1.15;
}
.gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-place-top-actions {
  flex: none;
  width: auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
/* The city name is shown by the target bar below: this copy stays in the page, not on screen. */
.gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-place-target { display: none; }
.gt-app #placecity-container:not(.geotrainer-fullscreen) #toggle-fullscreen {
  position: relative;
  flex: none;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.05rem;
}
.gt-app #placecity-container:not(.geotrainer-fullscreen) #toggle-fullscreen > span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Target bar: the fullscreen bar, shown in the app layout (city to place, difficulty, rounds and average). */
.gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-fsbar {
  flex: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "city diff" "city stats";
  align-items: center;
  column-gap: 12px;
  row-gap: 5px;
  margin: 0;
  padding: 10px var(--gtm-gutter, 16px);
  border: 0;
  border-bottom: 1px solid var(--gt-border-soft);
  border-radius: 0;
  background: var(--gt-card);
}
.gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-city-badge {
  grid-area: city;
  gap: 12px;
  padding: 0;
  border: 0;
  background: none;
}
.gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-city-badge > i {
  display: grid;
  flex: none;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--gtm-accent) 18%, transparent);
  color: var(--gtm-accent-ink);
  font-size: 1.15rem;
}
.gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-city-badge small {
  font-size: .69rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-city-badge strong {
  max-width: none;
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: -.02em;
  line-height: 1.1;
}
.gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-fs-difficulty {
  grid-area: diff;
  justify-self: end;
  padding: 4px 10px;
  border: 0;
  border-radius: 999px;
  background: var(--gt-surface-2);
  font-size: .75rem;
  font-weight: 800;
}
.gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-fs-stats {
  grid-area: stats;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-fs-stats > span {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
}
.gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-fs-stats small {
  font-size: .75rem;
  font-weight: 600;
}
.gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-fs-stats strong { font-size: .8rem; font-weight: 800; }
/* On phones the bar keeps rounds and average; best and worst stay in "Your session" below, End in the sheet. */
.gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-fs-stats > span:nth-child(n+3),
.gt-app #placecity-container:not(.geotrainer-fullscreen) #end-session-fs { display: none; }

/* Map: the rest of the screen. */
.gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-place-map-frame {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--gt-map-ocean);
  box-shadow: none;
}
.gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-place-map-frame #map {
  height: 100%;
  min-height: 0;
  border-radius: 0;
}
/* The map HUD repeats the city name of the target bar. */
.gt-app #placecity-container:not(.geotrainer-fullscreen) #map .gt-map-hud { display: none; }
.gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-pc-confirm {
  right: 12px;
  bottom: 28px;
  left: 12px;
  justify-content: center;
  min-height: 52px;
  border-radius: 16px;
  font-size: 1rem;
  transform: none;
}

/* "⋯" sheet: difficulty, maximum distance, End session (the real controls of .gt-place-command). */
.gt-app .gt-place-page .gt-place-command.gtm-modesheet {
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  gap: 12px;
}
.gt-app .gt-place-page .gt-place-command.gtm-modesheet .gt-place-difficulty-buttons {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.gt-app .gt-place-page .gt-place-command.gtm-modesheet .gt-place-difficulty-buttons .btn {
  min-height: 48px;
  padding-inline: 4px;
  font-size: .9rem;
}
.gt-app .gt-place-page .gt-place-command.gtm-modesheet .gt-place-tolerance {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.gt-app .gt-place-page .gt-place-command.gtm-modesheet .gt-place-tolerance span { font-size: .8rem; }
.gt-app .gt-place-page .gt-place-command.gtm-modesheet > .btn-end-session {
  width: 100%;
  min-height: 52px;
}

/* Intro paragraph: moved under the game (data-gtm-move), at the top of "Your session". */
.gt-app .gt-place-page .gt-progress-section p[data-gtm-move] {
  max-width: 680px;
  margin: 0 0 22px;
  color: var(--gt-muted);
  font-size: 1rem;
  line-height: 1.6;
}
.gt-app .gt-place-page .gt-progress-section { padding-top: 32px; }

@media (max-width: 899.98px) {
  /* Pinch to zoom on phones: the +/− buttons only take room, and the label takes their corner. */
  .gt-app #placecity-container:not(.geotrainer-fullscreen) .leaflet-control-zoom { display: none; }
  .gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-place-map-label { top: 12px; right: auto; left: 12px; }
}

/* ------------------------------------------------------------ tablet landscape: map left, panel right */
@media (min-width: 900px) {
  .gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-place-game-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    grid-template-rows: auto auto auto auto minmax(0, 1fr);
    column-gap: 16px;
    box-sizing: border-box;
    padding: 16px var(--gtm-gutter, 32px) 24px;
  }
  /* The panel's card, drawn behind the panel's cells. */
  .gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-place-game-body::before {
    content: "";
    grid-column: 2;
    grid-row: 1 / -1;
    border: 1px solid var(--gt-border-soft);
    border-radius: 22px;
    background: var(--gt-card);
  }
  .gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-place-map-frame {
    grid-column: 1;
    grid-row: 1 / -1;
    overflow: hidden;
    border: 1px solid var(--gt-border-soft);
    border-radius: 22px;
  }
  .gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-game-topbar {
    grid-column: 2;
    grid-row: 1;
    align-items: flex-start;
    padding: 20px 20px 14px;
    border-bottom: 0;
  }
  .gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-game-heading h1 { font-size: 1.5rem; }
  .gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-place-more { display: none; }
  .gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-fsbar { display: contents; }
  .gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-city-badge {
    grid-column: 2;
    grid-row: 2;
    margin: 0 20px;
    padding: 12px 14px;
    border: 1px solid var(--gt-border-soft);
    border-radius: 16px;
    background: var(--gt-surface);
  }
  .gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-fs-difficulty { display: none; }
  .gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-fs-stats {
    grid-column: 2;
    grid-row: 4;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 12px 20px 0;
  }
  .gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-fs-stats > span,
  .gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-fs-stats > span:nth-child(n+3) {
    display: grid;
    gap: 2px;
    padding: 10px 12px;
    border-radius: 14px;
    background: var(--gt-surface);
    text-align: left;
  }
  .gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-fs-stats strong { font-size: 1.05rem; font-weight: 900; }
  /* The difficulty block is a card of the panel here, not a sheet. */
  .gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-place-command.gtm-modesheet {
    position: static !important;
    inset: auto !important;
    z-index: auto;
    grid-column: 2;
    grid-row: 3;
    width: auto !important;
    max-height: none;
    margin: 12px 20px 0 !important;
    padding: 12px !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
    border: 1px solid var(--gt-border-soft) !important;
    border-radius: 16px !important;
    background: var(--gt-surface) !important;
    box-shadow: none !important;
    transform: none;
    visibility: visible;
    transition: none;
  }
  .gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-place-command.gtm-modesheet::before { display: none; }
  .gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-place-command.gtm-modesheet .gt-place-difficulty { grid-column: 1 / -1; }
  .gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-place-command.gtm-modesheet .gt-place-difficulty-buttons .btn { min-height: 44px; }
  .gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-place-command.gtm-modesheet .gt-place-tolerance,
  .gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-place-command.gtm-modesheet > .btn-end-session { min-height: 48px; }
  .gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-place-command.gtm-modesheet .gt-place-tolerance { display: grid; gap: 0; align-content: center; }
  .gt-app #placecity-container:not(.geotrainer-fullscreen) .gt-place-command.gtm-modesheet .gt-place-tolerance span { font-size: .65rem; }
}
