/* =====================================================================
   Cookie Baker Game Styles (Ages 3-5)
   Wooden Pastry Board, Rolling Pin, Cookie Cutters, Oven & Frosting
   ===================================================================== */

:root {
  --wood-counter: #92400e;
  --wood-board: #d97706;
  --dough-raw: #fef08a;
  --dough-baked: #ca8a04;
  --dough-border: #eab308;
}

body {
  background: radial-gradient(circle at 50% 15%, #fef3c7 0%, #fed7aa 60%, #fdba74 100%);
  color: #1e293b;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  overflow: hidden;
}

.game-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  box-sizing: border-box;
}

/* ---------------------------------------------------------------------
   Workspace Layout
   --------------------------------------------------------------------- */

.bakery-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  max-width: 500px;
  width: 100%;
  margin: 0 auto;
  padding: 4px 12px 10px;
  box-sizing: border-box;
  position: relative;
}

/* ---------------------------------------------------------------------
   Stage Stepper
   --------------------------------------------------------------------- */

.stage-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-bottom: 4px;
}

.step-pill {
  padding: 4px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
  border: 2px solid #d97706;
  font-size: 0.92rem;
  font-weight: 800;
  color: #92400e;
  transition: all 0.2s ease;
}

.step-pill.active {
  background: #f59e0b;
  color: #ffffff;
  border-color: #b45309;
  transform: scale(1.08);
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.35);
}

.step-pill.completed {
  background: rgba(16, 185, 129, 0.2);
  border-color: #10b981;
  color: #047857;
}

.step-arrow {
  color: #b45309;
  font-weight: 900;
  font-size: 0.85rem;
}

/* ---------------------------------------------------------------------
   Kitchen Board Stage
   --------------------------------------------------------------------- */

.kitchen-stage {
  position: relative;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin: 4px 0;
  min-height: 0;
}

.view-panel {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.wooden-board {
  position: relative;
  width: min(340px, 86vw);
  height: min(290px, 64vh);
  background: radial-gradient(circle, #fde68a 0%, #f59e0b 80%, #d97706 100%);
  border: 8px solid var(--wood-counter);
  border-radius: 28px;
  box-shadow: 0 10px 25px rgba(120, 53, 15, 0.25), inset 0 0 15px rgba(146, 64, 14, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

/* ---------------------------------------------------------------------
   Stage 1: Rolling Dough
   --------------------------------------------------------------------- */

.dough-blob {
  position: absolute;
  width: 220px;
  height: 180px;
  background: radial-gradient(circle at 40% 40%, #fef9c3 0%, var(--dough-raw) 70%, #fde047 100%);
  border: 4px solid var(--dough-border);
  border-radius: 46% 54% 50% 50% / 48% 46% 54% 52%;
  box-shadow: 0 8px 18px rgba(180, 83, 9, 0.2);
  transform: scale(0.48);
  transition: transform 0.18s ease-out, border-radius 0.2s ease-out;
  pointer-events: none;
}

.rolling-pin {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  width: 260px;
  height: 52px;
  z-index: 10;
  pointer-events: none;
  transition: transform 0.1s ease-out;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.25));
}

.pin-handle {
  width: 38px;
  height: 22px;
  background: #78350f;
  border-radius: 10px;
  border: 2px solid #451a03;
}

.pin-body {
  flex: 1;
  height: 52px;
  background: linear-gradient(to bottom, #d97706 0%, #b45309 50%, #92400e 100%);
  border-radius: 12px;
  border: 2px solid #78350f;
  box-shadow: inset 0 3px 5px rgba(255, 255, 255, 0.35);
}

.progress-bar-wrapper {
  width: min(340px, 86vw);
  height: 12px;
  background: rgba(255, 255, 255, 0.8);
  border: 2px solid #d97706;
  border-radius: 10px;
  margin-top: 10px;
  overflow: hidden;
}

.roll-progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(to right, #10b981, #059669);
  transition: width 0.15s ease;
}

.flour-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.flour-puff {
  position: absolute;
  width: 14px;
  height: 14px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  animation: flourDisperse 0.5s ease-out forwards;
}

@keyframes flourDisperse {
  0% { transform: scale(0.4); opacity: 1; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* ---------------------------------------------------------------------
   Stage 2: Cutting Shapes
   --------------------------------------------------------------------- */

.dough-sheet {
  position: relative;
  width: min(280px, 88%);
  height: min(230px, 86%);
  background: radial-gradient(circle at 40% 40%, #fef9c3 0%, var(--dough-raw) 70%, #fde047 100%);
  border: 4px solid var(--dough-border);
  border-radius: 36px;
  box-shadow: inset 0 0 16px rgba(180, 83, 9, 0.15);
  cursor: pointer;
}

.stamped-cookies-tray {
  position: absolute;
  inset: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-around;
  padding: 14px;
  box-sizing: border-box;
}

.stamped-cookie {
  width: 72px;
  height: 72px;
  background: #fef08a;
  border: 3px dashed #b45309;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  animation: cookiePop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.cutters-tray {
  display: flex;
  gap: 12px;
  margin-top: 10px;
}

.cutter-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid #94a3b8;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease;
}

.cutter-btn.active {
  border-color: #f59e0b;
  transform: translateY(-3px) scale(1.12);
  box-shadow: 0 6px 14px rgba(245, 158, 11, 0.35);
}

.cutter-icon {
  font-size: 2rem;
}

/* ---------------------------------------------------------------------
   Stage 3: Oven Baking
   --------------------------------------------------------------------- */

.oven-appliance {
  width: min(340px, 86vw);
  height: min(290px, 64vh);
  background: linear-gradient(135deg, #475569 0%, #1e293b 100%);
  border: 8px solid #0f172a;
  border-radius: 28px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  padding: 12px;
  box-sizing: border-box;
}

.oven-top-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.oven-knob {
  width: 24px;
  height: 24px;
  background: #cbd5e1;
  border: 3px solid #64748b;
  border-radius: 50%;
}

.oven-timer-screen {
  background: #020617;
  color: #ef4444;
  font-family: monospace, monospace;
  font-size: 1.35rem;
  font-weight: 900;
  padding: 4px 14px;
  border-radius: 10px;
  border: 2px solid #334155;
  letter-spacing: 2px;
}

.oven-window {
  position: relative;
  flex: 1;
  background: #090d16;
  border: 4px solid #334155;
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.oven-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(249, 115, 22, 0.75) 0%, rgba(220, 38, 38, 0.3) 70%, transparent 100%);
  animation: glowPulse 1.2s infinite alternate ease-in-out;
}

@keyframes glowPulse {
  0% { opacity: 0.6; }
  100% { opacity: 1; }
}

.oven-tray {
  position: relative;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: center;
  width: 90%;
}

.baking-cookie {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  background: var(--dough-raw);
  transition: background 1.8s ease-in-out, transform 0.3s ease;
}

.baking-cookie.golden {
  background: radial-gradient(circle, #fde047 0%, var(--dough-baked) 80%, #a16207 100%);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  transform: scale(1.06);
}

.steam-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.steam-puff {
  position: absolute;
  font-size: 1.8rem;
  opacity: 0;
  animation: steamRise 1.2s ease-out forwards;
  pointer-events: none;
}

@keyframes steamRise {
  0% { transform: translateY(12px) scale(0.6); opacity: 0.85; }
  100% { transform: translateY(-38px) scale(1.3); opacity: 0; }
}

/* ---------------------------------------------------------------------
   Stage 4: Decorating
   --------------------------------------------------------------------- */

.decorating-board {
  background: radial-gradient(circle, #ffffff 0%, #fef3c7 100%);
  border-color: #f59e0b;
}

.cookies-plate {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.decorated-cookie {
  position: relative;
  width: 76px;
  height: 76px;
  background: radial-gradient(circle, #fde047 0%, var(--dough-baked) 80%, #a16207 100%);
  border: 3px solid #78350f;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.6rem;
  cursor: pointer;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.18);
  transition: transform 0.15s ease;
}

.decorated-cookie:hover {
  transform: scale(1.08);
}

.decorated-cookie:active {
  transform: scale(0.95);
}

.cookie-glaze-layer {
  position: absolute;
  inset: 6px;
  border-radius: 14px;
  pointer-events: none;
  opacity: 0.65;
}

.glaze-strawberry {
  background: radial-gradient(circle, #f472b6 30%, #db2777 100%);
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.6);
}

.glaze-chocolate {
  background: radial-gradient(circle, #78350f 30%, #451a03 100%);
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.4);
}

.glaze-vanilla {
  background: radial-gradient(circle, #ffffff 30%, #fef08a 100%);
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.8);
}

.cookie-sprinkles {
  position: absolute;
  font-size: 1.2rem;
  top: 4px;
  right: 4px;
  pointer-events: none;
}

.glaze-tray {
  display: flex;
  gap: 12px;
  margin-top: 10px;
}

.glaze-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.12s ease, border-color 0.15s ease;
}

.glaze-btn.active {
  border-color: #ec4899;
  transform: translateY(-3px) scale(1.12);
  box-shadow: 0 6px 14px rgba(236, 72, 153, 0.35);
}

.glaze-swatch {
  font-size: 1.8rem;
}

/* ---------------------------------------------------------------------
   Footer Actions
   --------------------------------------------------------------------- */

.action-footer {
  width: 100%;
  display: flex;
  justify-content: center;
}

.action-btn {
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 800;
  padding: 12px 28px;
  border-radius: 22px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: transform 0.1s ease, filter 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}

.action-btn:active {
  transform: scale(0.96);
}

.action-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  pointer-events: none;
}

.wooden-board:focus-visible,
.dough-sheet:focus-visible,
.cutter-btn:focus-visible,
.glaze-btn:focus-visible,
.decorated-cookie:focus-visible,
.action-btn:focus-visible {
  outline: 3px solid #f59e0b;
  outline-offset: 3px;
}

.main-action-btn {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  border-bottom: 4px solid #b45309;
  width: 100%;
}

.play-again-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-bottom: 4px solid #047857;
}

.hidden {
  display: none !important;
}

/* ---------------------------------------------------------------------
   Sparks & Celebration Modal
   --------------------------------------------------------------------- */

.sparks-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 40;
}

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

@keyframes sparkBurst {
  0% { transform: translate(0, 0) scale(0.5); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1.3); opacity: 0; }
}

.celebration-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  padding: 16px;
}

.celebration-card {
  background: #ffffff;
  border: 4px solid #f59e0b;
  padding: 24px 28px;
  border-radius: 28px;
  text-align: center;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
  max-width: 420px;
  width: 100%;
  animation: cardBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.celebration-icon {
  font-size: 3.2rem;
  margin-bottom: 8px;
}

.celebration-text {
  font-size: 1.25rem;
  font-weight: 800;
  color: #78350f;
  margin-bottom: 20px;
  line-height: 1.4;
}

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

/* ---------------------------------------------------------------------
   Mobile Responsive
   --------------------------------------------------------------------- */

@media (max-width: 480px) {
  .wooden-board,
  .oven-appliance {
    width: 290px;
    height: 250px;
  }
  .dough-blob {
    width: 180px;
    height: 150px;
  }
  .dough-sheet {
    width: 250px;
    height: 195px;
  }
  .rolling-pin {
    width: 220px;
    height: 44px;
  }
  .pin-body {
    height: 44px;
  }
  .stamped-cookie,
  .decorated-cookie {
    width: 60px;
    height: 60px;
    font-size: 2rem;
  }
  .cutter-btn,
  .glaze-btn {
    width: 50px;
    height: 50px;
  }
  .cutter-icon,
  .glaze-swatch {
    font-size: 1.6rem;
  }
  .action-btn {
    font-size: 1.05rem;
    padding: 10px 20px;
  }
}

@media (max-height: 600px) {
  .wooden-board,
  .oven-appliance {
    width: 270px;
    height: 190px;
  }
  .dough-blob {
    width: 160px;
    height: 120px;
  }
  .dough-sheet {
    width: 240px;
    height: 160px;
  }
  .rolling-pin {
    width: 200px;
    height: 38px;
  }
  .pin-body {
    height: 38px;
  }
  .stamped-cookie,
  .decorated-cookie,
  .baking-cookie {
    width: 50px;
    height: 50px;
    font-size: 1.7rem;
  }
  .cutter-btn,
  .glaze-btn {
    width: 44px;
    height: 44px;
  }
  .cutter-icon,
  .glaze-swatch {
    font-size: 1.4rem;
  }
  .cutters-tray,
  .glaze-tray {
    margin-top: 6px;
    gap: 8px;
  }
  .action-btn {
    padding: 8px 18px;
    font-size: 1rem;
  }
}

/* ---------------------------------------------------------------------
   Reduced Motion
   --------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .dough-blob,
  .stamped-cookie,
  .baking-cookie,
  .oven-glow,
  .steam-puff,
  .flour-puff,
  .sparkle,
  .celebration-card {
    transition: none !important;
    animation: none !important;
  }
}
