:root {
  --tile-gap: 12px;
  --max-width: 480px;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Comic Sans MS', cursive, sans-serif;
  background: linear-gradient(to bottom, #fef9f9, #f5faff);
  color: #333;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  overflow-x: hidden;
}

.instruction-popup {
  position: fixed;
  top: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #fff8e1, #ffe0b2);
  border: 4px dashed #ff9800;
  padding: 20px 25px;
  border-radius: 18px 4px 18px 4px; /* Irregular edges */
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 999;
  max-width: 90%;
  text-align: center;
  font-family: 'Comic Sans MS', cursive;
  animation: fadeIn 0.6s ease;
}

.instruction-popup h2 {
  margin: 0 0 10px;
  color: #ff5722;
}

.instruction-popup p {
  margin: 0;
  font-size: 1rem;
  color: #444;
}

.close-btn {
  position: absolute;
  top: 4px;
  right: 10px;
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateX(-50%) scale(0.8); }
  to { opacity: 1; transform: translateX(-50%) scale(1); }
}

@media screen and (max-width: 480px) {
  .instruction-popup {
    top: 35%;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    padding: 16px 20px;
    font-size: 0.95rem;
    border-width: 3px;
    border-radius: 16px 6px 16px 6px;
  }

  .instruction-popup h2 {
    font-size: 1.2rem;
    margin-bottom: 8px;
  }

  .instruction-popup p {
    font-size: 0.9rem;
  }

  .close-btn {
    top: 2px;
    right: 8px;
    font-size: 1rem;
  }
}



h1 {
  margin: 20px 0 10px;
  font-size: 2rem;
  color: #ff5722;
  text-shadow: 0 0 4px #ffccbc;
  text-align: center;
}

.stats-bar {
  background: #fff;
  border: 2px solid #eee;
  padding: 10px 14px;
  border-radius: 12px;
  margin-bottom: 10px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  width: 90%;
  max-width: var(--max-width);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.stats-bar p {
  margin: 0;
  font-size: 0.95rem;
  color: #333;
  font-weight: bold;
}

#controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 15px;
}

#controls button {
  background-color: #ff9800;
  color: white;
  font-size: 1rem;
  padding: 10px 16px;
  border: none;
  border-radius: 10px;
  box-shadow: 0 4px #ef6c00;
  transition: 0.2s;
  cursor: pointer;
}

#controls button:hover {
  background-color: #fb8c00;
}

#game-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--tile-gap);
  width: 100%;
  max-width: var(--max-width);
  margin-top: 15px;
  padding: 10px;
  box-sizing: border-box;
}

.tile {
  position: relative;
  aspect-ratio: 1 / 1;
  background: linear-gradient(145deg, #ffffff, #e0e0e0);
  border-radius: 12px;
  box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.15), -4px -4px 10px rgba(255, 255, 255, 0.8);
  overflow: hidden;
  transition: transform 0.3s ease;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tile img {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  display: none;
  object-fit: cover;
}

.tile.flipped img,
.tile.matched img {
  display: block;
}

.tile.flipped,
.tile.matched {
  background: none;
  transform: scale(1.05) rotateY(180deg);
}

button {
  background-color: #4caf50;
  color: white;
  border: none;
  padding: 8px 16px;
  margin-top: 20px;
  border-radius: 10px;
  font-size: 1rem;
  box-shadow: 0 4px #388e3c;
  transition: background 0.2s;
  cursor: pointer;
}

button:hover {
  background-color: #43a047;
}

#post-game {
  text-align: center;
  padding: 20px;
  color: #f57c00;
  font-size: 1.1rem;
}

.hidden {
  display: none;
}

/* 🎉 Celebration full-screen modal */
#celebration {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  flex-direction: column;
  font-size: 2rem;
  color: #ff5722;
  text-align: center;
}

.celebration-content {
  animation: popIn 0.8s ease forwards;
}

@keyframes popIn {
  0% { transform: scale(0.3); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

#celebration button {
  margin-top: 20px;
  font-size: 1rem;
  padding: 10px 20px;
  border-radius: 10px;
  border: none;
  background-color: #4caf50;
  color: white;
  box-shadow: 0 4px #388e3c;
}

#celebration button:hover {
  background-color: #43a047;
}

/* ✅ Responsive for small screens */
@media screen and (max-width: 480px) {
  h1 {
    font-size: 1.6rem;
    margin-top: 10px;
  }

  .stats-bar {
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    width: 95%;
  }

  #game-board {
    grid-template-columns: repeat(4, 1fr);
    width: 100%;
    max-width: 100vw;
  }

  #controls button, button {
    font-size: 0.9rem;
    padding: 8px 12px;
  }
}

.game-footer {
  width: 100%;
  text-align: center;
  background: linear-gradient(to right, #ffccbc, #ffe0b2);
  color: #4e342e;
  font-family: 'Comic Sans MS', cursive, sans-serif;
  padding: 16px 10px;
  margin-top: auto;
  font-size: 0.95rem;
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.1);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  letter-spacing: 0.3px;
}

.game-footer a {
  color: #ff5722;
  text-decoration: none;
  font-weight: bold;
  margin: 0 4px;
  transition: color 0.3s ease;
}

.game-footer a:hover {
  color: #e65100;
}

/* 📱 Mobile-friendly adjustments */
@media screen and (max-width: 480px) {
  .game-footer {
    font-size: 0.85rem;
    padding: 12px 6px;
  }

  .game-footer a {
    display: inline-block;
    margin: 6px 8px;
  }
}

