@import url('https://fonts.googleapis.com/css2?family=Bubblegum+Sans&family=Fredoka:wght@400;600;700&display=swap');

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

body {
  font-family: 'Fredoka', 'Comic Sans MS', cursive;
  min-height: 100vh;
  background: linear-gradient(135deg, #ff6b6b, #ffa500, #ffd93d, #6bcb77, #4d96ff, #9b59b6, #ff6b9d);
  background-size: 400% 400%;
  animation: rainbowBg 8s ease infinite;
  display: flex;
  flex-direction: column;
  align-items: center;
}

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

/* ===== HEADER ===== */
.site-header {
  text-align: center;
  padding: 30px 20px 10px;
}

.site-title {
  font-family: 'Bubblegum Sans', cursive;
  font-size: 3rem;
  color: #fff;
  text-shadow: 3px 3px 0 #ff6b9d, 6px 6px 0 rgba(0,0,0,0.1);
  animation: bounce 2s ease infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.site-subtitle {
  font-size: 1.2rem;
  color: #fff;
  margin-top: 5px;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  width: 100%;
  max-width: 600px;
}

/* ===== GAME CARDS / BUTTONS ===== */
.game-cards {
  display: flex;
  flex-direction: column;
  gap: 25px;
  width: 100%;
  max-width: 400px;
  margin: 30px 0;
}

.game-card {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 25px 30px;
  border-radius: 20px;
  text-decoration: none;
  color: #fff;
  font-size: 1.5rem;
  font-weight: 700;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  cursor: pointer;
  border: none;
}

.game-card:hover {
  transform: scale(1.05) rotate(-1deg);
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

.game-card:active {
  transform: scale(0.98);
}

.game-card.ttt {
  background: linear-gradient(135deg, #ff6b9d, #ff4757);
}

.game-card.memory {
  background: linear-gradient(135deg, #4d96ff, #9b59b6);
}

.game-card.snake {
  background: linear-gradient(135deg, #6bcb77, #2ecc71);
}

.game-card.colorpuzzle {
  background: linear-gradient(135deg, #ffa500, #ff6b6b);
}

.game-card.simon {
  background: linear-gradient(135deg, #ffd93d, #f39c12);
}

.game-card .icon {
  font-size: 2.5rem;
}

/* Grid layout for home page */
.game-cards.grid-layout {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  max-width: 550px;
  gap: 18px;
}

.game-cards.grid-layout .game-card {
  flex-direction: column;
  text-align: center;
  gap: 8px;
  padding: 22px 15px;
  font-size: 1.2rem;
}

.game-cards.grid-layout .game-card:last-child:nth-child(odd) {
  grid-column: 1 / -1;
  max-width: 260px;
  justify-self: center;
}

/* ===== GAME CONTAINER ===== */
.game-container {
  background: rgba(255,255,255,0.95);
  border-radius: 25px;
  padding: 30px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  width: 100%;
  max-width: 500px;
  text-align: center;
}

.game-title {
  font-family: 'Bubblegum Sans', cursive;
  font-size: 2rem;
  color: #ff6b9d;
  margin-bottom: 20px;
}

/* ===== TIC-TAC-TOE ===== */
.ttt-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 320px;
  margin: 0 auto 20px;
}

.ttt-cell {
  aspect-ratio: 1;
  border: none;
  border-radius: 15px;
  background: linear-gradient(135deg, #f0f0f0, #e0e0e0);
  font-size: 3rem;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ttt-cell:hover:not(.taken) {
  background: linear-gradient(135deg, #fff3cd, #ffeaa7);
  transform: scale(1.05);
}

.ttt-cell.taken {
  cursor: default;
}

.ttt-cell .heart {
  color: #ff4757;
  animation: popIn 0.3s ease;
}

.ttt-cell .diamond {
  color: #4d96ff;
  animation: popIn 0.3s ease;
}

@keyframes popIn {
  0% { transform: scale(0); }
  70% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.status-text {
  font-size: 1.3rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 15px;
  min-height: 40px;
}

.status-text.win {
  color: #ff6b9d;
  animation: bounce 0.5s ease;
}

/* ===== MEMORY GAME ===== */
.memory-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  max-width: 400px;
  margin: 0 auto 20px;
}

.memory-card {
  aspect-ratio: 1;
  border: none;
  border-radius: 15px;
  cursor: pointer;
  perspective: 600px;
  background: transparent;
}

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

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

.memory-card-front, .memory-card-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
}

.memory-card-front {
  background: linear-gradient(135deg, #ff6b9d, #9b59b6);
  color: #fff;
  font-size: 1.5rem;
}

.memory-card-back {
  background: #fff;
  transform: rotateY(180deg);
  box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
}

.memory-card.matched .memory-card-inner {
  animation: matchPop 0.4s ease;
}

.memory-card.matched .memory-card-back {
  background: linear-gradient(135deg, #d4fc79, #96e6a1);
}

@keyframes matchPop {
  0% { transform: rotateY(180deg) scale(1); }
  50% { transform: rotateY(180deg) scale(1.15); }
  100% { transform: rotateY(180deg) scale(1); }
}

.score-board {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-bottom: 15px;
  font-size: 1.1rem;
  color: #555;
  font-weight: 600;
}

/* ===== BUTTONS ===== */
.btn {
  padding: 12px 30px;
  border: none;
  border-radius: 50px;
  font-family: 'Fredoka', cursive;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  text-decoration: none;
  display: inline-block;
}

.btn:hover {
  transform: scale(1.05);
  box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.btn-primary {
  background: linear-gradient(135deg, #ff6b9d, #ff4757);
  color: #fff;
}

.btn-secondary {
  background: linear-gradient(135deg, #a8e6cf, #6bcb77);
  color: #fff;
}

.btn-home {
  background: linear-gradient(135deg, #ffd93d, #ffa500);
  color: #fff;
  margin-top: 10px;
}

.btn-group {
  display: flex;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ===== CELEBRATION OVERLAY ===== */
.celebration {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
  z-index: 100;
}

.celebration.show {
  display: flex;
}

.celebration-box {
  background: #fff;
  border-radius: 25px;
  padding: 40px;
  text-align: center;
  animation: popIn 0.5s ease;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.celebration-box h2 {
  font-family: 'Bubblegum Sans', cursive;
  font-size: 2.5rem;
  color: #ff6b9d;
  margin-bottom: 10px;
}

.celebration-box p {
  font-size: 1.2rem;
  color: #555;
  margin-bottom: 20px;
}

/* ===== CONFETTI ===== */
.confetti-piece {
  position: fixed;
  width: 10px;
  height: 10px;
  top: -10px;
  z-index: 200;
  animation: confettiFall 3s ease-in forwards;
}

@keyframes confettiFall {
  0% { top: -10px; opacity: 1; }
  100% { top: 110vh; opacity: 0; }
}

/* ===== FOOTER ===== */
.site-footer {
  text-align: center;
  padding: 20px;
  color: rgba(255,255,255,0.8);
  font-size: 0.9rem;
}

/* ===== SNAKE GAME ===== */
.canvas-wrapper {
  position: relative;
  display: inline-block;
  border-radius: 15px;
  overflow: hidden;
  margin-bottom: 15px;
}

.canvas-wrapper canvas {
  display: block;
  border-radius: 15px;
  border: 3px solid #ddd;
}

.game-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 15px;
}

.overlay-content {
  text-align: center;
  color: #fff;
}

.overlay-content h3 {
  font-family: 'Bubblegum Sans', cursive;
  font-size: 2rem;
  margin-bottom: 8px;
}

.overlay-content p {
  font-size: 1rem;
  margin-bottom: 15px;
  opacity: 0.9;
}

.snake-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  margin-bottom: 15px;
}

.controls-row {
  display: flex;
  gap: 5px;
}

.control-btn {
  width: 55px;
  height: 55px;
  border: none;
  border-radius: 12px;
  background: rgba(255,255,255,0.9);
  font-size: 1.5rem;
  cursor: pointer;
  transition: transform 0.1s;
  box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}

.control-btn:active {
  transform: scale(0.9);
  background: #ffd93d;
}

/* ===== COLOR PUZZLE ===== */
.puzzle-board {
  display: grid;
  gap: 4px;
  max-width: 360px;
  margin: 0 auto 15px;
}

.puzzle-cell {
  aspect-ratio: 1;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.3s;
}

.puzzle-cell:hover:not(:disabled) {
  transform: scale(1.08);
}

.puzzle-cell.highlight {
  opacity: 0.7;
  transform: scale(1.08);
  box-shadow: 0 0 10px rgba(255,255,255,0.8);
}

.hint-text {
  font-size: 0.95rem;
  color: #888;
  margin-bottom: 15px;
  min-height: 24px;
}

/* ===== SIMON SAYS ===== */
.simon-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  max-width: 280px;
  margin: 0 auto 20px;
}

.simon-btn {
  aspect-ratio: 1;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  transition: filter 0.15s, transform 0.15s;
  opacity: 0.6;
}

.simon-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.simon-btn:disabled {
  cursor: default;
}

.simon-btn.lit {
  opacity: 1;
  transform: scale(1.05);
  box-shadow: 0 0 25px rgba(255,255,255,0.5);
}

.simon-red { background: #ff4757; }
.simon-red.lit { background: #ff6b81; }

.simon-green { background: #2ed573; }
.simon-green.lit { background: #7bed9f; }

.simon-blue { background: #1e90ff; }
.simon-blue.lit { background: #70a1ff; }

.simon-yellow { background: #ffa502; }
.simon-yellow.lit { background: #ffda79; }

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
  .site-title { font-size: 2.2rem; }
  .game-container { padding: 20px; margin: 10px; }
  .ttt-cell { font-size: 2.2rem; }
  .memory-card-front { font-size: 1.2rem; }
  .memory-card-back { font-size: 1.8rem; }
  .memory-board { gap: 6px; }
  .game-cards.grid-layout {
    grid-template-columns: 1fr;
    max-width: 350px;
  }
  .game-cards.grid-layout .game-card {
    flex-direction: row;
    text-align: left;
  }
  .game-cards.grid-layout .game-card:last-child:nth-child(odd) {
    max-width: 100%;
  }
  .simon-board { max-width: 220px; gap: 8px; }
  .puzzle-board { max-width: 280px; }
}
