/* SpotCountry in the app layout (phones and touch tablets, html.gt-app). Shared frame: assets/css/mode-app.css.
   Same frame as SpotCity: banner (kicker, the real h1, "Countries found", "⋯"), the map, the input dock.
   The hint, the status, the stats and the round Hint / Skip buttons sit on the map; the intro is moved under the
   frame by data-gtm-move (mode-app.js). The native fullscreen (:fullscreen) keeps its own rules: every rule skips it.
   spotcountry.js frames the outline inside what sits on the map (targetPadding) and again on "gtm:layout". */

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

.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 #spotcountry-game:not(: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 #spotcountry-game:not(:fullscreen) :is(.gt-country-map-frame, #spotcountry-map) { transition: none; }
.gt-app #spotcountry-game:not(:fullscreen)::before {
  content: "";
  grid-row: 1 / 3;
  grid-column: 1 / -1;
  border-bottom: 1px solid var(--sh-border-soft);
  pointer-events: none;
}
.gt-app #spotcountry-game:not(:fullscreen) :is(.gt-game-topbar, .gt-game-heading, .gt-country-top-actions) { display: contents; }
.gt-app #spotcountry-game:not(:fullscreen) #toggle-fullscreen { display: none; }
.gt-app #spotcountry-game:fullscreen #spotcountry-more-btn { display: none; }

.gt-app #spotcountry-game:not(: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 #spotcountry-game:not(:fullscreen) #spotcountry-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;
}

/* "Countries found": the real counter, as a compact pill (number above its label). */
.gt-app #spotcountry-game:not(: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 #spotcountry-game:not(:fullscreen) .gt-primary-stat-icon { display: none; }
.gt-app #spotcountry-game:not(:fullscreen) .gt-primary-stat > span:last-child { display: flex; flex-direction: column-reverse; align-items: flex-end; line-height: 1.1; }
.gt-app #spotcountry-game:not(:fullscreen) .gt-primary-stat strong { margin: 0; font-size: 1.1rem; font-weight: 900; line-height: 1; }
.gt-app #spotcountry-game:not(:fullscreen) .gt-primary-stat small { font-size: .69rem; font-weight: 600; white-space: nowrap; }

.gt-app #spotcountry-game:not(:fullscreen) #spotcountry-more-btn { grid-area: more; align-self: center; margin-right: var(--gtm-gutter, 16px); }

/* ------------------------------------------------------------ the map and what sits on it */
.gt-app #spotcountry-game:not(:fullscreen) .gt-country-map-frame {
  grid-area: map;
  position: relative;
  z-index: 0;
  min-height: 0;
  height: auto;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.gt-app #spotcountry-game:not(:fullscreen) #spotcountry-map { height: 100%; min-height: 0; }

/* Hint, top of the map. */
.gt-app #spotcountry-game:not(:fullscreen) #hint-panel {
  grid-area: map;
  align-self: start;
  position: relative;
  z-index: 2;
  margin: 12px;
  padding: 10px 14px;
  background: color-mix(in srgb, #ffb703 12%, var(--sh-card));
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
}
.gt-app #spotcountry-game:not(:fullscreen) #hint-panel.d-none { display: none; }

/* Status ("Which country is highlighted?"), bottom left, above the stats. */
.gt-app #spotcountry-game:not(:fullscreen) #spotcountry-status {
  grid-area: map;
  align-self: end;
  justify-self: start;
  position: relative;
  z-index: 2;
  max-width: calc(100% - 24px);
  min-height: 32px;
  margin: 0 0 74px 12px;
  padding: 6px 12px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--sh-border);
  border-radius: 16px;
  background: var(--sh-navbar-bg);
  font-size: .8rem;
  line-height: 1.3;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.gt-app #spotcountry-game:not(:fullscreen) #spotcountry-status:empty { display: none; }

/* Stats, bottom left: pills, labels kept for screen readers only. */
.gt-app #spotcountry-game:not(:fullscreen) .gt-country-stats {
  grid-area: map;
  align-self: end;
  justify-self: start;
  position: relative;
  z-index: 2;
  max-width: calc(100% - 130px);
  margin: 0 0 30px 12px; /* above the map credits */
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.gt-app #spotcountry-game:not(:fullscreen) .gt-country-stats > 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 #spotcountry-game:not(:fullscreen) .gt-country-stats > span > i { width: auto; height: auto; border-radius: 0; background: none; color: var(--sh-muted); font-size: .85rem; }
.gt-app #spotcountry-game:not(:fullscreen) .gt-country-stats strong { font-size: .82rem; font-weight: 800; }
.gt-app #spotcountry-game:not(:fullscreen) .gt-country-stats small {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ------------------------------------------------------------ the dock, with Hint / Skip as round buttons on the map */
.gt-app #spotcountry-game:not(:fullscreen) .gt-country-command {
  grid-area: dock;
  position: relative;
  z-index: 3;
  margin: 0;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
  display: block;
  border-top: 1px solid var(--sh-border-soft);
  background: var(--sh-card);
}
.gt-app.gtm-kb-open #spotcountry-game:not(:fullscreen) .gt-country-command { padding-bottom: 10px; }
.gt-app #spotcountry-game:not(:fullscreen) .gt-country-command .input-group { display: flex; flex-wrap: nowrap; min-height: 52px; box-shadow: none; }
.gt-app #spotcountry-game:not(:fullscreen) .gt-country-command .input-group .input-group-text { border-radius: 0; }
.gt-app #spotcountry-game:not(:fullscreen) .gt-country-command .input-group input { width: auto; font-size: 16px; border-radius: 0 !important; }
.gt-app #spotcountry-game:not(:fullscreen) .gt-country-command .input-group .btn {
  margin-top: 0 !important;
  padding-inline: 18px;
  border-radius: 11px !important;
  font-weight: 800;
}
.gt-app #spotcountry-game:not(:fullscreen) .gt-country-actions {
  position: absolute;
  right: 12px;
  bottom: calc(100% + 30px);
  display: flex;
  gap: 8px;
}
.gt-app #spotcountry-game:not(:fullscreen) #end-session { display: none; }
.gt-app #spotcountry-game:not(:fullscreen) :is(#hint-country, #skip-country) {
  width: 44px;
  min-width: 0;
  height: 44px;
  min-height: 44px;
  padding: 0;
  justify-content: center;
  border: 1px solid var(--sh-border);
  border-radius: 50%;
  background: var(--sh-navbar-bg);
  color: var(--sh-text);
  font-size: 1.05rem;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.gt-app #spotcountry-game:not(:fullscreen) #hint-country > i { color: #ffb703; }
.gt-app #spotcountry-game:not(:fullscreen) :is(#hint-country, #skip-country) > span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 759.98px) {
  .gt-app #spotcountry-game:not(:fullscreen) .leaflet-control-zoom,
  .gt-app #spotcountry-game:not(:fullscreen) .gt-map-badge { display: none; }
}

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

/* ------------------------------------------------------------ under the frame: the intro (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 #spotcountry-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 #spotcountry-game:not(:fullscreen) {
    grid-template-columns: minmax(0, 1fr) 380px;
    grid-template-rows: auto auto auto auto auto auto auto minmax(0, 1fr);
    grid-template-areas:
      "map kicker"
      "map title"
      "map dock"
      "map hint"
      "map status"
      "map stat"
      "map stats"
      "map rest";
    column-gap: 16px;
    padding: 16px var(--gtm-gutter, 32px) 20px;
  }
  .gt-app #spotcountry-game:not(: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 #spotcountry-game:not(:fullscreen) .gt-country-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 #spotcountry-game:not(:fullscreen) .gt-kicker { margin: 20px 64px 0 20px; }
  .gt-app #spotcountry-game:not(:fullscreen) #spotcountry-more-btn { grid-area: kicker; justify-self: end; align-self: start; margin: 12px 14px 0 0; }
  .gt-app #spotcountry-game:not(:fullscreen) #spotcountry-title { margin: 6px 20px 14px; font-size: 1.5rem; }
  .gt-app #spotcountry-game:not(:fullscreen) .gt-country-command { margin: 0 20px; padding: 0; border: 0; background: transparent; }
  .gt-app #spotcountry-game:not(:fullscreen) .gt-country-actions {
    position: static;
    margin-top: 10px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .gt-app #spotcountry-game:not(:fullscreen) :is(#hint-country, #skip-country, #end-session) {
    display: inline-flex;
    width: auto;
    height: auto;
    min-height: 44px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: .9rem;
  }
  .gt-app #spotcountry-game:not(:fullscreen) :is(#hint-country, #skip-country) > span { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .gt-app #spotcountry-game:not(:fullscreen) #hint-panel { grid-area: hint; margin: 12px 20px 0; box-shadow: none; }
  .gt-app #spotcountry-game:not(:fullscreen) #spotcountry-status {
    grid-area: status;
    justify-self: stretch;
    align-self: start;
    max-width: none;
    margin: 12px 20px 0;
    border: 0;
    background: var(--sh-surface);
  }
  .gt-app #spotcountry-game:not(:fullscreen) .gt-primary-stat { justify-self: stretch; margin: 14px 20px 0; padding: 10px 14px; }
  .gt-app #spotcountry-game:not(:fullscreen) .gt-primary-stat > span:last-child { flex: 1; flex-direction: row-reverse; justify-content: space-between; align-items: baseline; gap: 8px; }
  .gt-app #spotcountry-game:not(:fullscreen) .gt-primary-stat small { font-size: .8rem; }
  .gt-app #spotcountry-game:not(:fullscreen) .gt-country-stats {
    grid-area: stats;
    justify-self: stretch;
    align-self: start;
    max-width: none;
    margin: 8px 20px 0;
  }
  .gt-app #spotcountry-game:not(:fullscreen) .gt-country-stats small { position: static; width: auto; height: auto; overflow: visible; clip: auto; color: var(--sh-muted); font-size: .74rem; }
  .gt-app.gtm-kb-open #spotcountry-game:not(:fullscreen) .gt-kicker { display: inline-flex; }
}

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