/* reset et layout */
* { box-sizing: border-box; margin:0; padding:0; }
body {
  font-family: Verdana, sans-serif;
  width: auto;
  margin: auto;
  background-color: lightblue;
}
.popup-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.75);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  backdrop-filter: blur(6px);
}

.popup-content {
  background: white;
  border: 5px solid gold;
  border-radius: 20px;
  padding: 3rem;
  text-align: center;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.7);
  animation: popupFadeIn 0.3s ease;
  position: relative;
  padding-top: 3rem;
}

.popup-close {
  position: absolute;
  top: 0.85rem;              /* tu peux ajuster */
  right: 0.85rem;            /* idem */
  width: 30px;
  height: 24px;
  cursor: pointer;
  z-index: 10;
}

.popup-close img {
  display: block;
  width: 24px;
  height: 24px;
  margin: 0;        /* supprime tout margin interne sur l’image */
}
.popup-content h2 {
  margin-bottom: 1rem;
  font-size: 2rem;
  font-family: 'Luckiest Guy', cursive;
  color: #ff6347;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
  display: flex;
  flex-flow: column;
}
.hmd{
    margin-bottom: 1rem;
  font-size: 2rem;
  font-family: 'Luckiest Guy', cursive;
  color: #ff6347;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
  display: flex;
  flex-flow: column;
}
.popup-content p {
  font-size: 1.1rem;
  line-height: 1.8;
  margin-bottom: 1rem;
}

#close-popup {
  position: absolute;
  top: 0.5rem;    /* distance depuis le haut : ajuste selon ton design */
  right: 0.5rem;  /* distance depuis la droite */
  width: 24px;    /* ou la taille que tu veux pour ton icône */
  height: 24px;
  cursor: pointer;
  z-index: 10;
}

#close-popup:hover {
  color: #555;
}

.hidden {
  display: none;
}

@keyframes popupAppear {
  from {
    opacity: 0;
    transform: translateY(-40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.popup-content img {
  max-width: 180px;
  height: auto;
  margin-top: 5px;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
align-self: center;
}

html, body {
  height: 100%;
}

#main-container {
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
}
header{
  /* aligne tout sur une même ligne */
  display:flex;
  align-items:center;
  gap:1rem;          /* petit espace entre chaque bloc */
  padding:0.5rem 1rem;
background: linear-gradient(95deg, rgba(0, 0, 0, 1) 34%, rgba(155, 50, 42, 1) 60%, rgba(255, 255, 255, 1) 80%, rgba(255, 229, 0, 1) 100%);
}
header > div{
  display:flex;
  align-items:center;
  gap:3.5rem;
  justify-content: center;
}

header > div > h1 {
    color: rgb(255, 255, 255);
    width: 50%;
    font-size: 2rem;
    text-align: center;
}
header nav{
  display:flex;
  flex-direction:column; /* empile les <a> */
  gap:0.25rem;           /* espace entre les liens */
}

header nav a{
  text-decoration:none;
  color:#333;
  font-weight:600;
}

/* ---------- h3 calé à droite ---------- */
header h3{
  margin-left:auto; /* occupe tout l’espace restant sur la ligne */
  font-weight:normal;
  white-space:nowrap;   /* évite que la phrase se casse brusquement */
  font-size:0.9rem;     /* “non agressif” : un ton en dessous du h1 */
}
img {
	width: 15%;
}
nav {
    display: flex;
}
a {
    align-self: center;
}
header > nav > a{
    text-decoration: none;
    text-transform: uppercase;
    font-weight: bold;
    color: black;
    padding: 1px;
    background-color: white;
    transition: background-color 1s, color 0.5s linear 0.5s;
    border-radius: 25px;
}
header > nav > a:hover {
    background-color: tomato;
    color: white;

}
h1 {
    width: 50%
}
nav>a::after,
nav a::before {
        content: " - ";
    }
/* game-container + canvas */
#game-container {
  position: relative;
  max-width: 800px;
  overflow: hidden;
  border: 4px solid #444;
  background-size: cover;
  padding: 0 !important;
  margin: 0 !important;
    display: flex;
  flex-direction: column;
    justify-content: flex-end;
  height: 100%;
}

#game {
   background: transparent;
    position: relative;
    margin: 0 !important;
    padding: 0  !important;
    display: block;
    margin-bottom: 0 !important;
 /* ← HAUTEUR de la ligne du bas */
  }
  #game::after {
  content: "";
  position: absolute;
  bottom: -1px;            /* colle à la base */
  left: 0;
  right: 0;
  height: 20px;            /* hauteur de ta bordure de sol */
  background: #5e3d1b;     /* couleur bois foncé */
  box-shadow: inset 0 2px 3px rgba(0,0,0,0.4); /* petit relief */
  z-index: 3;
  pointer-events: none;
}
.letter-cube { z-index: 2; }
canvas       { position:relative; z-index:1; }
/* overlays */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(191, 13, 13, 0.119);
  z-index: 10;
}
.hidden { display: none; }
#start-btn,
#save-score {
  padding: 0.5rem 1.5rem;
  font-size: 1.1rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
#start-btn { background: #2e86de; color: #fff; }
#save-score { background: #27ae60; color: #fff; }

/* leaderboard */
#leaderboard-container {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1rem;
  background: #222;
  color: #eee;
  overflow-y: auto;
  gap: 1.5rem;
  box-sizing: border-box;
}
#leaderboard-wrapper {
  display: flex;
  flex-direction: column;
  background: #222;
  color: #eee;
  padding: 1.5rem;
  box-sizing: border-box;
}
#victory-canvas {
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
}
aside {
  display:flex;
  align-self: start;
}
#leaderboard-online,
#leaderboard-local {
  flex-shrink: 0;
}

#leaderboard-online h2,
#leaderboard-local h2 {
  margin-bottom: 0.5rem;
  text-align: center;
}

#leaderboard-wrapper table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
#score-table-online,
#score-table-local {
  flex-shrink: 0;
}
#score-table-online td,
#score-table-local td {
  padding: 0.6rem 0.4rem;
  vertical-align: top;
}
#score-table-online tr,
#score-table-local tr {
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
#score-table-online td span,
#score-table-local td span {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75em;
  color: #aaa;
}
.highscore          { width:100%; border-collapse:collapse; }
.highscore th,
.highscore td       { padding:4px 8px; }
.highscore thead    { background:#222; color:#fff; }
.highscore tbody tr:nth-child(even) { background:#f7f7f7; }
.right              { text-align:right; }
#leaderboard-container h2 {
  margin-bottom: 0.5rem;
  text-align: center;
}
#leaderboard-container h2 {
  margin-bottom: 0.5rem;
  text-align: center;
}
#leaderboard li {
  margin-bottom: 0.5rem;
}
@media screen and (max-width: 600px) {
    body {
        width: 100%;
    }
    header, header > div {
        flex-direction: column;
    }

    header > nav {
        display: flex;
        flex-direction: column;
        width: 100%;
        margin: 20px;
        /* background-color: lightblue; */
    }
    header > nav > a {
        display: inline-block;
        width: 100%;
        margin: 1px;
        text-align: center;
        border-radius: 0px;
        background: linear-gradient(95deg, rgba(0, 0, 0, 1) 34%, rgba(155, 50, 42, 1) 60%, rgba(255, 255, 255, 1) 80%, rgba(255, 229, 0, 1) 100%);
        align-self: center;
    }
      header{
    flex-wrap:wrap;     /* passe à la ligne si l’écran est étroit */
  }
  header h3{
    margin-left:0;
    width:100%;         /* le <h3> s’étale sous le reste, centré */
    text-align:center;
    margin-top:0.5rem;
  }

  #leaderboard-container {
    height: auto;
  }
}

@media screen and (max-width: 768px) {
  #leaderboard-wrapper {
    height: auto;
    padding: 1rem;
  }
}

@media screen and (min-width: 600px) and (max-width: 900px) {
    body {
        width: 90%;
    }
    header, header > div {
        flex-direction: column;
    }
    header > nav {
        width: 100%;
        margin: 20px;
        background-color: lightblue;
        justify-content: space-around;
    }
    header > nav > a {
        background-color: transparent;
    }
    main {
        flex-direction: column;
    }
}