:root {
  --fast-fade: 0.4s;
  --slow-fade: 0.6s;
}

* {
  box-sizing: border-box;
  
}


body {
  height: 100%;
  width: 80%;
  margin: 0 auto;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 100vh;
  padding: 20px;
  overflow: hidden;
  background-image: url('bg.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

h1, h2, h3, label{
  color: #f5deb3;
  text-shadow: 1px 1px 5px rgba(0, 0, 0, 0.6);
}

.avertissement{
  color: rgb(0, 0, 0);
  font-weight: 600;
  font-size: 1.1em;
}

.hidden {
  display: none;
}

.fade-in-fast {
  animation: fadeIn var(--fast-fade) forwards;
}
.fade-out-fast {
  animation: fadeOut var(--fast-fade) forwards;
}

.fade-in-slow {
  animation: fadeIn var(--slow-fade) forwards;
}
.fade-out-slow {
  animation: fadeOut var(--slow-fade) forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
@keyframes fadeOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.98);
  }
}

/* --- Menu --- */
.menu {
  width: 600px;
  max-width: 80vw;
}

.name-section {
  margin: 8px 0 14px;
}
#player-name {
  padding: 8px 10px;
  width: 300px;
  max-width: 40vw;
  border-radius: 6px;
  border: none;
  outline: none;
  font-size: 14px;
  margin-top: 10px;
}

.size-section {
  margin-bottom: 14px;
}
.size-section label {
  margin-right: 12px;
  font-size: 15px;
}

/* --- Play button --- */
#start-btn {
  margin-top: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(90deg, #8b6f47, #a0826d);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s;
}

#start-btn:hover {
  transform: scale(1.05);
}

/* --- scoreboard --- */
.scoreboard {
  margin-top: 24px;
}
.score-columns {
  display: flex;
  justify-content: center;
  gap: 4%;
  margin-top: 10px;
  flex-wrap: wrap;
  flex-direction: row;
}
.score-column {
  width: 43%;
  min-width: 250px;
  text-align: left;
  background-color: rgba(139, 111, 71, 0.9);
  padding: 10px;
  border-radius: 10px;
  margin-bottom: 20px;
  border: 1px solid rgba(139, 111, 71, 0.3);
}

.score-column h3 {
  margin-top: 0;
  margin-bottom: 20px;
}
.score-column ol {
  padding-left: 18px;
  margin: 0;
}
.score-column li {
  margin: 6px 0;
  font-size: 14px;
  color: #f5deb3;
}
.score-column li.best {
  color: #fff47f;
  font-weight: 700;
  text-shadow: 0 0 2px rgba(212, 175, 55, 0.5);
}

/* --- Game --- */
.game-container {
  width: 100%;
  max-width: 900px;
}
.timer,
.clicks {
  font-size: 18px;
  margin: 8px 0 14px;
}

.abandon-button {
  background-color: #d9534f;
  color: white;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  margin-top: 20px;
  transition: background-color 0.2s;
}

.abandon-button:hover {
  background-color: #c9302c;
}

.memory-game {
  display: grid;
  justify-content: center;
  gap: 12px;
  margin: 0 auto;
}

/* Card */
.card {
  perspective: 1000px;
  cursor: pointer;
  width: 80px;
  height: 80px;
  user-select: none;
}
.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  transform-style: preserve-3d;
  transition: transform 0.6s ease;
}
.card.flipped .card-inner {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  border-radius: 8px;
}
.card-front {
  background: linear-gradient(135deg, #8b6f47, #6b5435);
  color: #fff;
  font-size: 28px;
}
.card-back {
  transform: rotateY(180deg);
  background: white;
  color: #111;
  border: 2px solid #8b6f47;
  font-size: 36px;
}

/* --- Inactivity Pop-up --- */
.inactivity-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.inactivity-overlay.hidden {
  display: none;
}

.inactivity-popup {
  background: linear-gradient(135deg, #8b6f47, #6b5435);
  padding: 30px 40px;
  border-radius: 15px;
  text-align: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
  max-width: 400px;
  animation: popupBounce 0.4s ease-out;
}

@keyframes popupBounce {
  0% {
    transform: scale(0.7);
    opacity: 0;
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.inactivity-popup h2 {
  margin-top: 0;
  margin-bottom: 15px;
  color: #fff;
  font-size: 24px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.inactivity-popup p {
  color: #f5deb3;
  font-size: 16px;
  margin: 10px 0;
}

.inactivity-popup .countdown {
  font-weight: 700;
  font-size: 18px;
  color: #ffcc00;
  margin: 20px 0;
}

.continue-button {
  padding: 12px 30px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(90deg, #4CAF50, #45a049);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
  margin-top: 10px;
}

.continue-button:hover {
  transform: scale(1.05);
  background: linear-gradient(90deg, #45a049, #3d8b40);
}

/* Responsive: scale cards smaller on narrow screens */
@media (max-width: 420px) {
  .card {
    width: 60px;
    height: 60px;
  }
  .score-columns {
    gap: 18px;
  }
  .inactivity-popup {
    max-width: 90%;
    padding: 20px 25px;
  }
}