html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 6px 0 24px;
  padding: 0;
  background: linear-gradient(to right, blue, purple);
  font-family: "Bungee", sans-serif;
  font-weight: 400;
  font-style: normal;
  color: white;
  overflow: hidden;
}

#H-H2O48-ht {
  color: rgba(255, 255, 255, 0.8);
}
#O-H2048-ht {
  color: rgb(116, 192, 252);
}

/* ── ARROWS ── */
#info-arrows {
  display: grid;
  grid-template-columns: repeat(3, 60px);
  grid-template-rows: repeat(3, 60px);
  gap: 10px;
  justify-items: center;
  align-items: center;
  justify-content: center;
  align-content: end;
  min-height: 55vh;
  box-sizing: border-box;
}
#info-arrows .arrow-up {
  grid-column: 2;
  grid-row: 1;
}
#info-arrows .arrow-left {
  grid-column: 1;
  grid-row: 2;
}
#info-arrows .arrow-down {
  grid-column: 2;
  grid-row: 2;
}
#info-arrows .arrow-right {
  grid-column: 3;
  grid-row: 2;
}

/* ── BTN BASE ── */
.btn-base {
  background: var(--btn-bg, #0288d1);
  color: var(--btn-color, white);
  border: 1px solid var(--btn-border, rgba(255, 255, 255, 0.25));
  border-radius: var(--btn-radius, 14px);
  padding: var(--btn-padding, 12px 22px);
  width: var(--btn-width, auto);
  height: var(--btn-height, auto);
  min-width: var(--btn-min-width, 0);
  min-height: var(--btn-min-height, 0);
  box-shadow: 0 5px 0 var(--btn-shadow, #01579b);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    filter 0.15s ease,
    background 0.2s ease,
    box-shadow 0.15s ease;
  outline: none;
  user-select: none;
  font-family: "Bungee", sans-serif;
}
.btn-base:hover {
  filter: brightness(1.08);
}
.btn-base:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--btn-shadow, #01579b);
  filter: brightness(0.88);
}

/* --- BTN REJOUER LIQUID GLASS --- */
#restart-btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-family: "Bungee", sans-serif;
  font-size: 18px;
  padding: 16px 40px;
  border-radius: 20px;
  color: white;
  position: relative;
  outline: none;

  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);

  /* Bordures de cristal fines et brillantes */
  border: 1.5px solid rgba(255, 255, 255, 0.4);

  /* 3D Réaliste : L'épaisseur est maintenant translucide elle aussi */
  box-shadow:
    0 8px 0 rgba(255, 255, 255, 0.1),
    /* Le socle en verre */ 0 15px 35px rgba(0, 0, 0, 0.3),
    /* L'ombre portée au sol */ inset 0 1px 2px rgba(255, 255, 255, 0.5); /* Éclat sur le rebord intérieur */

  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);

  /* Nettoyage des bords */
  background-clip: padding-box;
  overflow: hidden;
}

/* Nouveau reflet linéaire (plus de cercle au milieu) */
#restart-btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 45%;
  /* Dégradé plat pour simuler un reflet de vitre */
  background: linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.25) 0%,
    rgba(255, 255, 255, 0.05) 100%
  );
  pointer-events: none;
}

/* Animation Jelly + Enfoncement */
#restart-btn.is-pressing {
  animation: jelly 0.4s ease;
  transform: translateY(6px); /* S'enfonce sur le socle */
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.1),
    0 5px 15px rgba(0, 0, 0, 0.4);
}

@keyframes jelly {
  0% {
    transform: translateY(0) scale(1, 1);
  }
  30% {
    transform: translateY(6px) scale(1.1, 0.9);
  } /* Compression */
  60% {
    transform: translateY(4px) scale(0.98, 1.02);
  } /* Rebond */
  100% {
    transform: translateY(6px) scale(1, 1);
  }
}

/* Hover : Le bouton s'illumine légèrement */
#restart-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  filter: brightness(1.1);
  transform: translateY(-2px);
  box-shadow:
    0 10px 0 rgba(0, 0, 0, 0.25),
    0 20px 30px rgba(0, 0, 0, 0.4),
    inset 0 4px 4px rgba(255, 255, 255, 0.5);
}

/* Active : ENFONCEMENT */
#restart-btn:active {
  transform: translateY(6px);
  box-shadow:
    0 2px 0 rgba(0, 0, 0, 0.25),
    0 5px 10px rgba(0, 0, 0, 0.3),
    inset 0 2px 5px rgba(0, 0, 0, 0.3);
  filter: brightness(0.9);
  transition: all 0.05s;
}

.btn-arrow {
  --btn-width: 60px;
  --btn-height: 60px;
  --btn-padding: 0;
  --btn-radius: 12px;
  --btn-bg: #0288d1;
  --btn-shadow: #01579b;
}
.arrow-icon {
  font-family: "Bungee", cursive !important;
  font-size: 32px;
  display: inline-block;
  pointer-events: none;
  line-height: 1;
}
.left {
  transform: rotate(-90deg);
}
.right {
  transform: rotate(90deg);
}
.down {
  transform: rotate(180deg);
}
.up {
  transform: rotate(0deg);
}

/* ── SETTINGS ICON ── */
#icon-settings {
  width: 40px;
  height: 40px;
  cursor: pointer;
  transition:
    color 0.4s ease-in-out,
    transform 0.4s ease-in-out;
  color: rgba(255, 255, 255, 0.8);
  display: flex;
  transform-origin: center center;
}
#icon-settings:hover {
  color: white;
  transform: scale(1.2) rotate(45deg);
}
#btn-settings {
  border: none;
  background-color: transparent;
  padding: 0;
  display: flex;
}

/* ── LAYOUT ── */
main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
}
.game-settings-row {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 20px;
  margin-top: 16px;
}
.play-area {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 20px;
}

/* ── SETTINGS PANEL ── */
#settings-play {
  opacity: 0;
  max-height: 0;
  overflow: visible;
  align-self: flex-start;
  transition:
    opacity 0.3s ease,
    max-height 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 8px;
}
.param-card,
.toggle-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  box-sizing: border-box;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}
.toggle-control__label {
  color: rgba(255, 255, 255, 0.92);
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
}
.toggle-control {
  overflow: visible;
}

/* The switch - the box around the slider */
.switch {
  font-size: 13px;
  position: relative;
  display: inline-block;
  width: 3.5em;
  height: 2em;
}

/* Hide default HTML checkbox */
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

/* The slider */
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgb(141, 141, 141);
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.3);
  transition: .4s;
  border-radius: 10px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 1.4em;
  width: 1.4em;
  border-radius: 6px;
  left: 0.3em;
  bottom: 0.3em;
  transform: rotate(270deg);
  background-color: rgb(255, 255, 255);
  transition: .4s;
}

.switch input:checked + .slider {
  background-color: #2196F3;
  box-shadow: 0 0 6px rgba(33, 150, 243, 0.6);
}

.switch input:focus + .slider {
  outline: none;
}

.switch input:checked + .slider:before {
  transform: translateX(1.5em);
}

#settings-play button.btn-base {
  font-size: 14px;
}

/* ── GAME BOARD ── */
#game {
  width: min(500px, 90vw);
  height: min(500px, 90vw);
  margin: 0 0 48px 0;
  background-color: rgba(255, 255, 255, 0.15);
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 15px;
  padding: 10px;
  transition:
    width 0.4s ease,
    height 0.4s ease,
    margin 0.4s ease,
    transform 0.4s ease;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  position: relative;
  touch-action: none; /* Prevents scroll on mobile swipe */
}

/* ── TILES (Pixel Perfect Positionning) ── */
.tile {
  box-sizing: border-box; /* Indispensable pour inclure le padding dans la taille */
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: bold;
  border-radius: 15px;
  overflow: hidden;
  padding: 2px;
  container-type: inline-size;
  position: absolute;
  z-index: 10;
  transform-style: preserve-3d;
  will-change: left, top, transform;

  /* --- CALCULS DYNAMIQUES --- */

  /* 1. Taille d'une tuile : (Largeur totale - padding wrapper - somme des gaps) / nombre de tuiles */
  --tile-size: calc(
    (100% - 20px - (var(--grid-size, 6) - 1) * 8px) / var(--grid-size, 6)
  );

  width: var(--tile-size);
  height: var(--tile-size);

  /* 2. Position : padding départ + (taille tuile + gap) * index */
  left: calc(10px + var(--x) * (var(--tile-size) + 8px));
  top: calc(10px + var(--y) * (var(--tile-size) + 8px));

  /* --- ANIMATIONS --- */
  transition:
    left 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    top 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.18s cubic-bezier(0.4, 0, 0.2, 1),
    background-color 0.25s ease,
    opacity 0.2s ease;
}
.tile span {
  font-size: clamp(12px, 35cqw, 32px);
}

.tile-2 {
  background-color: #e0f7fa;
  color: #555;
}
.tile-2:hover {
  box-shadow: 0 0 16px rgba(224, 247, 250, 0.6);
  transition: box-shadow 0.6s ease;
}
.tile-4 {
  background-color: #b2ebf2;
  color: #555;
}
.tile-4:hover {
  box-shadow: 0 0 16px rgba(178, 235, 242, 0.6);
  transition: box-shadow 0.6s ease;
}
.tile-8 {
  background-color: #81d4fa;
  color: #fff;
}
.tile-8:hover {
  box-shadow: 0 0 16px rgba(129, 212, 250, 0.6);
  transition: box-shadow 0.6s ease;
}
.tile-16 {
  background-color: #4fc3f7;
  color: #fff;
}
.tile-16:hover {
  box-shadow: 0 0 16px rgba(79, 195, 247, 0.6);
  transition: box-shadow 0.6s ease;
}
.tile-32 {
  background-color: #29b6f6;
  color: #fff;
}
.tile-32:hover {
  box-shadow: 0 0 16px rgba(41, 182, 246, 0.6);
  transition: box-shadow 0.6s ease;
}
.tile-64 {
  background-color: #039be5;
  color: #fff;
}
.tile-64:hover {
  box-shadow: 0 0 16px rgba(3, 157, 229, 0.6);
  transition: box-shadow 0.6s ease;
}
.tile-128 {
  background-color: #0288d1;
  color: #fff;
}
.tile-128:hover {
  box-shadow: 0 0 16px rgba(2, 136, 209, 0.6);
  transition: box-shadow 0.6s ease;
}
.tile-256 {
  background-color: #0277bd;
  color: #fff;
}
.tile-256:hover {
  box-shadow: 0 0 16px rgba(2, 119, 189, 0.6);
  transition: box-shadow 0.6s ease;
}
.tile-512 {
  background-color: #01579b;
  color: #fff;
}
.tile-512:hover {
  box-shadow: 0 0 16px rgba(1, 87, 155, 0.6);
  transition: box-shadow 0.6s ease;
}
.tile-1024 {
  background-color: #002f6c;
  color: #fff;
}
.tile-1024:hover {
  box-shadow: 0 0 16px rgba(0, 47, 108, 0.6);
  transition: box-shadow 0.6s ease;
}
.tile-2048 {
  background-color: #001233;
  color: #fff;
}
.tile-2048:hover {
  box-shadow: 0 0 16px rgba(0, 19, 51, 0.6);
  transition: box-shadow 0.6s ease;
}
.tile-4096 {
  background-color: #4a148c;
  color: #fff;
}
.tile-4096:hover {
  box-shadow: 0 0 16px rgba(74, 20, 140, 0.6);
  transition: box-shadow 0.6s ease;
}
.tile-8192 {
  background-color: #311b92;
  color: #fff;
}
.tile-8192:hover {
  box-shadow: 0 0 16px rgba(49, 27, 146, 0.6);
  transition: box-shadow 0.6s ease;
}
.tile-16384 {
  background-color: #004d40;
  color: #fff;
}
.tile-16384:hover {
  box-shadow: 0 0 16px rgba(0, 77, 64, 0.6);
  transition: box-shadow 0.6s ease;
}
.tile-32768 {
  background-color: #1a237e;
  color: #fff;
}
.tile-32768:hover {
  box-shadow: 0 0 16px rgba(26, 35, 126, 0.6);
  transition: box-shadow 0.6s ease;
}
.tile-65536 {
  background-color: #000;
  color: #00d4ff;
  border: 2px solid #00d4ff;
  box-shadow: 0 0 32px #039be5;
}
.tile-65536:hover {
  box-shadow: 0 0 32px #00d4ff, 0 0 64px #039be5;
  transition: box-shadow 0.6s ease;
}

/* ── TILE ANIMATIONS ── */
@keyframes flip-water {
  0% {
    transform: rotateY(0deg);
  }
  100% {
    transform: rotateY(360deg);
  }
}
.animate-flip {
  animation: flip-water 1s ease-in-out;
}

@keyframes tile-appearance {
  0% {
    opacity: 0;
    transform: perspective(900px) scale(0.2) rotate3d(1, 1, 0, 55deg)
      translateY(-18px);
  }
  40% {
    opacity: 1;
    transform: perspective(900px) scale(1.08) rotate3d(1, 1, 0, -5deg)
      translateY(0);
  }
  70% {
    transform: perspective(900px) scale(0.98) rotate3d(0, 0, 0, 0);
  }
  100% {
    opacity: 1;
    transform: perspective(900px) scale(1) rotate3d(0, 0, 0, 0);
  }
}
@keyframes tile-fusion {
  0% {
    transform: perspective(900px) scale(1);
  }
  25% {
    transform: perspective(900px) scale(1.16) rotate3d(0.2, 0.8, 0.1, 4deg);
  }
  55% {
    transform: perspective(900px) scale(0.96);
  }
  100% {
    transform: perspective(900px) scale(1);
  }
}

.tile-new {
  animation: tile-appearance 0.42s cubic-bezier(0.22, 1, 0.36, 1);
}
.tile-merged {
  animation: tile-fusion 0.42s cubic-bezier(0.25, 1, 0.3, 1);
  z-index: 20;
}
.tile-moving {
  transform: translateZ(0) scale(1.005);
  z-index: 15;
}
.tile-empty {
  width: 100%;
  height: 100%;
  z-index: 1;
}

.visuel-match {
  outline: 3px solid rgba(255, 220, 80, 0.9);
  outline-offset: 2px;
  filter: brightness(1.2) saturate(1.3) !important;
  z-index: 20 !important;
  transform: scale(1.06) !important;
  transition: outline 0.8s ease-out, transform 0.8s ease-out, filter 0.8s ease-out !important;
}
.visuel-dim {
  filter: brightness(0.4) saturate(0.3) !important;
}

/* ── HEADER ── */
header {
  position: relative;
  overflow: hidden;
  min-height: 110px;
  padding: 10px 20px;
  display: flex;
  align-items: center;
}
#header-wrapper {
  display: flex;
  width: 200%;
  height: 100%;
  align-items: center;
  transition: transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}
#header-main {
  display: flex;
  align-items: center;
  gap: 60px;
  width: 100%;
  padding-right: 180px;
}
#hello-txt {
  margin: 0;
  font-size: 34px;
  white-space: nowrap;
}
#header-scores {
  display: flex;
  align-items: center;
  gap: 32px;
}
/* Réduction de la taille quand le timer est présent */
#header-scores.small-header h1 {
  font-size: 22px; /* Taille réduite (original: 26px) */
  margin-right: 25px; /* Espacement réduit */
}
#header-scores.small-header {
  gap: 35px; /* Espace entre Score, Meilleur Score et Time */
}

#btn-settings {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  transition: all 0.7s cubic-bezier(0.4, 0, 0.2, 1);
  background: none;
  border: none;
  padding: 0;
}

/* ── SETTINGS-OPEN STATE ── */
body.settings-open #header-wrapper {
  transform: translateX(-100%);
}
body.settings-open main {
  justify-content: flex-start;
  align-items: flex-start;
  padding-left: 20px;
}
body.settings-open #game {
  width: 48vh;
  height: 48vh;
  margin: 0 0 24px;
  transform: scale(0.94);
}
body.settings-open #settings-play {
  opacity: 1;
  max-height: 240px;
}
body.settings-open #btn-settings {
  right: calc(100% - 70px);
  transform: translateY(-50%) rotate(360deg);
}
body.settings-open #info-arrows {
  display: none;
}
body.settings-open #icon-settings {
  transform: rotate(-360deg);
}

/* ── SCORE ── */
#score,
#best-score,
#time-txt {
  font-size: 26px;
  margin-right: 30px;
  color: rgba(255, 255, 255, 0.8);
  text-align: center;
}
#time-txt {
  display: none;
}
#score-value {
  display: inline-block;
  transition: transform 0.2s ease-in;
}
#score-value.score-pop {
  transform: scale(1.2);
  transition: transform 0.1s ease-out;
}

/* Style unifié pour les boutons dans le panneau des paramètres */
#settings-play .action-btn {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    0 4px 0 rgba(0, 0, 0, 0.15);
  font-family: "Bungee", sans-serif;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
}

#settings-play .action-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    0 6px 0 rgba(0, 0, 0, 0.15);
}

#settings-play .action-btn:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 rgba(0, 0, 0, 0);
  background: rgba(255, 255, 255, 0.1);
}

#settings-play .action-btn.resetBestScore:hover {
  color: rgba(255, 23, 23, 0.7);
}

/* ── GAME OVER OVERLAY ── */
#game-over-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  animation: fadeIn 0.4s forwards;
}
@keyframes fadeIn {
  to {
    opacity: 1;
  }
}
#game-over-overlay h2 {
  font-size: 40px;
  margin: 0 0 10px;
  color: #ff5252;
  text-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}
#game-over-overlay p {
  font-size: 20px;
  margin: 0 0 20px;
  color: white;
}

/* ── DEV MODE PANEL ── */
#dev-mode {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: rgba(10, 10, 20, 0.92);
  padding: 16px;
  border-radius: 16px;
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  flex-direction: column;
  gap: 12px;
  z-index: 1000;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  min-width: 200px;
}
body.show-debug #dev-mode {
  display: flex;
}
#dev-mode-top-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
#dev-value {
  flex: 1;
  padding: 8px 12px;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  border-radius: 10px;
  font-family: "Bungee";
  outline: none;
  transition:
    border-color 0.2s ease,
    background 0.2s ease;
}
#dev-value:focus {
  border-color: rgba(116, 192, 252, 0.7);
  background: rgba(116, 192, 252, 0.1);
}
#info-dev-mode {
  background: rgba(116, 192, 252, 0.15);
  border: 1px solid rgba(116, 192, 252, 0.3);
  color: rgb(116, 192, 252);
  padding: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition:
    transform 0.2s ease,
    filter 0.2s ease,
    background 0.2s ease;
  flex-shrink: 0;
}
#info-dev-mode:hover {
  background: rgba(116, 192, 252, 0.28);
  transform: scale(1.1);
}
#info-dev-mode:active {
  transform: scale(0.92);
}

#vPossibles {
  display: none;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 4px 4px;
  opacity: 0;
  transform: translateY(-6px);
  transition:
    opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 220px;
  overflow-y: auto;
}
#vPossibles.visible {
  opacity: 1;
  transform: translateY(0);
}

.tile-value-btn {
  font-family: "Bungee", sans-serif;
  font-size: 11px;
  color: var(--tile-color, #fff);
  background: var(--tile-bg, #0288d1);
  border: none;
  border-radius: 8px;
  padding: 6px 8px;
  min-width: 44px;
  cursor: pointer;
  user-select: none;
  box-shadow:
    0 4px 0 var(--tile-shadow, #015f96),
    0 6px 12px rgba(0, 0, 0, 0.3);
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    filter 0.12s ease;
  outline: none;
  position: relative;
}
.tile-value-btn:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
  box-shadow:
    0 5px 0 var(--tile-shadow, #015f96),
    0 8px 16px rgba(0, 0, 0, 0.35);
}
.tile-value-btn:active {
  transform: translateY(3px);
  box-shadow:
    0 1px 0 var(--tile-shadow, #015f96),
    0 2px 6px rgba(0, 0, 0, 0.3);
  filter: brightness(0.88);
}
.tile-value-btn.selected {
  outline: 2px solid rgba(255, 255, 255, 0.9);
  outline-offset: 2px;
  filter: brightness(1.15);
}

#btnToggleDev {
  cursor: pointer;
  background: #fbc02d;
  border: none;
  padding: 8px 12px;
  border-radius: 10px;
  font-family: "Bungee";
  color: #333;
  font-size: 12px;
  box-shadow: 0 4px 0 #c49c00;
  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    background 0.2s ease;
}
#btnToggleDev:hover {
  filter: brightness(1.08);
}
#btnToggleDev:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #c49c00;
}
#dev-status {
  font-size: 10px;
  margin: 0;
  text-align: center;
  opacity: 0.5;
  color: white;
}
.dev-active .tile-empty {
  cursor: cell;
  background-color: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}
body.dev-active .tile:hover {
  cursor: not-allowed;
  filter: brightness(1.2) contrast(1.2);
  outline: 2px solid #ff5252;
}

/* ── VISUEL PANEL ── */
#visuel-panel {
  position: fixed;
  top: 50%;
  right: 20px;
  transform: translateY(-50%) translateX(30px);
  opacity: 0;
  transition:
    opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  background: rgba(10, 10, 20, 0.94);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(20px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  padding: 16px;
  z-index: 500;
  width: 280px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#visuel-panel.visible {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}
#visuel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
#visuel-close {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.15s ease,
    transform 0.15s ease;
}
#visuel-close:hover {
  background: rgba(255, 80, 80, 0.3);
  transform: scale(1.1);
}
#visuel-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  overflow-y: auto;
  padding-right: 4px;
}
#visuel-grid::-webkit-scrollbar {
  width: 4px;
}
#visuel-grid::-webkit-scrollbar-track {
  background: transparent;
}
#visuel-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.visuel-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  transition: background 0.15s ease;
  cursor: default;
}
.visuel-cell:hover {
  background: rgba(255, 255, 255, 0.1);
}
.visuel-tile {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Bungee", sans-serif;
  font-size: 11px;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
  cursor: pointer;
}
.visuel-tile:hover {
  transform: scale(1.1);
}
.visuel-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.visuel-val {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.2;
}
.visuel-sub {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.45);
  font-family: sans-serif;
}

#game {
  height: 55vh;
  width: 55vh;
  margin: 0 0 48px 0;
  background-color: rgba(255, 255, 255, 0.15);
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 15px;
  padding: 10px;
  transition:
    width 0.4s ease,
    height 0.4s ease,
    margin 0.4s ease,
    transform 0.4s ease;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  position: relative;
  touch-action: none;
  box-sizing: border-box;
}

/* Style spécifique à la victoire */
.win-style {
  background: rgba(10, 30, 10, 0.9) !important; /* Fond légèrement verdâtre */
  border: 4px solid #4caf50;
}

.stats-win {
  text-align: left;
  margin-bottom: 20px;
}

.stats-win p {
  margin: 8px 0 !important;
  font-size: 16px !important;
}

.win-buttons {
  display: flex;
  gap: 15px;
}

.win-btn {
  font-family: "Bungee", sans-serif;
  padding: 10px 20px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: transform 0.2s;
}

.win-btn.continue {
  background: #0288d1;
  color: white;
}

.win-btn.restart {
  background: #4caf50;
  color: white;
}

.win-btn:hover {
  transform: scale(1.1);
}

/* On s'assure que l'ID game-over-overlay et win-overlay partagent la base */
#game-over-overlay,
#win-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.4s forwards;
}

#time-chronoMode{
  display: none;
  font-size: 38px;
  color: rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.1);
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

@keyframes chrono-blink {
  0% { color: white; transform: scale(1); }
  50% { color: #ff4d4d; transform: scale(1.1); }
  100% { color: white; transform: scale(1); }
}

.chrono-warning {
  animation: chrono-blink 0.5s infinite;
  font-weight: bold;
  text-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
}