/* ===============================
   Tower Defense – styles spécifiques
   =============================== */

/* Barre commune (css/games.css) aux couleurs du terrain */
.td-jeu {
  --mg-jeu-largeur: 1132px;
  --mgb-fond: radial-gradient(120% 160% at 0% 0%, rgba(230, 126, 34, 0.25), transparent 55%),
    linear-gradient(120deg, #1e3a20, #3d6b2f);
  --mgb-accent: #f9e79f;
  --mgb-titre: linear-gradient(100deg, #f9e79f, #e67e22);
  --mg-fs-fond: #eef3e6;
  --mg-bulle-fond: #2c3e50;
}

/* Vitesse (×1, ×2…) : texte dans un bouton rond de la barre */
.td-jeu .td-speed {
  font-weight: 800;
  font-size: 0.85rem;
}

.td-jeu .mg-barre-btn.on {
  background: var(--mgb-accent);
  color: #2c3e50;
}

.td-jeu.mg-fs .td-root {
  flex: 1;
  min-height: 0;
}

.td-jeu.mg-fs .td-board {
  flex-basis: calc((100vh - 110px) * 4 / 3);
}

.td-jeu.mg-fs #td-canvas {
  max-width: none;
}

.td-root {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 18px;
  margin: 0 auto 20px auto;
}

.td-board {
  position: relative;
  flex: 0 1 800px;
  min-width: 0;
}

#td-canvas {
  display: block;
  width: 100%;
  max-width: 800px;
  aspect-ratio: 4 / 3;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(30, 50, 30, 0.3);
  cursor: crosshair;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

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

.td-side {
  flex: 0 0 290px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.td-stat.td-bump b {
  animation: td-bump 0.35s;
}

@keyframes td-bump {
  40% {
    transform: scale(1.3);
    color: #c0392b;
  }
}

.td-wave-btn {
  position: relative;
  overflow: hidden;
  border: none;
  border-radius: 12px;
  padding: 12px 10px 14px 10px;
  background: #e67e22;
  color: #fff;
  font-weight: bold;
  font-size: 1em;
  cursor: pointer;
  box-shadow: 0 3px 0 #b85f12;
  transition: background 0.15s;
}

.td-wave-btn:hover:not(:disabled) {
  background: #d35400;
}

.td-wave-btn:disabled {
  background: #95a5a6;
  box-shadow: 0 3px 0 #7f8c8d;
  cursor: not-allowed;
}

.td-wave-lbl {
  position: relative;
  z-index: 1;
}

.td-wave-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 5px;
  width: 0;
  background: #f9e79f;
}

/* ---------- Boutique ---------- */

.td-shop {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.td-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  padding: 4px 6px;
  cursor: pointer;
  text-align: left;
  transition:
    transform 0.12s,
    border-color 0.12s;
}

.td-card:hover {
  transform: translateY(-2px);
}

.td-card canvas {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
}

.td-card-name {
  display: block;
  font-weight: bold;
  color: #2c3e50;
  font-size: 0.95em;
}

.td-card-cost {
  display: block;
  font-size: 0.85em;
  color: #9a6a00;
  font-weight: bold;
}

.td-card-key {
  position: absolute;
  top: 3px;
  right: 6px;
  font-size: 0.7em;
  color: #aab4bd;
  font-weight: bold;
}

.td-card.sel {
  border-color: #27ae60;
  background: #eafaf0;
}

.td-card.poor {
  opacity: 0.45;
}

/* ---------- Informations ---------- */

.td-info {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  padding: 12px 14px;
  color: #34495e;
  font-size: 0.93em;
  line-height: 1.4;
}

.td-info-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: "Madimi One", cursive;
  font-size: 1.3em;
  color: #2c3e50;
  margin-bottom: 4px;
}

.td-pips {
  font-family: Arial, sans-serif;
  font-size: 0.7em;
  color: #f1c40f;
  letter-spacing: 1px;
}

.td-desc {
  color: #6b7a86;
  margin-bottom: 6px;
}

.td-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  border-bottom: 1px dashed #e3e8ec;
}

.td-row b {
  color: #2c3e50;
}

.td-next {
  color: #27ae60;
  font-weight: bold;
}

.td-modes {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin: 8px 0;
}

.td-modes button {
  border: 2px solid #dfe6ec;
  background: #f6f8fa;
  border-radius: 8px;
  padding: 4px 0;
  font-size: 0.82em;
  cursor: pointer;
  color: #34495e;
}

.td-modes button.sel {
  border-color: #2c3e50;
  background: #2c3e50;
  color: #fff;
}

.td-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}

.td-actions button {
  border: none;
  border-radius: 9px;
  padding: 8px 4px;
  color: #fff;
  font-weight: bold;
  cursor: pointer;
}

.td-up {
  background: #27ae60;
}

.td-up:disabled {
  background: #95a5a6;
  cursor: not-allowed;
}

.td-sell {
  background: #e74c3c;
}

.td-keys {
  margin-top: 8px;
  font-size: 0.85em;
  color: #8a97a3;
}

.td-keys kbd {
  display: inline-block;
  min-width: 16px;
  padding: 0 4px;
  border: 1px solid #cfd6dc;
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #f7f9fa;
  font-size: 0.9em;
  text-align: center;
  color: #4a5864;
}

/* ---------- Fin de partie ---------- */

.td-over {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 30, 20, 0.55);
  border-radius: 12px;
}

.td-over-box {
  background: #fff;
  border-radius: 14px;
  padding: 22px 30px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.td-over-title {
  font-family: "Madimi One", cursive;
  font-size: 2em;
  color: #c0392b;
}

.td-over-text {
  margin: 6px 0 14px 0;
  font-size: 1.1em;
  line-height: 1.5;
}

/* ---------- Choix du terrain ---------- */

.td-choose-box {
  max-width: 94%;
  max-height: 94%;
  overflow-y: auto;
  padding: 16px 18px;
  box-sizing: border-box;
}

.td-choose-title {
  color: #2c3e50;
  font-size: 1.6em;
  margin-bottom: 10px;
}

.td-path-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  min-width: min(560px, 80vw);
}

.td-path-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 3px solid #e3e8ec;
  border-radius: 12px;
  background: #fff;
  padding: 6px;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
}

.td-path-card:hover {
  transform: translateY(-3px);
  border-color: #3498db;
}

.td-path-card.sel {
  border-color: #27ae60;
}

.td-path-card canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
}

.td-path-card span {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 4px;
  color: #2c3e50;
}

.td-path-card i {
  font-style: normal;
  font-size: 0.75em;
  font-weight: bold;
  color: #fff;
  border-radius: 8px;
  padding: 1px 7px;
}

@media (max-width: 1150px) {
  .td-root {
    flex-direction: column;
    align-items: center;
  }
  .td-board {
    flex: none;
    width: 100%;
    max-width: 800px;
  }
  .td-side {
    flex: none;
    width: 100%;
    max-width: 800px;
  }
  .td-shop {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}
