/* ── Variables ─────────────────────────────────────────────── */
:root {
  --sky:    #67e0f5;
  --sun:    #ffd93d;
  --grass:  #6bcb77;
  --coral:  #ff6b6b;
  --purple: #a855f7;
  --card-radius: 2rem;
  --shadow: 0 8px 0px rgba(0,0,0,0.18);
  --shadow-hover: 0 4px 0px rgba(0,0,0,0.18);
}

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow-x: hidden;
  font-family: 'Nunito', sans-serif;
  background: var(--sky);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background:
    radial-gradient(ellipse 80% 40% at 50% 0%, #fff8c9 0%, transparent 70%),
    linear-gradient(180deg, #93e4f5 0%, #67e0f5 40%, #b8f5c8 100%);
}

/* ── Clouds (decorative) ───────────────────────────────────── */
body::before, body::after {
  content: '☁️';
  font-size: 5rem;
  position: fixed;
  top: 1rem;
  opacity: 0.55;
  animation: drift 20s linear infinite;
  pointer-events: none;
  z-index: 0;
}
body::before { left: -6rem; animation-duration: 28s; }
body::after  { left: -10rem; animation-duration: 20s; animation-delay: -9s; top: 3.5rem; font-size: 3rem; }

@keyframes drift {
  from { transform: translateX(-8rem); }
  to   { transform: translateX(110vw); }
}

/* ── Update Overlay ────────────────────────────────────────── */
#update-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(30, 20, 60, 0.88);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
}
#update-overlay.hidden { display: none; }

.update-box {
  background: #fff;
  border-radius: 2.5rem;
  padding: 3rem 4rem;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  max-width: 480px;
  width: 90%;
}
.update-rocket {
  font-size: 5rem;
  animation: bounce 0.7s ease-in-out infinite alternate;
}
.update-box h2 {
  font-family: 'Baloo 2', cursive;
  font-size: 2rem;
  color: var(--purple);
  margin: 1rem 0 0.5rem;
}
.update-box p { color: #555; font-size: 1.1rem; }

.dots { display: flex; justify-content: center; gap: 0.6rem; margin-top: 1.5rem; }
.dots span {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--purple);
  animation: pulse 1.2s ease-in-out infinite;
}
.dots span:nth-child(2) { animation-delay: 0.2s; background: var(--coral); }
.dots span:nth-child(3) { animation-delay: 0.4s; background: var(--grass); }

@keyframes pulse {
  0%, 100% { transform: scale(0.7); opacity: 0.5; }
  50%       { transform: scale(1.2); opacity: 1; }
}
@keyframes bounce {
  from { transform: translateY(0); }
  to   { transform: translateY(-18px) rotate(10deg); }
}

/* ── Header ────────────────────────────────────────────────── */
header {
  position: relative; z-index: 2;
  padding: 1.2rem 1.5rem 0.8rem;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1100px;
  margin: 0 auto;
}
.logo {
  font-family: 'Baloo 2', cursive;
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 3px 0 rgba(0,0,0,0.15), 0 6px 20px rgba(0,0,0,0.1);
  letter-spacing: -0.5px;
}
.stars {
  font-size: clamp(1.4rem, 4vw, 2rem);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

/* ── Main ──────────────────────────────────────────────────── */
main {
  flex: 1;
  position: relative; z-index: 2;
  padding: 1rem 1.5rem 2rem;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.welcome h1 {
  font-family: 'Baloo 2', cursive;
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  font-weight: 600;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.12);
  margin-bottom: 1.5rem;
  text-align: center;
}

/* ── Game Grid ─────────────────────────────────────────────── */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.5rem;
}

.loading-games {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 1.4rem;
  color: #fff;
  padding: 3rem;
  font-family: 'Baloo 2', cursive;
}

/* ── Game Card ─────────────────────────────────────────────── */
.game-card {
  border-radius: var(--card-radius);
  padding: 2rem 1.5rem 1.8rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  border: none;
  text-decoration: none;
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.game-card::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.25) 0%, transparent 60%);
  border-radius: inherit;
  pointer-events: none;
}

.game-card:active {
  transform: translateY(4px) scale(0.97);
  box-shadow: var(--shadow-hover);
}

/* Colour palette cycles for cards */
.game-card:nth-child(4n+1) { background: linear-gradient(145deg, #ff6b6b, #ee5a24); }
.game-card:nth-child(4n+2) { background: linear-gradient(145deg, #ffd93d, #f9a825); }
.game-card:nth-child(4n+3) { background: linear-gradient(145deg, #6bcb77, #27ae60); }
.game-card:nth-child(4n+4) { background: linear-gradient(145deg, #a855f7, #7c3aed); }

.game-card .game-emoji {
  font-size: clamp(3.5rem, 8vw, 5rem);
  line-height: 1;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
  transition: transform 0.2s ease;
}
.game-card:hover .game-emoji { transform: scale(1.15) rotate(-5deg); }

.game-card .game-name {
  font-family: 'Baloo 2', cursive;
  font-size: clamp(1.3rem, 3.5vw, 1.8rem);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0,0,0,0.2);
  text-align: center;
}

.game-card .game-desc {
  font-size: clamp(0.85rem, 2.2vw, 1rem);
  color: rgba(255,255,255,0.88);
  text-align: center;
  line-height: 1.4;
}

.game-card .play-btn {
  margin-top: 0.5rem;
  background: rgba(255,255,255,0.3);
  border: 2px solid rgba(255,255,255,0.6);
  border-radius: 999px;
  padding: 0.5rem 1.8rem;
  color: #fff;
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  pointer-events: none;
}

/* ── Footer ────────────────────────────────────────────────── */
footer {
  position: relative; z-index: 2;
  text-align: center;
  padding: 1rem;
  color: rgba(255,255,255,0.7);
  font-size: 0.85rem;
}

/* ── Tablet & Large screen tweaks ──────────────────────────── */
@media (min-width: 768px) {
  .game-grid { gap: 2rem; }
  .game-card { padding: 2.5rem 2rem 2rem; }
}

@media (min-width: 1024px) {
  .game-grid { grid-template-columns: repeat(3, 1fr); }
}
