/* =========================================================
   HELP THE RABBIT FIND THE CARROT!
   Fun, Colorful & Interactive Maze Game for Grade 2 Students
   ========================================================= */

/* --- Reset & Base Variables --- */
:root {
  --bg-gradient-top: #64b5f6;
  --bg-gradient-bottom: #a5d6a7;
  --card-bg: #ffffff;
  --text-dark: #2c3e50;
  --text-muted: #546e7a;
  
  /* Hedge & Garden Colors */
  --wall-color: #2e7d32;
  --wall-light: #43a047;
  --wall-shadow: #1b5e20;
  --path-color: #fff9e6;
  --path-border: #ffe8b3;
  --trail-color: #e8f5e9;

  /* Accent Colors */
  --color-orange: #ff7043;
  --color-orange-dark: #e64a19;
  --color-yellow: #ffca28;
  --color-yellow-dark: #f57f17;
  --color-green: #66bb6a;
  --color-green-dark: #388e3c;
  --color-blue: #42a5f5;
  --color-blue-dark: #1976d2;
  --color-purple: #ab47bc;

  /* Typography */
  --font-main: 'Fredoka', 'Nunito', 'Comic Sans MS', cursive, sans-serif;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 50px;
  --shadow-card: 0 10px 25px rgba(0, 0, 0, 0.12), 0 4px 10px rgba(0, 0, 0, 0.08);
  --shadow-btn: 0 5px 0 rgba(0, 0, 0, 0.18);
  --shadow-btn-pressed: 0 1px 0 rgba(0, 0, 0, 0.18);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  box-sizing: border-box;
}

body {
  font-family: var(--font-main);
  background: 
    radial-gradient(circle at 10% 12%, rgba(255, 255, 255, 0.45) 0%, transparent 20%),
    radial-gradient(circle at 92% 10%, rgba(254, 240, 138, 0.5) 0%, transparent 25%),
    radial-gradient(circle at 50% 100%, rgba(134, 239, 172, 0.4) 0%, transparent 40%),
    linear-gradient(180deg, 
      #38bdf8 0%, 
      #60a5fa 18%, 
      #93c5fd 35%, 
      #fef08a 62%, 
      #fed7aa 78%, 
      #86efac 92%, 
      #4ade80 100%
    );
  background-attachment: fixed;
  color: var(--text-dark);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 6px;
  position: relative;
}

/* --- Child-Friendly Colourful Scenery Background --- */
.kids-scenery-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.scenery-item {
  position: absolute;
  pointer-events: none;
  user-select: none;
}

/* Sun */
.sun-container {
  top: 10px;
  right: 18px;
  animation: floatSun 6s ease-in-out infinite alternate;
}

.sun-rays-group {
  transform-origin: 80px 80px;
  animation: spinRays 28s linear infinite;
}

@keyframes spinRays {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes floatSun {
  0% { transform: translateY(0px) scale(1); }
  100% { transform: translateY(8px) scale(1.03); }
}

/* Rainbow */
.rainbow-container {
  top: 8px;
  left: -15px;
  opacity: 0.96;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.1));
  animation: gentlePulseRainbow 8s ease-in-out infinite alternate;
}

@keyframes gentlePulseRainbow {
  0% { transform: scale(1) rotate(0deg); }
  100% { transform: scale(1.02) rotate(1deg); }
}

/* Floating Clouds */
.cloud-1 {
  top: 7%;
  left: -140px;
  animation: driftCloud 32s linear infinite;
}

.cloud-2 {
  top: 20%;
  left: -170px;
  animation: driftCloud 44s linear infinite 14s;
  opacity: 0.92;
}

.cloud-3 {
  top: 45%;
  left: -120px;
  animation: driftCloud 38s linear infinite 7s;
  opacity: 0.88;
}

@keyframes driftCloud {
  0% { transform: translateX(0); }
  100% { transform: translateX(calc(100vw + 250px)); }
}

/* Floating Balloons */
.balloon-left {
  top: 25%;
  left: 14px;
  animation: bobBalloon 5s ease-in-out infinite alternate;
}

.balloon-right {
  top: 30%;
  right: 18px;
  animation: bobBalloon 6s ease-in-out infinite alternate 1.5s;
}

@keyframes bobBalloon {
  0% { transform: translateY(0) rotate(-3deg); }
  100% { transform: translateY(-16px) rotate(4deg); }
}

/* Butterflies */
.butterfly-1 {
  top: 18%;
  left: 20%;
  animation: flutterPath1 18s ease-in-out infinite;
}

.butterfly-2 {
  top: 38%;
  right: 16%;
  animation: flutterPath2 22s ease-in-out infinite;
}

.butterfly .wing-left {
  transform-origin: 25px 20px;
  animation: flapWingLeft 0.35s ease-in-out infinite alternate;
}

.butterfly .wing-right {
  transform-origin: 25px 20px;
  animation: flapWingRight 0.35s ease-in-out infinite alternate;
}

@keyframes flapWingLeft {
  0% { transform: scaleX(1); }
  100% { transform: scaleX(0.28); }
}

@keyframes flapWingRight {
  0% { transform: scaleX(1); }
  100% { transform: scaleX(0.28); }
}

@keyframes flutterPath1 {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(30px, -25px) rotate(10deg); }
  50% { transform: translate(60px, 10px) rotate(-8deg); }
  75% { transform: translate(20px, 30px) rotate(12deg); }
}

@keyframes flutterPath2 {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  30% { transform: translate(-35px, -20px) rotate(-12deg); }
  60% { transform: translate(-60px, 15px) rotate(8deg); }
  85% { transform: translate(-20px, -10px) rotate(-6deg); }
}

/* Sparkles & Stars */
.sparkle {
  font-size: 1.6rem;
  animation: twinkleStar 3s ease-in-out infinite alternate;
}

.sparkle-1 { top: 10%; left: 30%; animation-delay: 0.2s; }
.sparkle-2 { top: 14%; right: 16%; font-size: 2rem; animation-delay: 0.9s; }
.sparkle-3 { top: 35%; left: 8%; font-size: 1.4rem; animation-delay: 1.6s; }
.sparkle-4 { top: 52%; right: 7%; font-size: 1.8rem; animation-delay: 2.3s; }

@keyframes twinkleStar {
  0% { transform: scale(0.7) rotate(0deg); opacity: 0.5; }
  100% { transform: scale(1.25) rotate(25deg); opacity: 1; }
}

/* Rolling Garden Hills at Viewport Bottom */
.garden-hills {
  bottom: 0;
  left: 0;
  width: 100vw;
  height: 120px;
  z-index: 1;
}

.hills-svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* --- Main Layout Wrapper --- */
.game-wrapper {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16), 0 4px 12px rgba(0, 0, 0, 0.08);
  border: 3px solid #ffffff;
  width: min(1140px, 96vw);
  height: min(94vh, 740px);
  max-height: calc(100vh - 16px);
  padding: 10px 20px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  position: relative;
  z-index: 10;
  box-sizing: border-box;
  overflow: hidden;
}

/* --- Header Section --- */
.game-header {
  text-align: center;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
}

.title-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.bouncing-icon {
  font-size: 1.65rem;
  display: inline-block;
}

.rabbit-icon {
  animation: hopSide 2s ease-in-out infinite;
}

.carrot-icon {
  animation: wiggle 2.2s ease-in-out infinite;
}

@keyframes hopSide {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  30% { transform: translateY(-8px) rotate(-8deg); }
  50% { transform: translateY(0) rotate(0deg); }
  70% { transform: translateY(-5px) rotate(6deg); }
}

@keyframes wiggle {
  0%, 100% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(-10deg) scale(1.06); }
  75% { transform: rotate(10deg) scale(1.06); }
}

.game-title {
  font-size: 1.65rem;
  font-weight: 800;
  color: #d84315;
  text-shadow: 1.5px 1.5px 0px #ffe082;
  letter-spacing: 0.4px;
  margin: 0;
  line-height: 1.15;
}

.game-subtitle {
  font-size: 0.88rem;
  font-weight: 600;
  color: #2e7d32;
  margin-top: 1px;
}

/* --- Main Game Layout Area (Sidebar + Large Maze Puzzle) --- */
.game-layout-body {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 20px;
  width: 100%;
  flex: 1;
  min-height: 0;
  box-sizing: border-box;
}

/* Left Sidebar for Controls & Stats */
.game-sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 320px;
  max-width: 340px;
  flex-shrink: 0;
  justify-content: center;
  box-sizing: border-box;
}

/* --- Control Panel (Difficulty & Buttons) --- */
.control-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  background: #f1f8e9;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  border: 1.5px solid #c8e6c9;
  box-sizing: border-box;
}

.difficulty-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.panel-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #37474f;
}

.difficulty-buttons {
  display: flex;
  gap: 6px;
  width: 100%;
}

.level-btn {
  font-family: var(--font-main);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 5px 8px;
  flex: 1;
  border-radius: var(--radius-pill);
  border: 1.5px solid #cfd8dc;
  background: #ffffff;
  color: #546e7a;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 0 rgba(0,0,0,0.06);
}

.level-btn:hover {
  transform: translateY(-1px);
  border-color: #90a4ae;
}

.level-btn.active {
  background: #2e7d32;
  color: #ffffff;
  border-color: #1b5e20;
  box-shadow: 0 2px 0 #1b5e20;
}

.level-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot-green { background: #4caf50; }
.dot-yellow { background: #fbc02d; }
.dot-red { background: #e53935; }

.action-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  width: 100%;
}

.action-btn {
  font-family: var(--font-main);
  font-size: 0.86rem;
  font-weight: 700;
  padding: 7px 10px;
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-btn);
}

.action-btn:active {
  transform: translateY(3px);
  box-shadow: var(--shadow-btn-pressed);
}

.btn-start {
  background: #ff7043;
  color: #ffffff;
  box-shadow: 0 5px 0 #d84315;
}

.btn-start:hover {
  background: #ff5722;
}

.btn-start:active {
  box-shadow: 0 1px 0 #d84315;
}

.btn-restart {
  background: #26a69a;
  color: #ffffff;
  box-shadow: 0 5px 0 #00796b;
}

.btn-restart:hover {
  background: #00897b;
}

.btn-restart:active {
  box-shadow: 0 1px 0 #00796b;
}

.btn-pause {
  background: #ab47bc;
  color: #ffffff;
  box-shadow: 0 5px 0 #7b1fa2;
}

.btn-pause:hover {
  background: #9c27b0;
}

.btn-pause:active {
  box-shadow: 0 1px 0 #7b1fa2;
}

.btn-pause.is-paused {
  background: #ff9800;
  box-shadow: 0 5px 0 #e65100;
  animation: pulsePause 1.2s infinite alternate;
}

@keyframes pulsePause {
  0% { transform: scale(1); }
  100% { transform: scale(1.05); }
}

.btn-sound {
  background: #7e57c2;
  color: #ffffff;
  box-shadow: 0 5px 0 #512da8;
  font-size: 0.85rem;
  padding: 8px 12px;
}

.btn-sound:hover {
  background: #673ab7;
}

.btn-sound:active {
  box-shadow: 0 1px 0 #512da8;
}

.btn-sound.muted {
  background: #9e9e9e;
  box-shadow: 0 5px 0 #616161;
}

/* --- Stats Dashboard --- */
.stats-dashboard {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}

.stat-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 2px solid #e0e0e0;
  box-shadow: 0 3px 0 rgba(0,0,0,0.04);
}

.time-card {
  border-color: #90caf9;
  background: #e3f2fd;
}

.time-card .stat-value {
  color: #1565c0;
}

.stat-value.time-low {
  color: #d32f2f !important;
  animation: pulseTimeLow 0.8s infinite alternate;
}

@keyframes pulseTimeLow {
  0% { transform: scale(1); }
  100% { transform: scale(1.15); }
}

.score-card {
  grid-column: span 2;
  border-color: #ffe082;
  background: #fffde7;
  justify-content: center;
}

.moves-card {
  border-color: #b2dfdb;
  background: #e0f2f1;
}

.level-card {
  border-color: #c8e6c9;
  background: #f1f8e9;
}

.stat-icon {
  font-size: 1.45rem;
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: #78909c;
  line-height: 1;
}

.stat-value {
  font-size: 1.3rem;
  font-weight: 900;
  color: #263238;
  line-height: 1.1;
  margin-top: 1px;
}

.score-card .stat-value {
  color: #e65100;
}

.highscore-card .stat-value {
  color: #f57f17;
}

.moves-card .stat-value {
  color: #00695c;
}

.level-card .stat-value {
  color: #2e7d32;
}

/* --- Maze Board Container --- */
.maze-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
  height: 100%;
  min-height: 0;
}

.maze-frame {
  position: relative;
  background: #795548;
  padding: 8px;
  border-radius: var(--radius-lg);
  box-shadow: inset 0 3px 6px rgba(0,0,0,0.3), 0 8px 18px rgba(0,0,0,0.18);
  border: 4px solid #5d4037;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  max-height: 100%;
}

.maze-board {
  display: grid;
  background: #f7ede2;
  gap: 3px;
  padding: 4px;
  border-radius: var(--radius-md);
  width: min(70vh, 530px, 50vw);
  height: min(70vh, 530px, 50vw);
  aspect-ratio: 1 / 1;
  box-sizing: border-box;
}

/* Maze Cells */
.cell {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 4px;
  overflow: visible;
  transition: background-color 0.15s ease;
}

/* Wall cell: lush, attractive garden hedge with 3D depth and leaf textures */
.cell.wall {
  background: linear-gradient(145deg, #2e7d32 0%, #1b5e20 100%);
  border: 1.5px solid #0e3d12;
  box-shadow: inset 0 2px 2px rgba(255, 255, 255, 0.3), inset 0 -2px 3px rgba(0, 0, 0, 0.45), 0 2px 4px rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}

/* Subtle leafy texture icon for walls */
.cell.wall::after {
  content: "🌿";
  font-size: 0.75rem;
  opacity: 0.45;
  pointer-events: none;
}

/* Responsive scaling per difficulty */
.maze-board.level-easy .cell.wall::after {
  font-size: 0.85rem;
}

.maze-board.level-medium .cell.wall::after {
  font-size: 0.6rem;
}

.maze-board.level-hard .cell.wall::after {
  font-size: 0.45rem;
}

/* Path cell: bright, sunny, clean garden walkway with high contrast against walls */
.cell.path {
  background-color: #fffde7;
  border: 1px solid #ffe082;
  box-shadow: inset 0 1px 2px rgba(255, 236, 179, 0.5);
  border-radius: 4px;
}

/* Travelled Footprints: Cute rabbit paw prints */
.rabbit-footprint {
  position: absolute;
  width: 44%;
  height: 44%;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  z-index: 2;
  animation: footprintPopIn 0.25s ease-out;
}

@keyframes footprintPopIn {
  0% { transform: scale(0.3); opacity: 0; }
  100% { transform: scale(1); opacity: 0.88; }
}

.footprint-svg {
  filter: drop-shadow(0 1px 1px rgba(27, 94, 32, 0.35));
}

/* Start & Goal marker highlights */
.cell.start-cell {
  background: radial-gradient(circle, #f1f8e9 30%, #c8e6c9 100%);
  border: 2px solid #4caf50;
  box-shadow: inset 0 0 6px rgba(76, 175, 80, 0.35);
}

.cell.goal-cell {
  background: radial-gradient(circle, #fff8e1 25%, #ffe082 100%);
  border: 2px dashed #ff9800;
  box-shadow: 0 0 14px rgba(255, 152, 0, 0.55), inset 0 0 6px rgba(255, 183, 77, 0.4);
  animation: goalCellGlow 2.5s ease-in-out infinite alternate;
}

@keyframes goalCellGlow {
  0% { box-shadow: 0 0 8px rgba(255, 152, 0, 0.4), inset 0 0 4px rgba(255, 183, 77, 0.3); }
  100% { box-shadow: 0 0 18px rgba(255, 152, 0, 0.8), inset 0 0 8px rgba(255, 183, 77, 0.6); }
}

/* Full-Body Rabbit Character Element */
.rabbit-character {
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 94%;
  height: 94%;
  z-index: 10;
  transition: transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.28));
}

.rabbit-character svg {
  width: 100%;
  height: 100%;
  display: block;
}

.rabbit-character.facing-left {
  transform: scaleX(-1);
}

.rabbit-character.hop-anim {
  animation: bunnyHop 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes bunnyHop {
  0% { transform: translateY(0) scale(1, 1); }
  50% { transform: translateY(-20%) scale(1.08, 0.94); }
  100% { transform: translateY(0) scale(1, 1); }
}

.rabbit-character.facing-left.hop-anim {
  animation: bunnyHopLeft 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes bunnyHopLeft {
  0% { transform: scaleX(-1) translateY(0) scale(1, 1); }
  50% { transform: scaleX(-1) translateY(-20%) scale(1.08, 0.94); }
  100% { transform: scaleX(-1) translateY(0) scale(1, 1); }
}

/* Wall bump wiggle animation */
.cell.bumped {
  animation: wallShake 0.25s ease;
}

@keyframes wallShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px) rotate(-3deg); }
  75% { transform: translateX(4px) rotate(3deg); }
}

/* Complete Carrot Item */
.carrot-item {
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 92%;
  height: 92%;
  z-index: 5;
  animation: carrotPulse 1.8s ease-in-out infinite;
  filter: drop-shadow(0 2px 4px rgba(255, 112, 67, 0.45));
  pointer-events: none;
}

.carrot-item svg {
  width: 100%;
  height: 100%;
  display: block;
}

@keyframes carrotPulse {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.15) rotate(6deg); }
}

/* Rabbit Eating Carrot Animation */
.rabbit-character.rabbit-nibbling {
  animation: rabbitNibbleMunch 0.22s infinite alternate ease-in-out;
}

@keyframes rabbitNibbleMunch {
  0% { transform: scale(1, 1) translateY(0); }
  50% { transform: scale(1.08, 0.92) translateY(-3px) rotate(-3deg); }
  100% { transform: scale(0.96, 1.04) translateY(1px) rotate(3deg); }
}

.rabbit-character.facing-left.rabbit-nibbling {
  animation: rabbitNibbleMunchLeft 0.22s infinite alternate ease-in-out;
}

@keyframes rabbitNibbleMunchLeft {
  0% { transform: scaleX(-1) scale(1, 1) translateY(0); }
  50% { transform: scaleX(-1) scale(1.08, 0.92) translateY(-3px) rotate(-3deg); }
  100% { transform: scaleX(-1) scale(0.96, 1.04) translateY(1px) rotate(3deg); }
}

.carrot-item.carrot-shrinking {
  animation: carrotCrunchShrink 1.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes carrotCrunchShrink {
  0% { transform: scale(1) rotate(0deg); opacity: 1; }
  25% { transform: scale(0.75) rotate(-10deg); opacity: 0.9; }
  50% { transform: scale(0.5) rotate(10deg); opacity: 0.8; }
  75% { transform: scale(0.25) rotate(-6deg); opacity: 0.6; }
  100% { transform: scale(0) rotate(20deg); opacity: 0; }
}

/* Floating eating sparkles/stars/hearts */
.eating-sparkle {
  position: absolute;
  font-size: 1.25rem;
  pointer-events: none;
  z-index: 20;
  animation: floatEatingSparkle 1.1s ease-out forwards;
  animation-delay: var(--delay, 0s);
}

@keyframes floatEatingSparkle {
  0% { transform: translate(0, 0) scale(0.4); opacity: 0; }
  30% { transform: translate(calc(var(--x-offset) * 0.5), calc(var(--y-offset) * 0.5)) scale(1.3); opacity: 1; }
  100% { transform: translate(var(--x-offset), var(--y-offset)) scale(0.7); opacity: 0; }
}

/* Score Pop Floating Indicator */
.score-card {
  position: relative;
  overflow: visible;
}

.score-pop {
  position: absolute;
  top: -12px;
  right: 8px;
  font-size: 1.25rem;
  font-weight: 900;
  pointer-events: none;
  z-index: 20;
  text-shadow: 0 1px 2px rgba(255,255,255,0.8);
  animation: floatScorePop 0.75s ease-out forwards;
}

@keyframes floatScorePop {
  0% { transform: translateY(0) scale(0.8); opacity: 1; }
  50% { transform: translateY(-16px) scale(1.25); opacity: 0.95; }
  100% { transform: translateY(-28px) scale(1.35); opacity: 0; }
}

/* --- Start Overlay --- */
.game-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(46, 125, 50, 0.9);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 20;
  border-radius: var(--radius-sm);
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.game-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.overlay-content {
  text-align: center;
  color: #ffffff;
  padding: 12px;
  max-width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.overlay-content h2 {
  font-size: 1.25rem;
  color: #fff9c4;
  text-shadow: 1.5px 1.5px 0px #1b5e20;
  margin: 0;
}

.overlay-content p {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.3;
  margin: 0;
}

.large-emoji {
  font-size: 2.2rem;
  animation: bounce 1.4s ease infinite;
}

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

.pulse-btn {
  font-size: 0.95rem;
  padding: 8px 20px;
  animation: pulseGlow 1.6s infinite;
}

@keyframes pulseGlow {
  0%, 100% { transform: scale(1); box-shadow: 0 5px 0 #d84315, 0 0 0 rgba(255, 112, 67, 0.4); }
  50% { transform: scale(1.05); box-shadow: 0 5px 0 #d84315, 0 0 16px rgba(255, 112, 67, 0.8); }
}

/* --- On-Screen D-Pad (Child & Touch Friendly) --- */
.dpad-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.dpad-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #78909c;
}

.dpad-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.dpad-row {
  display: flex;
  gap: 10px;
}

.dpad-btn {
  width: 52px;
  height: 48px;
  font-size: 1.4rem;
  border: none;
  border-radius: var(--radius-md);
  background: #ffffff;
  color: #37474f;
  box-shadow: 0 4px 0 #cfd8dc, 0 2px 6px rgba(0,0,0,0.1);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.1s ease;
}

.dpad-btn:hover {
  background: #f1f8e9;
}

.dpad-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #cfd8dc;
  background: #c8e6c9;
}

/* --- Win Modal Popup --- */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 16px;
  transition: opacity 0.3s ease;
}

.modal-backdrop.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  border: 4px solid #ffb300;
  box-shadow: 0 15px 35px rgba(0,0,0,0.25), 0 0 30px rgba(255, 179, 0, 0.4);
  padding: 18px 22px;
  max-width: 420px;
  width: 90%;
  max-height: 92vh;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: popIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
}

@keyframes popIn {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.trophy-bounce {
  font-size: 2.8rem;
  display: inline-block;
  animation: bounce 1.2s infinite;
}

.win-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: #2e7d32;
  line-height: 1.25;
  margin: 0;
}

.win-subtitle {
  font-size: 0.85rem;
  font-weight: 600;
  color: #607d8b;
  margin: 0;
}

.win-rewards {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: center;
  width: 100%;
  margin: 2px 0;
  max-height: 52vh;
  overflow-y: auto;
  padding: 2px;
}

.reward-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 92%;
  padding: 5px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.9rem;
  font-weight: 800;
  box-sizing: border-box;
  flex-shrink: 0;
}

.final-score-row {
  background: #fff8e1;
  border: 2px solid #ffb300;
  color: #e65100;
  box-shadow: 0 3px 8px rgba(255, 179, 0, 0.25);
  font-size: 1.05rem;
}

.final-score-row .reward-val {
  font-size: 1.3rem;
  color: #d84315;
}

.carrot-score-row {
  background: #fff3e0;
  border: 2px solid #ff9800;
  color: #e65100;
}

.carrot-score-row .reward-val {
  font-size: 1.1rem;
  color: #ef6c00;
}

.time-bonus-row {
  background: #e8f5e9;
  border: 2px solid #66bb6a;
  color: #2e7d32;
}

.time-bonus-row .reward-val {
  font-size: 1.1rem;
  color: #1b5e20;
}

.moves-bonus-row {
  background: #ede7f6;
  border: 2px solid #ab47bc;
  color: #6a1b9a;
}

.moves-bonus-row .reward-val {
  font-size: 1.1rem;
  color: #4a148c;
}

.bonus-disabled {
  opacity: 0.55;
  background: #f5f5f5;
  border-color: #cfd8dc;
  color: #78909c;
}

.bonus-disabled .reward-val {
  color: #90a4ae;
}

.moves-row {
  background: #e0f2f1;
  border: 2px solid #80cbc4;
  color: #00695c;
}

.moves-row .reward-val {
  font-size: 1.1rem;
  color: #004d40;
}

.wall-penalty-row {
  background: #ffebee;
  border: 2px solid #ef5350;
  color: #c62828;
}

.wall-penalty-row .reward-val {
  font-size: 1.1rem;
  color: #b71c1c;
}

.time-row {
  background: #e1f5fe;
  border: 2px solid #81d4fa;
  color: #0277bd;
}

.time-row .reward-val {
  font-size: 1.05rem;
  color: #01579b;
}

.scoring-rules-badge {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: rgba(255, 255, 255, 0.18);
  border: 1.5px dashed #fff9c4;
  border-radius: var(--radius-md);
  padding: 8px 14px;
  margin: 4px 0 6px 0;
  font-size: 0.85rem;
  color: #ffffff;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.35);
}

.scoring-rules-badge span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* --- Game Footer: Creator Credit (Bottom-Right Corner) --- */
.footer-container {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  width: 100%;
  margin-top: auto;
  padding-top: 2px;
  flex-shrink: 0;
  z-index: 5;
}

.game-footer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 2px solid #ff9800;
  border-radius: var(--radius-pill);
  padding: 5px 20px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(255, 152, 0, 0.22);
  user-select: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.game-footer:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.12), 0 2px 5px rgba(255, 152, 0, 0.35);
}

.footer-text {
  font-family: 'Nunito', 'Fredoka', sans-serif;
  font-size: 1.02rem;
  font-weight: 800;
  color: #1d4ed8;
  letter-spacing: 0.3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1.2;
}

.footer-creator {
  font-weight: 900;
  color: #d81b60;
  letter-spacing: 0.4px;
}

.timeup-card {
  border-color: #ef5350;
  box-shadow: 0 15px 35px rgba(0,0,0,0.25), 0 0 30px rgba(239, 83, 80, 0.35);
}

.timeup-title {
  color: #d32f2f;
}

.modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
  margin-top: 4px;
}

/* Fullscreen Confetti Canvas */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 99;
}

/* --- Responsive Adjustments --- */
@media (max-width: 860px) {
  .game-wrapper {
    width: min(640px, 98vw);
    height: 98vh;
    padding: 8px 12px;
    justify-content: space-between;
  }

  .game-title {
    font-size: 1.35rem;
  }

  .game-layout-body {
    flex-direction: column;
    gap: 6px;
  }

  .game-sidebar {
    width: 100%;
    max-width: 100%;
    gap: 6px;
  }

  .control-panel {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    gap: 6px;
  }

  .difficulty-group {
    flex-direction: row;
    align-items: center;
    gap: 4px;
  }

  .difficulty-buttons {
    width: auto;
  }

  .action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    width: auto;
  }

  .action-btn {
    padding: 5px 10px;
    font-size: 0.8rem;
  }

  .stats-dashboard {
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
  }

  .footer-container {
    justify-content: flex-end;
    margin-top: 2px;
  }

  .game-footer {
    padding: 3px 12px;
  }

  .footer-text {
    font-size: 0.85rem;
  }

  .stat-card {
    padding: 4px 6px;
    gap: 5px;
  }

  .stat-icon {
    font-size: 1.15rem;
  }

  .stat-label {
    font-size: 0.6rem;
  }

  .stat-value {
    font-size: 1.05rem;
  }

  .maze-board {
    width: min(48vh, 380px, 86vw);
    height: min(48vh, 380px, 86vw);
  }

  .sun-container svg {
    width: 95px;
    height: 95px;
  }

  .rainbow-container svg {
    width: 200px;
    height: 115px;
  }

  .balloon-cluster, .butterfly {
    display: none;
  }

  .garden-hills {
    height: 80px;
  }
}

/* Reduced motion accessibility */
@media (prefers-reduced-motion: reduce) {
  .sun-rays-group, .sun-container, .rainbow-container, .cloud-1, .cloud-2, .cloud-3,
  .balloon-left, .balloon-right, .butterfly-1, .butterfly-2, .butterfly .wing-left,
  .butterfly .wing-right, .sparkle {
    animation: none !important;
  }
}
