:root {
  --game-bg: radial-gradient(circle at 50% 25%, #1c255e 0%, #121842 50%, #090c21 100%);
  --room-dim: rgba(0, 0, 0, 0);
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 4px 16px;
  box-sizing: border-box;
  gap: 12px;
}

.top-bar .instruction-banner {
  flex: 1;
  margin: 0;
}

.lullaby-btn {
  background: rgba(255, 238, 88, 0.2);
  border: 2px solid #ffee58;
  color: #fff9c4;
  font-size: 16px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.2s, transform 0.2s;
}

.lullaby-btn:hover {
  background: rgba(255, 238, 88, 0.35);
  transform: scale(1.04);
}

.lullaby-btn.active {
  background: #ffee58;
  color: #1a237e;
  box-shadow: 0 0 16px rgba(255, 238, 88, 0.6);
}

.sleepy-field {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 12px 16px 20px;
  box-sizing: border-box;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* Ambient Room Dimmer Overlay */
.sleepy-field::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--room-dim);
  pointer-events: none;
  transition: background 0.8s ease;
  z-index: 12;
}

/* Nursery Window with Moon & Stars */
.nursery-window {
  width: 140px;
  height: 90px;
  background: linear-gradient(180deg, #0d1238 0%, #171f54 100%);
  border: 4px solid #5d4037;
  border-radius: 60px 60px 8px 8px;
  position: relative;
  margin-bottom: 12px;
  box-shadow: inset 0 0 16px rgba(255, 238, 88, 0.15), 0 4px 12px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.moon-icon {
  position: absolute;
  top: 8px;
  left: 14px;
  font-size: 38px;
  line-height: 1;
  filter: drop-shadow(0 0 10px rgba(255, 238, 88, 0.6));
  animation: moon-glow 3s infinite ease-in-out;
}

@keyframes moon-glow {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 8px rgba(255, 238, 88, 0.5)); }
  50% { transform: scale(1.05); filter: drop-shadow(0 0 14px rgba(255, 238, 88, 0.85)); }
}

.stars-cluster {
  position: absolute;
  right: 12px;
  top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.twinkle-star {
  font-size: 16px;
  line-height: 1;
  animation: star-blink 2s infinite ease-in-out alternate;
}

.star-1 { animation-delay: 0s; }
.star-2 { animation-delay: 0.7s; font-size: 14px; margin-left: 10px; }
.star-3 { animation-delay: 1.3s; font-size: 18px; }

@keyframes star-blink {
  0% { opacity: 0.3; transform: scale(0.8); }
  100% { opacity: 1; transform: scale(1.1); }
}

/* Beds Row */
.beds-row {
  display: flex;
  gap: 16px;
  justify-content: center;
  align-items: center;
  width: min(96vw, 560px);
  z-index: 10;
}

.bed-card {
  position: relative;
  flex: 1;
  max-width: 170px;
  height: 250px;
  background: linear-gradient(180deg, #4e342e 0%, #2b1d19 100%);
  border-radius: 28px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  cursor: pointer;
  border: 3px solid #6d4c41;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  outline: none;
}

.bed-card:hover {
  transform: translateY(-4px) scale(1.02);
}

.bed-card:focus-visible {
  outline: 4px solid #ffee58;
  outline-offset: 4px;
}

.bed-pillow {
  position: absolute;
  top: 16px;
  width: 82%;
  height: 52px;
  background: #fff9c4;
  border-radius: 20px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.12), 0 3px 6px rgba(0, 0, 0, 0.2);
}

.friend-avatar {
  position: absolute;
  top: 26px;
  font-size: 68px;
  line-height: 1;
  z-index: 2;
  transition: transform 0.4s ease;
  animation: breathing 2.8s infinite ease-in-out;
}

@keyframes breathing {
  0%, 100% { transform: scale(1) translateY(0); }
  50% { transform: scale(1.04, 0.96) translateY(2px); }
}

.friend-name {
  position: absolute;
  top: 104px;
  font-size: 15px;
  font-weight: 700;
  color: #fff9c4;
  background: rgba(0, 0, 0, 0.5);
  padding: 2px 10px;
  border-radius: 12px;
  z-index: 3;
  pointer-events: none;
}

.night-star {
  position: absolute;
  top: 2px;
  right: 12px;
  font-size: 28px;
  line-height: 1;
  opacity: 0;
  z-index: 4;
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
}

.star-lit {
  opacity: 1;
  transform: translateY(8px) scale(1.15);
  animation: nightlight-pulse 1.8s ease-in-out infinite alternate;
}

@keyframes nightlight-pulse {
  0% { transform: translateY(8px) scale(1); filter: drop-shadow(0 0 6px #ffeb3b); }
  100% { transform: translateY(8px) scale(1.25); filter: drop-shadow(0 0 14px #ffffff); }
}

.bed-blanket {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 85px;
  border-radius: 24px 24px 0 0;
  box-shadow: inset 0 4px 10px rgba(255, 255, 255, 0.35), 0 -4px 12px rgba(0, 0, 0, 0.2);
  border-top: 3px solid rgba(255, 255, 255, 0.3);
  z-index: 5;
  transition: height 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}

.blanket-up {
  height: 185px !important;
}

/* Floating Sleep Bubbles */
.bubbles-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 20;
}

.sleep-bubble {
  position: absolute;
  font-size: 28px;
  color: #bbdefb;
  pointer-events: auto;
  cursor: pointer;
  animation: float-sleep 2.4s ease-out forwards;
}

@keyframes float-sleep {
  0% { transform: translateY(0) scale(0.6); opacity: 0; }
  20% { opacity: 0.9; }
  100% { transform: translateY(-110px) translateX(var(--drift, 15px)) scale(1.2); opacity: 0; }
}

/* All Asleep Celebration Card */
.all-asleep-card {
  position: absolute;
  inset: 0;
  background: rgba(9, 12, 33, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 40;
  backdrop-filter: blur(4px);
  animation: overlay-fade 0.4s ease-out;
}

@keyframes overlay-fade {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.asleep-content {
  background: linear-gradient(180deg, #1e265c 0%, #101538 100%);
  border: 4px solid #ffee58;
  border-radius: 36px;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  max-width: 330px;
  width: 85%;
  text-align: center;
  animation: pop-sleep 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.sleeping-moon {
  font-size: 80px;
  line-height: 1;
  filter: drop-shadow(0 0 16px rgba(255, 238, 88, 0.5));
}

.asleep-title {
  font-size: 24px;
  font-weight: 800;
  color: #fff9c4;
  margin-top: 12px;
}

.new-evening-btn {
  margin-top: 16px;
  background: linear-gradient(135deg, #7986cb 0%, #3f51b5 100%);
  color: #ffffff;
  border: 3px solid #9fa8da;
  font-size: 20px;
  font-weight: 800;
  padding: 10px 32px;
  border-radius: 28px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(63, 81, 181, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
}

.new-evening-btn:hover,
.new-evening-btn:active {
  transform: scale(1.06);
  box-shadow: 0 8px 24px rgba(63, 81, 181, 0.55);
}

.new-evening-btn:focus-visible {
  outline: 4px solid #ffee58;
  outline-offset: 3px;
}

@media (max-height: 600px) {
  .nursery-window { height: 65px; width: 110px; margin-bottom: 6px; }
  .moon-icon { font-size: 28px; }
  .bed-card { height: 190px; }
  .friend-avatar { font-size: 52px; top: 18px; }
  .friend-name { font-size: 13px; top: 76px; }
  .blanket-up { height: 140px !important; }
}

@media (prefers-reduced-motion: reduce) {
  .friend-avatar,
  .bed-blanket,
  .moon-icon,
  .twinkle-star,
  .sleep-bubble,
  .asleep-content {
    animation: none !important;
    transition: none !important;
  }
}
