/* ===============================
   2048 – styles spécifiques
   =============================== */

:root {
  --tz-bleu: #1f5fbf;
  --tz-bleu-fonce: #174a96;
  --tz-fond: #bbada0;
  --tz-case: #cdc1b4;
  --tz-dur: 110ms; /* durée du glissement (modifiée par le jeu) */
}

/* ---------- Configuration ---------- */

.tz-panel {
  max-width: 600px;
  margin: 14px auto 36px auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  padding: 22px 32px 30px 32px;
  box-sizing: border-box;
}

.tz-intro {
  color: #555;
  line-height: 1.5;
  margin-bottom: 20px;
}

.tz-row {
  margin-bottom: 18px;
}

.tz-label {
  font-weight: bold;
  font-size: 0.95em;
  margin-bottom: 10px;
  color: #3a4250;
}

.tz-note {
  margin-top: 8px;
  font-size: 0.85em;
  color: #777;
}

.tz-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.tz-chips button {
  border: 2px solid #d3dae2;
  background: #f5f7fa;
  color: #333;
  border-radius: 22px;
  padding: 9px 18px;
  font-size: 0.95em;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}

.tz-chips button:hover {
  border-color: #8fb1dc;
}

.tz-chips button.sel {
  background: var(--tz-bleu);
  border-color: var(--tz-bleu);
  color: #fff;
}

.tz-start-row {
  text-align: center;
  padding-top: 8px;
}

.tz-start-row .tz-play {
  font-size: 1.1em;
  padding: 8px 34px;
}

/* Bouton principal (Jouer, Rejouer…) */
.tz-play {
  font-family: "Madimi One", sans-serif;
  font-size: 1.3em;
  letter-spacing: 0.5px;
  color: #fff;
  background: var(--tz-bleu);
  border: none;
  border-radius: 30px;
  padding: 12px 54px;
  cursor: pointer;
  box-shadow:
    0 4px 0 var(--tz-bleu-fonce),
    0 6px 14px rgba(31, 95, 191, 0.35);
  transition:
    transform 0.1s,
    box-shadow 0.1s,
    background 0.15s;
}

.tz-play:hover {
  background: #2a6fd6;
}

.tz-play:active {
  transform: translateY(3px);
  box-shadow:
    0 1px 0 var(--tz-bleu-fonce),
    0 2px 6px rgba(31, 95, 191, 0.3);
}

/* Boutons secondaires */
.tz-btn {
  font-size: 0.95em;
  color: var(--tz-bleu);
  background: #fff;
  border: 2px solid #c9d6e8;
  border-radius: 22px;
  padding: 8px 16px;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    opacity 0.15s;
}

.tz-btn:hover:not(:disabled) {
  background: #eef4fc;
  border-color: var(--tz-bleu);
}

.tz-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.tz-btn-danger {
  color: #c62828;
  border-color: #ecc4c4;
}

.tz-btn-danger:hover {
  background: #fdeeee;
  border-color: #c62828;
}

/* ---------- Écran de jeu ---------- */

/* Barre commune (css/games.css) aux couleurs du jeu */
.tz-jeu {
  --mg-jeu-largeur: 624px;
  --mgb-fond: radial-gradient(120% 160% at 0% 0%, rgba(237, 194, 46, 0.25), transparent 55%),
    linear-gradient(120deg, #2a2e36, #4a4f5c);
  --mgb-accent: #edc22e;
  --mgb-titre: linear-gradient(100deg, #f9e27a, #edc22e 50%, #f59563);
  --mg-fs-fond: #eef2f7;
  --mg-bulle-fond: #333842;
}

.tz-jeu .tz-panel {
  width: 100%;
  margin: 0 auto 26px auto;
}

#tz-game {
  padding: 0 8px;
}

.tz-jeu.mg-fs {
  justify-content: center;
}

/* Points gagnés : s'envolent au-dessus du score (dans la barre) */
.tz-jeu .mg-stat {
  position: relative;
}

.mg-stat b.record {
  color: #ffd54f;
}

/* Points gagnés : s'envolent au-dessus du score */
.tz-gain {
  position: absolute;
  left: 0;
  right: 0;
  top: 18px;
  text-align: center;
  font-family: "Madimi One", sans-serif;
  font-size: 1.2em;
  color: #8ee08e;
  pointer-events: none;
  opacity: 0;
}

.tz-gain.vole {
  animation: tz-vole 0.7s ease-out;
}

@keyframes tz-vole {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-34px);
  }
}

/* Ligne d'état sous la barre */
.tz-status {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  margin: 8px auto 4px auto;
  font-weight: bold;
  color: #333;
  text-align: center;
}

.tz-status.aide {
  color: #6b7482;
  font-weight: normal;
}

.tz-status.alerte {
  color: #c62828;
}

.tz-status.bravo {
  color: #2e7d32;
}

/* Grille : cases de fond et tuiles positionnées en absolu par le script */
.tz-board {
  position: relative;
  margin: 0 auto;
  background: var(--tz-fond);
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}

.tz-board:active {
  cursor: grabbing;
}

.tz-cell,
.tz-tile {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 6px;
}

.tz-cell {
  background: var(--tz-case);
}

.tz-tile {
  transition: transform var(--tz-dur) ease-in-out;
  z-index: 1;
}

.tz-tile.fige {
  transition: none;
}

.tz-tile.fusion {
  z-index: 2;
}

.tz-in {
  width: 100%;
  height: 100%;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Madimi One", sans-serif;
  line-height: 1;
  background: #eee4da;
  color: #776e65;
}

.tz-tile.nouveau .tz-in {
  animation: tz-apparait 0.2s ease-out calc(var(--tz-dur) * 0.9) backwards;
}

.tz-tile.fusion .tz-in {
  animation: tz-fusion 0.22s ease-out calc(var(--tz-dur) * 0.9) backwards;
}

@keyframes tz-apparait {
  from {
    opacity: 0;
    transform: scale(0);
  }
}

@keyframes tz-fusion {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

/* Couleurs des tuiles */
.v2 .tz-in {
  background: #eee4da;
}
.v4 .tz-in {
  background: #ede0c8;
}
.v8 .tz-in {
  background: #f2b179;
  color: #f9f6f2;
}
.v16 .tz-in {
  background: #f59563;
  color: #f9f6f2;
}
.v32 .tz-in {
  background: #f67c5f;
  color: #f9f6f2;
}
.v64 .tz-in {
  background: #f65e3b;
  color: #f9f6f2;
}
.v128 .tz-in {
  background: #edcf72;
  color: #f9f6f2;
  box-shadow: 0 0 12px 2px rgba(243, 215, 116, 0.35);
}
.v256 .tz-in {
  background: #edcc61;
  color: #f9f6f2;
  box-shadow: 0 0 14px 3px rgba(243, 215, 116, 0.45);
}
.v512 .tz-in {
  background: #edc850;
  color: #f9f6f2;
  box-shadow: 0 0 16px 4px rgba(243, 215, 116, 0.55);
}
.v1024 .tz-in {
  background: #edc53f;
  color: #f9f6f2;
  box-shadow: 0 0 18px 5px rgba(243, 215, 116, 0.6);
}
.v2048 .tz-in {
  background: #edc22e;
  color: #f9f6f2;
  box-shadow: 0 0 22px 6px rgba(243, 215, 116, 0.7);
}
.v4096 .tz-in {
  background: #3c8dde;
  color: #fff;
}
.v8192 .tz-in {
  background: #2e6fc0;
  color: #fff;
}
.vbig .tz-in {
  background: #3c3a32;
  color: #f9f6f2;
}

/* Grille grisée quand la partie est finie */
.tz-board.fini .tz-tile {
  opacity: 0.55;
  transition: opacity 0.6s;
}

/* ---------- Barre d'outils ---------- */

.tz-rule {
  text-align: center;
  font-size: 0.85em;
  color: #777;
  margin: 0 auto 14px auto;
}

/* ---------- Fenêtres (fin de partie, confirmation) ---------- */

.tz-modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  background: rgba(15, 25, 45, 0.55);
  animation: tz-fade 0.25s ease-out;
}

.tz-modal-box {
  background: #fff;
  border-radius: 20px;
  padding: 24px 26px 22px 26px;
  width: 100%;
  max-width: 440px;
  box-sizing: border-box;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  animation: tz-pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.tz-modal-btns {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}

.tz-modal-btns .tz-play {
  font-size: 1.15em;
  padding: 10px 40px;
}

.tz-modal-btns2 {
  margin-top: 14px;
}

.tz-end-title {
  font-family: "Madimi One", sans-serif;
  font-size: 2.2em;
  line-height: 1.1;
  color: #2a2f38;
}

.tz-end-title.gagne {
  color: #2e7d32;
}

.tz-end-title.perdu {
  color: #c62828;
}

.tz-end-sub {
  margin-top: 8px;
  color: #555;
  line-height: 1.45;
}

.tz-confirm-txt {
  font-weight: bold;
  font-size: 1.05em;
  color: #333;
  line-height: 1.4;
}

@keyframes tz-fade {
  from {
    opacity: 0;
  }
}

@keyframes tz-pop {
  from {
    transform: scale(0.7);
    opacity: 0;
  }
}

@media (max-width: 520px) {
  .tz-panel {
    padding: 16px 18px 24px 18px;
  }
  .tz-btn {
    padding: 7px 12px;
    font-size: 0.9em;
  }
  .tz-end-title {
    font-size: 1.8em;
  }
}
