@import url("https://fonts.googleapis.com/css2?family=DynaPuff:wght@400..700&display=swap");

* {
  box-sizing: border-box;
  font-family: "Comfortaa", cursive;
}

body {
  font-family: "DynaPuff", system-ui;
  background-color: #f4eef6;
}

.container {
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 40px;
  padding: 40px;
}

.game-title {
  background: #ffffff88;
  border: 2px solid #7a2b8a;
  border-radius: 15px;
  padding: 15px 20px;
  text-align: center;
  margin-bottom: 20px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  animation: floatIn 0.7s ease;
}

.game-title h1 {
  font-family: "DynaPuff", cursive;
  color: #7a2b8a;
  font-size: 28px;
  letter-spacing: 1.5px;
  margin: 0;
}

.scoreboard {
  width: 350px;
  background: #ffffff88;
  border-radius: 20px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
  border: 2px solid #7a2b8a;
  animation: floatIn 0.7s ease;
}

.timer {
  background: #fff;
  border: 3px solid #7a2b8a;
  border-radius: 15px;
  padding: 15px 30px;
  font-size: 32px;
  color: #7a2b8a;
  font-weight: bold;
  letter-spacing: 2px;
  width: 100%;
  text-align: center;
  position: relative;
}

.label {
  position: absolute;
  top: -19px;
  left: 15px;
  font-size: 14px;
  background: #fefcea;
  padding: 0 6px;
  color: #7a2b8a;
}

.info-row {
  display: flex;
  justify-content: space-between;
  width: 100%;
  gap: 10px;
}

.info-box {
  flex: 1;
  background: #fff;
  border: 2px solid #7a2b8a;
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  font-weight: bold;
  font-size: 16px;
  position: relative;
  color: #7a2b8a;
}

.label-small {
  position: absolute;
  top: -16px;
  left: 10px;
  font-size: 13px;
  background: #fefcea;
  padding: 0 6px;
  color: #7a2b8a;
}

.game-board {
  width: 600px;
  background: #ffffff88;
  border-radius: 20px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
  padding: 20px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  border: 2px solid #7a2b8a;
  justify-content: center;
  align-content: center;
  animation: floatIn 0.7s ease;
}

.card {
  width: 100%;
  aspect-ratio: 1 / 1;
  perspective: 1000px;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.6s ease;
}

.card__inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s;
}

.card__front,
.card__back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 2px solid #7a2b8a;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.card__back {
  background: linear-gradient(135deg, #fffef9, #eecdfc);
  font-size: 23px;
  font-weight: bold;
  color: #7a2b8a;
  transform: rotateY(180deg);
}

.card__image {
  width: 140px;
  height: 140px;
  object-fit: contain;
}

.card--hidden {
  transform: rotateY(180deg);
}

.card--matched {
  animation: Fade 0.5s ease forwards, DimCard 0.5s ease forwards;
  animation-delay: 0s, 0.5s;
  pointer-events: none;
  border-radius: 11px;
}

@keyframes Fade {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 transparent;
  }
  30% {
    transform: scale(1.2) rotate(3deg);
    box-shadow: 0 0 20px #ffbbf4;
  }
  60% {
    transform: scale(0.95) rotate(-3deg);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 10px #ffccff;
  }
}
@keyframes DimCard {
  0% {
    filter: grayscale(0%);
    opacity: 1;
  }
  100% {
    filter: grayscale(100%);
    opacity: 0.4;
    transform: scale(1.05);
  }
}

.card--notmatched {
  animation: shake 0.4s ease;
  box-shadow: 0 0 15px rgba(255, 0, 0, 0.6);
  border-color: #ff4d4d;
  border-radius: 11px;
}

@keyframes shake {
  0% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  50% {
    transform: translateX(5px);
  }
  75% {
    transform: translateX(-5px);
  }
  100% {
    transform: translateX(0);
  }
}

.card--disabled {
  pointer-events: none;
}

.game-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem 2rem;
  background: transparent;
  font-family: "DynaPuff", cursive;
  position: relative;
  z-index: 5;
  flex-wrap: wrap;
  gap: 1rem;
  animation: floatIn 0.7s ease;
}

.game-footer__help-icon {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgb(255, 255, 255);
  border: 2px solid #7a2b8a;
  border-radius: 18px;
  padding: 0.5rem 1rem;
  color: #5e156d;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(4px);
  cursor: help;
}

.game-footer__help-icon:hover {
  transform: scale(1.05) rotate(-2deg);
  background: rgba(255, 255, 255, 0.15);
}

.game-footer__help-icon img {
  width: 25px;
  height: 28px;
}

.game-footer__help-box {
  position: absolute;
  top: 73px;
  left: -1rem;
  width: 380px;
  background: linear-gradient(135deg, #fffefa, #f6e2ff);
  border: 2px solid rgba(255, 255, 255, 0.745);
  border-radius: 20px;
  padding: 1.2rem 1.5rem;
  font-size: 0.95rem;
  font-weight: bold;
  backdrop-filter: blur(6px);
  box-shadow: 0 0 20px rgba(193, 193, 193, 0.649);
  display: none;
  z-index: 10;
  text-align: left;
  color: #5e156d;
  animation: fadeIn 0.3s ease forwards;
}

.game-footer__help-box h2 {
  font-size: 1.4rem;
  margin-bottom: 0.6rem;
  color: #5e156d;
  text-shadow: 1px 1px 3px #000000a7;
  font-family: "DynaPuff", cursive;
}

.game-footer__help-box ul {
  padding-left: 1.2rem;
  margin: 0.8rem 0;
  font-family: "DynaPuff", cursive;
  color: #5e156d;
}

.game-footer__help-box li {
  margin-bottom: 0.4rem;
  list-style: disc;
  font-family: "DynaPuff", cursive;
  color: #5e156d;
  font-weight: 400;
}

.game-footer__help-box button {
  margin-top: 0.6rem;
  background: #ff66b2;
  color: #fff;
  border: none;
  padding: 0.4rem 1rem;
  border-radius: 12px;
  font-weight: bold;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.3s ease;
  font-family: "DynaPuff", cursive;
}

.game-footer__help-box button:hover {
  background: #cc327a;
}

.game-footer__buttons button {
  background: rgb(255, 255, 255);
  border: 2px solid #7a2b8a;
  border-radius: 18px;
  padding: 0.6rem 1.75rem;
  color: #5e156d;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.game-footer__buttons button:hover {
  transform: scale(1.05) rotate(-2deg);
  background: rgba(255, 255, 255, 0.15);
}

.popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(228, 201, 253, 0.466);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
  display: none;
  animation: fadeIn 0.3s ease-in-out forwards;
}

.popup__content {
  background: #ffffffc8;
  border-radius: 15px;
  padding: 1rem 2rem;
  text-align: center;
  color: #5e156d;
  font-family: "DynaPuff", cursive;
  backdrop-filter: blur(6px);
  box-shadow: 0 0 25px rgba(255, 255, 255, 0.2);
  width: 300px;
  animation: popUp 0.4s ease-out;
}

.winPopup-img {
  width: 170px;
  position: absolute;
  top: -5.5rem;
  right: 4rem;
}

.losePopup-img {
  width: 215px;
  position: absolute;
  top: -6.5rem;
  right: 2rem;
}

.popup__content h2 {
  font-size: 1.5rem;
  color: #5e156d;
  text-shadow: 2px 2px 4px #000000cb;
}

.popup__content p {
  font-size: 1.2rem;
}

.popup__content button {
  background: #ff66b2;
  color: #fff;
  font-size: 1rem;
  padding: 0.6rem 1.4rem;
  border: none;
  border-radius: 18px;
  cursor: pointer;
  font-weight: bold;
  font-family: "DynaPuff", cursive;
  box-shadow: 0 0 12px rgba(255, 102, 178, 0.4);
  transition: all 0.3s ease;
}

.popup__content button:hover {
  transform: scale(1.05) rotate(1deg);
  background-color: #cc327a;
}

.popup__content.lost {
  animation: shake 0.5s ease;
}

@keyframes shake {
  0% {
    transform: translate(0, 0);
  }
  25% {
    transform: translate(4px, -4px);
  }
  50% {
    transform: translate(-4px, 4px);
  }
  75% {
    transform: translate(4px, 4px);
  }
  100% {
    transform: translate(0, 0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes popUp {
  0% {
    transform: scale(0.8) rotate(-2deg);
    opacity: 0;
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

@keyframes floatIn {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 768px) {
  .container {
    flex-direction: column;
    align-items: center;
    padding: 20px;
    gap: 0;
  }

  .game-title {
    display: none;
  }

  .scoreboard {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;
    max-width: 505px;
    padding: 10px;
    background-color: transparent;
  }

  .info-box {
    flex: 1;
    background-color: #ffffff;
    border-radius: 12px;
    border: 2px solid #ccc;
    padding: 10px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60px;
  }

  .info-box .label {
    position: absolute;
    top: -10px;
    left: 10px;
    background: white;
    padding: 0 5px;
    font-size: 12px;
    color: #666;
  }

  .info-box .value {
    font-size: 20px;
    font-weight: bold;
    color: #333;
  }

  .game-board {
    width: 100%;
    max-width: 420px;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 20px 0;
  }

  .card__image {
    width: 80px;
    height: 80px;
  }

  .game-footer {
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
    padding: 10px;
    gap: 0.5rem;
  }

  .game-footer__buttons,
  .game-footer__help-icon {
    flex: 1;
    max-width: 30%;
    font-size: 0.9rem;
    padding: 8px;
    text-align: center;
  }

  .game-footer__help-icon {
    order: 1;
  }

  .game-footer__buttons {
    order: 3;
    display: flex;
    justify-content: flex-end;
  }
}

@media (max-width: 480px) {
  .container {
    flex-direction: column;
    align-items: center;
    padding: 20px;
    gap: 0;
  }

  .game-title {
    display: none;
  }

  .scoreboard {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;
    max-width: 300px;
    padding: 10px;
    background-color: transparent;
  }

  .info-box {
    flex: 1;
    background-color: #ffffff;
    border-radius: 12px;
    border: 2px solid #ccc;
    padding: 10px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60px;
  }

  .info-box .label {
    position: absolute;
    top: -10px;
    left: 10px;
    background: white;
    padding: 0 5px;
    font-size: 11px;
    color: #666;
  }

  .info-box .value {
    font-size: 18px;
    font-weight: bold;
    color: #333;
  }

  .game-board {
    width: 100%;
    max-width: 100%;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 20px 0;
  }

  .card__image {
    width: 70px;
    height: 70px;
  }

  .game-footer {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    width: 100%;
    padding: 10px;
    gap: 40px;
  }

  .game-footer__help-icon,
  .game-footer__buttons {
    text-align: center;
    font-size: 0.85rem;
    padding: 8px;
  }
}
