/* === Défends ton Village — page de jeu (solo) === */

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

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: #14210c;
  color: #e7efe0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.dtv-wrapper {
  width: 100%;
  max-width: 1180px;
  padding: 8px 10px 24px;
}

/* --- Barre du haut --- */
.dtv-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.dtv-retour {
  color: #bbf7d0;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 6px 12px;
  border: 1px solid rgba(187, 247, 208, 0.3);
  border-radius: 8px;
  transition: background 0.15s, border-color 0.15s;
}
.dtv-retour:hover { background: rgba(187, 247, 208, 0.12); border-color: rgba(187, 247, 208, 0.6); }

/* Le HUD suit « Accueil », à gauche : la barre de connexion du réseau est fixée
   en haut à droite et le recouvrait sur tous les écrans de moins de 1600 px. */
.dtv-hud {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.dtv-son {
  background: rgba(20, 40, 12, 0.7);
  border: 1px solid rgba(134, 239, 172, 0.18);
  border-radius: 10px;
  font-size: 1.2rem;
  line-height: 1;
  padding: 10px 12px;
  cursor: pointer;
}
.dtv-son:hover { border-color: rgba(134, 239, 172, 0.5); }
.dtv-son[hidden] { display: none; }
.dtv-hud-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 64px;
  padding: 5px 12px;
  background: rgba(20, 40, 12, 0.7);
  border: 1px solid rgba(134, 239, 172, 0.18);
  border-radius: 10px;
}
.dtv-hud-cell .lbl { font-size: 0.7rem; color: #9ec995; letter-spacing: 0.5px; }
.dtv-hud-cell .val { font-size: 1.25rem; font-weight: 800; color: #f0fdf4; font-variant-numeric: tabular-nums; }

/* --- Scène : canvas + colonne latérale --- */
.dtv-stage {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.dtv-canvas-frame {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  max-width: 960px;
  aspect-ratio: 16 / 9;
  /* Le dézoom de la vague 66 EST cette transition : le cadre s'allonge, le
     renderer cale toujours la largeur, donc le bas de la carte (la rivière)
     entre dans le champ. Aucune animation de caméra en JS. */
  transition: aspect-ratio 1.6s cubic-bezier(0.22, 1, 0.36, 1);
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid rgba(134, 239, 172, 0.25);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  background: #365314;
}
/* Terrain complet révélé (960 x 660) : la rivière est dans le champ. */
.dtv-canvas-frame.etendu { aspect-ratio: 960 / 660; }
/* Reprise d'une partie déjà au-delà de la vague 66 : on ne rejoue pas l'animation. */
.dtv-canvas-frame.sans-transition { transition: none; }

#dtv-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

/* --- Colonne latérale (boutique) --- */
.dtv-side {
  flex: 0 0 250px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dtv-phase {
  font-size: 0.85rem;
  color: #cde8c0;
  min-height: 2.4em;
  line-height: 1.2;
}
.dtv-shop-titre {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #9ec995;
  margin-top: 4px;
}
.dtv-shop { display: flex; flex-direction: column; gap: 8px; }

.dtv-shop-btn {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "emoji nom cout" "emoji desc desc";
  gap: 1px 10px;
  align-items: center;
  text-align: left;
  padding: 8px 12px;
  background: rgba(20, 40, 12, 0.7);
  border: 1.5px solid rgba(134, 239, 172, 0.2);
  border-radius: 10px;
  color: #e7efe0;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.dtv-shop-btn:hover { border-color: rgba(134, 239, 172, 0.55); background: rgba(30, 55, 18, 0.85); }
.dtv-shop-btn.actif {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.16);
  box-shadow: inset 0 0 0 2px rgba(245, 158, 11, 0.4);
}
.dtv-shop-btn.inabordable { opacity: 0.5; }
/* Tour pas encore débloquée : grisée, mais toujours lisible — voir ce qui arrive fait partie de la carotte. */
.dtv-shop-btn.verrouille {
  opacity: 0.45;
  filter: grayscale(0.8);
  cursor: not-allowed;
}
.dtv-shop-btn.verrouille:hover { border-color: rgba(134, 239, 172, 0.2); background: rgba(20, 40, 12, 0.7); }
/* Nombre maximum d'exemplaires en jeu (dirigeable) */
.dtv-shop-btn.plein { opacity: 0.6; cursor: not-allowed; }
.dtv-shop-btn.plein .dtv-shop-cout { color: #fca5a5; }
.dtv-shop-btn.verrouille .dtv-shop-cout { color: #9ec995; }
.dtv-shop-emoji { grid-area: emoji; font-size: 1.7rem; }
.dtv-shop-nom { grid-area: nom; font-weight: 700; }
.dtv-shop-cout { grid-area: cout; font-weight: 700; color: #fbbf24; font-size: 0.85rem; white-space: nowrap; }
.dtv-shop-desc { grid-area: desc; font-size: 0.72rem; color: #9ec995; }

.dtv-aide { font-size: 0.72rem; color: #8fae84; line-height: 1.3; margin-top: 2px; }

/* Composition de la prochaine vague, sous le bouton de lancement */
.dtv-apercu { font-size: 0.78rem; color: #cde8c0; min-height: 1.2em; margin-top: -4px; }

.dtv-controles { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.dtv-btn-pause {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 6px 12px;
  font-size: 0.8rem;
}
.dtv-btn-pause[hidden] { display: none; }

/* Voile de pause, par-dessus le terrain */
.dtv-pause-voile {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 20, 6, 0.45);
  z-index: 5;
  pointer-events: none;
  font-size: 1.6rem;
  font-weight: 900;
  color: #f0fdf4;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
}
.dtv-pause-voile.visible { display: flex; }

/* --- Boutons génériques --- */
.dtv-btn {
  padding: 10px 16px;
  border: none;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.15s, opacity 0.15s;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  color: #fff;
}
.dtv-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.dtv-btn-lancer {
  background: #b45309;
  font-size: 1rem;
  box-shadow: none;
}
.dtv-btn-lancer:not(:disabled):hover { transform: translateY(-1px); box-shadow: none; }
.dtv-btn-primaire { background: #16a34a; box-shadow: none; }
.dtv-btn-primaire:hover { transform: translateY(-1px); }
.dtv-btn-second { background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.18); }
.dtv-btn-second:hover { background: rgba(255, 255, 255, 0.16); }
.dtv-btn-amel { background: #16a34a; flex: 1; }
.dtv-btn-vendre { background: #b45309; flex: 1; }

/* --- Sélecteur de vitesse (x1 / x2 / x3) --- */
.dtv-vitesse {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.dtv-vitesse-lbl {
  font-size: 0.72rem;
  color: #9ec995;
  letter-spacing: 0.5px;
}
.dtv-vitesse-btns {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: rgba(20, 40, 12, 0.7);
  border: 1px solid rgba(134, 239, 172, 0.18);
  border-radius: 9px;
}
.dtv-vitesse-btn {
  padding: 4px 11px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #cde8c0;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.dtv-vitesse-btn:hover { background: rgba(134, 239, 172, 0.14); }
.dtv-vitesse-btn.actif {
  background: #15803d;
  color: #fff;
}

/* --- Abandon (discret : ce n'est pas une action qu'on cherche) --- */
.dtv-btn-abandon {
  background: transparent;
  border: 1px solid rgba(252, 165, 165, 0.28);
  color: #fca5a5;
  font-size: 0.78rem;
  padding: 7px 12px;
}
.dtv-btn-abandon:hover { background: rgba(220, 38, 38, 0.14); border-color: rgba(252, 165, 165, 0.6); }
.dtv-btn-abandon[hidden] { display: none; }

/* --- Panneau tour sélectionnée --- */
.dtv-panneau {
  position: absolute;
  left: 10px;
  bottom: 10px;
  width: 230px;
  background: rgba(15, 28, 8, 0.95);
  border: 1px solid rgba(134, 239, 172, 0.35);
  border-radius: 12px;
  padding: 12px 14px 14px;
  display: none;
  z-index: 6;
}
.dtv-panneau.visible { display: block; }
.dtv-panneau-fermer {
  position: absolute;
  top: 6px; right: 8px;
  background: none; border: none;
  color: #9ec995; font-size: 1.3rem;
  cursor: pointer; line-height: 1;
}
.dtv-panneau-titre { font-weight: 800; margin-bottom: 8px; padding-right: 18px; }
.dtv-panneau-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 10px;
  font-size: 0.78rem;
  color: #cde8c0;
  margin-bottom: 10px;
}
.dtv-panneau-stats b { color: #f0fdf4; }
/* Ligne « amplifiée par un beffroi » : occupe toute la largeur du panneau */
.dtv-panneau-stats .dtv-buff {
  grid-column: 1 / -1;
  color: #fbbf24;
  font-weight: 700;
  font-size: 0.74rem;
}
.dtv-panneau-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.dtv-panneau-actions .dtv-btn { padding: 8px 6px; font-size: 0.78rem; flex: 1 1 auto; }
.dtv-btn-cibler { background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.2); }
.dtv-btn-cibler[hidden] { display: none; }
.dtv-btn-deplacer { background: #0284c7; color: #f0f9ff; }
.dtv-btn-deplacer:hover:not(:disabled) { background: #0369a1; }
.dtv-btn-deplacer[hidden] { display: none; }

/* --- Toast --- */
.dtv-toast {
  position: absolute;
  top: 12px; left: 50%;
  transform: translate(-50%, -12px);
  background: rgba(15, 28, 8, 0.95);
  border: 1px solid rgba(245, 158, 11, 0.5);
  color: #fde68a;
  padding: 8px 18px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.88rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 8;
}
.dtv-toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* --- Overlays --- */
.dtv-overlay {
  position: absolute;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
  background: rgba(10, 20, 6, 0.82);
  z-index: 10;
  padding: 16px;
}
.dtv-overlay.visible { display: flex; }
.dtv-overlay-card {
  background: rgba(20, 40, 12, 0.97);
  border: 1px solid rgba(134, 239, 172, 0.3);
  border-radius: 18px;
  padding: 26px 30px;
  text-align: center;
  max-width: 420px;
  width: 100%;
  max-height: 92%;
  overflow-y: auto;
}
.dtv-overlay-card h2 {
  font-size: 1.6rem;
  margin-bottom: 12px;
  color: #86efac;
}
.dtv-overlay-card p { color: #cde8c0; margin-bottom: 8px; font-size: 0.92rem; line-height: 1.4; }
.dtv-overlay-card p.muted { color: #9ec995; font-size: 0.82rem; }
/* Les liens de texte en jaune, pas les boutons-liens : « Créer un compte » était
   écrit en jaune sur vert et avait l'air désactivé. */
.dtv-overlay-card a:not(.dtv-btn) { color: #fbbf24; }
.dtv-overlay-card a.dtv-btn { color: #fff; }
.dtv-go-info { color: #fde68a !important; font-weight: 700; margin-top: 12px !important; }
.dtv-lien-btn {
  background: none;
  border: none;
  color: #9ec995;
  text-decoration: underline;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  margin-top: 6px;
}
.dtv-score-final {
  font-size: 2.6rem !important;
  font-weight: 900;
  color: #fbbf24 !important;
  margin: 6px 0 !important;
  font-variant-numeric: tabular-nums;
}
.dtv-overlay-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.dtv-save-note { color: #7dd3fc !important; font-size: 0.8rem !important; margin-top: 10px !important; }

/* --- Bouton « vague de boss » --- */
.dtv-btn-boss {
  background: #dc2626 !important;
  box-shadow: none !important;
}

/* --- Badge de sauvegarde --- */
.dtv-save-badge {
  font-size: 0.72rem;
  color: #7dd3fc;
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.2;
}
.dtv-save-ok {
  color: #22c55e;
  font-weight: 700;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.25s, transform 0.25s;
}
.dtv-save-badge.flash .dtv-save-ok { opacity: 1; transform: translateX(0); }

/* --- Barre de vie du boss (en haut du canvas) --- */
.dtv-boss-bar {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: min(70%, 460px);
  display: none;
  flex-direction: column;
  gap: 3px;
  z-index: 7;
  pointer-events: none;
}
.dtv-boss-bar.visible { display: flex; }
.dtv-boss-nom {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 800;
  color: #fecaca;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  letter-spacing: 0.5px;
}
.dtv-boss-track {
  height: 12px;
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(239, 68, 68, 0.6);
  border-radius: 7px;
  overflow: hidden;
}
.dtv-boss-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ef4444, #b91c1c);
  transition: width 0.2s linear;
}

/* --- Warning plein écran (vague de boss) --- */
.dtv-warning {
  position: absolute;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 9;
  pointer-events: none;
  background: radial-gradient(circle, rgba(127, 29, 29, 0.35), rgba(0, 0, 0, 0.55));
}
.dtv-warning.visible { display: flex; animation: dtv-warn-flash 0.5s steps(2) 4; }
@keyframes dtv-warn-flash {
  0%, 100% { background: radial-gradient(circle, rgba(127,29,29,0.15), rgba(0,0,0,0.4)); }
  50% { background: radial-gradient(circle, rgba(220,38,38,0.45), rgba(0,0,0,0.6)); }
}
.dtv-warning-inner {
  text-align: center;
  transform: scale(0.8);
  animation: dtv-warn-pop 0.4s ease-out forwards;
}
@keyframes dtv-warn-pop {
  to { transform: scale(1); }
}
.dtv-warning-icon { font-size: 3.2rem; display: block; animation: dtv-warn-shake 0.4s ease-in-out infinite; }
@keyframes dtv-warn-shake {
  0%, 100% { transform: rotate(-6deg); }
  50% { transform: rotate(6deg); }
}
.dtv-warning-txt {
  display: block;
  margin-top: 8px;
  font-size: 1.5rem;
  font-weight: 900;
  color: #fee2e2;
  text-shadow: 0 0 14px rgba(239, 68, 68, 0.9), 0 2px 4px rgba(0, 0, 0, 0.8);
  letter-spacing: 1px;
}

/* --- Bandeau de déblocage de niveau --- */
.dtv-unlock {
  position: absolute;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -10px);
  background: rgba(20, 40, 12, 0.95);
  border: 1px solid rgba(245, 158, 11, 0.7);
  color: #fde68a;
  padding: 10px 20px;
  border-radius: 14px;
  font-weight: 800;
  font-size: 1rem;
  text-align: center;
  z-index: 9;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
}
.dtv-unlock.visible { opacity: 1; transform: translate(-50%, 0); }

/* --- Responsive : la colonne passe sous le canvas --- */
@media (max-width: 860px) {
  /* La barre de connexion du réseau est fixée en haut : on lui laisse sa place,
     sinon elle recouvre « Accueil ». */
  .dtv-wrapper { padding-top: 50px; }
  .dtv-stage { flex-direction: column; }
  .dtv-side { flex-basis: auto; width: 100%; }
  .dtv-hud { flex: 1; min-width: 0; justify-content: space-between; flex-wrap: nowrap; gap: 6px; }
  .dtv-hud-cell { min-width: 0; flex: 1; padding: 4px 4px; }
  .dtv-hud-cell .val { font-size: 1.05rem; }
  .dtv-topbar { flex-wrap: wrap; }
  .dtv-retour { order: 0; }
  .dtv-son { order: 1; margin-left: auto; }
  .dtv-hud { order: 2; flex-basis: 100%; }

  /* Boutique compacte : icône, nom, prix. La description s'affiche au choix de
     la tour (toast), elle faisait déborder la page à droite. */
  .dtv-shop { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .dtv-shop-btn {
    grid-template-columns: 1fr;
    grid-template-areas: "emoji" "nom" "cout";
    justify-items: center;
    text-align: center;
    padding: 6px 4px;
    min-width: 0;
  }
  .dtv-shop-desc { display: none; }
  .dtv-shop-nom { font-size: 0.72rem; line-height: 1.15; }
  .dtv-shop-cout { font-size: 0.72rem; white-space: normal; }
  .dtv-shop-emoji { font-size: 1.5rem; }

  /* Le cadre du terrain passe au-dessus de la colonne : sans ça, le panneau et
     les écrans qu'il contient, placés en « fixed », passaient sous la boutique. */
  .dtv-canvas-frame { z-index: 20; }
  .dtv-toast { font-size: 0.78rem; padding: 6px 12px; max-width: 92%; text-align: center; }

  /* Écrans (départ, fin, abandon, inscription) en plein écran : dans le cadre du
     terrain (≈ 200 px de haut sur un téléphone), leurs boutons étaient coupés. */
  .dtv-overlay { position: fixed; z-index: 1100; }
  .dtv-overlay-card { max-height: 90vh; }

  /* Panneau de tour en bas de l'écran plutôt que sur le terrain, qu'il masquait aux deux tiers. */
  .dtv-panneau {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    width: auto;
    border-radius: 14px 14px 0 0;
    z-index: 1050;
    background: #0f1c08;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.5);
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }
  .dtv-panneau-actions .dtv-btn { padding: 11px 6px; }
  .dtv-panneau-fermer { top: 2px; right: 4px; font-size: 1.7rem; padding: 6px 12px; }
}
@media (max-width: 520px) {
  .dtv-overlay-card { padding: 20px 18px; }
  .dtv-overlay-card h2 { font-size: 1.3rem; }
}

/* --- Téléphone en paysage : terrain à gauche, commandes à droite, tout à l'écran --- */
@media (max-height: 520px) and (orientation: landscape) {
  .dtv-wrapper { padding: 6px 10px; max-width: none; }
  .dtv-topbar { margin-bottom: 6px; padding-right: 380px; flex-wrap: nowrap; }
  .dtv-retour { white-space: nowrap; padding: 6px 10px; }
  .dtv-hud { flex-basis: auto; order: 1; }
  .dtv-son { order: 2; margin-left: 0; }
  .dtv-hud-cell { flex-direction: row; gap: 4px; padding: 3px 8px; }
  .dtv-hud-cell .lbl { font-size: 0.65rem; }
  .dtv-hud-cell .val { font-size: 0.95rem; }
  .dtv-stage { flex-direction: row; gap: 10px; }
  .dtv-canvas-frame { width: min(100%, calc((100dvh - 76px) * 16 / 9)); flex: 0 0 auto; }
  .dtv-canvas-frame.etendu { width: min(100%, calc((100dvh - 76px) * 960 / 660)); }
  .dtv-side {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    max-height: calc(100dvh - 76px);
    overflow-y: auto;
    gap: 6px;
  }
  .dtv-phase { min-height: 0; font-size: 0.75rem; }
  .dtv-btn-lancer { padding: 8px 10px; font-size: 0.85rem; }
  .dtv-shop { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dtv-aide, .dtv-save-badge { display: none; }
  .dtv-panneau { left: auto; width: 320px; border-radius: 14px 0 0 0; }
}
