html {
  box-sizing: border-box;
  background: url('images/Background.png') center center / cover repeat;
  background-attachment: fixed;
  overscroll-behavior: none; /* Prevent some scroll chaining effects */
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  height: 100%;
  overflow-x: hidden;
  font-family: 'Rubik', cursive;
  font-size: 1em;
  text-align: center;
  color: #fff;
  background: none;
  position: relative;
  z-index: 0;
}

body {
  background-image: url('your-image.jpg');
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: transparent;
}

body::before {
 font-family: 'Segoe UI', sans-serif;
  margin: 0;
  padding: 0;
 background-color: #ffffff; /* solid light blue */
  color: #2d4771; /* darker text for readability */
}

.container {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  padding: 10px;
}

h1 {
  font-family: 'Rubik', cursive;
  font-weight: 300;
  color: #2d4771;
  font-size: 2.5em; 
}

/* Styles for the deck of cards */


.deck {
  width: 90%; 
  max-width: 45em; /* Ograničavamo maksimalnu širinu na 720px za velike ekrane */
  min-height: auto; 
  /* aspect-ratio je uklonjen jer je $4 \times 6$ pravokutnik, ne kvadrat. */
  
  background: linear-gradient(160deg, rgba(29, 109, 141, 0.5) 0%, rgba(98, 191, 228, 0.5) 100%);
  padding: 0.5em;  
  border-radius: 10px;
  box-shadow: 12px 15px 20px 0 rgba(46, 61, 73, 0.5);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  align-items: center;
  margin: 1em 0 3em;
}

.deck .card {
  height: auto;
  margin: 0.2rem;
  background: #2d4771;
  font-size: 0;
  color: #ffffff;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 5px 2px 20px 0 rgba(46, 61, 73, 0.5);
  
  /* KLJUČNA PROMJENA: Koristimo 33% za 3 kartice vodoravno */
  flex-basis: calc(33% - 0.4rem); /* 33% širine minus margina */
  aspect-ratio: 1 / 1; /* Kartica je kvadratna */
  position: relative;
  overflow: hidden;
  border: 2px solid #ccc;
  box-sizing: border-box;
  padding: 0;
}


.deck .card:not(.match):not(.open) {
  background-color: #2d4771;
}
.card img.card-img {
  position: absolute; 
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background-color: #e4e2dd;
  display: block;
  pointer-events: none;
  opacity: 0;              
  transition: opacity 0.3s ease-in-out;
}


.deck .card.open {
  transform: rotateY(0);
  background: #86a9e3; 
  cursor: default;
  animation-name: flipInY;
  -webkit-backface-visibility: visible !important;
  backface-visibility: visible !important;
  animation-duration: .75s;
}

.deck .card.show {
  font-size: 33px;
}

.deck .card.match {
  cursor: default;
  background: #1bc45f;
  font-size: 33px;
  animation-name: rubberBand;
  -webkit-backface-visibility: visible !important;
  backface-visibility: visible !important;
  animation-duration: .75s;
  border-color: limegreen; 
}

.deck .card.unMatch {
  animation-name: pulse;
  -webkit-backface-visibility: visible !important;
  backface-visibility: visible !important;
  animation-duration: .75s;
  cursor: default;
  background: #ffb366;
  font-size: 33px;
  border-color: red; 
}

/* Show the image only when card is open or matched */
.card.open img.card-img,
.card.match img.card-img {
  opacity: 1;              
}


.card.open.show img {
  opacity: 1;
}


.back {
  background: #2e3d49;
  position: absolute;
  left: 0;
  top: 0;
  padding: 0;
  border: none;
  outline: none;
}

.check {
  transform: rotateY(180deg);
}

/*modal section*/

.pop-up {
  z-index: 1000;
  position: fixed; 
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: none;
  justify-content: center;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.6);

  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px); 
}

.hidden{
  display: none !important;
}

.pop-up.showed {
  display: flex; 
}

.result {
  background-color: rgba(29, 109, 141, 0.8); 
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
  border-radius: 30px;
  padding: 3em 2em;
  max-width: 90%;
  width: 480px;
  text-align: center;
  position: relative;
  color: #1c2e4a;
  font-family: 'Rubik', sans-serif;
  animation: fadeInPopUp 0.8s ease-out;

  text-align: center;
  animation: fadeIn 1s ease
}

@media (max-width: 640px) {
  .deck .card {
    flex-basis: calc(50% - 0.4rem);
  }
}

.pop-up-header {
  font-size: 2em;
  font-weight: 600;
  color: #fff;
  margin-bottom: 0.5em;
  display: block;
}

.result p {
  font-size: 1.1em;
  margin: 0.5em 0;
  color: #fff;
}

.restart-modal {
  margin-top: 1.5em;
  font-size: 1em;
  background: #5c9dd8;
  border: none;
  padding: 0.8em 2em;
  border-radius: 30px;
  color: #fff;
  cursor: pointer;
  transition: background 0.3s ease;
}
.restart-modal:hover {
  background: #2d4771;
}

/* close button in highscore modal uses same style */
.close-highscore,
.view-highscore {
  margin-top: 1.5em;
  font-size: 1em;
  background: #5c9dd8;
  border: none;
  padding: 0.8em 2em;
  border-radius: 30px;
  color: #fff;
  cursor: pointer;
  transition: background 0.3s ease;
}
.close-highscore:hover,
.view-highscore:hover {
  background: #2d4771;
}

#highscore-list {
  text-align: left;
  padding-left: 1.2em;
  color: #fff;
  max-height: 300px;
  overflow-y: auto;
  margin: 0;
}

#highscore-list li {
  margin: 0.3em 0;
}

@keyframes fadeInPopUp {
  from {
    transform: scale(0.85);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

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

.fa-star {
  color: #ffff99;
}


/* Styles for the Score Panel */

.score-panel {
  display: flex;
  justify-content: space-around;
  align-items: center;
  width: 90%;
  max-width: 456px;
  margin-bottom: 10px;
  background-color: rgba(29, 109, 141, 0.5);
  border-radius: 25px;
  padding: 10px;
  box-sizing: border-box; 
}

.score-panel .star-rating {
  margin: 0;
  padding: 0;
  display: inline-block;
  margin: 0 5px 0 0;
}

.score-panel .star-rating li {
  list-style: none;
  display: inline-block;
}

.score-panel .restart {
  cursor: pointer;
  color: #fff;
  background-color: rgba(173, 190, 225, 0.6);
  box-sizing: border-box;
  outline: none;

}

/* high-score button uses same styling as restart but with slight margin */
.score-panel .highscore {
  cursor: pointer;
  color: #fff;
  background-color: rgba(173, 190, 225, 0.6);
  box-sizing: border-box;
  outline: none;
  margin-left: 0.5rem;
}

.timer {
  display: inline-block;
  margin: 0 1rem;
}

.btn {
  width: 85px;
  height: 45px;
  border-radius: 40px;
  font-family: 'Maven Pro', sans-serif;
  font-weight: bold;
  color: white;
  background: rgba(29, 109, 141, 0.5);
  border: 1px solid rgb(29, 109, 141);
  box-sizing: border-box;
  outline: none;
  font-size: 0.83em;
}

.counter span {
  display: inline-block;
  width: 100%;
}

#fireworks {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 999; 
  background: transparent !important; 
}

/* ========================================================= */
/* MEDIA QUERIES (PRILAGODLJIVOST)         */
/* ========================================================= */

/* Tablet i manji desktop (Max širina 992px) */
@media screen and (max-width: 992px) {
  h1 {
    font-size: 2em;
  }
}

/* Mobitel (Max širina 600px) */
@media screen and (max-width: 600px) {
  
  html, body {
    font-size: 0.9em; 
  }

  .container {
    padding: 5px;
  }
  
  h1 {
    font-size: 1.8em;
  }

  .score-panel {
    padding: 8px;
    font-size: 0.9em;
    width: 95%; 
    max-width: none; 
  }

  /* KLJUČNA PROMJENA ZA MOBITELE: Održavamo 4 kartice vodoravno i na mobitelima */
  .deck .card {
    /* Održavamo 4 kartice u redu, ali smanjujemo margine */
    flex-basis: calc(25% - 0.2rem); 
    margin: 0.1rem;
  }

  .deck {
    padding: 0.5em; 
    width: 98%; 
  }
  
  .deck .card.show {
      font-size: 20px; 
  }
  .deck .card.match {
      font-size: 20px;
  }
  .deck .card.unMatch {
      font-size: 20px;
  }
}

/* Landscape mode za mobitele i male tablete (Max širina 768px i minimalna visina) */
@media screen and (max-height: 500px) and (max-width: 768px) {
  .deck {
    margin: 0.5em 0 1em; 
  }
  .container {
    padding: 0;
  }
}


/* animations */