/* 🌌 COOL DARK BACKGROUND */
body {
  margin: 0;
  min-height: 100vh;
  padding: 25px 16px;
  box-sizing: border-box;
  font-family: Arial, sans-serif;
  text-align: center;
  color: #f8fafc;
  background:
    radial-gradient(ellipse at top left, #312e81 0%, transparent 45%),
    radial-gradient(ellipse at bottom right, #701a75 0%, transparent 45%),
    #080b18;
  background-attachment: fixed;
}

/* 🚀 GRADIENT HEADER */
header {
  max-width: 850px;
  margin: 0 auto;
  padding: 45px 20px;
  color: white;
  border: 1px solid #818cf8;
  border-radius: 22px;
  background: linear-gradient(135deg, #4f46e5, #9333ea, #db2777);
  box-shadow: 0 0 35px #7c3aed55;
  animation: slideIn 1s ease-out;
}

header h1 {
  font-size: clamp(28px, 5vw, 48px);
  margin: 0 0 15px;
  text-shadow: 0 0 18px #ffffff66;
}

header p {
  margin: 0;
  font-size: 17px;
  line-height: 1.6;
}

/* ✨ MAIN CONTENT CARD */
main {
  box-sizing: border-box;
  width: 100%;
  max-width: 600px;
  margin: 30px auto;
  padding: 35px 24px;
  color: #e2e8f0;
  background: #151a2c;
  border: 1px solid #3730a3;
  border-radius: 22px;
  box-shadow: 0 15px 45px #00000055;
  animation: fadeIn 0.8s ease-out;
}

main h2 {
  margin-top: 0;
  color: #c4b5fd;
  font-size: 28px;
}

main p {
  line-height: 1.8;
}

/* 💜 SUPER BUTTON */
button {
  padding: 15px 26px;
  border: 1px solid #c4b5fd;
  border-radius: 12px;
  background: linear-gradient(135deg, #7c3aed, #db2777);
  color: white;
  font-size: 17px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 0 20px #9333ea55;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
  transform: scale(1.08);
  box-shadow: 0 0 30px #c084fcaa;
}

button:active {
  transform: scale(0.96);
}

button:focus-visible {
  outline: 3px solid #fde68a;
  outline-offset: 3px;
}

/* 🎉 BOUNCE ANIMATION */
button.bounce {
  animation: bounce 0.45s ease;
}

@keyframes bounce {
  0%, 100% { transform: scale(1); }
  35% { transform: scale(1.3); }
  65% { transform: scale(0.9); }
}

/* 🌠 SMOOTH APPEARANCES */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 👋 INTRO BOX */
.azlan-box {
  max-width: 500px;
  margin: 25px auto;
  padding: 25px;
  text-align: center;
  color: white;
  background: linear-gradient(135deg, #4f46e5, #9333ea, #db2777);
  border: 2px solid #c4b5fd;
  border-radius: 20px;
  box-shadow: 0 0 25px #9333eaaa;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.azlan-box:hover {
  transform: translateY(-5px);
  box-shadow: 0 0 35px #c084fc;
}

.azlan-box h2 {
  margin-top: 0;
  color: white;
}

.azlan-box p {
  margin-bottom: 0;
  font-size: 18px;
}

/* 🎮 GAME CARD */
.game-card {
  margin: 30px auto;
  padding: 22px;
  box-sizing: border-box;
  width: 100%;
  max-width: 600px;
  border: 1px solid #6366f1;
  border-radius: 20px;
  background: #0b1020;
  color: #f8fafc;
  box-shadow: 0 0 25px #6366f133;
}

.game-card h2 {
  margin-top: 0;
  color: #c4b5fd;
  text-align: center;
}

.game-stats {
  display: flex;
  justify-content: center;
  gap: 25px;
  flex-wrap: wrap;
  margin: 20px 0;
  color: #a5b4fc;
}

/* ⭐ GAME PLAYING AREA */
.game-arena {
  position: relative;
  height: 230px;
  overflow: hidden;
  box-sizing: border-box;
  border: 1px solid #4f46e5;
  border-radius: 14px;
  background:
    radial-gradient(circle at 20% 20%, #312e8155, transparent 40%),
    #11152a;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

#gameHint {
  margin: 0;
  color: #cbd5e1;
  text-align: center;
  padding: 0 8px;
}

#gameResult {
  text-align: center;
  color: #c4b5fd;
  font-weight: bold;
  overflow-wrap: anywhere;
}

/* 🍪 THE MOVING COOKIE */
#starTarget.game-star {
  position: absolute;
  z-index: 2;
  padding: 8px;
  border: 1px solid #d6a15f;
  border-radius: 50%;
  background: #5b3a1e;
  font-size: 27px;
  line-height: 1.2;
  box-shadow: 0 0 20px #f59e0baa;
  cursor: pointer;
  touch-action: manipulation;
}

#starTarget.game-star:hover {
  background: #7a4e28;
  box-shadow: 0 0 28px #f59e0b;
}

/* 😋 MUNCHING ANIMATION */
.cookie-ghost {
  position: absolute;
  z-index: 3;
  box-sizing: content-box;
  padding: 8px;
  border: 1px solid #d6a15f;
  border-radius: 50%;
  background: #5b3a1e;
  font-size: 27px;
  line-height: 1.2;
  pointer-events: none;
  animation: munch 0.5s ease-in forwards;
}

@keyframes munch {
  0%   { transform: scale(1, 1) rotate(0); opacity: 1; }
  15%  { transform: scale(1.25, 0.7) rotate(-8deg); }
  30%  { transform: scale(0.85, 1.15) rotate(6deg); }
  45%  { transform: scale(1.2, 0.75) rotate(-6deg); }
  65%  { transform: scale(0.7, 0.8) rotate(4deg); opacity: 1; }
  100% { transform: scale(0, 0) rotate(0); opacity: 0; }
}

.cookie-crumb {
  position: absolute;
  z-index: 3;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: #c68642;
  pointer-events: none;
  animation: crumb 0.6s ease-out forwards;
}

@keyframes crumb {
  from { transform: translate(0, 0) scale(1); opacity: 1; }
  to   { transform: translate(var(--dx), var(--dy)) scale(0.4); opacity: 0; }
}

.cookie-nom {
  position: absolute;
  z-index: 4;
  transform: translateX(-50%);
  color: #fde68a;
  font-size: 15px;
  font-weight: bold;
  pointer-events: none;
  animation: nom 0.7s ease-out forwards;
}

@keyframes nom {
  from { transform: translate(-50%, 0); opacity: 1; }
  to   { transform: translate(-50%, -28px); opacity: 0; }
}

/* Keep hidden game pieces hidden even though buttons set display */
#gameArena [hidden] {
  display: none !important;
}

/* 🏅 LEADERBOARD */
.score-form {
  margin: 20px 0;
  color: #cbd5e1;
}

.score-form-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.score-form input {
  flex: 1 1 160px;
  max-width: 260px;
  padding: 12px 14px;
  border: 1px solid #6366f1;
  border-radius: 12px;
  background: #11152a;
  color: #f8fafc;
  font-size: 16px;
}

.score-form input:focus-visible {
  outline: 3px solid #fde68a;
  outline-offset: 2px;
}

.score-form button {
  padding: 12px 20px;
  font-size: 16px;
}

.score-form button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.leaderboard {
  margin-top: 25px;
  padding-top: 20px;
  border-top: 1px solid #312e81;
}

.leaderboard h3 {
  margin: 0 0 10px;
  color: #c4b5fd;
}

.leaderboard-status {
  margin: 0 0 10px;
  color: #a5b4fc;
  font-size: 14px;
}

.leaderboard ol {
  max-width: 340px;
  margin: 0 auto;
  padding-left: 28px;
  text-align: left;
  color: #e2e8f0;
}

.leaderboard li {
  padding: 6px 0;
}

.leaderboard li::marker {
  color: #a5b4fc;
  font-weight: bold;
}

.leaderboard li span {
  display: inline-block;
  max-width: 70%;
  overflow-wrap: anywhere;
  vertical-align: top;
}

.leaderboard li strong {
  float: right;
  color: #fde68a;
}

/* 🕴️ STICK MAN */
.stickman {
  --x: 12px;
  --y: calc(100dvh - 72px);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10;
  padding: 6px 8px;
  border: none;
  border-radius: 12px;
  background: transparent;
  box-shadow: none;
  color: #e2e8f0;
  line-height: 0;
  transform: translate(var(--x), var(--y));
  transition: transform 0.7s cubic-bezier(0.3, 1.3, 0.5, 1);
}

/* Override the global button hover/active so he doesn't jump out of his corner */
.stickman:hover,
.stickman:active {
  transform: translate(var(--x), var(--y));
  box-shadow: none;
  color: #fde68a;
}

.stickman svg.hop {
  animation: hop 0.7s ease-in-out;
}

/* Two bouncy hops with a little tilt while he runs to the next corner */
@keyframes hop {
  0%, 100% { transform: translateY(0) rotate(0); }
  20% { transform: translateY(-18px) rotate(-12deg); }
  40% { transform: translateY(0) rotate(8deg); }
  60% { transform: translateY(-18px) rotate(12deg); }
  80% { transform: translateY(0) rotate(-6deg); }
}

/* 📝 FOOTER */
footer {
  padding: 20px;
  color: #a5b4fc;
  font-size: 14px;
}

footer p {
  margin: 0 0 8px;
}

footer a {
  color: #c4b5fd;
}

/* 📱 SMALL SCREENS */
@media (max-width: 480px) {
  header {
    padding: 32px 16px;
  }

  main {
    padding: 28px 18px;
  }

  .game-card {
    padding: 14px;
  }

  .game-stats {
    gap: 12px;
  }
}

/* ♿ Respect reduced-motion settings */
@media (prefers-reduced-motion: reduce) {
  header, main {
    animation: none;
  }

  button,
  .azlan-box {
    transition: none;
  }

}
