@import url("https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Press+Start+2P&family=Schoolbell&display=swap");

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Poppins", sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100vh;
  padding: clamp(10px, 5vw, 30px);
  transform: translateZ(0);
  overflow-x: hidden;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: white;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.86);
} 
 body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
      135deg,
      rgba(26, 42, 108, 0.3),
      rgba(178, 31, 31, 0.3),
      rgba(253, 187, 45, 0.3)
    ),
    url(p) center/cover;
  background-size: 400% 400%;
  animation: gradientBG 30s ease infinite;
  z-index: -1;
  opacity: 0.7;
}

@keyframes gradientBG {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
} 

#bg-video {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -1;
  filter: brightness(0.5);
}
#bg-video::after {
  content: "";
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.4); /* black overlay */
}

.game-title {
  font-family: "Schoolbell", cursive;
  text-align: center;
  font-size: 2.8rem;
  font-weight: 700;
  margin-top: 20px;
  margin-bottom: 20px;
  color: #fff;
  text-shadow: 3px 3px 5px rgba(0, 0, 0, 0.7);
  animation: titleGlow 2s ease-in-out infinite alternate;
}

@keyframes titleGlow {
  0% {
    text-shadow: 3px 3px 5px rgba(0, 0, 0, 0.7),
      0 0 10px rgba(255, 255, 255, 0.5);
  }
  100% {
    text-shadow: 3px 3px 5px rgba(0, 0, 0, 0.7),
      0 0 20px rgba(255, 255, 255, 0.8), 0 0 30px rgba(255, 215, 0, 0.6);
  }
}

.wrapper {
  padding: 50px;
  padding-inline: 30px;
  margin: 10px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 15px;
  box-shadow: 10px 10px 20px rgba(9, 9, 9, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  animation: fadeIn 1.2s ease;
}

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


.cards {
  height: 650px;
  width: 650px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  list-style: none;
  padding: 0;
  margin: 0;
}


.cards .card {
  cursor: pointer;
  position: relative;
  perspective: 1000px;
  transform-style: preserve-3d;
  height: calc(100% / 4 - 10px);
  width: calc(100% / 4 - 10px);
  transition: transform 0.25s ease;
  margin: 0;
}

.cards .card:hover {
  transform: scale(1.05);
}

.card.shake {
  animation: shake 0.35s ease-in-out;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-13px);
  }
  40% {
    transform: translateX(13px);
  }
  60% {
    transform: translateX(-8px);
  }
  80% {
    transform: translateX(8px);
  }
}

.card .view {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid #ffcf67ae;
  box-shadow: 10px 10px 10px rgba(0, 0, 0, 0.405);
  transition: transform 0.4s ease;
  display: flex;
  justify-content: center;
  align-items: center;
}

.card .front-view {
  background: linear-gradient(135deg, #a7a7a7 0%, #555555 100%);
  font-size: 32px;
  color: white;
  transform: rotateY(0deg);
}

.card .back-view {
  background: white;
  transform: rotateY(180deg);
  font-size: 40px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.card.flip .front-view {
  transform: rotateY(180deg);
}

.card.flip .back-view {
  transform: rotateY(0deg);
}

.card.matched .back-view {
  border: 2px solid #4eff9d;
  box-shadow: 0 0 15px #4eff9d;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0% {
    transform: rotateY(0deg) scale(1);
  }
  50% {
    transform: rotateY(0deg) scale(1.1);
  }
  100% {
    transform: rotateY(0deg) scale(1);
  }
}

.details {
  width: 100%;
  margin-top: 15px;
  padding: 30px;
  border-radius: 7px;
  background: rgba(210, 200, 200, 0.533);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
  gap: 10px;
  flex-wrap: wrap;
}

.details p {
  font-size: 18px;
  height: 17px;
  padding-right: 18px;
  border-right: 1px solid #ccc;
  margin: 0;
  display: flex;
  align-items: center;
}

.details p:last-child {
  border-right: none;
}

.details select {
  padding: 4px 6px;
  border-radius: 4px;
  border: 1px solid #080709;
}

.details button {
  cursor: pointer;
  font-size: 14px;
  color: #08080c;
  border-radius: 4px;
  padding: 4px 11px;
  background: #fff;
  border: 2px solid #696969;
  transition: 0.2s ease;
}

.details button:hover {
  color: #fff;
  background: #5e5e5f;
}


.popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: rgba(255, 255, 255, 0.15);
  padding: 100px 200px;
  border-radius: 20px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
  text-align: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: all 0.35s ease;
  z-index: 1000;
}

.popup.show {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.popup p {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 20px;
  color: #120e06;
  text-shadow: 0 0 5px #ffcf67, 0 0 10px #ffcf67, 0 0 15px #ffcf67;
  font-family: "Press Start 2P", cursive;
  animation: glow 1.5s ease-in-out infinite alternate;
}

@keyframes glow {
  0% {
    text-shadow: 0 0 5px #ffcf67, 0 0 10px #ffcf67, 0 0 15px #ffcf67;
  }
  50% {
    text-shadow: 0 0 10px #ffcf67, 0 0 20px #ffcf67, 0 0 30px #ffd700;
  }
  100% {
    text-shadow: 0 0 5px #ffcf67, 0 0 10px #ffcf67, 0 0 15px #ffcf67;
  }
}

.popup button {
  margin: 8px;
  padding: 10px 18px;
  font-size: 15px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  background: linear-gradient(135deg, #de3c14, #feb47b);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.popup button:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.popup select {
  padding: 8px 12px;
  border-radius: 6px;
  border: none;
  margin-bottom: 15px;
  font-size: 16px;
  width: 100%;
}

.hidden {
  display: none;
}

/* Form container */
.form-group {
  margin-bottom: 20px;
  text-align: left;
}

/* Labels */
.form-group label {
  display: block;
  margin-bottom: 6px;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

/* Inputs & selects */
.form-group input,
.form-group select {
  font-family: "Press Start 2P", system-ui;
  width: 100%;
  padding: 20px 24px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.85);
  font-size: 15px;
  color: #333;
  transition: all 0.25s ease;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Focus effect */
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #ffcf67;
  box-shadow: 0 0 10px rgba(255, 207, 103, 0.6);
  transform: scale(1.02);
  background: #fff;
}

/* Button group container */
.button-group {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 10px;
}

/* Start button */
#start-btn {
  background: linear-gradient(135deg, #ffcf67, #ff9a3c);
  color: #fff;
  font-weight: 700;
  padding: 10px 20px;
  font-size: 16px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

#start-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  background: linear-gradient(135deg, #ffb347, #ff7e5f);
}

#player-greeting {
  margin-top: 20px;
  padding: 15px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

#player-greeting p {
  margin: 5px 0;
  font-size: 18px;
}

/* Popup sizing */
.popup {
  min-width: 350px;
  max-width: 90%;
}

.popup button {
  min-width: 120px;
}

/* Game Over Popup Styles */
#game-over-popup {
  min-width: 400px;
  max-width: 90%;
  text-align: center;
}

.game-over-content {
  padding: 20px;
}

#game-over-icon {
  font-size: 60px;
  margin-bottom: 15px;
  animation: bounce 1s infinite alternate;
}

@keyframes bounce {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(-10px);
  }
}

#game-over-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 10px;
  color: #fff;
  text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.6);
}

#game-over-message {
  font-size: 18px;
  margin-bottom: 25px;
  color: #fff;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.game-stats {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 15px;
  margin-bottom: 25px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.stat {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.stat:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.stat-label {
  color: #fff;
  font-weight: 500;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.stat-value {
  color: #ffcf67;
  font-weight: 600;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

#game-over-popup .button-group {
  display: flex;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
}

#game-over-popup button {
  margin: 0;
  padding: 12px 24px;
  font-size: 16px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  min-width: 140px;
}

#play-again-btn {
  background: linear-gradient(135deg, #4caf50, #45a049);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#play-again-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  background: linear-gradient(135deg, #45a049, #4caf50);
}

#main-menu-btn {
  background: linear-gradient(135deg, #ff7e5f, #feb47b);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#main-menu-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  background: linear-gradient(135deg, #feb47b, #ff7e5f);
}

/* High scores section */
.high-scores {
  margin-top: 20px;
  padding: 15px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.high-scores h3 {
  color: #ffcf67;
  margin-bottom: 10px;
  text-align: center;
  font-size: 18px;
}

.high-score-item {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.high-score-item:last-child {
  border-bottom: none;
}

.high-score-name {
  color: white;
  font-weight: 500;
}

.high-score-value {
  color: #4eff9d;
  font-weight: 600;
}

/* Audio controls */
.audio-controls {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  display: flex;
  gap: 10px;
  align-items: center;
  background: rgba(255, 255, 255, 0.2);
  padding: 10px 15px;
  border-radius: 50px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.audio-controls button {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: white;
  transition: transform 0.2s ease;
}

.audio-controls button:hover {
  transform: scale(1.1);
}

.audio-controls input[type="range"] {
  width: 80px;
}

.difficulty-indicator {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.2);
  padding: 5px 10px;
  border-radius: 15px;
  font-size: 14px;
  color: white;
  backdrop-filter: blur(10px);
}

/* Power-ups section */
.power-ups {
  display: flex;
  gap: 10px;
  margin-top: 15px;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
}

.power-up-btn {
  padding: 8px 12px;
  border-radius: 20px;
  border: 2px solid #ffcf67;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
}

.power-up-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.power-up-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #666;
}

/* Theme-specific card styles */
.card[data-theme="animals"] .back-view {
  background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
}

.card[data-theme="food"] .back-view {
  background: linear-gradient(135deg, #a1c4fd 0%, #c2e9fb 100%);
}

.card[data-theme="sports"] .back-view {
  background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
}

.card[data-theme="travel"] .back-view {
  background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
}

/* Animation for new high score */
@keyframes highScoreGlow {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}

.new-high-score {
  animation: highScoreGlow 0.6s ease-in-out 3;
  color: gold !important;
}

/* Responsive design */
@media screen and (max-width: 700px) {
  .cards {
    height: 400px;
    width: 400px;
  }

  .details {
    flex-direction: column;
    gap: 15px;
  }

  .details p {
    border-right: none;
    padding-right: 0;
    border-bottom: 1px solid #ccc;
    padding-bottom: 10px;
    width: 100%;
    text-align: center;
    justify-content: center;
  }
}

@media screen and (max-width: 530px) {
  .cards {
    height: 350px;
    width: 350px;
  }

  .game-title {
    font-size: 22px;
    margin-top: 20px;
  }

  .popup {
    padding: 20px;
    width: 90%;
  }

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

  .card .front-view {
    font-size: 24px;
  }

  .card .back-view {
    font-size: 30px;
  }
}

@media screen and (max-width: 400px) {
  .cards {
    height: 300px;
    width: 300px;
  }
}

/* Responsive adjustments for game over popup */
@media screen and (max-width: 530px) {
  #game-over-popup {
    min-width: 300px;
  }

  #game-over-title {
    font-size: 24px;
  }

  #game-over-message {
    font-size: 16px;
  }

  #game-over-popup .button-group {
    flex-direction: column;
    gap: 10px;
  }

  #game-over-popup button {
    width: 100%;
  }
}