/* Mobile-first, sombre, gros boutons tactiles. */
:root {
  --bg: #0b1120;
  --panel: #131c31;
  --accent: #1769aa;
  --accent-2: #0f4c81;
  --text: #e8f1fa;
  --muted: #93a4bd;
  --good: #2ecc71;
  --bad: #e74c3c;
  --radius: 14px;
  --app-height: 100vh;
}

@supports (height: 100dvh) {
  :root {
    --app-height: 100dvh;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: var(--app-height);
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

main {
  max-width: 520px;
  margin: 0 auto;
  min-height: var(--app-height);
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

#loading {
  text-align: center;
  color: var(--muted);
}

/* Écrans : un seul visible à la fois. */
.screen {
  display: none;
  flex: 1;
  flex-direction: column;
}
.screen.active {
  display: flex;
}

#screen-game {
  min-height: 0;
}

h1 {
  font-size: 1.6rem;
  text-align: center;
  margin: 0.4em 0 0.2em;
}
h2 {
  font-size: 0.95rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 1.1em 0 0.5em;
}
.subtitle {
  text-align: center;
  color: var(--muted);
  margin: 0 0 0.5em;
}
.best {
  text-align: center;
  color: var(--muted);
  margin-top: auto;
  padding-top: 1em;
}

/* Puces (continents / niveaux) */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  border: 1px solid #2a3a5c;
  background: var(--panel);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 1rem;
  cursor: pointer;
}
.chip.selected {
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}
.chip.locked {
  opacity: 0.45;
  cursor: not-allowed;
}

/* HUD */
.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: 12px;
}
#hud-score {
  font-variant-numeric: tabular-nums;
}

/* Drapeau */
.flag-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  height: min(270px, 42vh);
  height: min(270px, 42dvh);
  margin: 8px 0 18px;
}
#flag {
  width: 100%;
  height: 100%;
  max-width: 360px;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  border-radius: var(--radius);
  background: #0006;
  box-shadow: 0 8px 28px #0008;
}

body.keyboard-open main {
  padding-top: max(8px, env(safe-area-inset-top));
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}

body.keyboard-open .hud {
  margin-bottom: 8px;
  font-size: 0.9rem;
}

body.keyboard-open .flag-wrap {
  height: clamp(96px, calc(var(--app-height) - 260px), 220px);
  margin: 4px 0 10px;
}

body.keyboard-open #flag {
  max-width: 320px;
}

body.keyboard-open #guess {
  padding: 12px;
  font-size: 1rem;
}

body.keyboard-open .feedback {
  min-height: 1.2em;
  margin: 8px 0;
}

body.keyboard-open .hints {
  gap: 6px;
  margin-bottom: 8px;
}

body.keyboard-open .hint-option {
  padding: 8px 10px;
  font-size: 0.9rem;
}

body.keyboard-open .actions {
  gap: 8px;
}

body.keyboard-open .primary,
body.keyboard-open .ghost {
  padding: 12px;
}

body.keyboard-open .link {
  margin-top: 8px;
}

/* Champ de saisie */
#guess {
  width: 100%;
  padding: 16px;
  font-size: 1.15rem;
  border-radius: var(--radius);
  border: 2px solid #2a3a5c;
  background: var(--panel);
  color: var(--text);
  text-align: center;
}
#guess:focus {
  outline: none;
  border-color: var(--accent);
}
#guess:disabled {
  opacity: 0.7;
}

/* Feedback */
.feedback {
  min-height: 1.5em;
  text-align: center;
  margin: 12px 0;
  font-weight: 600;
}
.feedback.good {
  color: var(--good);
}
.feedback.bad {
  color: var(--bad);
}

.hints {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.hints[hidden] {
  display: none;
}
.hint-option {
  padding: 10px 12px;
  border-radius: calc(var(--radius) - 4px);
  border: 1px solid #2a3a5c;
  background: #0f172a;
  color: var(--text);
  font-size: 0.95rem;
}
.hint-option:active {
  border-color: var(--accent);
}

/* Boutons d'action */
.actions {
  display: flex;
  gap: 10px;
}
.actions.column {
  flex-direction: column;
}
button {
  font-family: inherit;
}
.primary,
.ghost {
  flex: 1;
  padding: 16px;
  font-size: 1.05rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-weight: 600;
}
.primary {
  background: var(--accent);
  color: #fff;
}
.primary:active {
  background: var(--accent-2);
}
.ghost {
  background: transparent;
  color: var(--text);
  border: 2px solid #2a3a5c;
}
.link {
  background: none;
  border: none;
  color: var(--muted);
  margin-top: 16px;
  align-self: center;
  cursor: pointer;
  font-size: 0.95rem;
}
