/* Happy Maze styles */

:root {
  --grass-bunny: linear-gradient(180deg, #dcfce7 0%, #bbf7d0 50%, #86efac 100%);
  --grass-bee:   linear-gradient(180deg, #ecfccb 0%, #d9f99d 50%, #a3e635 100%);
  --grass-bear:  linear-gradient(180deg, #ecfdf5 0%, #a7f3d0 50%, #6ee7b7 100%);
  --grass-car:   linear-gradient(180deg, #e0f2fe 0%, #bae6fd 50%, #7dd3fc 100%);
  --grass-kitty: linear-gradient(180deg, #fdf2f8 0%, #fce7f3 50%, #fbcfe8 100%);
}

.maze-field {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0.5rem 1rem 1rem;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Theme Navigation */
.theme-nav {
  display: flex;
  flex-shrink: 0;
  gap: 0.4rem;
  justify-content: center;
  margin-bottom: 0.5rem;
  width: 100%;
  max-width: 600px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.theme-tab-btn {
  flex: 1;
  min-width: 75px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.4rem 0.5rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: #166534;
  background: #ffffff;
  border: 2px solid #bbf7d0;
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.theme-tab-btn:hover {
  transform: translateY(-2px);
  background: #f0fdf4;
}

.theme-tab-btn.active {
  background: #22c55e;
  border-color: #15803d;
  color: #ffffff;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.3);
}

.theme-tab-btn:focus-visible {
  outline: 3px solid #15803d;
  outline-offset: 2px;
}

.theme-icon {
  font-size: 1.2rem;
  line-height: 1;
}

/* Interactive Maze Stage */
.maze-stage {
  position: relative;
  width: 100%;
  max-width: min(600px, calc((100dvh - 220px) * (600 / 420)));
  aspect-ratio: 600 / 420;
  height: auto;
  flex-shrink: 0;
  border-radius: 1.75rem;
  border: 4px solid #ffffff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  box-sizing: border-box;
  overflow: hidden;
  transition: background 0.35s ease;
  touch-action: none; /* Prevent scroll while dragging */
  cursor: pointer;
}

.theme-bunny { background: var(--grass-bunny); }
.theme-bee   { background: var(--grass-bee); }
.theme-bear  { background: var(--grass-bear); }
.theme-car   { background: var(--grass-car); }
.theme-kitty { background: var(--grass-kitty); }

/* SVG Road Pathway */
.maze-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.path-border {
  fill: none;
  stroke: rgba(0, 0, 0, 0.18);
  stroke-width: 56;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.path-road {
  fill: none;
  stroke-width: 48;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.3s ease;
}

.theme-bunny .path-road { stroke: url(#road-grad-bunny); }
.theme-bee   .path-road { stroke: url(#road-grad-bee); }
.theme-bear  .path-road { stroke: url(#road-grad-bear); }
.theme-car   .path-road { stroke: url(#road-grad-car); }
.theme-kitty .path-road { stroke: url(#road-grad-kitty); }

.path-dashes {
  fill: none;
  stroke: rgba(255, 255, 255, 0.7);
  stroke-width: 4;
  stroke-dasharray: 8 12;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Collectible Stars Layer */
.stars-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.maze-star {
  position: absolute;
  width: 36px;
  height: 36px;
  margin-left: -18px;
  margin-top: -18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(245, 158, 11, 0.4));
  animation: star-float 2s ease-in-out infinite alternate;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

@keyframes star-float {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(-4px) scale(1.1); }
}

.maze-star.collected {
  opacity: 0;
  transform: scale(1.6);
}

/* Target Goal at the end */
.target-goal {
  position: absolute;
  width: 58px;
  height: 58px;
  margin-left: -29px;
  margin-top: -29px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 3px solid #f59e0b;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
  font-size: 2.2rem;
  line-height: 1;
  pointer-events: none;
  animation: goal-pulse 1.8s ease-in-out infinite alternate;
  z-index: 10;
}

@keyframes goal-pulse {
  0% { transform: scale(1); box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35); }
  100% { transform: scale(1.12); box-shadow: 0 6px 18px rgba(245, 158, 11, 0.6); }
}

.target-goal.reached {
  animation: goal-celebrate 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes goal-celebrate {
  0% { transform: scale(1); }
  50% { transform: scale(1.35) rotate(10deg); }
  100% { transform: scale(1.2) rotate(0deg); }
}

/* Draggable Character Token */
.char-token {
  position: absolute;
  width: 56px;
  height: 56px;
  margin-left: -28px;
  margin-top: -28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 3px solid #10b981;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  font-size: 2.3rem;
  line-height: 1;
  z-index: 20;
  cursor: grab;
  touch-action: none;
  pointer-events: none;
  transition: transform 0.15s ease, border-color 0.2s ease;
}

.char-token:focus-visible {
  outline: 3px solid #22c55e;
  outline-offset: 3px;
}

.char-token.dragging {
  cursor: grabbing;
  transform: scale(1.15);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
}

.char-token.hopping {
  animation: hop-step 0.25s ease-out;
}

@keyframes hop-step {
  0% { transform: scale(1); }
  50% { transform: scale(1.2) translateY(-6px); }
  100% { transform: scale(1) translateY(0); }
}

.char-token.celebrating {
  animation: char-dance 0.6s ease-in-out infinite alternate;
}

@keyframes char-dance {
  0% { transform: scale(1.1) rotate(-8deg); }
  100% { transform: scale(1.18) rotate(8deg); }
}

/* Action Controls Bar */
.action-bar {
  display: flex;
  flex-shrink: 0;
  gap: 0.75rem;
  justify-content: center;
  align-items: center;
  margin: 0.5rem 0 0;
  min-height: 48px;
}

.action-pill-btn {
  padding: 0.65rem 1.6rem;
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffffff;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  animation: pop-btn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.action-pill-btn:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.45);
}

.action-pill-btn:active {
  transform: translateY(1px) scale(0.98);
}

.action-pill-btn:focus-visible {
  outline: 3px solid #059669;
  outline-offset: 2px;
}

.retry-btn {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

.retry-btn:hover {
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.45);
}

.retry-btn:focus-visible {
  outline-color: #d97706;
}

@keyframes pop-btn {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Confetti & Sparks */
.sparks-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}

.sparkle {
  position: absolute;
  font-size: 1.5rem;
  animation: burst 0.85s ease-out forwards;
}

@keyframes burst {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.35); opacity: 0; }
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .maze-field {
    padding: 0.35rem 0.5rem 0.75rem;
  }
  .char-token {
    width: 48px;
    height: 48px;
    margin-left: -24px;
    margin-top: -24px;
    font-size: 1.9rem;
  }
  .target-goal {
    width: 50px;
    height: 50px;
    margin-left: -25px;
    margin-top: -25px;
    font-size: 1.9rem;
  }
  .maze-star {
    font-size: 1.5rem;
  }
  .theme-tab-btn {
    min-width: 62px;
    padding: 0.35rem 0.4rem;
    font-size: 0.8rem;
  }
  .action-pill-btn {
    font-size: 1rem;
    padding: 0.55rem 1.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .maze-star,
  .target-goal,
  .action-pill-btn,
  .char-token.celebrating,
  .char-token.hopping,
  .sparkle {
    animation: none;
  }
}
