@import url("https://fonts.googleapis.com/css2?family=Fredoka :wght@400;500;600&display=swap");

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  width: 100%;
  font-family: "Fredoka", sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  overflow-y: scroll;
}

html {
  scrollbar-gutter: stable;
}

@media screen and (max-width: 768px) {
  body.game-active {
    overflow: hidden;
  }
}

/* --- Landing Page --- */
#landing-page {
  position: absolute;
  width: 100vw;
  height: 100vh;
  background-color: #1547f7;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 48px;
  animation: fadeOut 2s ease 2s forwards;
}

@keyframes fadeOut {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

/* --- Menu Page --- */
#menu-page {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  min-height: 100vh;
  height: auto;
  gap: 0;
  background-color: #1547f7;
  color: white;
  padding: clamp(20px, 4vw, 40px);
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: hidden;
}

#menu-page h1.logo {
  font-size: 88px;
  color: white;
  margin-bottom: 100px; /* ← Spazio personalizzato sotto il logo */
}

#menu-page h2 {
  font-size: 16pt;
  font-family: "Fredoka", sans-serif;
  font-weight: 300; /* Fredoka Light */
  margin-top: 30px;
  margin-bottom: 15px;
}

/* Avvicina i pulsanti ai titoli */
#menu-page h2 + .buttons {
  margin-top: -20px;
}

#menu-page .buttons {
  justify-content: flex-start;
  margin: 0;
  padding: 10px 0;
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 50px;
}
/* --- Stile per i pulsanti principali --- */
#one-player,
#two-players {
  font-family: "Fredoka", sans-serif;
  font-weight: 700; /* Fredoka Bold */
  font-size: 50pt !important;
  line-height: 1;
  padding: 10px 0; /* regola lo spazio verticale se serve */
}
/* Quando uno dei due è selezionato, il testo diventa nero */
#one-player.selected,
#two-players.selected {
  color: black !important;
}

/* === STILE PULSANTI LIVELLO === */

.level-btn {
  font-family: "Fredoka", sans-serif;
  font-weight: 400;
  font-size: 50pt !important;
  line-height: 1.1;
}

#menu-page button {
  background-color: transparent;
  border: none;
  color: white;
  font-size: 20px;
  font-weight: 500;
  cursor: pointer;
  padding: 5px 10px;
  transition: color 0.3s ease;
}

#menu-page button:hover {
  color: black;
}

button.selected {
  background-color: #f9a825;
  color: black;
}

.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
}

.popup {
  background: white;
  padding: 20px;
  border-radius: 10px;
  width: 500px;
  text-align: center;
  position: relative;
}
.popup {
  font-family: "Fredoka", sans-serif;
  color: #1547f7; /* ← Colore del testo */
}

.close-btn {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 30px;
  height: 30px;
  background-color: #1547f7; /* Blu del logo */
  color: white;
  border-radius: 50%; /* Cerchio */
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0);
  transition: background-color 0.3s ease, transform 0.2s ease;
  z-index: 10;
}

.close-btn:hover {
  background-color: #0a35c7;
  transform: scale(1.1);
}

#info-btn,
#credits-btn {
  font-family: "Fredoka", sans-serif;
  font-weight: 300;
  font-size: 16pt;
}

#game-interface {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  height: 100vh;
}

@supports (height: 100svh) {
  #game-interface {
    min-height: 100svh;
    height: 100svh;
  }
}

/* --- Header --- */
#game-header {
  height: 80px;
  background-color: #1547f7;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: relative;
}

#game-logo {
  height: 60px; /* Adatto a stare bene dentro l’header da 80px */
  width: auto;
  max-width: 300px;
}

/* --- Pulsante Schermo Intero --- */
#fullscreen-btn {
  position: fixed;
  right: 20px;
  top: 20px;
  background-color: transparent;
  border: none;
  cursor: pointer;
  padding: 6px 10px;
  z-index: 1500;
  transition: background-color 0.3s ease;
}

#fullscreen-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 5px;
}

#fullscreen-btn img {
  width: 30px;
  height: auto;
  display: block;
}

/* --- Footer --- */
#game-footer {
  height: 50px;
  background-color: #1547f7;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 50px 0 20px; /* Era 0 20px, ora 0 80px 0 20px per dare spazio al sound button */
}

#game-main {
  padding: 10px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

.memory-game {
  display: grid;
  width: 100%;
  height: 100%;
  gap: 4px;
  justify-content: stretch;
  align-content: stretch;
  grid-template-columns: repeat(auto-fit, minmax(min(80px, 12vw), 1fr));
  grid-auto-rows: 1fr;
  padding: 0;
}

.memory-card {
  perspective: 1000px;
}

.memory-card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s;
}

.memory-card.flip .memory-card-inner {
  transform: rotateY(180deg);
}

.front-face,
.back-face {
  width: 100%;
  height: 100%;
  position: absolute;
  backface-visibility: hidden;
  border-radius: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.front-face {
  background-color: #1547f7;
  transform: rotateY(180deg);
}

/* Immagine frontale (SVG) - Contenuta dentro la carta */
.front-face img,
.back-face img {
  max-width: 90%;
  max-height: 90%;
  width: auto;
  height: auto;
  object-fit: contain;
  pointer-events: none;
  display: block;
  margin: 0 auto;
}

/* Stile retro carta */
.back-face {
  background-color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 1px solid #ddd;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.05);
  border-radius: 10px;
  position: relative;
  overflow: hidden;
}

.pattern-wrapper {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  bottom: 8px;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='6' viewBox='0 0 24 6'%3E%3Cpath d='M0 3 L6 1 L12 3 L18 1 L24 3' stroke='%231547f7' stroke-width='1' fill='none'/%3E%3C/svg%3E");
  background-size: 24px 13px;
  background-repeat: repeat;
  pointer-events: none;
}

#back-button {
  background-color: transparent;
  border: none;
  padding: 6px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  margin-left: 15px; /* Move back button to the left */
}

#back-button img {
  width: 30px;
  height: auto;
  display: block;
}

/* Animazione di comparsa logo */
@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

/* Media Query - Responsive spacing su mobile */
@media screen and (max-width: 600px) {
  #menu-page {
    padding: 20px;
  }

  #menu-page h1.logo {
    font-size: 64px;
    margin-bottom: 30px;
  }

  #menu-page .buttons {
    padding: 8px 0;
    gap: 8px;
  }

  #menu-page button {
    font-size: 18px;
  }
}
#menu-logo {
  margin-bottom: 40px;
  margin-top: -10px;
  text-align: left;
  line-height: 1;
}

#logo-svg {
  height: 200px; /* Altezza uguale al font originale */
  width: auto;
  display: block;
}
#logo-svg {
  max-width: 80%;
  height: auto;
}

/* new */
.turn-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    135deg,
    rgba(0, 0, 0, 0.7) 0%,
    rgba(0, 0, 0, 0.5) 100%
  );
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.turn-overlay.show {
  opacity: 1;
}

.turn-text {
  font-family: "Fredoka", sans-serif;
  font-size: 36px;
  font-weight: 600;
  color: white;
  text-align: center;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

/* Score display styles */
/* .score-display {
  font-family: "Fredoka", sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: white;
  margin-left: 20px;
} */

/* Media Query - Responsive spacing su mobile */
@media screen and (max-width: 600px) {
  #menu-page {
    padding: 20px;
  }

  #menu-page h1.logo {
    font-size: 64px;
    margin-bottom: 30px;
  }

  #menu-page .buttons {
    padding: 8px 0;
    gap: 8px;
  }

  #menu-page button {
    font-size: 18px;
  }
	

  /* Responsive per pulsanti mode */
  #one-player,
  #two-players {
    font-size: 28pt !important;
  }

  /* Responsive per pulsanti livello */
  .level-btn {
    font-size: 60pt !important;
  }

  /* Responsive per turn overlay */
  .turn-text {
    font-size: 28px;
    padding: 0 20px;
  }

  /* Responsive per game interface */
  #game-header {
    padding: 0 15px;
    height: 70px;
  }

  #game-logo {
    height: 45px;
  }

  #fullscreen-btn {
    right: 15px;
    top: 15px;
    padding: 4px 8px;
  }

  #fullscreen-btn img {
    width: 24px;
  }

  #game-footer {
    padding: 0 15px;
    height: auto;
    min-height: 50px;
    flex-wrap: wrap;
  }

  #move-counter {
    font-size: 14px;
    text-align: center;
    line-height: 1.3;
  }

  #back-button img {
    width: 24px;
  }

  /* Responsive per le carte */
  .memory-card {
    min-width: 0;
    min-height: 0;
  }

  #game-main {
    padding: 8px;
  }

  .memory-game {
    gap: 3px;
  }

  /* Responsive per popup */
  .popup {
    width: 90%;
    max-width: 400px;
    padding: 15px;
    margin: 20px;
  }

  .popup h3 {
    font-size: 18px;
  }

  .popup p,
  .popup li {
    font-size: 14px;
  }
}

/* Media Query per tablet */
@media screen and (max-width: 768px) and (min-width: 601px) {
  #one-player,
  #two-players {
    font-size: 32pt !important;
  }

  .level-btn {
    font-size: 68pt !important;
  }

  .turn-text {
    font-size: 32px;
  }

  #game-main {
    padding: 8px;
  }

  .memory-game {
    gap: 3px;
  }
}

/* Media Query per schermi molto piccoli */
@media screen and (max-width: 480px) {
  #menu-page {
    padding: 15px;
  }

  #menu-page h2 {
    font-size: 14pt;
  }

  #one-player,
  #two-players {
    font-size: 24pt !important;
  }

  .level-btn {
    font-size: 50pt !important;
  }

  .turn-text {
    font-size: 24px;
    padding: 0 15px;
  }

  #game-header {
    height: 60px;
    padding: 0 10px;
  }

  #game-logo {
    height: 35px;
  }

  #fullscreen-btn {
    right: 10px;
    top: 10px;
  }

  #fullscreen-btn img,
  #back-button img {
    width: 20px;
  }

  #game-footer {
    padding: 0 10px;
    min-height: 60px;
  }

  #move-counter {
    font-size: 12px;
  }

  .memory-card {
    min-width: 0;
    min-height: 0;
  }
}

/* Orientamento landscape su mobile */
@media screen and (max-height: 500px) and (orientation: landscape) {
  #menu-page {
    padding: 15px;
    gap: 5px;
  }

  #menu-page h1.logo {
    margin-bottom: 20px;
  }

  #menu-page h2 {
    margin-top: 15px;
    margin-bottom: 8px;
  }

  #one-player,
  #two-players {
    font-size: 22pt !important;
  }

  .level-btn {
    font-size: 40pt !important;
  }

  #game-header {
    height: 50px;
  }

  #game-logo {
    height: 30px;
  }

  #game-footer {
    height: 40px;
  }

  #move-counter {
    font-size: 11px;
  }
}

#logo-canvas {
  max-width: 120%;
  height: auto;
  max-height: 299px;
  display: block;
  width: auto;
}

/* Responsive per il logo */
@media screen and (max-width: 600px) {
  #logo-canvas {
    max-height: 224px;
  }
}

@media screen and (max-width: 480px) {
  #logo-canvas {
    max-height: 180px;
  }
}

/* Sound control button */
.sound-btn {
  position: fixed;
  bottom: 10px;
  right: 10px;
  width: 30px;
  height: 30px;	
  background-color: transparent;
  border: none;
  border-radius: 0;
  cursor: pointer;
  z-index: 1500;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
  box-shadow: none;
  padding: 0;
  margin: 0;
  opacity: 1;
}

.sound-btn:hover {
  opacity: 0.8;
}

.sound-btn.muted {
  opacity: 0.5;
}

.sound-btn.muted:hover {
  opacity: 0.6;
}

/* Responsive per mobile */
@media screen and (max-width: 600px) {
  .sound-btn {
    bottom: 50px; /* Keep aligned with footer */
    right: 15px;
    width: 45px;
    height: 45px;
  }

  #back-button {
    margin-left: 10px;
  }

  .sound-btn img {
    width: 20px;
    height: 20px;
  }
}

@media screen and (max-width: 480px) {
  .sound-btn {
    bottom: 45px; /* Adjust for smaller footer if needed */
    right: 10px;
    width: 40px;
    height: 40px;
  }

  #back-button {
    margin-left: 8px;
  }

  .sound-btn img {
    width: 18px;
    height: 18px;
  }
}
	.footer-buttons {
  margin-top: 100px;
  display: flex;
  gap: 20px;
  justify-content: flex-start;
}

/* Responsive: meno margine su mobile */
@media screen and (max-width: 600px) {
  .footer-buttons {
    margin-top: 40px;
    gap: 15px;
  }
}

@media screen and (max-width: 480px) {
  .footer-buttons {
    margin-top: 30px;
    gap: 10px;
  }
}
.copyright-text {
  font-family: "Fredoka", sans-serif;
  font-weight: 400;
  font-size: clamp(10px, 2vw, 12px);
  color: white;
  margin-top: auto;
  margin-bottom: 0;
  text-align: left;
  opacity: 0.8;
  padding-top: 8px;
  padding-bottom: 0;
}
#animated-cards-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none; /* ← Non blocca i click sui pulsanti */
  z-index: -1; /* ← Dietro tutto */
  overflow: hidden;
}

.animated-card {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.5s ease-in-out;
}

.animated-card img {
  width: 30px;
  height: auto;
  filter: drop-shadow(0 0px 0px rgba(0,0,0,0.2));
}
/* --- Stile pulsante PLAY AGAIN --- */
.play-again-btn {
  font-family: "Fredoka", sans-serif;
  font-weight: 700; /* Fredoka Bold */
  font-size: 18px;
  padding: 12px 30px;
  background-color: #1547f7; /* Blu del brand */
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.3s ease, color 0.3s ease, transform 0.2s ease;
  margin-top: 20px;
}

.play-again-btn:hover {
  background-color: black;
  color: white;
  
}

/* Responsive: più grande su mobile */
@media screen and (max-width: 600px) {
  .play-again-btn {
    font-size: 20px;
    padding: 14px 32px;
  }
}
