html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #16202b 0%, #0a0e14 70%);
}

#page {
  position: relative;
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* canvas-area : conteneur positionné qui borne le globe ET tout ce qui se
   superpose dessus (bandeau, écrans d'accueil/fin) à la zone RÉELLEMENT
   occupée par le canvas — pas à #page entier. Avant ce wrapper, #puzzle-stage
   (position:absolute;inset:0) se calait sur #page, qui inclut aussi
   #top-panel ; sur mobile (#page en colonne, #top-panel sous le globe),
   l'écran d'accueil se centrait donc sur la hauteur TOTALE de la page et son
   bas (le mode "50 pays") se retrouvait à moitié caché sous le panneau,
   pendant que le globe lui-même ne restait visible que sur un mince bandeau
   en haut d'écran — donnant l'impression que "le globe ne s'affiche pas".
*/
#canvas-area {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

#globe-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

#globe-canvas:active {
  cursor: grabbing;
}

#fallback[hidden] {
  display: none;
}

#fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #98a2ae;
  font: 15px/1.4 system-ui, sans-serif;
}

/* ---- Bandeau "pays à trouver", superposé au globe ---- */

#target-banner {
  position: absolute;
  top: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 28px;
  background: rgba(10, 14, 20, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  backdrop-filter: blur(8px);
  pointer-events: none;
  text-align: center;
  max-width: min(80%, 480px);
}

#target-banner[hidden] {
  display: none;
}

#target-name {
  color: #e6ebf0;
  font: 700 22px/1.3 system-ui, sans-serif;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6);
  transition: color 0.15s;
}

#target-name.flash-wrong {
  color: #f43f5e;
  animation: puzzle-shake 0.35s ease;
}

#target-name.flash-correct {
  color: #22c55e;
}

@keyframes puzzle-shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-6px);
  }

  75% {
    transform: translateX(6px);
  }
}

#target-hint {
  color: rgba(152, 162, 174, 0.85);
  font: 12px/1.4 system-ui, sans-serif;
}

/* ---- Écrans d'accueil / de fin, superposés au globe ---- */

#puzzle-stage {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  pointer-events: none;
}

#puzzle-stage:empty {
  display: none;
}

#puzzle-stage>* {
  pointer-events: auto;
}

.puzzle-intro-screen,
.puzzle-end-screen {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
  max-width: 460px;
  padding: 28px 32px;
  background: rgba(8, 11, 16, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  backdrop-filter: blur(10px);
}

.puzzle-intro-screen h1,
.puzzle-end-screen h1 {
  margin: 0;
  font: 700 26px/1.3 system-ui, sans-serif;
  color: #e6ebf0;
}

.puzzle-intro-screen p,
.puzzle-end-screen p {
  margin: 0;
  color: #98a2ae;
  font: 14px/1.5 system-ui, sans-serif;
}

.mode-cards {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
}

.mode-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 22px 26px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(135deg, rgba(79, 195, 247, 0.18), rgba(10, 14, 20, 0.4));
  color: #e6ebf0;
  cursor: pointer;
  font: inherit;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.mode-card:hover {
  transform: translateY(-2px);
  border-color: rgba(79, 195, 247, 0.6);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}

.mode-card .mode-count {
  font: 700 28px/1 system-ui, sans-serif;
  color: #4fc3f7;
}

.mode-card .mode-label {
  font: 13px/1 system-ui, sans-serif;
  color: #98a2ae;
}

.puzzle-cta-btn {
  padding: 14px 30px;
  border-radius: 999px;
  border: none;
  background: #4fc3f7;
  color: #0a0e14;
  font: 700 14px/1 system-ui, sans-serif;
  cursor: pointer;
}

.puzzle-cta-btn:hover {
  background: #7ad4fa;
}

.puzzle-end-score {
  font: 700 40px/1 system-ui, sans-serif;
  color: #ffcf3f;
}

/* ---- Panneau latéral ---- */

#top-panel {
  flex: 0 0 320px;
  width: 320px;
  height: 100%;
  box-sizing: border-box;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: rgba(8, 11, 16, 0.85);
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 7;
}

#top-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
}

#brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

#brand {
  font: 700 20px/1 system-ui, sans-serif;
  letter-spacing: 0.02em;
  text-decoration: none;
  cursor: pointer;
  margin-right: 0.2em;
}

.brand-globe {
  color: #4fc3f7;
  margin-right: 0.2em;
}

.brand-trip {
  color: #ffcf3f;
}

#lang-switcher {
  position: relative;
  flex: 0 0 auto;
}

#lang-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font: 600 12px/1 system-ui, sans-serif;
  color: #e6ebf0;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 5px 10px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

#lang-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.22);
}

#lang-toggle img {
  width: 18px;
  height: 12px;
  object-fit: cover;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15);
  display: block;
}

#lang-toggle .bi-chevron-down {
  font-size: 9px;
  color: #98a2ae;
  margin-left: 1px;
  transition: transform 0.2s ease;
}

#lang-toggle[aria-expanded="true"] .bi-chevron-down {
  transform: rotate(180deg);
}

#lang-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 112px;
  background: rgba(12, 16, 22, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  z-index: 20;
}

#lang-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 600 12px/1 system-ui, sans-serif;
  color: #e6ebf0;
  padding: 8px 9px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

#lang-list li img {
  width: 18px;
  height: 12px;
  object-fit: cover;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.15);
  display: block;
}

#lang-list li:hover {
  background: rgba(255, 255, 255, 0.08);
}

#lang-list li[aria-selected="true"] {
  background: rgba(79, 195, 247, 0.15);
  color: #4fc3f7;
}

/* ---- HUD (progression/erreurs/temps) ---- */

#puzzle-hud {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#puzzle-hud[hidden] {
  display: none;
}

#hud-progress-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

#hud-progress-fill {
  height: 100%;
  background: #4fc3f7;
  border-radius: 999px;
  transition: width 0.25s ease;
  width: 0%;
}

.hud-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#hud-progress-label,
#hud-errors,
#hud-time {
  font: 600 12px/1 system-ui, sans-serif;
  color: #e6ebf0;
  white-space: nowrap;
}

#hud-errors {
  color: #f4a3a3;
}

#hud-restart {
  font: 600 11px/1 system-ui, sans-serif;
  color: #4fc3f7;
  background: rgba(79, 195, 247, 0.12);
  border: 1px solid rgba(79, 195, 247, 0.3);
  border-radius: 999px;
  padding: 5px 10px;
  cursor: pointer;
  transition: background 0.15s;
}

#hud-restart:hover {
  background: rgba(79, 195, 247, 0.22);
}

/* ---- CTA téléchargement (identique aux autres modules) ---- */

#download-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: auto;
  padding-top: 2em;
}

.download-text {
  margin: 0;
  text-align: center;
  color: rgba(230, 235, 240, 0.85);
  font: 13px/1.5 system-ui, sans-serif;
}

.store-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.store-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(10, 14, 20, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 8px 12px;
  color: #e6ebf0;
  text-decoration: none;
  backdrop-filter: blur(6px);
  transition: background 0.2s, border-color 0.2s, transform 0.2s ease;
}

.store-btn i {
  font-size: 1.2rem;
  color: #4fc3f7;
}

.store-btn:hover {
  background: rgba(10, 14, 20, 0.75);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.store-sub {
  font-size: 0.6rem;
  color: #98a2ae;
  line-height: 1;
}

.store-name {
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.3;
  margin-top: 1px;
}

.store-btn-disabled {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}

@media (max-width: 700px) {
  #page {
    flex-direction: column;
  }

  #canvas-area {
    flex: 1 1 auto;
    height: auto;
    min-height: 200px;
  }

  #top-panel {
    flex: 0 0 auto;
    width: 100%;
    height: auto;
    max-height: 40vh;
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    order: 1;
  }

  #target-banner {
    top: 16px;
    padding: 10px 18px;
    max-width: calc(100% - 32px);
  }

  #target-name {
    font-size: 18px;
  }
}
