@import url("https://fonts.googleapis.com/css2?family=Irish+Grover&display=swap");

:root {
  --primary: #6366f1;
  --bg: #0f172a;
  --card-bg: rgba(30, 41, 59, 0.7);
  --text: #f8fafc;
  --accent: #10b981;
  --error: #ef4444;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family:
    "Inter",
    -apple-system,
    system-ui,
    sans-serif;
}

body {
  background: radial-gradient(circle at top left, #1e1b4b, #0f172a);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* start loader  */
#loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  transition:
    opacity 0.8s ease,
    visibility 0.8s;
}

.loader-content {
  text-align: center;
  width: 300px;
}

.logo-loader {
  font-size: 4rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 2rem;
  animation: pulse 1.5s infinite;
}

.progress-container {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.2s ease;
}

#loaderStatus {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #64748b;
}

/* Cacher le loader en JS */
.loader-hidden {
  opacity: 0;
  visibility: hidden;
}

header {
  padding: 2rem;
  text-align: center;
}

.title {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 1.5rem;
  text-transform: uppercase;
  letter-spacing: 2px;
}

/* Layout Principal */
main {
  width: 100%;
  max-width: 1000px;
  margin-top: 2rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  align-items: start;
}

/* Le Coeur du Jeu */
.container {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 2rem 1.5rem;
  border-radius: 24px;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
}

h2 {
  font-size: clamp(1.2rem, 5vw, 1.8rem);
  margin-bottom: 1rem;
}

.random-number {
  display: block;
  text-align: center;
  font-size: 5rem;
  font-weight: 800;
  margin: 1rem 0;
  color: var(--primary);
  text-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}

input[type="number"] {
  background: rgba(15, 23, 42, 0.6);
  border: 2px solid #334155;
  border-radius: 12px;
  color: white;
  font-size: 2rem;
  padding: 1rem;
  width: 80%;
  font-weight: 700;
  letter-spacing: 2px;
  text-align: center;
  margin-bottom: 1.5rem;
  transition: all 0.3s ease;
}

input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

button#guessButton {
  display: block;
  width: 80%;
  padding: 1rem;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  transition:
    transform 0.2s,
    background 0.3s;
}

button#guessButton:hover {
  background: #4f46e5;
  transform: translateY(-2px);
}

/* Modal */
.modal-body {
  text-align: left; /* Plus lisible pour du texte descriptif */
  margin-top: 1rem;
}

.modal-body ul {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
}

.modal-body li {
  margin-bottom: 0.8rem;
  padding-left: 1.5rem;
  position: relative;
}

.modal-body li::before {
  content: "⚡";
  position: absolute;
  left: 0;
  color: var(--primary);
}

.tip {
  font-size: 0.85rem;
  background: rgba(99, 102, 241, 0.1);
  padding: 10px;
  border-radius: 8px;
  border-left: 3px solid var(--primary);
}

.btn-modal {
  position: absolute;
  top: 5%;
  right: 2%;
  padding: 0.5rem 1rem;
  border-radius: 5px;
  font-size: 1.5rem;
  font-weight: bold;
  background-color: var(--primary);
  color: var(--text);
  border: none;
  cursor: pointer;
  z-index: 200;
  transition: all 0.3s ease;

  &:hover {
    background-color: #4f46e5;
    transform: scale(1.1);
  }
}

.right-side .instruction {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 50%;
  z-index: 100;
  background-color: #94a3b8;
  backdrop-filter: blur(25px);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.5);
  text-align: center;
  padding: 1.5rem;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #f2f3f6;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1); /* Courbe Apple-style */
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

.overlay-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 99;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: end;
  padding-bottom: 20px;
  font-size: 1.4rem;
  transition: opacity 0.4s ease;
  opacity: 1;
}

.overlay-modal.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: none; /* Pas de scale sur l'overlay */
}

.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate(-50%, -45%) scale(0.95);
}

/* Scores */
.result {
  display: flex;
  justify-content: space-around;
  margin-top: 2rem;
  background: rgba(15, 23, 42, 0.4);
  padding: 1rem;
  border-radius: 12px;
}

.score-game,
.best-score-game {
  text-align: center;
}

#scoreValue,
#bestScoreValue {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--accent);
}

/* Refresh Button Floating */
#refreshButton {
  background-color: transparent;
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  border-radius: 50%;
  width: 60px;
  height: 60px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  border: none;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

#refreshButton img {
  width: 100%;
  height: 100%;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

#refreshButton:hover img {
  transform: rotate(180deg);
}

#muteBtn {
  position: absolute;
  top: 5%;
  right: 12%; /* Juste à côté du bouton ? */
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
}

footer {
  padding: 2rem;
  text-align: center;
}

/* Animation pour le loader */
@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.1);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 0.5;
  }
}

/* Animation de vibration (Erreur/Mauvais choix) */
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-10px);
  }
  75% {
    transform: translateX(10px);
  }
}
.shake {
  animation: shake 0.2s ease-in-out 0s 2;
}

/* Animation de "Pop" pour le score qui descend */
@keyframes shrink {
  0% {
    transform: scale(1);
    color: var(--error);
  }
  50% {
    transform: scale(1.3);
  }
  100% {
    transform: scale(1);
  }
}
.score-pop {
  animation: shrink 0.4s ease-out;
}

/* Animation de victoire pour le nombre mystère */
@keyframes win-glow {
  0% {
    transform: scale(1);
    text-shadow: 0 0 10px var(--accent);
  }
  50% {
    transform: scale(1.2);
    text-shadow: 0 0 30px var(--accent);
  }
  100% {
    transform: scale(1);
  }
}
.win-anim {
  animation: win-glow 1s infinite;
}

/* Tablette Responsive */
@media (min-width: 1024px) {
  header {
    padding: 1rem;
  }

  main {
    padding: 0 1rem;
    grid-template-columns: 1fr;
    max-width: 600px; /* On garde le jeu focus au centre */
  }
}

/* Mobile Responsive */
@media (max-width: 600px) {
  .container {
    gap: 10px;
  }

  .title h1 {
    font-size: 1.2rem;
  }

  .title img {
    width: 2rem;
  }

  input[type="number"] {
    font-size: 1rem;
    padding: 1rem;
    width: 100%;
  }

  button#guessButton {
    width: 100%;
    font-size: 1.2rem;
  }

  .random-number {
    font-size: 3.5rem;
    margin-top: -1rem;
  }

  .result {
    flex-direction: row; /* On garde côte à côte */
    gap: 10px;
    font-size: 0.9rem;
  }

  #refreshButton {
    width: 50px;
    height: 50px;
    bottom: 2rem;
    right: 2rem;
  }

  #refreshButton img {
    width: 50%;
    height: 50%;
  }

  .right-side .instruction {
    width: 90%;
  }

  .overlay-modal p {
    display: none;
  }

  footer {
    display: none;
  }
}
