/* ========================================
   GÉOGRILLE — Styles principaux
   Aesthetic: Geo-minimal, terre & atlas
   ======================================== */

:root {
  --bg:         #F5F0E8;
  --surface:    #FFFFFF;
  --border:     #D6CCBA;
  --text:       #1C1A16;
  --text-muted: #7A7264;
  --accent:     #2D6A4F;
  --accent-2:   #E76F51;
  --correct:    #2D6A4F;
  --error:      #C1440E;
  --cell-hover: #EAE4D8;
  --cell-done:  #D8EDDF;
  --cell-error: #FCEEE8;
  --header-bg:  #1C1A16;
  --header-txt: #F5F0E8;
  --modal-bg:   rgba(28, 26, 22, 0.6);
  --radius:     10px;
  --shadow:     0 4px 24px rgba(28,26,22,0.12);
  --font-display: 'Syne', sans-serif;
  --font-body:    'DM Sans', sans-serif;
}

/* ---- Thème sombre ---- */
[data-theme="dark"] {
  --bg:         #1A1815;
  --surface:    #242220;
  --border:     #3A3830;
  --text:       #F5F0E8;
  --text-muted: #9A9285;
  --cell-hover: #2E2C28;
  --cell-done:  #1E3D2A;
  --cell-error: #3D1A10;
  --header-bg:  #0F0E0C;
  --header-txt: #F5F0E8;
  --modal-bg:   rgba(0, 0, 0, 0.75);
  --shadow:     0 4px 24px rgba(0,0,0,0.4);
}

/* ---- Détection préférence système ---- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:         #1A1815;
    --surface:    #242220;
    --border:     #3A3830;
    --text:       #F5F0E8;
    --text-muted: #9A9285;
    --cell-hover: #2E2C28;
    --cell-done:  #1E3D2A;
    --cell-error: #3D1A10;
    --header-bg:  #0F0E0C;
    --header-txt: #F5F0E8;
    --modal-bg:   rgba(0, 0, 0, 0.75);
    --shadow:     0 4px 24px rgba(0,0,0,0.4);
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}

/* ---- Ads ---- */
.ad-slot {
  display: none !important;
}

/* ---- Header ---- */
.site-header {
  background: var(--header-bg);
  color: var(--header-txt);
  padding: 0 16px 10px;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 52px;
}
.logo {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.logo-geo    { color: #F5F0E8; }
.logo-grille { color: var(--accent-2); }

.header-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding-bottom: 8px;
}

.btn-icon {
  background: rgba(255,255,255,0.1);
  border: none;
  color: var(--header-txt);
  width: 36px; height: 36px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
  text-decoration: none;
  flex-shrink: 0;
}
.btn-icon:hover { background: rgba(255,255,255,0.2); }

.puzzle-date {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(245,240,232,0.5);
  padding-bottom: 8px;
}

/* ---- Main layout ---- */
.main-layout {
  display: flex;
  flex: 1;
  gap: 16px;
  padding: 16px;
  align-items: center;
  justify-content: center;
}

.game-area {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  position: relative;
}

/* ---- Lives ---- */
.lives-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}
.lives-dots { display: flex; gap: 6px; }
.dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid var(--text);
  transition: background 0.3s, border-color 0.3s;
}
.lives-dots .dot.dot-error { background: var(--error); border-color: var(--error); }
.lives-remaining  { font-variant-numeric: tabular-nums; }

/* ---- Grid ---- */
.grid-wrapper {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) repeat(3, minmax(0, 1fr));
  grid-template-rows: auto repeat(3, 1fr);
  gap: 6px;
  width: 100%;
  aspect-ratio: 4/3.2;
}

.grid-corner { /* empty top-left */ }

.col-header, .row-header {
  background: var(--header-bg);
  color: var(--header-txt);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6px 4px;
  gap: 2px;
}
.header-label {
  font-size: clamp(0.5rem, 1.6vw, 0.65rem);
  font-weight: 500;
  opacity: 0.55;
  letter-spacing: 0.04em;
  line-height: 1.1;
}
.header-val {
  font-size: clamp(0.58rem, 2vw, 0.78rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.cell {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: clamp(0.55rem, 1.8vw, 0.72rem);
  font-weight: 600;
  line-height: 1.3;
  padding: 4px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  user-select: none;
  overflow: hidden;
  position: relative;
}
.cell:hover:not(.cell-done):not(.cell-error-state) {
  background: var(--cell-hover);
  border-color: #B8AF9E;
  transform: scale(1.02);
}
.cell:active { transform: scale(0.97); }
.cell:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.cell.cell-done {
  background: var(--cell-done);
  border-color: var(--correct);
  color: var(--correct);
  cursor: default;
}
.cell.cell-done::after {
  content: '✓';
  position: absolute;
  top: 3px; right: 5px;
  font-size: 0.65rem;
  color: var(--correct);
  opacity: 0.7;
}
.cell.cell-error-state {
  background: var(--cell-error);
  border-color: var(--error);
  animation: shake 0.35s ease;
}
.cell.cell-pulse {
  animation: pulse 0.5s ease;
}

@keyframes shake {
  0%,100%  { transform: translateX(0); }
  20%      { transform: translateX(-5px); }
  60%      { transform: translateX(5px); }
}
@keyframes pulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* ---- Progress ---- */
.progress-bar-wrap {
  width: 100%;
  height: 5px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #52B788);
  border-radius: 99px;
  width: 0%;
  transition: width 0.4s cubic-bezier(.25,.8,.25,1);
}
.progress-label {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ---- Modal overlay ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: var(--modal-bg);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  padding-top: env(safe-area-inset-top, 0);
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--surface);
  border-radius: 0 0 20px 20px;
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  padding: 20px 20px 0;
  transform: translateY(-30px);
  transition: transform 0.25s cubic-bezier(.25,.8,.25,1);
  overflow: hidden;
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}
.modal-hint {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 2px;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
}
.modal-close {
  background: #F0EAE0;
  border: none;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 0.85rem;
  cursor: pointer;
  flex-shrink: 0;
  color: var(--text);
  transition: background 0.15s;
}
.modal-close:hover { background: var(--border); }

/* ---- Search ---- */
.search-wrap {
  position: relative;
  margin-bottom: 10px;
}
.search-wrap input {
  width: 100%;
  padding: 11px 40px 11px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.search-wrap input:focus { border-color: var(--accent); }
.search-icon {
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  pointer-events: none;
}

/* ---- Country list ---- */
.country-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  margin: 0 -20px;
  padding: 0 20px 20px;
}
.country-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.12s;
}
.country-list li:hover { background: var(--bg); }
.country-list li.disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.country-list li .flag {
  font-size: 1.4rem;
  line-height: 1;
  flex-shrink: 0;
}
.country-list li .country-name { flex: 1; }
.country-list li .country-used {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-style: italic;
}
.country-list .no-result {
  text-align: center;
  color: var(--text-muted);
  padding: 20px;
  cursor: default;
}
.country-list .no-result:hover { background: none; }

/* ---- End modal ---- */
.modal-end {
  border-radius: 20px 20px 0 0;
  align-items: center;
  text-align: center;
  padding: 28px 24px;
  gap: 12px;
  position: relative;
}
.end-close {
  position: absolute;
  top: 16px; right: 16px;
}
.end-emoji { font-size: 3rem; }
.end-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
}
.end-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
}
/* ---- Compteur de solutions par case ---- */
.cell-count {
  position: absolute;
  bottom: 4px;
  right: 5px;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-muted);
  opacity: 0.6;
  pointer-events: none;
}
.cell-done .cell-count { display: none; }

/* ---- Grille résultat fin de partie ---- */
.end-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  margin: 4px 0;
}
.end-cell {
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 500;
  flex-wrap: wrap;
}
.end-cell-done {
  background: var(--cell-done);
  border: 1.5px solid var(--correct);
  color: var(--correct);
}
.end-cell-missed {
  background: #f5f0e8;
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  font-size: 0.78rem;
}
.end-flag { font-size: 1.2rem; }
.end-pays { font-weight: 600; }
.end-solutions-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  opacity: 0.6;
  flex-shrink: 0;
}

/* ── Idée 6 : Drapeau en filigrane ── */
.cell-flag-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  border-radius: 6px;
  opacity: 0.12;
  pointer-events: none;
}
.cell-content {
  position: relative;
  z-index: 1;
  text-align: center;
  line-height: 1.3;
}

/* ── Idée 7 : Animation victoire ── */
.victory-map-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 26, 22, 0.85);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.victory-map-overlay.vmap-show { opacity: 1; }

.vmap-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.vmap-globe {
  font-size: 3.5rem;
  animation: spinGlobe 1.8s ease-in-out;
}
@keyframes spinGlobe {
  0%   { transform: scale(0.5) rotate(-20deg); opacity: 0; }
  40%  { transform: scale(1.2) rotate(5deg);   opacity: 1; }
  100% { transform: scale(1)   rotate(0deg);   opacity: 1; }
}
.vmap-flags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  max-width: 340px;
}
.vmap-flag {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transform: translateY(12px);
  animation: popFlag 0.35s ease forwards;
}
@keyframes popFlag {
  to { opacity: 1; transform: translateY(0); }
}
.vmap-flag img {
  width: 44px;
  height: 30px;
  object-fit: cover;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}
.vmap-flag span {
  font-size: 0.6rem;
  color: rgba(245,240,232,0.8);
  font-weight: 500;
  text-align: center;
  max-width: 52px;
  line-height: 1.2;
}

.end-resume-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 6px;
}
/* ── Idée 8 : Résumé géographique ── */
.end-resume {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  width: 100%;
}
.resume-item { white-space: nowrap; }
.resume-sep  { opacity: 0.4; }
.cell-reveal-mode {
  cursor: pointer !important;
  border-style: dashed !important;
  border-color: var(--text-muted) !important;
}
.cell-reveal-mode:hover {
  background: var(--cell-hover) !important;
  transform: scale(1.02);
}
.cell-done.cell-reveal-mode {
  border-style: dashed !important;
  border-color: var(--correct) !important;
}

/* ---- Hint révélation dans modal fin ---- */
.end-reveal-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ---- Streak ---- */
.end-streak {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-2);
  min-height: 1.2em;
}

.btn-share {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px 28px;
  border-radius: 99px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
.btn-share:hover  { background: #235c40; }
.btn-share:active { transform: scale(0.97); }

.end-next {
  font-size: 0.8rem;
  color: var(--text-muted);
}
#nextTimer { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---- Tutoriel interactif ---- */
.modal-help {
  border-radius: 20px 20px 0 0;
  padding: 24px 24px 20px;
  position: relative;
  gap: 0;
  min-height: 0;
  height: auto;
  justify-content: space-between;
}
.modal-help .modal-close {
  position: absolute;
  top: 16px; right: 16px;
}
.tuto-step {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  width: 100%;
  flex: 1;
  padding: 8px 0;
}
.tuto-emoji { font-size: 2.8rem; }
.help-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
}
.tuto-text {
  font-size: 0.9rem;
  line-height: 1.6;
  color: #3a3830;
  max-width: 340px;
  text-align: center;
  margin: 0 auto;
}
.tuto-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 8px;
  padding: 8px 12px;
  line-height: 1.5;
}
.tuto-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 11px 28px;
  border-radius: 99px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 14px;
}
.tuto-btn:hover { background: #235c40; }

/* Mini grille démo */
.tuto-grid-demo {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  gap: 4px;
  width: 100%;
  max-width: 300px;
}
.tuto-corner { width: 60px; }
.tuto-hdr {
  background: var(--header-bg);
  color: var(--header-txt);
  border-radius: 6px;
  padding: 5px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}
.tuto-row-hdr { justify-content: center; text-align: right; }
.tuto-label { font-size: 0.52rem; opacity: 0.55; font-weight: 500; }
.tuto-val   { font-size: 0.7rem;  font-weight: 700; }
.tuto-cell {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 6px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--text-muted);
}
.tuto-cell-highlight {
  border-color: var(--accent-2);
  background: #FEF0EC;
  color: var(--accent-2);
  font-weight: 700;
  animation: pulse 1.2s ease infinite;
}

/* Choix interactifs */
.tuto-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}
.tuto-choice {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 10px 8px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.tuto-choice:hover:not(:disabled) {
  border-color: var(--accent);
  background: #eaf3ee;
}
.tuto-choice-correct { background: var(--cell-done) !important; border-color: var(--correct) !important; color: var(--correct); }
.tuto-choice-wrong   { background: var(--cell-error) !important; border-color: var(--error) !important; color: var(--error); opacity: 0.7; }

.tuto-feedback {
  font-size: 0.82rem;
  font-weight: 500;
  min-height: 1.4em;
  line-height: 1.4;
}

/* Règles finales */
.tuto-rules {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  width: 100%;
  font-size: 0.88rem;
  line-height: 1.5;
}
.tuto-rules li strong { color: var(--text); }

/* Barre de progression */
.tuto-progress {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding-top: 16px;
}
.tuto-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.2s;
}
.tuto-dot-active { background: var(--accent); }

/* ---- Footer ---- */
.site-footer {
  text-align: center;
  padding: 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
}
.site-footer a {
  color: var(--text-muted);
  text-decoration: none;
}
.site-footer a:hover { color: var(--text); }

/* ========================================
   RESPONSIVE
   ======================================== */
@media (min-width: 768px) {
  .ad-left, .ad-right {
    display: flex;
    flex-direction: column;
    width: 160px;
    min-width: 160px;
    height: 600px;
    align-self: center;
    flex-shrink: 0;
  }
  .modal, .modal-help, .modal-end {
    border-radius: 20px;
    margin: auto;
    align-self: center;
  }
  .modal-overlay { align-items: center; padding-top: 0; }
}

@media (max-width: 400px) {
  .grid-wrapper { gap: 4px; }
  .col-header, .row-header { font-size: 0.56rem; padding: 4px 3px; }
  .cell { font-size: 0.52rem; }
}

/* ---- Toast notification ---- */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: 14px;
  font-size: 0.85rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 200;
  white-space: normal;
  max-width: calc(100vw - 32px);
  width: max-content;
  text-align: center;
  line-height: 1.4;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---- Bannière mode archive ---- */
.archive-banner {
  width: 100%;
  background: #2D3A30;
  border: 1.5px solid var(--accent);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #D8EDDF;
}
.archive-banner-icon { font-size: 1.2rem; flex-shrink: 0; }
.archive-banner-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
}
.archive-banner-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  opacity: 0.7;
}
.archive-banner-date {
  font-size: 0.88rem;
  font-weight: 600;
}
.archive-banner-link {
  font-size: 0.75rem;
  font-weight: 600;
  color: #52B788;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.archive-banner-link:hover { text-decoration: underline; }

/* ---- Bouton indice ---- */
.btn-hint {
  background: #FEF3C7;
  border: 1.5px solid #F59E0B;
  color: #92400E;
  border-radius: 99px;
  padding: 5px 12px;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-hint:hover { background: #FDE68A; }

.hint-reveal {
  background: #FFFBEB;
  border: 1.5px solid #F59E0B;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.84rem;
  color: #78350F;
  margin-bottom: 4px;
  line-height: 1.5;
}

/* ---- Bannière mode entraînement ---- */
.training-banner {
  width: 100%;
  background: rgba(231, 111, 81, 0.08);
  border: 1.5px solid var(--accent-2);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--accent-2);
  font-size: 0.88rem;
  font-weight: 600;
}
.training-banner-btns {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.training-new-btn {
  background: var(--accent-2);
  color: #fff;
  border: none;
  border-radius: 99px;
  padding: 6px 12px;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.training-new-btn:hover { background: #c8532b; }

/* ---- Indice niveau 2 ---- */
.btn-hint-2 {
  background: #FEE2E2;
  border-color: #EF4444;
  color: #7F1D1D;
}
.btn-hint-2:hover { background: #FECACA; }

.hint-line { margin-bottom: 4px; }
.hint-line:last-child { margin-bottom: 0; }
.hint-line-2 {
  padding-top: 6px;
  border-top: 1px dashed #F59E0B;
  margin-top: 4px;
}

/* ---- Score ---- */
.progress-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}
.score-display {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* ---- Bouton abandonner ---- */
.btn-abandon {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 4px 0;
  transition: color 0.15s;
}
.btn-abandon:hover { color: var(--error); }

/* ---- Bouton partager persistant ---- */
.btn-share-persistent {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 99px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  width: 100%;
}
.btn-share-persistent:hover  { background: #235c40; }
.btn-share-persistent:active { transform: scale(0.97); }

/* ---- Coût des indices ---- */
.hint-cost {
  font-size: 0.7em;
  font-weight: 500;
  opacity: 0.7;
  margin-left: 3px;
}

/* ---- Streak bar ---- */
.streak-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(135deg, rgba(231,111,81,0.12), rgba(231,111,81,0.06));
  border: 1.5px solid rgba(231,111,81,0.3);
  border-radius: 99px;
  padding: 6px 16px;
  width: fit-content;
  align-self: center;
}
.streak-flame {
  font-size: 1.1rem;
  animation: flicker 1.5s ease-in-out infinite alternate;
}
@keyframes flicker {
  0%   { transform: scale(1)    rotate(-3deg); }
  100% { transform: scale(1.15) rotate(3deg);  }
}
.streak-text {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-2);
  white-space: nowrap;
}

/* ========================================
   THÈME SOMBRE — overrides
   ======================================== */
[data-theme="dark"] .cell.cell-done {
  color: #A8D5B8;
}
[data-theme="dark"] .cell.cell-done::after {
  color: #A8D5B8;
}

[data-theme="dark"] .modal-close {
  background: #3A3830;
  color: var(--text);
}
[data-theme="dark"] .modal-close:hover { background: #4A4840; }

[data-theme="dark"] .tuto-text,
[data-theme="dark"] .tuto-hint,
[data-theme="dark"] .tuto-rules li {
  color: #C8C0B0;
}

[data-theme="dark"] .tuto-hint {
  background: #2A2820;
  border: none;
}

[data-theme="dark"] .tuto-hdr {
  background: #0F0E0C;
}

[data-theme="dark"] .tuto-cell {
  background: #2A2820;
  border-color: #4A4840;
  color: #9A9285;
}

[data-theme="dark"] .tuto-choice {
  background: #2A2820;
  border-color: #4A4840;
  color: var(--text);
}
[data-theme="dark"] .tuto-choice:hover:not(:disabled) {
  border-color: var(--accent);
  background: #1E3D2A;
}

[data-theme="dark"] .help-example {
  background: #2A2820;
}

[data-theme="dark"] .search-wrap input {
  background: #2A2820;
  border-color: #4A4840;
  color: var(--text);
}

[data-theme="dark"] .country-list li:hover {
  background: #2A2820;
}

[data-theme="dark"] .archive-card {
  background: #242220;
  border-color: #3A3830;
}
[data-theme="dark"] .archive-card:hover {
  background: #2A2820;
}
[data-theme="dark"] .archive-tag {
  background: #2A2820;
  border-color: #4A4840;
}

[data-theme="dark"] .hint-reveal {
  background: #2A2215;
  border-color: #8B5E3C;
  color: #D4A574;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .modal-close {
    background: #3A3830;
    color: var(--text);
  }
  :root:not([data-theme="light"]) .modal-close:hover { background: #4A4840; }
  :root:not([data-theme="light"]) .tuto-text,
  :root:not([data-theme="light"]) .tuto-hint,
  :root:not([data-theme="light"]) .tuto-rules li { color: #C8C0B0; }
  :root:not([data-theme="light"]) .tuto-hint { background: #2A2820; }
  :root:not([data-theme="light"]) .tuto-hdr  { background: #0F0E0C; }
  :root:not([data-theme="light"]) .tuto-cell { background: #2A2820; border-color: #4A4840; color: #9A9285; }
  :root:not([data-theme="light"]) .tuto-choice { background: #2A2820; border-color: #4A4840; color: var(--text); }
  :root:not([data-theme="light"]) .search-wrap input { background: #2A2820; border-color: #4A4840; }
  :root:not([data-theme="light"]) .country-list li:hover { background: #2A2820; }
}

/* ---- Badge parfait ---- */
.end-badge-parfait {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(239,159,39,0.12);
  border: 1.5px solid #EF9F27;
  border-radius: 99px;
  padding: 7px 18px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #92400E;
  margin: 2px 0 6px;
}
[data-theme="dark"] .end-badge-parfait {
  background: rgba(239,159,39,0.15);
  color: #EF9F27;
}

/* ---- Le saviez-vous ? ---- */
.saviezvous-card {
  position: absolute;
  bottom: -82px;
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1.5px solid var(--accent);
  border-radius: 12px;
  padding: 12px 16px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s, transform 0.3s;
  z-index: 10;
  pointer-events: none;
}
.saviezvous-card.saviezvous-show {
  opacity: 1;
  transform: translateY(0);
}
.saviezvous-card.saviezvous-hide {
  opacity: 0;
  transform: translateY(8px);
}
.saviezvous-label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}
.saviezvous-text {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text);
  font-weight: 500;
}
