/* SpotCity in the app layout (phones and touch tablets, html.gt-app). Shared frame: assets/css/mode-app.css.
   The game shell becomes the game frame: banner (kicker, the real h1, "Cities found", "⋯"), the map, the input dock.
   Its wrappers (.gt-game-topbar, .gt-game-heading, .gt-spot-top-actions) turn into display: contents so their
   children are placed on one grid; the zone, the round badges, the stats and "Skip" sit on the map.
   The intro and the admin panel are moved under the frame by data-gtm-move (mode-app.js); the help and progress
   sections stay below, in the page. Fullscreen (.geotrainer-fullscreen) keeps its own rules: every rule skips it. */

.gt-app { --gtm-accent: #ff7a45; --gtm-accent-ink: color-mix(in srgb, #ff7a45 72%, #101820); }
.gt-app[data-bs-theme="dark"] { --gtm-accent-ink: #ff7a45; }

.gt-app .gt-game-section { padding: 0; }
.gt-app .gt-game-section > .container { max-width: none; padding: 0; }

/* ------------------------------------------------------------ the frame (phone and tablet portrait) */
.gt-app #spotcity-container:not(.geotrainer-fullscreen) {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  grid-template-areas:
    "kicker stat more"
    "title  stat more"
    "map    map  map"
    "dock   dock dock";
  column-gap: 10px;
  height: var(--gtm-game-h);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  transition: none; /* the frame must reach its new height before Leaflet measures it (keyboard) */
}
.gt-app #spotcity-container:not(.geotrainer-fullscreen) :is(.gt-map-frame, #map) { transition: none; }
/* Banner rule under the two banner rows. */
.gt-app #spotcity-container:not(.geotrainer-fullscreen)::before {
  content: "";
  grid-row: 1 / 3;
  grid-column: 1 / -1;
  border-bottom: 1px solid var(--sh-border-soft);
  pointer-events: none;
}
.gt-app #spotcity-container:not(.geotrainer-fullscreen) :is(.gt-game-topbar, .gt-game-heading, .gt-spot-top-actions) { display: contents; }
.gt-app #spotcity-container:not(.geotrainer-fullscreen) #toggle-fullscreen { display: none; }

.gt-app #spotcity-container:not(.geotrainer-fullscreen) .gt-kicker {
  grid-area: kicker;
  align-self: end;
  min-width: 0;
  margin: 10px 0 0 var(--gtm-gutter, 16px);
  color: var(--gtm-accent-ink);
  font-size: .69rem;
  font-weight: 800;
  letter-spacing: .1em;
}
.gt-app #spotcity-container:not(.geotrainer-fullscreen) #spotcity-title {
  grid-area: title;
  align-self: start;
  min-width: 0;
  margin: 3px 0 10px var(--gtm-gutter, 16px);
  font-size: 1.19rem;
  font-weight: 850;
  letter-spacing: -.02em;
  line-height: 1.15;
}

/* "Cities found": the real counter, as a compact pill (number above its label). */
.gt-app #spotcity-container:not(.geotrainer-fullscreen) .gt-primary-stat {
  grid-area: stat;
  align-self: center;
  min-width: 0;
  width: auto;
  padding: 6px 12px;
  gap: 0;
  border: 0;
  border-radius: 14px;
  background: var(--sh-surface);
}
.gt-app #spotcity-container:not(.geotrainer-fullscreen) .gt-primary-stat-icon { display: none; }
.gt-app #spotcity-container:not(.geotrainer-fullscreen) .gt-primary-stat > span:last-child { display: flex; flex-direction: column-reverse; align-items: flex-end; line-height: 1.1; }
.gt-app #spotcity-container:not(.geotrainer-fullscreen) .gt-primary-stat strong { margin: 0; font-size: 1.1rem; font-weight: 900; line-height: 1; }
.gt-app #spotcity-container:not(.geotrainer-fullscreen) .gt-primary-stat small { font-size: .69rem; font-weight: 600; white-space: nowrap; }

.gt-app #spotcity-container:not(.geotrainer-fullscreen) #spotcity-more-btn { grid-area: more; align-self: center; margin-right: var(--gtm-gutter, 16px); }
/* Fullscreen keeps its own controls (and its exit button): no "⋯" there. */
.gt-app #spotcity-container.geotrainer-fullscreen #spotcity-more-btn { display: none; }

/* ------------------------------------------------------------ the map and what sits on it */
.gt-app #spotcity-container:not(.geotrainer-fullscreen) .gt-map-frame {
  grid-area: map;
  position: relative;
  z-index: 0;
  min-height: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.gt-app #spotcity-container:not(.geotrainer-fullscreen) #map { height: 100%; min-height: 0; }
.gt-app #spotcity-container:not(.geotrainer-fullscreen) #map .gt-map-toast { top: 68px; }

/* Zone, top left of the map (still the real select). */
.gt-app #spotcity-container:not(.geotrainer-fullscreen) .gt-spot-zone {
  grid-area: map;
  align-self: start;
  justify-self: start;
  position: relative;
  z-index: 2;
  max-width: calc(100% - 24px);
  min-height: 44px;
  margin: 12px;
  padding: 4px 12px 4px 6px;
  gap: 8px;
  border-radius: 999px;
  background: var(--sh-navbar-bg);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.gt-app #spotcity-container:not(.geotrainer-fullscreen) .gt-spot-zone__icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--gtm-accent) 18%, transparent);
  color: var(--gtm-accent-ink);
}
.gt-app #spotcity-container:not(.geotrainer-fullscreen) .gt-spot-zone__copy small { font-size: .63rem; letter-spacing: .06em; text-transform: uppercase; line-height: 1.1; }
.gt-app #spotcity-container:not(.geotrainer-fullscreen) .gt-spot-zone__select { max-width: 200px; margin: 0; font-size: 1rem; font-weight: 750; line-height: 1.2; }

/* Round badges and stats, bottom left of the map: pills, labels kept for screen readers only. */
.gt-app #spotcity-container:not(.geotrainer-fullscreen) #spotcity-stats-row {
  grid-area: map;
  align-self: end;
  justify-self: start;
  position: relative;
  z-index: 2;
  max-width: calc(100% - 140px);
  margin: 0 0 30px 12px; /* above the map credits (OpenStreetMap / CARTO) */
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.gt-app #spotcity-container:not(.geotrainer-fullscreen) #spotcity-stats-row > span {
  min-height: 32px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--sh-border);
  border-radius: 999px;
  background: var(--sh-navbar-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.gt-app #spotcity-container:not(.geotrainer-fullscreen) #spotcity-stats-row > span.d-none { display: none; }
.gt-app #spotcity-container:not(.geotrainer-fullscreen) #spotcity-stats-row > span > i { width: auto; height: auto; border-radius: 0; background: none; color: var(--sh-muted); font-size: .85rem; }
.gt-app #spotcity-container:not(.geotrainer-fullscreen) #spotcity-stats-row strong { font-size: .82rem; font-weight: 800; }
.gt-app #spotcity-container:not(.geotrainer-fullscreen) #spotcity-stats-row small {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
/* Capital / To review: the accent pill, first. */
.gt-app #spotcity-container:not(.geotrainer-fullscreen) #spotcity-stats-row .gt-spot-bucket {
  order: -1;
  border: 0;
  background: var(--gtm-accent);
  color: #101820;
  font-size: .78rem;
  font-weight: 800;
}
.gt-app #spotcity-container:not(.geotrainer-fullscreen) #spotcity-stats-row .gt-spot-bucket > i { color: inherit; }
.gt-app #spotcity-container:not(.geotrainer-fullscreen) #spotcity-stats-row .gt-spot-streak { background: var(--sh-navbar-bg); }

/* ------------------------------------------------------------ the dock: answer field, Validate, and Skip on the map */
.gt-app #spotcity-container:not(.geotrainer-fullscreen) .gt-command-bar {
  grid-area: dock;
  position: relative;
  z-index: 3;
  margin: 0;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  display: block;
  border: 0;
  border-top: 1px solid var(--sh-border-soft);
  border-radius: 0;
  background: var(--sh-card);
}
.gt-app.gtm-kb-open #spotcity-container:not(.geotrainer-fullscreen) .gt-command-bar { padding-bottom: 10px; }
.gt-app #spotcity-container:not(.geotrainer-fullscreen) .gt-input-group { min-height: 52px; box-shadow: none; }
.gt-app #spotcity-container:not(.geotrainer-fullscreen) .gt-city-input { font-size: 16px; }
.gt-app #spotcity-container:not(.geotrainer-fullscreen) .gt-btn-validate { min-width: 0; padding-inline: 18px; font-weight: 800; }
.gt-app #spotcity-container:not(.geotrainer-fullscreen) .gt-session-actions {
  position: absolute;
  right: 12px;
  bottom: calc(100% + 30px);
  display: flex;
  gap: 8px;
}
.gt-app #spotcity-container:not(.geotrainer-fullscreen) #end-session { display: none; }
.gt-app #spotcity-container:not(.geotrainer-fullscreen) #skip-city {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--sh-border);
  border-radius: 999px;
  background: var(--sh-navbar-bg);
  color: var(--sh-text);
  font-weight: 750;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* Phones: pinch to zoom, no +/- buttons. */
@media (max-width: 759.98px) {
  .gt-app #spotcity-container:not(.geotrainer-fullscreen) .leaflet-control-zoom { display: none; }
}

/* ------------------------------------------------------------ keyboard up: banner on one line, map kept */
.gt-app.gtm-kb-open #spotcity-container:not(.geotrainer-fullscreen) .gt-kicker,
.gt-app.gtm-kb-open #spotcity-container:not(.geotrainer-fullscreen) .gt-spot-zone { display: none; }
.gt-app.gtm-kb-open #spotcity-container:not(.geotrainer-fullscreen) #spotcity-title {
  margin-top: 10px;
  overflow: hidden;
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gt-app.gtm-kb-open #spotcity-container:not(.geotrainer-fullscreen) .gt-primary-stat small {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.gt-app.gtm-kb-open #spotcity-container:not(.geotrainer-fullscreen) #map .gt-map-toast { top: 12px; }

/* ------------------------------------------------------------ under the frame: intro and admin panel (moved) */
.gt-app .gt-game-section > .container > p[data-gtm-move] {
  max-width: 680px;
  margin: 18px var(--gtm-gutter, 16px) 0;
  color: var(--gt-muted);
  font-size: .95rem;
  line-height: 1.6;
}
.gt-app .gt-game-section > .container > #gt-admin-tools { margin: 14px var(--gtm-gutter, 16px) 0; flex-wrap: wrap; }

/* "Found cities" from the sheet: the fullscreen sidebar, shown outside fullscreen too while it is open. */
.gt-app body.gt-sidebar-open .gt-sidebar { display: block; }

/* Sheet header: mode eyebrow and close button. */
.gt-app #spotcity-more .gtm-sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }

/* ------------------------------------------------------------ touch tablets in landscape: map left, panel right */
@media (min-width: 1000px) {
  .gt-app #spotcity-container:not(.geotrainer-fullscreen) {
    grid-template-columns: minmax(0, 1fr) 380px;
    grid-template-rows: auto auto auto auto auto auto minmax(0, 1fr);
    grid-template-areas:
      "map kicker"
      "map title"
      "map dock"
      "map stat"
      "map stats"
      "map zone"
      "map rest";
    column-gap: 16px;
    padding: 16px var(--gtm-gutter, 32px) 20px;
  }
  /* The panel's card, behind the panel items. */
  .gt-app #spotcity-container:not(.geotrainer-fullscreen)::before {
    grid-row: 1 / -1;
    grid-column: 2;
    border: 1px solid var(--sh-border-soft);
    border-radius: 22px;
    background: var(--sh-card);
  }
  .gt-app #spotcity-container:not(.geotrainer-fullscreen) .gt-map-frame {
    grid-area: auto;
    grid-row: 1 / -1;
    grid-column: 1;
    border: 1px solid var(--sh-border-soft);
    border-radius: 22px;
    overflow: hidden;
  }
  .gt-app #spotcity-container:not(.geotrainer-fullscreen) .gt-kicker { margin: 20px 64px 0 20px; }
  .gt-app #spotcity-container:not(.geotrainer-fullscreen) #spotcity-more-btn { grid-area: kicker; justify-self: end; align-self: start; margin: 12px 14px 0 0; }
  .gt-app #spotcity-container:not(.geotrainer-fullscreen) #spotcity-title { margin: 6px 20px 14px; font-size: 1.5rem; }
  .gt-app #spotcity-container:not(.geotrainer-fullscreen) .gt-command-bar {
    margin: 0 20px;
    padding: 0;
    border: 0;
    background: transparent;
  }
  .gt-app #spotcity-container:not(.geotrainer-fullscreen) .gt-session-actions {
    position: static;
    margin-top: 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .gt-app #spotcity-container:not(.geotrainer-fullscreen) #end-session { display: inline-flex; min-height: 44px; border-radius: 999px; }
  .gt-app #spotcity-container:not(.geotrainer-fullscreen) .gt-primary-stat {
    justify-self: stretch;
    margin: 16px 20px 0;
    padding: 10px 14px;
  }
  .gt-app #spotcity-container:not(.geotrainer-fullscreen) .gt-primary-stat > span:last-child { flex: 1; flex-direction: row-reverse; justify-content: space-between; align-items: baseline; gap: 8px; }
  .gt-app #spotcity-container:not(.geotrainer-fullscreen) .gt-primary-stat small { font-size: .8rem; }
  /* Room for the stat labels in the panel. */
  .gt-app #spotcity-container:not(.geotrainer-fullscreen) #spotcity-stats-row small {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    color: var(--sh-muted);
    font-size: .74rem;
  }
  .gt-app #spotcity-container:not(.geotrainer-fullscreen) #spotcity-stats-row {
    grid-area: stats;
    justify-self: stretch;
    align-self: start;
    max-width: none;
    margin: 8px 20px 0;
  }
  .gt-app #spotcity-container:not(.geotrainer-fullscreen) .gt-spot-zone {
    grid-area: zone;
    justify-self: stretch;
    max-width: none;
    margin: 12px 20px 0;
    border: 1px solid var(--sh-border-soft);
    background: var(--sh-surface);
    box-shadow: none;
  }
  .gt-app #spotcity-container:not(.geotrainer-fullscreen) .gt-spot-zone__select { max-width: none; width: 100%; }
  .gt-app #spotcity-container:not(.geotrainer-fullscreen) #map .gt-map-toast,
  .gt-app.gtm-kb-open #spotcity-container:not(.geotrainer-fullscreen) #map .gt-map-toast { top: 18px; }
  .gt-app.gtm-kb-open #spotcity-container:not(.geotrainer-fullscreen) .gt-kicker { display: inline-flex; }
}

/* Touch-sized zoom buttons where they are shown (tablets). */
.gt-app #spotcity-container:not(.geotrainer-fullscreen) .leaflet-bar a { width: 44px; height: 44px; line-height: 44px; font-size: 20px; }
