/* ============================================
   UNI ANGLE DANCE — STYLES
   Aesthetic: Lisa Frank maximalism meets arcade
   ============================================ */

:root {
  /* Colors */
  --hot-pink: #ff2d9c;
  --neon-cyan: #00f0ff;
  --electric-purple: #a855f7;
  --sunshine: #ffd60a;
  --lime: #b5ff3a;
  --deep-indigo: #1a0f3d;
  --dark-gray: #2a2a32;
  --dark-gray-pause: #3d3d48;

  /* Fonts */
  --font-display: 'Bungee', 'Impact', sans-serif;
  --font-body: 'Fredoka', system-ui, sans-serif;

  /* Shadows */
  --neon-glow-pink: 0 0 20px rgba(255, 45, 156, 0.7), 0 0 40px rgba(255, 45, 156, 0.4);
  --neon-glow-cyan: 0 0 20px rgba(0, 240, 255, 0.7), 0 0 40px rgba(0, 240, 255, 0.4);
  --neon-glow-yellow: 0 0 20px rgba(255, 214, 10, 0.7), 0 0 40px rgba(255, 214, 10, 0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  color: white;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body {
  background: var(--deep-indigo);
}

button {
  font-family: inherit;
  border: none;
  cursor: pointer;
  color: inherit;
  background: none;
}

/* ============================================
   SCREENS
   ============================================ */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.screen.active { display: flex; }

/* ============================================
   TITLE SCREEN
   ============================================ */
#title-screen {
  background: linear-gradient(135deg,
    #ff2d9c 0%,
    #a855f7 35%,
    #00f0ff 70%,
    #ffd60a 100%);
  background-size: 300% 300%;
  animation: titleBgShift 12s ease infinite;
  justify-content: center;
  align-items: center;
  padding: 2rem;
}

@keyframes titleBgShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.title-sparkle-bg {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,0.8) 0%, transparent 2%),
    radial-gradient(circle at 80% 20%, rgba(255,255,255,0.8) 0%, transparent 2%),
    radial-gradient(circle at 40% 80%, rgba(255,255,255,0.8) 0%, transparent 2%),
    radial-gradient(circle at 90% 70%, rgba(255,255,255,0.8) 0%, transparent 2%),
    radial-gradient(circle at 10% 60%, rgba(255,255,255,0.6) 0%, transparent 1.5%);
  background-size: 400px 400px, 350px 350px, 500px 500px, 300px 300px, 450px 450px;
  animation: sparkleFloat 20s linear infinite;
  pointer-events: none;
}

@keyframes sparkleFloat {
  0% { background-position: 0 0, 0 0, 0 0, 0 0, 0 0; }
  100% { background-position: 400px 400px, -350px 350px, 500px -500px, -300px -300px, 450px 450px; }
}

.title-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 700px;
  width: 100%;
}

.game-title {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 10vw, 5.5rem);
  line-height: 0.95;
  margin-bottom: 1.5rem;
  filter: drop-shadow(0 6px 0 rgba(0,0,0,0.3));
}
.title-uni, .title-angle, .title-dance {
  display: inline-block;
  padding: 0 0.2em;
  margin: 0 0.1em;
}
.title-uni {
  color: white;
  text-shadow:
    -3px -3px 0 var(--hot-pink),
    3px -3px 0 var(--hot-pink),
    -3px 3px 0 var(--hot-pink),
    3px 3px 0 var(--hot-pink),
    0 0 30px rgba(255,255,255,0.8);
  transform: rotate(-5deg);
  animation: titleBounce 2s ease-in-out infinite;
}
.title-angle {
  color: var(--sunshine);
  text-shadow:
    -3px -3px 0 var(--deep-indigo),
    3px -3px 0 var(--deep-indigo),
    -3px 3px 0 var(--deep-indigo),
    3px 3px 0 var(--deep-indigo);
  transform: rotate(3deg);
  animation: titleBounce 2s ease-in-out 0.3s infinite;
}
.title-dance {
  color: var(--neon-cyan);
  text-shadow:
    -3px -3px 0 var(--deep-indigo),
    3px -3px 0 var(--deep-indigo),
    -3px 3px 0 var(--deep-indigo),
    3px 3px 0 var(--deep-indigo),
    0 0 30px rgba(0,240,255,0.8);
  transform: rotate(-4deg);
  animation: titleBounce 2s ease-in-out 0.6s infinite;
}
@keyframes titleBounce {
  0%, 100% { transform: rotate(var(--r, 0deg)) translateY(0); }
  50% { transform: rotate(var(--r, 0deg)) translateY(-10px); }
}
.title-uni { --r: -5deg; }
.title-angle { --r: 3deg; }
.title-dance { --r: -4deg; }

.tagline {
  font-size: clamp(1rem, 2.5vw, 1.4rem);
  font-weight: 700;
  margin-bottom: 2rem;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.3);
}

.how-to-play {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 2rem;
}
@media (max-width: 600px) {
  .how-to-play { grid-template-columns: repeat(2, 1fr); }
}
.how-card {
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(255,255,255,0.4);
  border-radius: 16px;
  padding: 1rem 0.5rem;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
}
.how-num {
  display: block;
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: var(--sunshine);
  margin-bottom: 0.3rem;
  text-shadow: 2px 2px 0 var(--deep-indigo);
}

.mega-btn {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  background: var(--sunshine);
  color: var(--deep-indigo);
  padding: 1rem 3rem;
  border-radius: 100px;
  border: 4px solid white;
  box-shadow:
    0 8px 0 rgba(0,0,0,0.4),
    var(--neon-glow-yellow);
  transition: transform 0.1s, box-shadow 0.1s;
  letter-spacing: 0.05em;
}
.mega-btn:hover {
  transform: translateY(-2px);
  box-shadow:
    0 10px 0 rgba(0,0,0,0.4),
    var(--neon-glow-yellow);
}
.mega-btn:active {
  transform: translateY(4px);
  box-shadow:
    0 2px 0 rgba(0,0,0,0.4),
    var(--neon-glow-yellow);
}

.angle-legend {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-top: 2rem;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}
@media (max-width: 600px) {
  .angle-legend { grid-template-columns: repeat(2, 1fr); }
}
.legend-item {
  background: rgba(0,0,0,0.25);
  border-radius: 10px;
  padding: 0.5rem;
  font-size: 0.8rem;
  text-align: center;
}
.legend-item strong {
  display: block;
  font-family: var(--font-display);
  color: var(--sunshine);
  margin-bottom: 0.2rem;
}
.legend-item span {
  opacity: 0.9;
}

/* ============================================
   SONG SELECT SCREEN
   ============================================ */
#song-select-screen {
  background: linear-gradient(135deg,
    #1a0f3d 0%,
    #3d1064 35%,
    #6b1d8a 70%,
    #1a0f3d 100%);
  background-size: 300% 300%;
  animation: titleBgShift 14s ease infinite;
  justify-content: flex-start;
  align-items: center;
  padding: 2rem 1rem;
  overflow-y: auto;
}
.song-select-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1100px;
  text-align: center;
}
.song-select-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.5rem);
  color: var(--sunshine);
  letter-spacing: 0.05em;
  text-shadow:
    -3px -3px 0 var(--hot-pink),
    3px 3px 0 var(--hot-pink),
    0 0 30px rgba(255, 214, 10, 0.6);
  margin-bottom: 0.5rem;
}
.song-select-tagline {
  font-size: clamp(0.9rem, 2vw, 1.2rem);
  font-weight: 600;
  margin-bottom: 1.5rem;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.3);
  opacity: 0.9;
}

.song-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.song-card {
  position: relative;
  background: linear-gradient(135deg, rgba(255,255,255,0.18), rgba(255,255,255,0.05));
  backdrop-filter: blur(10px);
  border: 3px solid rgba(255,255,255,0.4);
  border-radius: 20px;
  padding: 1.2rem 1rem;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, border-color 0.2s;
  text-align: left;
  overflow: hidden;
  isolation: isolate;
}
.song-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--song-accent, linear-gradient(135deg, var(--hot-pink), var(--electric-purple)));
  opacity: 0.45;
  z-index: -1;
  transition: opacity 0.2s;
}
.song-card:hover {
  transform: translateY(-4px);
  border-color: white;
  box-shadow: 0 8px 30px rgba(255, 45, 156, 0.4);
}
.song-card:hover::before {
  opacity: 0.65;
}
.song-card:active {
  transform: translateY(0);
}
.song-card-name {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2vw, 1.4rem);
  color: white;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.5);
  margin-bottom: 0.3rem;
  line-height: 1.1;
}
.song-card-desc {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.85);
  margin-bottom: 0.8rem;
  font-style: italic;
}
.song-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.85);
}
.song-card-time {
  font-family: var(--font-display);
  font-size: 1rem;
  color: var(--sunshine);
}
.song-card-difficulty {
  letter-spacing: 0.1em;
  font-size: 1.1rem;
}

/* Per-card accent colors so each song looks distinct */
.song-card[data-id="rainbow-rush"]      { --song-accent: linear-gradient(135deg, #ff2d9c, #ffd60a); }
.song-card[data-id="sparkle-party"]     { --song-accent: linear-gradient(135deg, #ff5cb8, #ffb700); }
.song-card[data-id="curious-hooves"]    { --song-accent: linear-gradient(135deg, #00f0ff, #b5ff3a); }
.song-card[data-id="wonder-woods"]      { --song-accent: linear-gradient(135deg, #4ade80, #00f0ff); }
.song-card[data-id="cosmic-glow"]       { --song-accent: linear-gradient(135deg, #a855f7, #00f0ff); }
.song-card[data-id="moonlight-stretch"] { --song-accent: linear-gradient(135deg, #6b7afc, #a855f7); }
.song-card[data-id="jungle-jubilee"]    { --song-accent: linear-gradient(135deg, #b5ff3a, #ffd60a); }
.song-card[data-id="rainy-disco"]       { --song-accent: linear-gradient(135deg, #00f0ff, #a855f7); }
.song-card[data-id="focus-field"]       { --song-accent: linear-gradient(135deg, #6b7afc, #ff5cb8); }

/* Tag for super-short songs */
.song-card-tag {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.7rem;
  background: var(--sunshine);
  color: var(--deep-indigo);
  padding: 0.15rem 0.5rem;
  border-radius: 100px;
  letter-spacing: 0.1em;
  margin-left: 0.4rem;
  vertical-align: middle;
}

.back-btn {
  font-family: var(--font-display);
  font-size: clamp(1rem, 2vw, 1.3rem);
  background: rgba(255,255,255,0.15);
  color: white;
  padding: 0.7rem 1.8rem;
  border-radius: 100px;
  border: 2px solid rgba(255,255,255,0.4);
  letter-spacing: 0.05em;
  transition: background 0.15s, transform 0.1s;
  backdrop-filter: blur(8px);
}
.back-btn:hover {
  background: rgba(255,255,255,0.25);
}
.back-btn:active {
  transform: scale(0.96);
}

/* ============================================
   GAME SCREEN
   ============================================ */
#game-screen {
  background: var(--deep-indigo);
  position: relative;
}

.bg-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* Celebration bg - shown when song is playing
   The dominant color shifts based on which category theme is active */
.bg-celebration {
  opacity: 1;
  background:
    radial-gradient(circle at 25% 30%, var(--theme-color-1, rgba(255, 45, 156, 0.55)) 0%, transparent 45%),
    radial-gradient(circle at 75% 70%, var(--theme-color-2, rgba(0, 240, 255, 0.45)) 0%, transparent 45%),
    radial-gradient(circle at 50% 50%, var(--theme-color-3, rgba(168, 85, 247, 0.35)) 0%, transparent 55%),
    linear-gradient(135deg, var(--theme-bg-1, #1a0f3d) 0%, var(--theme-bg-2, #3d0f5d) 50%, var(--theme-bg-1, #1a0f3d) 100%);
  animation: celebrationPulse 1.2s ease-in-out infinite;
  transition: background 0.8s ease;
}

/* Default (no theme set yet) */
#game-screen {
  --theme-color-1: rgba(255, 45, 156, 0.45);
  --theme-color-2: rgba(0, 240, 255, 0.45);
  --theme-color-3: rgba(168, 85, 247, 0.35);
  --theme-bg-1: #1a0f3d;
  --theme-bg-2: #3d0f5d;
}

/* ACUTE = hot pink dominant */
#game-screen.theme-acute {
  --theme-color-1: rgba(255, 45, 156, 0.7);
  --theme-color-2: rgba(255, 100, 180, 0.55);
  --theme-color-3: rgba(255, 45, 156, 0.45);
  --theme-bg-1: #3a0a3d;
  --theme-bg-2: #5d0f45;
}
/* RIGHT = cyan dominant */
#game-screen.theme-right {
  --theme-color-1: rgba(0, 200, 240, 0.7);
  --theme-color-2: rgba(80, 220, 255, 0.55);
  --theme-color-3: rgba(0, 150, 200, 0.45);
  --theme-bg-1: #0a2a3d;
  --theme-bg-2: #0f4d5d;
}
/* OBTUSE = purple dominant */
#game-screen.theme-obtuse {
  --theme-color-1: rgba(168, 85, 247, 0.7);
  --theme-color-2: rgba(192, 132, 252, 0.55);
  --theme-color-3: rgba(140, 70, 220, 0.45);
  --theme-bg-1: #2a0a3d;
  --theme-bg-2: #3d1f5d;
}
/* STRAIGHT = yellow/gold dominant */
#game-screen.theme-straight {
  --theme-color-1: rgba(255, 214, 10, 0.65);
  --theme-color-2: rgba(255, 175, 50, 0.55);
  --theme-color-3: rgba(255, 150, 0, 0.4);
  --theme-bg-1: #3d2a0a;
  --theme-bg-2: #5d3f0f;
}

@keyframes celebrationPulse {
  0%, 100% {
    background-size: 100% 100%, 100% 100%, 100% 100%, 100% 100%;
    filter: brightness(1) saturate(1.2);
  }
  50% {
    background-size: 120% 120%, 120% 120%, 130% 130%, 100% 100%;
    filter: brightness(1.3) saturate(1.5);
  }
}

/* Paused bg - dark gray when waiting for answer */
.bg-paused {
  opacity: 0;
  background: linear-gradient(135deg, var(--dark-gray) 0%, var(--dark-gray-pause) 100%);
}

#game-screen.paused .bg-celebration { opacity: 0; }
#game-screen.paused .bg-paused { opacity: 1; }

/* Wrong answer flash */
#game-screen.wrong .bg-paused {
  background: linear-gradient(135deg, #3a1a1a 0%, #4d2020 100%);
  animation: wrongShake 0.4s ease;
}
@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* HUD */
.hud {
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  gap: 1rem;
}
.hud-left, .hud-right {
  flex: 0 0 auto;
}
.hud-center {
  flex: 1;
  max-width: 400px;
}
.score-label {
  font-family: var(--font-display);
  font-size: 0.7rem;
  color: var(--sunshine);
  letter-spacing: 0.1em;
}
.score-value {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  color: white;
  text-shadow: var(--neon-glow-pink);
  line-height: 1;
}
.progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--hot-pink), var(--sunshine), var(--neon-cyan));
  border-radius: 4px;
  transition: width 0.3s linear;
  box-shadow: 0 0 10px rgba(255, 214, 10, 0.6);
}
.prompts-done {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 0.75;
  margin-top: 0.3rem;
}
.quit-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: 2px solid rgba(255,255,255,0.3);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

/* PLAY AREA: cue card + big Uni side by side */
.play-area {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(1rem, 4vw, 4rem);
  padding: clamp(0.5rem, 2vw, 2rem) clamp(1rem, 4vw, 3rem);
}

/* PROMPT PANEL */
.prompt-panel {
  position: relative;
  z-index: 5;
  text-align: center;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.25s, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  flex: 0 0 auto;
}
.prompt-panel.visible {
  opacity: 1;
  transform: scale(1);
}
/* Preview state: visible but clearly NOT the current question. Greys out so
   kids understand "this is what's coming, not what Uni is currently being." */
.prompt-panel.preview {
  opacity: 1;
  transform: scale(0.7);
}
.prompt-panel.preview .prompt-image-wrap {
  animation: none !important;  /* no wobble */
  transform: rotate(0deg);      /* lock any mid-animation rotation */
  filter: saturate(0) contrast(0.95);
  background: #8a8884;
  background-image: none;       /* kill the grid pattern too */
  border: 4px solid #5a5855;
  box-shadow: none !important;
  opacity: 0.72;                /* applied here so parent stays opaque */
  transition: filter 0.35s ease, background 0.35s ease,
              border-color 0.35s ease, box-shadow 0.35s ease, opacity 0.35s ease;
}
.prompt-panel.preview .prompt-label {
  opacity: 0.6;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.4);
}
.prompt-panel.preview .prompt-label::after {
  content: " (coming up...)";
  color: rgba(0, 240, 255, 0.7);
  font-size: 0.75em;
  letter-spacing: 0.05em;
}
/* When the panel transitions from preview → visible (active question),
   the SVG card "wakes up": colors return, wobble resumes, glow ignites. */
.prompt-panel.visible .prompt-image-wrap {
  animation: promptWobble 1.5s ease-in-out infinite;
  filter: saturate(1) brightness(1);
  background: #fffaf0;
  border-color: white;
  box-shadow: var(--neon-glow-pink);
}
.prompt-panel.minimized {
  opacity: 0.9;
  transform: scale(0.75);
}
.prompt-panel.minimized .prompt-image-wrap {
  animation: none;
  box-shadow: 0 0 12px rgba(255, 214, 10, 0.5);
}
.prompt-label {
  font-family: var(--font-display);
  font-size: clamp(0.9rem, 1.8vw, 1.3rem);
  color: var(--sunshine);
  letter-spacing: 0.15em;
  text-shadow: 2px 2px 0 var(--deep-indigo);
  margin-bottom: 0.6rem;
}
.prompt-image-wrap {
  position: relative;
  width: clamp(180px, 32vmin, 440px);
  height: clamp(180px, 32vmin, 440px);
  margin: 0 auto;
  background: #fffaf0;
  background-image:
    linear-gradient(rgba(26, 15, 61, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26, 15, 61, 0.05) 1px, transparent 1px);
  background-size: 24px 24px;
  border-radius: 32px;
  border: 4px solid white;
  box-shadow: var(--neon-glow-pink);
  overflow: hidden;
  animation: promptWobble 1.5s ease-in-out infinite;
  display: flex;
  align-items: center;
  justify-content: center;
}
.angle-svg {
  width: 90%;
  height: 90%;
  display: block;
}
@keyframes promptWobble {
  0%, 100% { transform: rotate(-2deg); }
  50% { transform: rotate(2deg); }
}

/* COUNT-IN INDICATOR — shows big 4/3/2/1 below the cue card during count-in */
.count-indicator {
  height: 2.5rem;
  margin-top: 0.5rem;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3.5vw, 2.4rem);
  color: var(--sunshine);
  text-shadow:
    -2px -2px 0 var(--deep-indigo),
    2px -2px 0 var(--deep-indigo),
    -2px 2px 0 var(--deep-indigo),
    2px 2px 0 var(--deep-indigo),
    0 0 20px rgba(255, 214, 10, 0.9);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.count-indicator.active {
  opacity: 1;
}
.count-indicator.pulse {
  animation: countPulse 0.5s ease-out;
}
@keyframes countPulse {
  0% { transform: scale(2); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* STAGE CATEGORY LABEL — huge text behind Uni showing current category */
.stage-category-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-size: clamp(3rem, 9vw, 8rem);
  color: rgba(255, 255, 255, 0.12);
  letter-spacing: 0.1em;
  white-space: nowrap;
  pointer-events: none;
  z-index: 1;
  font-weight: bold;
  text-shadow:
    -2px -2px 0 rgba(0,0,0,0.2),
    2px 2px 0 rgba(0,0,0,0.2);
  transition: color 0.5s ease;
}
#prompt-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.prompt-category {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--hot-pink);
  color: white;
  font-family: var(--font-display);
  font-size: 0.9rem;
  padding: 0.3rem;
  letter-spacing: 0.1em;
}

/* STAGE */
.stage {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  min-width: 0;
  max-height: 100%;
}
.stage-uni {
  position: relative;
  z-index: 2;
  max-height: 100%;
  max-width: 100%;
  height: clamp(240px, 60vh, 900px);
  object-fit: contain;
  filter: drop-shadow(0 10px 30px rgba(0,0,0,0.4));
  transition: transform 0.15s ease-out, filter 0.2s;
}
#game-screen.paused .stage-uni {
  animation: none;
  filter: drop-shadow(0 10px 30px rgba(0,0,0,0.4)) grayscale(0.3) brightness(0.85);
}
#game-screen.wrong .stage-uni {
  animation: stageUniWrong 0.4s ease;
}
@keyframes stageUniWrong {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-15px) rotate(-3deg); }
  75% { transform: translateX(15px) rotate(3deg); }
}
.stage-uni.correct-pop {
  animation: correctPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes correctPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.15) rotate(-3deg); }
  70% { transform: scale(1.08) rotate(2deg); }
  100% { transform: scale(1); }
}

.stage-sparkles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* POSE BUTTONS */
.pose-buttons {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(0.5rem, 1vw, 1rem);
  padding: clamp(0.5rem, 1.5vw, 1.2rem);
  padding-bottom: max(clamp(0.75rem, 1.5vw, 1.2rem), env(safe-area-inset-bottom));
  flex: 0 0 auto;
  height: clamp(140px, 26vh, 280px);
}
.pose-btn {
  position: relative;
  background: linear-gradient(135deg, rgba(255,255,255,0.15), rgba(255,255,255,0.05));
  border: 4px solid rgba(255,255,255,0.5);
  border-radius: 24px;
  padding: 0.5rem clamp(0.5rem, 1.5vw, 1.2rem);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: clamp(0.25rem, 1vw, 0.8rem);
  transition: transform 0.1s, box-shadow 0.15s, border-color 0.15s;
  min-height: 0;
  overflow: hidden;
}
.pose-btn img {
  width: auto;
  height: 100%;
  max-width: 45%;
  object-fit: contain;
  flex: 0 0 auto;
}
.pose-label {
  font-family: var(--font-display);
  font-size: clamp(1rem, 2.2vw, 2rem);
  letter-spacing: 0.05em;
  color: white;
  text-shadow: 3px 3px 0 rgba(0,0,0,0.5);
  flex: 1 1 auto;
  text-align: center;
  line-height: 1;
}

.pose-btn[data-category="acute"] {
  background: linear-gradient(135deg, var(--hot-pink), #c41c7a);
  border-color: #ff5cb8;
}
.pose-btn[data-category="right"] {
  background: linear-gradient(135deg, var(--neon-cyan), #009ca8);
  border-color: #66f6ff;
}
.pose-btn[data-category="obtuse"] {
  background: linear-gradient(135deg, var(--electric-purple), #6b21c9);
  border-color: #c084fc;
}
.pose-btn[data-category="straight"] {
  background: linear-gradient(135deg, var(--sunshine), #c29500);
  border-color: #ffe14d;
}
.pose-btn[data-category="straight"] .pose-label {
  color: var(--deep-indigo);
  text-shadow: 1px 1px 0 rgba(255,255,255,0.4);
}

.pose-btn:active,
.pose-btn.pressed {
  transform: scale(0.92);
}
.pose-btn.correct-flash {
  animation: correctFlash 0.5s ease;
}
@keyframes correctFlash {
  0%, 100% { box-shadow: 0 0 0 rgba(255,255,255,0); }
  50% { box-shadow: 0 0 30px 10px white; border-color: white; }
}
.pose-btn.wrong-flash {
  animation: wrongFlash 0.4s ease;
}
@keyframes wrongFlash {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(0.88); filter: brightness(0.5); }
}

/* While dancing (song playing, no prompt up): buttons visible but clearly
   not interactive. Colors stay so kids can see which one the bg is matching. */
#game-screen:not(.paused) .pose-btn {
  pointer-events: none;
  filter: brightness(0.7) saturate(0.9);
  transition: filter 0.4s ease;
}
/* Subtle "you're active" highlight on the button matching current category */
#game-screen.theme-acute:not(.paused) .pose-btn[data-category="acute"],
#game-screen.theme-right:not(.paused) .pose-btn[data-category="right"],
#game-screen.theme-obtuse:not(.paused) .pose-btn[data-category="obtuse"],
#game-screen.theme-straight:not(.paused) .pose-btn[data-category="straight"] {
  filter: brightness(1.05) saturate(1.1);
  border-color: white;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

/* Sparkle particle (emitted on correct hit) */
.spark {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  pointer-events: none;
  animation: sparkFly 0.9s ease-out forwards;
}
@keyframes sparkFly {
  0% {
    transform: translate(-50%, -50%) scale(0);
    opacity: 1;
  }
  50% { opacity: 1; }
  100% {
    transform: translate(var(--tx), var(--ty)) scale(0);
    opacity: 0;
  }
}

/* ============================================
   RESULTS SCREEN
   ============================================ */
#results-screen {
  background:
    radial-gradient(circle at 25% 25%, rgba(255, 45, 156, 0.35) 0%, transparent 45%),
    radial-gradient(circle at 75% 75%, rgba(0, 240, 255, 0.35) 0%, transparent 45%),
    radial-gradient(circle at 50% 50%, rgba(255, 214, 10, 0.25) 0%, transparent 50%),
    linear-gradient(135deg, #1a0f3d 0%, #3d0f5d 50%, #1a0f3d 100%);
  background-size: 150% 150%, 150% 150%, 200% 200%, 100% 100%;
  animation: resultsBgShift 10s ease-in-out infinite;
  justify-content: center;
  align-items: center;
  padding: clamp(1rem, 3vw, 2rem);
}
@keyframes resultsBgShift {
  0%, 100% { background-position: 0% 0%, 100% 100%, 50% 50%, 0% 0%; }
  50% { background-position: 30% 20%, 70% 80%, 60% 40%, 0% 0%; }
}

.results-sparkle-bg {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 15% 35%, rgba(255,255,255,0.7) 0%, transparent 1.5%),
    radial-gradient(circle at 85% 25%, rgba(255,255,255,0.7) 0%, transparent 1.5%),
    radial-gradient(circle at 40% 80%, rgba(255,255,255,0.7) 0%, transparent 1.5%),
    radial-gradient(circle at 92% 75%, rgba(255,255,255,0.7) 0%, transparent 1.5%),
    radial-gradient(circle at 25% 60%, rgba(255,255,255,0.5) 0%, transparent 1%);
  background-size: 400px 400px, 350px 350px, 500px 500px, 300px 300px, 450px 450px;
  animation: sparkleFloat 20s linear infinite;
  pointer-events: none;
}

.results-content {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "uni     score"
    "uni     score"
    "stats   stats"
    "buttons buttons";
  gap: clamp(1rem, 3vw, 2.5rem);
  align-items: center;
  max-width: 1100px;
  width: 100%;
}

/* Uni hero image */
.results-uni-wrap {
  grid-area: uni;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}
.results-uni {
  max-width: 100%;
  max-height: clamp(280px, 55vh, 520px);
  width: auto;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 15px 40px rgba(0,0,0,0.5));
  animation: resultsUniBounce 2.2s ease-in-out infinite;
}
@keyframes resultsUniBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-12px) scale(1.02); }
}

.results-new-best {
  position: absolute;
  top: 5%;
  right: -5%;
  background: linear-gradient(135deg, var(--sunshine), #ffb700);
  color: var(--deep-indigo);
  font-family: var(--font-display);
  font-size: clamp(0.9rem, 2vw, 1.3rem);
  padding: 0.5rem 1.2rem;
  border-radius: 100px;
  border: 3px solid white;
  letter-spacing: 0.1em;
  transform: rotate(12deg) scale(0);
  box-shadow:
    0 4px 0 rgba(0,0,0,0.3),
    0 0 25px rgba(255, 214, 10, 0.8);
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}
.results-new-best.show {
  animation: newBestPop 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s forwards,
             newBestWiggle 1.5s ease-in-out 1.1s infinite;
}
@keyframes newBestPop {
  0% { transform: rotate(12deg) scale(0); opacity: 0; }
  60% { transform: rotate(12deg) scale(1.2); opacity: 1; }
  100% { transform: rotate(12deg) scale(1); opacity: 1; }
}
@keyframes newBestWiggle {
  0%, 100% { transform: rotate(12deg) scale(1); }
  50% { transform: rotate(16deg) scale(1.05); }
}

/* Score area */
.results-score-area {
  grid-area: score;
  text-align: center;
}
.results-rating {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 3.5vw, 2.4rem);
  color: var(--sunshine);
  text-shadow:
    -2px -2px 0 var(--hot-pink),
    2px 2px 0 var(--hot-pink),
    0 0 25px rgba(255, 214, 10, 0.6);
  margin-bottom: 1rem;
  line-height: 1.1;
  min-height: 2em;
  animation: titleBounce 1.5s ease-in-out infinite;
}
.final-score-label {
  font-family: var(--font-display);
  font-size: clamp(0.85rem, 1.5vw, 1.1rem);
  color: var(--neon-cyan);
  letter-spacing: 0.2em;
  margin-bottom: 0.4rem;
  opacity: 0.9;
}
.final-score {
  font-family: var(--font-display);
  font-size: clamp(3rem, 9vw, 6rem);
  color: white;
  text-shadow:
    -3px -3px 0 var(--hot-pink),
    3px 3px 0 var(--hot-pink),
    0 0 40px rgba(255, 45, 156, 0.7);
  line-height: 1;
  margin-bottom: 0.8rem;
}
.results-best-score {
  font-family: var(--font-display);
  font-size: clamp(0.8rem, 1.4vw, 1.1rem);
  color: rgba(255,255,255,0.8);
  letter-spacing: 0.1em;
}
.results-best-score span {
  color: var(--sunshine);
  margin-left: 0.5em;
}

/* Stats row */
.results-stats {
  grid-area: stats;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  max-width: 700px;
  margin: 0 auto;
  width: 100%;
}
.stat {
  background: rgba(255,255,255,0.12);
  border: 2px solid rgba(255,255,255,0.25);
  border-radius: 16px;
  padding: 0.8rem 0.5rem;
  backdrop-filter: blur(8px);
}
.stat-value {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2.2vw, 1.6rem);
  color: var(--sunshine);
}
.stat-label {
  font-size: clamp(0.6rem, 1vw, 0.8rem);
  letter-spacing: 0.1em;
  opacity: 0.85;
  margin-top: 0.2rem;
  text-transform: uppercase;
}

/* Buttons */
.results-buttons {
  grid-area: buttons;
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.mega-btn-secondary {
  background: rgba(255,255,255,0.15);
  color: white;
  border-color: rgba(255,255,255,0.5);
  backdrop-filter: blur(8px);
  font-size: clamp(1.1rem, 3vw, 1.8rem);
  padding: 0.85rem 2rem;
  box-shadow:
    0 6px 0 rgba(0,0,0,0.3);
}
.mega-btn-secondary:hover {
  background: rgba(255,255,255,0.25);
}

/* Narrow screens: stack Uni above score */
@media (max-width: 720px) {
  .results-content {
    grid-template-columns: 1fr;
    grid-template-areas:
      "uni"
      "score"
      "stats"
      "buttons";
    gap: 1rem;
  }
  .results-uni { max-height: 35vh; }
  .results-new-best {
    right: 10%;
  }
}

/* Short screens: Uni smaller so everything fits */
@media (max-height: 700px) {
  .results-uni { max-height: clamp(200px, 45vh, 340px); }
  .results-rating { margin-bottom: 0.5rem; font-size: clamp(1.1rem, 2.5vw, 1.6rem); }
  .final-score { font-size: clamp(2.4rem, 7vw, 4.5rem); margin-bottom: 0.4rem; }
  .results-stats { gap: 0.5rem; }
  .stat { padding: 0.5rem 0.4rem; }
}

/* ============================================
   LAYOUT TWEAKS
   ============================================ */

/* On narrow screens, stack prompt above stage instead of side-by-side,
   and put label below button image since horizontal won't fit */
@media (max-width: 640px) {
  .play-area {
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.5rem;
  }
  .prompt-image-wrap {
    width: clamp(130px, 30vw, 200px);
    height: clamp(130px, 30vw, 200px);
  }
  .stage-uni { height: clamp(200px, 40vh, 320px); }

  .pose-btn {
    flex-direction: column;
    padding: 0.4rem 0.3rem;
    gap: 0.15rem;
  }
  .pose-btn img {
    max-width: 100%;
    height: auto;
    max-height: 70%;
    flex: 1 1 auto;
    min-height: 0;
  }
  .pose-label {
    font-size: 0.8rem;
    flex: 0 0 auto;
  }
  .pose-buttons {
    height: clamp(110px, 20vh, 180px);
  }
}

/* Short screens (landscape phones, compact laptops) */
@media (max-height: 600px) {
  .how-to-play { display: none; }
  .stage-uni { height: clamp(180px, 55vh, 500px); }
  .prompt-image-wrap {
    width: clamp(140px, 24vmin, 260px);
    height: clamp(140px, 24vmin, 260px);
  }
  .pose-buttons { height: clamp(100px, 22vh, 180px); }
}
