/* EP02 Player Styling - Berry's Flower Garden (Style & Color) */

body.ep02-mode #ep1StartBtn,
body.ep02-mode #ep1RocketFx,
body.ep02-mode #ep1CompleteWrap {
  display: none !important;
}

/* EP02 Interactive Overlay Layer */
#ep2InteractiveLayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  overflow: clip;
}

body:not(.ep02-mode) #ep2InteractiveLayer {
  display: none !important;
}

/* Foreground Interactive Flower */
.ep2-flower-container {
  position: absolute;
  bottom: 8%;
  left: 6%;
  width: clamp(90px, 18vw, 150px);
  height: clamp(90px, 18vw, 150px);
  pointer-events: auto;
  cursor: pointer;
  filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.35));
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ep2-flower-container:hover {
  transform: scale(1.08);
}

.ep2-flower-svg {
  width: 100%;
  height: 100%;
}

.ep2-petal {
  fill: #ffffff;
  stroke: #e2e8f0;
  stroke-width: 2.5;
  transition: fill 0.6s ease, stroke 0.6s ease, filter 0.6s ease;
}

.ep2-flower-center {
  fill: #fef08a;
  stroke: #f59e0b;
  stroke-width: 2;
  transition: transform 0.4s ease;
}

/* When colored */
.ep2-flower-container.colored-pink .ep2-petal {
  fill: url(#ep2PinkGrad);
  stroke: #ec4899;
  filter: drop-shadow(0 0 10px rgba(244, 114, 182, 0.8));
}

.ep2-flower-container.colored-yellow .ep2-petal {
  fill: url(#ep2YellowGrad);
  stroke: #eab308;
  filter: drop-shadow(0 0 10px rgba(250, 204, 21, 0.8));
}

.ep2-flower-container.colored-violet .ep2-petal {
  fill: url(#ep2VioletGrad);
  stroke: #a855f7;
  filter: drop-shadow(0 0 10px rgba(192, 132, 252, 0.8));
}

/* Color Palette Bar (Bottom-Right corner to protect left flower and center Berry) */
#ep2PaletteWrap {
  position: absolute;
  bottom: 16px;
  right: 24px;
  left: auto;
  transform: none;
  display: flex;
  align-items: center;
  gap: clamp(10px, 2vw, 18px);
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  border-radius: 9999px;
  padding: 8px 18px;
  pointer-events: auto;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  z-index: 25;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#ep2PaletteWrap.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px);
}

#ep2PaletteWrap[hidden] {
  display: none;
}

.ep2-color-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  min-height: 52px;
  width: clamp(52px, 12vw, 64px);
  height: clamp(52px, 12vw, 64px);
  border-radius: 50%;
  border: 3px solid #ffffff;
  cursor: pointer;
  font-size: 1.4rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
  position: relative;
}

.ep2-color-btn:hover {
  transform: scale(1.15) translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}

.ep2-color-btn:active {
  transform: scale(0.95);
}

.ep2-btn-pink {
  background: linear-gradient(135deg, #f472b6, #db2777);
  box-shadow: 0 4px 14px rgba(219, 39, 119, 0.45);
}

.ep2-btn-yellow {
  background: linear-gradient(135deg, #fde047, #ca8a04);
  box-shadow: 0 4px 14px rgba(202, 138, 4, 0.45);
}

.ep2-btn-violet {
  background: linear-gradient(135deg, #c084fc, #9333ea);
  box-shadow: 0 4px 14px rgba(147, 51, 234, 0.45);
}

.ep2-btn-label {
  position: absolute;
  bottom: -22px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #f8fafc;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
}

/* Palette Guide Tooltip */
.ep2-palette-guide {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fef08a;
  padding: 0 6px;
  white-space: nowrap;
}

/* Sparkle Burst Particles */
.ep2-sparkle-particle {
  position: absolute;
  pointer-events: none;
  font-size: 1.5rem;
  animation: ep2SparkleAnim 0.85s ease-out forwards;
}

@keyframes ep2SparkleAnim {
  0% {
    transform: translate(0, 0) scale(0.4);
    opacity: 1;
  }
  100% {
    transform: translate(var(--tx), var(--ty)) scale(1.2);
    opacity: 0;
  }
}

/* EP02 Completion Card (Placed cleanly below screenContainer) */
#ep2CompleteWrap {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, rgba(253, 242, 248, 0.96), rgba(254, 226, 226, 0.96));
  border: 2px solid #f472b6;
  border-radius: 20px;
  padding: 16px 24px;
  margin: 12px auto;
  max-width: 580px;
  width: 92%;
  box-shadow: 0 12px 28px rgba(219, 39, 119, 0.2);
  text-align: center;
  z-index: 30;
}

#ep2CompleteWrap.active {
  display: flex !important;
  animation: ep2SlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes ep2SlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.ep2-complete-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #9d174d;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ep2-complete-desc {
  font-size: 0.92rem;
  color: #475569;
  line-height: 1.4;
}

.ep2-complete-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 4px;
}

.ep2-btn-secondary {
  background: #ffffff;
  color: #db2777;
  border: 1.5px solid #f472b6;
  border-radius: 9999px;
  padding: 8px 18px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ep2-btn-secondary:hover {
  background: #fdf2f8;
  transform: translateY(-2px);
}

.ep2-btn-primary {
  background: linear-gradient(135deg, #ec4899, #db2777);
  color: #ffffff;
  border: none;
  border-radius: 9999px;
  padding: 8px 22px;
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(219, 39, 119, 0.4);
  transition: all 0.2s ease;
}

.ep2-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(219, 39, 119, 0.55);
}

/* Mobile responsive adjustments */
@media (max-width: 640px) {
  #ep2PaletteWrap {
    padding: 6px 12px;
    gap: 8px;
  }
  .ep2-color-btn {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    font-size: 1.2rem;
  }
  .ep2-palette-guide {
    display: none;
  }
  .ep2-flower-container {
    bottom: 5%;
    left: 4%;
  }
}

/* Desktop lesson view: the result and controls share the screen with the scene. */
@media (min-width: 900px) {
  body.ep02-mode .cinema-stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    grid-template-rows: auto auto repeat(4, auto);
    gap: 8px 14px;
    align-items: start;
  }
  body.ep02-mode .story-progress-bar,
  body.ep02-mode .scene-active-header { grid-column: 1 / -1; margin: 0; }
  body.ep02-mode .screen-container {
    grid-column: 1;
    grid-row: 3 / span 4;
    max-height: none;
    align-self: start;
  }
  body.ep02-mode #ep2CompleteWrap {
    grid-column: 2;
    grid-row: 3;
    width: 100%;
    margin: 0;
    padding: 12px;
    gap: 6px;
  }
  body.ep02-mode .cinema-subtitle-bar { grid-column: 2; grid-row: 4; margin: 0; }
  body.ep02-mode .control-deck { grid-column: 2; grid-row: 5; margin: 0; }
  body.ep02-mode .stage-extra-actions { grid-column: 2; grid-row: 6; margin: 0; }
  body.ep02-mode .voice-auto-status { display: none; }
  body.ep02-mode .deck-controls-right { width: 100%; }
}

@media (max-width: 899px) {
  body.ep02-mode #ep2CompleteWrap {
    width: 100%;
    max-width: none;
    margin: 7px 0 0;
    padding: 9px;
    gap: 5px;
  }
  body.ep02-mode .ep2-complete-title { font-size: 14px; }
  body.ep02-mode .ep2-complete-actions { margin: 0; }
  body.ep02-mode .ep2-btn-secondary,
  body.ep02-mode .ep2-btn-primary { min-height: 44px; }
}
