:root {
  --game-bg: radial-gradient(circle at 50% 25%, #1a237e 0%, #0d1238 60%, #050716 100%);
}

.top-controls {
  flex: 0 0 auto;
  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;
  color: #e8eaf6;
  font-weight: 600;
}

.top-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wish-star-btn {
  background: linear-gradient(135deg, #7e57c2 0%, #512da8 100%);
  color: #ffffff;
  border: 2px solid #b39ddb;
  font-size: 15px;
  font-weight: 800;
  padding: 6px 16px;
  border-radius: 20px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(81, 45, 168, 0.4);
  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-constellation-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.4);
  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;
}

.wish-star-btn:hover,
.next-constellation-btn:hover {
  transform: translateY(-2px) scale(1.05);
}

.wish-star-btn:active,
.next-constellation-btn:active {
  transform: scale(0.95);
}

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

.lights-field {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  touch-action: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

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

/* Soft Aurora Borealis Shimmer */
.aurora-layer {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 10%, rgba(38, 198, 218, 0.22) 0%, rgba(126, 87, 194, 0.18) 45%, transparent 75%);
  pointer-events: none;
  z-index: 1;
  animation: aurora-flow 8s ease-in-out infinite alternate;
}

@keyframes aurora-flow {
  0% { opacity: 0.5; transform: scaleY(0.95); }
  100% { opacity: 0.9; transform: scaleY(1.05); }
}

/* Twinkling Ambient Singing Stars */
.ambient-stars-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.ambient-star-btn {
  position: absolute;
  background: none;
  border: none;
  color: #fff9c4;
  font-size: 20px;
  cursor: pointer;
  pointer-events: auto;
  padding: 8px;
  animation: star-twinkle 3s ease-in-out infinite alternate;
  outline: none;
  transition: transform 0.2s ease;
}

.ambient-star-btn:hover {
  transform: scale(1.4) rotate(20deg);
  color: #ffffff;
}

@keyframes star-twinkle {
  0% { opacity: 0.25; transform: scale(0.85); }
  100% { opacity: 0.9; transform: scale(1.25); }
}

/* SVG Line Beams Layer */
.sky-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.guide-line {
  stroke: rgba(255, 255, 255, 0.28);
  stroke-width: 2.5;
  stroke-dasharray: 6 8;
  stroke-linecap: round;
}

.sky-beam {
  stroke: #fff59d;
  stroke-width: 5;
  stroke-linecap: round;
  filter: drop-shadow(0 0 12px #ffeb3b);
  animation: beam-appear 0.35s ease-out;
}

.sky-active-beam {
  stroke: #ffffff;
  stroke-width: 4.5;
  stroke-linecap: round;
  filter: drop-shadow(0 0 14px #fff) drop-shadow(0 0 6px #ffd54f);
}

@keyframes beam-appear {
  0% { stroke-dasharray: 400; stroke-dashoffset: 400; opacity: 0; }
  100% { stroke-dashoffset: 0; opacity: 1; }
}

/* Interactive Star Nodes */
.stars-stage {
  position: absolute;
  inset: 0;
  z-index: 10;
  --star-size: 66px;
  touch-action: none;
}

.star-point-btn {
  position: absolute;
  width: var(--star-size);
  height: var(--star-size);
  margin-left: calc(var(--star-size) / -2);
  margin-top: calc(var(--star-size) / -2);
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 0%, #fff9c4 40%, #ffca28 85%, #f57f17 100%);
  border: 3px solid #ffffff;
  box-shadow: 0 0 20px rgba(255, 235, 59, 0.75);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #e65100;
  font-weight: 900;
  padding: 0;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
  animation: star-pulse 1.4s ease-in-out infinite alternate;
  outline: none;
  touch-action: none;
}

.star-point-btn:hover {
  transform: scale(1.18);
  box-shadow: 0 0 30px #fff;
}

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

.star-point-btn:focus-visible {
  outline: 4px solid #ffee58;
  outline-offset: 4px;
}

.star-active-hint {
  animation: active-star-beacon 1s ease-in-out infinite alternate !important;
}

.star-nudge {
  animation: star-nudge 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

@keyframes star-nudge {
  0% { transform: scale(1); }
  50% { transform: scale(1.36); }
  100% { transform: scale(1); }
}

@keyframes active-star-beacon {
  0% { transform: scale(1); box-shadow: 0 0 16px #ffeb3b; }
  100% { transform: scale(1.28); box-shadow: 0 0 35px #ffffff, 0 0 16px #ffb300; }
}

@keyframes star-pulse {
  0% { transform: scale(0.92); box-shadow: 0 0 12px rgba(255, 235, 59, 0.5); }
  100% { transform: scale(1.12); box-shadow: 0 0 24px rgba(255, 255, 255, 0.9); }
}

.star-connected {
  background: radial-gradient(circle, #ffffff 0%, #fffde7 70%, #fff59d 100%) !important;
  box-shadow: 0 0 30px #ffffff !important;
  color: #f57f17 !important;
  animation: none !important;
  transform: scale(1.05) !important;
}

/* Constellation Reveal Result */
.constellation-result {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20;
  animation: result-fade 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: auto;
}

.result-glow-circle {
  position: absolute;
  width: min(72vw, 320px);
  height: min(72vw, 320px);
  background: radial-gradient(circle, rgba(255, 235, 59, 0.28) 0%, rgba(126, 87, 194, 0.18) 50%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  animation: glow-breathe 2.5s infinite alternate ease-in-out;
}

@keyframes glow-breathe {
  0% { transform: scale(0.85); opacity: 0.6; }
  100% { transform: scale(1.15); opacity: 1; }
}

.result-interactive-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px;
  outline: none;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 5;
}

.result-interactive-btn:hover {
  transform: scale(1.15) rotate(6deg);
}

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

.result-emoji {
  position: relative;
  font-size: min(44vw, 185px);
  line-height: 1;
  filter: drop-shadow(0 0 35px #fff) drop-shadow(0 0 16px #ffd54f);
  display: inline-block;
}

.result-name {
  position: relative;
  font-size: 32px;
  font-weight: 800;
  color: #ffffff;
  margin-top: 14px;
  background: rgba(255, 255, 255, 0.24);
  padding: 8px 32px;
  border-radius: 24px;
  backdrop-filter: blur(10px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  z-index: 5;
}

.result-name:empty {
  display: none;
}

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

/* Shooting Star */
.shooting-star {
  position: absolute;
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  z-index: 15;
  animation: shoot-across 1.1s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes shoot-across {
  0% { transform: translate(-80px, 0) scale(0.5); opacity: 0; }
  25% { opacity: 1; }
  100% { transform: translate(min(90vw, 720px), min(50vh, 260px)) scale(1.3) rotate(-35deg); opacity: 0; }
}

/* Stardust & Sparks */
.sparks-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 25;
}

.comet-spark {
  position: absolute;
  font-size: 26px;
  line-height: 1;
  pointer-events: none;
  animation: spark-fade 0.85s ease-out forwards;
}

@keyframes spark-fade {
  0% { transform: translate(0, 0) scale(0.4); opacity: 1; }
  100% { transform: translate(var(--tx, 0), var(--ty, -30px)) scale(1.2) rotate(var(--rot, 30deg)); opacity: 0; }
}

@media (max-height: 600px), (max-width: 480px) {
  .top-controls .instruction-banner { font-size: 13px; }
  .stars-stage { --star-size: 52px; }
  .result-emoji { font-size: min(30vw, 120px); }
  .result-name { font-size: 22px; padding: 6px 18px; }
  .star-point-btn { font-size: 22px; }
  .wish-star-btn, .next-constellation-btn { font-size: 13px; padding: 4px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .aurora-layer,
  .ambient-star-btn,
  .sky-beam,
  .sky-active-beam,
  .star-point-btn,
  .star-active-hint,
  .star-nudge,
  .result-glow-circle,
  .constellation-result,
  .shooting-star,
  .comet-spark {
    animation: none !important;
    transition: none !important;
  }
}
