/* ============================================================
   Pa_Capona_Tuyaux.css
   FEN_Pa_Capona_Tuyaux — Taquin des tuyaux 4×4
   ─────────────────────────────────────────────────────────────
   Layout flex-colonne (100svh) :
     • .top-bar      → titre + retour + score
     • .grid-wrapper → grille taquin centrée (flex:1)
     • .bas-zone     → bouton Nouveau jeu | lézard suite
   Thème : industriel bleu-gris foncé
============================================================ */

/* ============================================================
   RESET & BASE
============================================================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  background: #1e2d3d;
  overflow: hidden;
}

/* ============================================================
   ÉCRAN PRINCIPAL
============================================================ */
.screen {
  width: 100%;
  height: 100vh;
  height: 100svh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #1e2d3d;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ============================================================
   BARRE HAUT
============================================================ */
.top-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(6px, 1.4dvh, 12px) clamp(10px, 3%, 20px);
  background: #2a3a4a;
  border-bottom: 2px solid #3a5268;
}

.retour-btn {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  flex: 0 0 auto;
  -webkit-tap-highlight-color: transparent;
}
.retour-img {
  height: clamp(28px, 5.5dvh, 44px);
  width: auto;
  display: block;
}

.page-title {
  flex: 1;
  color: #c8dcea;
  font-size: clamp(0.80rem, 3.4vw, 1.15rem);
  font-weight: 700;
  text-align: center;
  padding: 0 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-zone {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: clamp(4px, 1.2vw, 8px);
}
.coffre-img {
  height: clamp(22px, 4.5dvh, 38px);
  width: auto;
  display: block;
}
.points-box {
  background: #cc0000;
  color: #fff;
  font-weight: 700;
  font-size: clamp(0.76rem, 2.8vw, 1rem);
  min-width: clamp(28px, 8vw, 50px);
  padding: 2px clamp(4px, 1vw, 8px);
  border-radius: 5px;
  text-align: center;
  line-height: 1.3;
}

/* ============================================================
   GRILLE — wrapper + taquin 4×4
============================================================ */
.grid-wrapper {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(8px, 2dvh, 18px) clamp(8px, 2vw, 18px);
}

.grid {
  /* Carré : aussi grand que possible sans dépasser l'écran */
  --gs: min(90vw, 58svh, 430px);
  width: var(--gs);
  height: var(--gs);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: clamp(2px, 0.5vmin, 4px);
  background: #0e1a26;
  border: clamp(2px, 0.5vmin, 4px) solid #0e1a26;
  border-radius: clamp(6px, 1.5vmin, 10px);
  overflow: hidden;
  /* Empêche le scroll du navigateur lors du balayage de tuiles */
  touch-action: none;
}

/* ── Tuile normale ── */
.cell {
  background: #c4d8e8;
  border-radius: clamp(2px, 0.4vmin, 4px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.08s ease, background-color 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.cell:active:not(.empty) {
  transform: scale(0.90);
}

/* ── Tuile verrouillée (DepartTuyau — ne peut pas bouger) ── */
.cell.locked {
  background: #b8ccd8;
  cursor: default;
  box-shadow: inset 0 0 0 clamp(2px, 0.5vmin, 3px) #7090a8;
}
.cell.locked::after {
  content: '🔒';
  position: absolute;
  bottom: 2px;
  right: 3px;
  font-size: clamp(8px, 2vmin, 11px);
  line-height: 1;
  opacity: 0.70;
  pointer-events: none;
}

/* ── Tuile déplaçable (adjacente à la case vide) ── */
.cell.movable {
  background: #9dc8e4;
  box-shadow: inset 0 0 0 clamp(2px, 0.5vmin, 3px) #4a8ab8;
}
.cell.movable::after {
  /* Petit indicateur visuel dans les coins */
  content: '';
  position: absolute;
  inset: 0;
  border: clamp(2px, 0.5vmin, 3px) solid rgba(74, 138, 184, 0.5);
  border-radius: inherit;
  pointer-events: none;
}

/* ── Case vide ── */
.cell.empty {
  background: #0a1520;
  cursor: default;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6);
}

/* ── Image dans chaque tuile ── */
.cell img {
  width: 88%;
  height: 88%;
  object-fit: contain;
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Animation flash lors d'un déplacement ── */
@keyframes tileSlide {
  0%   { background-color: #7ab8d8; }
  100% { background-color: #c4d8e8; }
}
.cell.slid {
  animation: tileSlide 0.18s ease-out;
}

/* ============================================================
   BARRE BAS
============================================================ */
.bas-zone {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(6px, 1.4dvh, 12px) clamp(12px, 4%, 24px);
  background: #2a3a4a;
  border-top: 2px solid #3a5268;
}

.btn-melanger {
  background: #3a5470;
  color: #c8dcea;
  border: 1px solid #4a6888;
  border-radius: 8px;
  padding: clamp(8px, 1.8dvh, 14px) clamp(14px, 4vw, 24px);
  font-size: clamp(0.76rem, 3vw, 0.96rem);
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s ease;
  font-family: inherit;
}
.btn-melanger:active { background: #4a6888; }

.lezard-img {
  height: clamp(44px, 9dvh, 74px);
  width: auto;
  display: block;
  cursor: pointer;
  filter: drop-shadow(1px 2px 5px rgba(0, 0, 0, 0.50));
  -webkit-user-drag: none;
  transition: transform 0.12s ease;
}
.lezard-img:active { transform: scale(0.93); }

/* ============================================================
   OVERLAY DE TRANSITION
============================================================ */
.transition-overlay {
  position: fixed;
  inset: 0;
  background: #000000;
  z-index: 100;
  opacity: 1;
  pointer-events: all;
  transition: opacity 0.4s ease;
}

/* ============================================================
   POPUP BRAVO
============================================================ */
.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.panel-box {
  background: #ffffff;
  border-radius: 16px;
  padding: clamp(20px, 5dvh, 32px) clamp(20px, 6vw, 32px);
  max-width: 320px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 2dvh, 16px);
}

.pouce-img {
  height: clamp(56px, 13dvh, 96px);
  width: auto;
}

.panel-titre {
  font-size: clamp(1.25rem, 5.5vw, 1.75rem);
  font-weight: 700;
  color: #1a2e3d;
}

.panel-pts {
  font-size: clamp(1rem, 4.2vw, 1.30rem);
  color: #cc0000;
  font-weight: 700;
  min-height: 1.4em;
}

.panel-btn {
  background: linear-gradient(135deg, #3a6a9a, #1e4a7a);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: clamp(10px, 2dvh, 14px) clamp(24px, 8vw, 42px);
  font-size: clamp(0.88rem, 3.5vw, 1.05rem);
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s ease;
  font-family: inherit;
  margin-top: 4px;
}
.panel-btn:active { opacity: 0.85; }

/* ============================================================
   RESPONSIVE — PORTRAIT ÉTROIT (≤ 360px)
============================================================ */
@media (max-width: 360px) {
  .page-title    { font-size: 0.74rem; }
  .btn-melanger  { font-size: 0.72rem; padding: 7px 11px; }
  .lezard-img    { height: 38px; }
  .grid { --gs: min(88vw, 56svh, 320px); }
}

/* ============================================================
   RESPONSIVE — SMARTPHONES (375–430px, ≥ 700px)
============================================================ */
@media (min-width: 375px) and (max-width: 430px) and (min-height: 700px) {
  .grid { --gs: min(90vw, 60svh, 390px); }
  .lezard-img { height: clamp(46px, 9dvh, 72px); }
}

/* ============================================================
   RESPONSIVE — TABLETTE (≥ 600px)
============================================================ */
@media (min-width: 600px) {
  .page-title   { font-size: clamp(1rem, 2.8vw, 1.35rem); }
  .lezard-img   { height: clamp(54px, 10dvh, 82px); }
  .btn-melanger { font-size: clamp(0.88rem, 2.2vw, 1.05rem); padding: 10px 22px; }
  .grid { --gs: min(80vw, 64svh, 480px); }
}

/* ============================================================
   RESPONSIVE — GRANDES TABLETTES (≥ 800px, ≥ 1000px)
============================================================ */
@media (min-width: 800px) and (min-height: 1000px) {
  .grid { --gs: min(70vw, 60svh, 520px); }
}

/* ============================================================
   RESPONSIVE — PAYSAGE MOBILE (hauteur ≤ 450px)
============================================================ */
@media (max-height: 450px) and (orientation: landscape) {
  .top-bar    { padding: 3px 10px; }
  .page-title { font-size: 0.68rem; }
  .retour-img { height: 24px; }
  .coffre-img { height: 20px; }
  .points-box { font-size: 0.68rem; min-width: 24px; }
  .bas-zone   { padding: 3px 10px; }
  .btn-melanger { font-size: 0.68rem; padding: 5px 10px; }
  .lezard-img   { height: 28px; }
  .grid { --gs: min(84svh, 68vw, 360px); }
}
