:root {
  --game-bg: radial-gradient(circle at 50% 25%, #fff9c4 0%, #fff59d 45%, #ffe082 100%);
}

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

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

.next-btn {
  background: linear-gradient(135deg, #ffb300 0%, #f57f17 100%);
  color: #ffffff;
  border: 2px solid #ffe082;
  font-size: 15px;
  font-weight: 800;
  padding: 6px 16px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(245, 127, 23, 0.35);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
  outline: none;
}

.next-btn:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 6px 18px rgba(245, 127, 23, 0.45);
}

.next-btn:active {
  transform: scale(0.95);
}

.next-btn:focus-visible {
  outline: 3px solid #ffb300;
  outline-offset: 2px;
}

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

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

/* Playroom Lighting */
.nursery-ambient {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 10%, rgba(255, 255, 255, 0.5) 0%, transparent 65%);
  pointer-events: none;
  z-index: 1;
}

/* Pyramid Stage */
.pyramid-stage {
  position: relative;
  width: min(88vw, 360px);
  height: 290px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  z-index: 10;
  margin-top: 10px;
}

.pyramid-rod {
  position: relative;
  width: 18px;
  height: 220px;
  background: linear-gradient(90deg, #a1887f 0%, #8d6e63 45%, #6d4c41 100%);
  border-radius: 9px 9px 0 0;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.35), 0 4px 8px rgba(0, 0, 0, 0.15);
  transform-origin: bottom center;
  cursor: pointer;
}

.rod-wobble {
  animation: rod-spring 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes rod-spring {
  0% { transform: rotate(0deg); }
  35% { transform: rotate(3deg); }
  70% { transform: rotate(-2.5deg); }
  100% { transform: rotate(0deg); }
}

.pyramid-base {
  position: relative;
  width: 230px;
  height: 32px;
  background: linear-gradient(180deg, #8d6e63 0%, #6d4c41 50%, #4e342e 100%);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.18), inset 0 3px 5px rgba(255, 255, 255, 0.3);
  border-top: 3px solid #bcaaa4;
}

.base-grain {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent, transparent 25px, rgba(0, 0, 0, 0.04) 25px, rgba(0, 0, 0, 0.04) 50px);
  pointer-events: none;
}

/* Stacked Rings on the Peg */
.stacked-rings {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  z-index: 5;
  pointer-events: auto;
}

.stack-ring {
  height: 38px;
  border-radius: 19px;
  border: 3px solid rgba(255, 255, 255, 0.85);
  box-shadow: inset 0 5px 8px rgba(255, 255, 255, 0.5), inset 0 -5px 8px rgba(0, 0, 0, 0.2), 0 6px 14px rgba(0, 0, 0, 0.16);
  margin-bottom: 2px;
  animation: ring-drop 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: pointer;
  outline: none;
}

.stack-ring:focus-visible {
  outline: 3px solid #ffb300;
  outline-offset: 2px;
}

@keyframes ring-drop {
  0% { transform: translateY(-160px) scale(0.7); opacity: 0; }
  70% { transform: translateY(4px) scale(1.04); }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

.stack-ring.ring-interactive:hover,
.stack-ring.ring-interactive:active {
  transform: scale(1.08) rotate(3deg);
}

.stack-ring.ring-tapped {
  transform: scale(1.08) rotate(3deg);
}

/* Star Topper */
.star-topper {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 20;
  background: transparent;
  border: none;
  padding: 0;
  outline: none;
}

.star-topper:focus-visible {
  outline: 3px solid #ffb300;
  outline-offset: 4px;
  border-radius: 50%;
}

.star-icon {
  font-size: 58px;
  line-height: 1;
  filter: drop-shadow(0 6px 16px rgba(255, 179, 0, 0.7));
  display: inline-block;
  animation: star-glow 0.8s ease-in-out infinite alternate;
}

@keyframes star-glow {
  0% { transform: scale(1); filter: drop-shadow(0 0 6px #ffd54f); }
  100% { transform: scale(1.2) rotate(10deg); filter: drop-shadow(0 0 22px #ff8f00); }
}

/* Tray Container for Choosing Rings */
.tray-container {
  position: relative;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 15;
}

.tray-board {
  position: absolute;
  inset: -6px -12px;
  background: radial-gradient(circle at 50% 30%, #fffde7 0%, #fff9c4 70%, #fff59d 100%);
  border-radius: 28px;
  border: 4px solid #ffffff;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1), inset 0 2px 4px rgba(255, 255, 255, 0.8);
  z-index: 1;
}

.tray-rings {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 12px;
  z-index: 5;
  width: 100%;
  box-sizing: border-box;
}

.tray-ring-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  min-width: 48px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  outline: none;
}

.tray-ring-btn:hover {
  transform: scale(1.15) translateY(-4px);
}

.tray-ring-btn:active {
  transform: scale(0.95);
}

.tray-ring-btn:focus-visible {
  outline: 3px solid #ffb300;
  border-radius: 20px;
}

.tray-ring-pill {
  height: 36px;
  border-radius: 18px;
  border: 3px solid rgba(255, 255, 255, 0.85);
  box-shadow: inset 0 4px 6px rgba(255, 255, 255, 0.5), inset 0 -4px 6px rgba(0, 0, 0, 0.2), 0 4px 10px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.star-tray-pill {
  width: 52px;
  height: 36px;
  border-radius: 18px;
  background: linear-gradient(135deg, #fff176 0%, #ffd54f 50%, #ffb300 100%);
  border: 3px solid #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
  box-shadow: 0 4px 12px rgba(255, 179, 0, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.8);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ring-next-hint .tray-ring-pill,
.ring-next-hint .star-tray-pill {
  animation: next-ring-pulse 1.2s infinite alternate ease-in-out;
}

@keyframes next-ring-pulse {
  0% { transform: scale(1); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15); }
  100% { transform: scale(1.12); box-shadow: 0 8px 20px rgba(255, 179, 0, 0.6); }
}

.ring-wiggle {
  animation: ring-shake 0.35s ease-in-out;
}

@keyframes ring-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px) rotate(-4deg); }
  75% { transform: translateX(6px) rotate(4deg); }
}

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

.pyramid-spark {
  position: absolute;
  font-size: 26px;
  line-height: 1;
  pointer-events: none;
  animation: spark-float 1s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes spark-float {
  0% { transform: translate(0, 0) scale(0.4); opacity: 1; }
  100% { transform: translate(var(--tx, 0), var(--ty, -50px)) scale(1.3) rotate(var(--rot, 35deg)); opacity: 0; }
}

@media (max-height: 600px) {
  .pyramid-stage { height: 230px; }
  .pyramid-rod { height: 175px; }
  .pyramid-base { width: 190px; height: 26px; }
  .stack-ring { height: 30px; border-radius: 15px; }
  .tray-ring-pill { height: 28px; border-radius: 14px; }
  .star-tray-pill { width: 44px; height: 28px; font-size: 18px; }
  .star-topper { top: 8px; }
  .star-icon { font-size: 44px; }
  .next-btn { font-size: 13px; padding: 4px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .pyramid-rod,
  .rod-wobble,
  .stack-ring,
  .star-topper,
  .star-icon,
  .tray-ring-btn,
  .ring-next-hint .tray-ring-pill,
  .ring-next-hint .star-tray-pill,
  .ring-wiggle,
  .ring-tapped,
  .pyramid-spark {
    animation: none !important;
    transition: none !important;
  }
}
