:root {
  --sky-day: linear-gradient(180deg, #42a5f5 0%, #90caf9 45%, #fff9c4 75%, #a5d6a7 100%);
  --sky-night: linear-gradient(180deg, #12092b 0%, #28144b 35%, #4a148c 65%, #f57c00 88%, #2e7d32 100%);
  --sky-rainbow: linear-gradient(180deg, #64b5f6 0%, #bbdefb 45%, #fff8e1 75%, #81c784 100%);
}

/* ========================================================
   Main Field & Environment
   ======================================================== */
.sky-toggle-field {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 100%;
  padding: 16px 12px 24px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: background 0.8s ease;
}

.sky-toggle-field.mode-day {
  background: var(--sky-day);
}

.sky-toggle-field.mode-night {
  background: var(--sky-night);
}

.sky-toggle-field.mode-rainbow {
  background: var(--sky-rainbow);
}

.sky-toggle-field:focus-visible {
  outline: 4px solid #ffb300;
  outline-offset: -4px;
}

/* ========================================================
   Stars Backdrop (in Twilight)
   ======================================================== */
.stars-backdrop {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.8s ease;
}

.mode-night .stars-backdrop {
  opacity: 1;
}

.night-star {
  position: absolute;
  color: #fff9c4;
  font-size: 20px;
  filter: drop-shadow(0 0 6px #ffe082);
  animation: star-twinkle 2s ease-in-out infinite alternate;
}

.ns-1 { top: 12%; left: 14%; animation-delay: 0.2s; font-size: 24px; }
.ns-2 { top: 22%; right: 18%; animation-delay: 0.8s; font-size: 18px; }
.ns-3 { top: 8%;  right: 28%; animation-delay: 1.4s; font-size: 22px; }
.ns-4 { top: 32%; left: 24%; animation-delay: 0.5s; font-size: 16px; }
.ns-5 { top: 18%; left: 45%; animation-delay: 1.1s; font-size: 20px; }

@keyframes star-twinkle {
  0% { transform: scale(0.8); opacity: 0.4; }
  100% { transform: scale(1.3); opacity: 1; }
}

/* ========================================================
   Rainbow Arch
   ======================================================== */
.rainbow-arch {
  position: absolute;
  top: 14%;
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 420px);
  height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  z-index: 3;
  filter: drop-shadow(0 0 16px rgba(255, 235, 59, 0.45));
  animation: rainbow-bloom 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes rainbow-bloom {
  0% { transform: translateX(-50%) scale(0.7) translateY(40px); opacity: 0; }
  100% { transform: translateX(-50%) scale(1) translateY(0); opacity: 1; }
}

.rainbow-band {
  width: 100%;
  height: 12px;
  border-radius: 200px 200px 0 0;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.4);
  pointer-events: auto;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.rainbow-band:hover {
  transform: scaleY(1.3);
}

.band-red    { background: #ff3b30; }
.band-orange { background: #ff9500; width: 95%; }
.band-yellow { background: #ffcc00; width: 90%; }
.band-green  { background: #34c759; width: 85%; }
.band-blue   { background: #007aff; width: 80%; }
.band-purple { background: #af52de; width: 75%; }

/* ========================================================
   Raindrop Layer
   ======================================================== */
.rain-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 8;
  overflow: hidden;
}

.rain-drop {
  position: absolute;
  width: 4px;
  height: 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.8) 0%, rgba(33, 150, 243, 0.9) 100%);
  border-radius: 2px;
  filter: drop-shadow(0 0 3px #90caf9);
  animation: rain-fall linear forwards;
}

@keyframes rain-fall {
  0% { transform: translateY(0); opacity: 0.9; }
  100% { transform: translateY(65vh); opacity: 0; }
}

/* ========================================================
   Celestial Stage (Sun & Cloud)
   ======================================================== */
.sky-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(88vw, 360px);
  height: min(88vw, 360px);
  margin: auto 0;
  z-index: 10;
}

.celestial-btn {
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  outline: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.celestial-btn:focus-visible {
  outline: 4px solid #fff;
  border-radius: 28px;
  outline-offset: 6px;
}

/* 1. Sun Character */
.sun-hero {
  position: relative;
  width: 210px;
  height: 210px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.sun-hero.hero-hop {
  animation: sun-hop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.sun-rays {
  position: absolute;
  inset: -22px;
  pointer-events: none;
  animation: sun-rays-rotate 28s linear infinite;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

@keyframes sun-rays-rotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.mode-night .sun-rays {
  opacity: 0.35;
  transform: scale(0.85);
}

.ray {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 38px;
  background: linear-gradient(180deg, #ffb300 0%, #ff8f00 100%);
  border-radius: 10px;
  box-shadow: 0 0 12px #ffe082;
  transform-origin: center center;
}

.ray-1 { transform: translate(-50%, -100%) translateY(-92px) rotate(0deg); }
.ray-2 { transform: translate(-50%, -100%) translateY(-92px) rotate(45deg); }
.ray-3 { transform: translate(-50%, -100%) translateY(-92px) rotate(90deg); }
.ray-4 { transform: translate(-50%, -100%) translateY(-92px) rotate(135deg); }
.ray-5 { transform: translate(-50%, -100%) translateY(-92px) rotate(180deg); }
.ray-6 { transform: translate(-50%, -100%) translateY(-92px) rotate(225deg); }
.ray-7 { transform: translate(-50%, -100%) translateY(-92px) rotate(270deg); }
.ray-8 { transform: translate(-50%, -100%) translateY(-92px) rotate(315deg); }

.sun-core {
  position: relative;
  width: 170px;
  height: 170px;
  background: radial-gradient(circle at 45% 40%, #fff59d 0%, #fdd835 55%, #f57f17 100%);
  border: 4px solid #fffde7;
  border-radius: 50%;
  box-shadow:
    inset 0 4px 8px rgba(255, 255, 255, 0.8),
    inset 0 -6px 12px rgba(245, 127, 23, 0.4),
    0 0 45px #ffee58;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.mode-night .sun-core {
  background: radial-gradient(circle at 45% 40%, #fff9c4 0%, #ffb74d 60%, #e65100 100%);
  box-shadow: 0 0 25px #ff9800;
}

/* Sun Face */
.sun-face {
  position: relative;
  width: 120px;
  height: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.sun-eyes {
  position: relative;
  display: flex;
  gap: 36px;
  margin-top: 10px;
}

.sun-eye {
  width: 20px;
  height: 24px;
  background: #2e1c0c;
  border-radius: 50%;
  position: relative;
  overflow: hidden;
}

.eye-pupil {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 7px;
  height: 7px;
  background: #ffffff;
  border-radius: 50%;
}

.sun-sleepy-eyes {
  position: absolute;
  inset: 0;
  display: flex;
  gap: 36px;
}

.sleep-arc {
  width: 22px;
  height: 12px;
  border-bottom: 4px solid #3e2723;
  border-radius: 0 0 16px 16px;
}

.sun-cheeks {
  display: flex;
  justify-content: space-between;
  width: 86px;
  margin-top: 4px;
}

.sun-cheek {
  width: 18px;
  height: 12px;
  background: rgba(255, 112, 67, 0.7);
  border-radius: 50%;
}

.sun-mouth {
  width: 24px;
  height: 12px;
  border-bottom: 4px solid #3e2723;
  border-radius: 0 0 18px 18px;
  margin-top: -2px;
}

/* 2. Cloud Character */
.cloud-hero {
  position: absolute;
  top: 10px;
  right: -20px;
  width: 210px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 14px 28px rgba(0, 0, 0, 0.24));
  transition: transform 0.65s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.5s ease;
  z-index: 15;
}

.cloud-aside {
  transform: translate(35px, -25px) scale(0.85);
  opacity: 0.95;
}

.cloud-covering {
  transform: translate(-70px, 20px) scale(1.1);
  opacity: 1;
}

.cloud-shape {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.cloud-puff {
  position: absolute;
  background: radial-gradient(circle at 40% 30%, #ffffff 0%, #e0f7fa 65%, #b2ebf2 100%);
  border-radius: 50%;
  box-shadow: inset 0 -4px 8px rgba(0, 0, 0, 0.08);
}

.mode-night .cloud-puff {
  background: radial-gradient(circle at 40% 30%, #ffffff 0%, #ede7f6 60%, #d1c4e9 100%);
}

.puff-main  { width: 150px; height: 80px; bottom: 10px; left: 30px; border-radius: 40px; }
.puff-left  { width: 75px;  height: 75px; bottom: 10px; left: 10px; }
.puff-right { width: 85px;  height: 85px; bottom: 10px; right: 10px; }
.puff-top   { width: 95px;  height: 95px; top: 12px;    left: 55px; }

.cloud-face {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 12px;
}

.cloud-eyes {
  display: flex;
  gap: 28px;
}

.c-eye {
  width: 8px;
  height: 8px;
  background: #37474f;
  border-radius: 50%;
}

.cloud-cheeks {
  display: flex;
  justify-content: space-between;
  width: 58px;
  margin-top: 2px;
}

.c-cheek {
  width: 12px;
  height: 8px;
  background: rgba(255, 138, 128, 0.65);
  border-radius: 50%;
}

.cloud-smile {
  width: 16px;
  height: 8px;
  border-bottom: 3px solid #37474f;
  border-radius: 0 0 12px 12px;
  margin-top: -2px;
}

/* ========================================================
   Fireflies in Twilight
   ======================================================== */
.fireflies-layer {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

.firefly-node {
  position: absolute;
  width: 52px;
  height: 52px;
  margin-left: -26px;
  margin-top: -26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  border: none;
  background: transparent;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.firefly-node:focus-visible {
  outline: 3px solid #ffeb3b;
  outline-offset: 4px;
  border-radius: 50%;
}

.firefly-node.firefly-caught {
  pointer-events: none;
  transform: scale(1.6) translateY(-40px);
  opacity: 0;
  transition: transform 0.6s ease-out, opacity 0.6s ease-out;
}

.firefly-glow {
  width: 16px;
  height: 16px;
  background: radial-gradient(circle, #ffffff 0%, #ffeb3b 65%, rgba(255, 235, 59, 0) 100%);
  border-radius: 50%;
  box-shadow: 0 0 16px #ffeb3b, 0 0 28px #ffd54f;
  animation: ff-glow-pulse 1.8s ease-in-out infinite alternate;
}

@keyframes ff-glow-pulse {
  0% { transform: scale(0.85); opacity: 0.6; }
  100% { transform: scale(1.3); opacity: 1; }
}

/* ========================================================
   Action Controls Bar
   ======================================================== */
.sky-controls {
  position: relative;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 12px;
}

.action-pill {
  background: rgba(255, 255, 255, 0.85);
  color: #37474f;
  border: 3px solid #fff;
  border-radius: 999px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  padding: 10px 22px;
  min-height: 48px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  touch-action: manipulation;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

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

.action-pill:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.22);
}

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

.action-pill.active {
  background: #ffffff;
  color: #e65100;
  border-color: #ffd54f;
  box-shadow: 0 0 20px rgba(255, 213, 79, 0.6);
}

.action-pill.sun-pill.active { color: #f57f17; border-color: #fbc02d; }
.action-pill.cloud-pill.active { color: #4527a0; border-color: #b39ddb; }
.action-pill.rainbow-pill.active { color: #00897b; border-color: #80cbc4; }

/* ========================================================
   Sparkles
   ======================================================== */
.sparkles-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 40;
}

.sparkle-pop {
  position: absolute;
  width: 16px;
  height: 16px;
  background: radial-gradient(circle, #ffffff 0%, #ffeb3b 60%, transparent 100%);
  border-radius: 50%;
  animation: spark-burst 0.7s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes spark-burst {
  0% { transform: translate(0, 0) scale(0.2); opacity: 1; }
  100% { transform: translate(var(--sx, 0), var(--sy, 0)) scale(1.4); opacity: 0; }
}

/* ========================================================
   Responsive & Reduced Motion
   ======================================================== */
@media (max-height: 600px) {
  .sky-toggle-field {
    padding: 8px 12px 14px;
  }
  .sky-stage {
    width: min(70vw, 240px);
    height: min(70vw, 240px);
    transform: scale(0.85);
  }
  .rainbow-arch {
    top: 6%;
    height: 160px;
    width: min(90vw, 340px);
  }
  .action-pill {
    font-size: 14px;
    padding: 6px 16px;
    min-height: 42px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sky-toggle-field,
  .cloud-hero,
  .sun-hero,
  .sun-rays,
  .night-star,
  .firefly-glow,
  .rainbow-arch,
  .rain-drop,
  .sparkle-pop,
  .firefly-node {
    transition: none !important;
    animation: none !important;
  }
}
