:root {
  --bg-color: #0f172a;
  --card-bg: #1e293b;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --accent-color: #38bdf8;
  --success-color: #10b981;
  --border-radius: 16px;
}

[data-theme="light"] {
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --accent-color: #0ea5e9;
}

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

body {
  font-family: 'Outfit', sans-serif;
  background: linear-gradient(135deg, var(--bg-color), var(--card-bg));
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  transition: background 0.3s ease, color 0.3s ease;
}

/* Screen Management */
.app-container {
  width: 100%;
  display: flex;
  justify-content: center;
}

.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  width: 100%;
  position: relative;
  z-index: 10;
}

.screen.active {
  display: flex;
}

/* Base Buttons */
.btn {
  padding: 1.2rem 2.5rem;
  font-size: 1.25rem;
  font-weight: 800;
  color: white;
  background: var(--accent-color);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
  font-family: inherit;
  margin-top: 1rem;
  box-shadow: 0 4px 15px rgba(56, 189, 248, 0.3);
}

.btn:hover:not(:disabled) {
  transform: translateY(-3px);
  background: #0284c7;
  box-shadow: 0 6px 20px rgba(56, 189, 248, 0.4);
}

.btn:disabled {
  background: #475569;
  color: #94a3b8;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: #334155;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.btn-secondary:hover:not(:disabled) {
  background: #475569;
}

.btn-small {
  padding: 0.6rem 1.2rem;
  font-size: 1rem;
  margin-top: 0;
}

.btn-success {
  background: var(--success-color);
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-success:hover:not(:disabled) {
  background: #059669;
}

/* Moving Nebula/Starfield for Level Select */
#level-select-screen::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at center, rgba(30, 41, 59, 0) 0%, rgba(15, 23, 42, 0.4) 100%),
    repeating-radial-gradient(circle at center, rgba(56, 189, 248, 0.05) 0%, transparent 10%, rgba(139, 92, 246, 0.05) 20%);
  animation: nebulaPulse 20s infinite alternate linear;
  z-index: -2;
  pointer-events: none;
}

[data-theme="light"] #level-select-screen::before {
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0) 0%, rgba(226, 232, 240, 0.4) 100%),
    repeating-radial-gradient(circle at center, rgba(14, 165, 233, 0.05) 0%, transparent 10%, rgba(139, 92, 246, 0.05) 20%);
}

@keyframes nebulaPulse {
  0% {
    transform: scale(1) rotate(0deg);
  }

  100% {
    transform: scale(1.1) rotate(5deg);
  }
}

/* Floating Orbs */
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  z-index: -1;
  pointer-events: none;
  animation: floatOrb 10s infinite ease-in-out alternate;
}

.orb-1 {
  top: 5%;
  left: 10%;
  width: 300px;
  height: 300px;
  background: rgba(56, 189, 248, 0.4);
  animation-delay: 0s;
}

.orb-2 {
  bottom: -10%;
  right: 5%;
  width: 400px;
  height: 400px;
  background: rgba(139, 92, 246, 0.3);
  animation-delay: -3s;
}

.orb-3 {
  top: 40%;
  right: -5%;
  width: 250px;
  height: 250px;
  background: rgba(16, 185, 129, 0.2);
  animation-delay: -5s;
}

.orb-4 {
  bottom: 20%;
  left: -10%;
  width: 350px;
  height: 350px;
  background: rgba(56, 189, 248, 0.2);
  animation-delay: -7s;
}

[data-theme="light"] .orb-1 {
  background: rgba(56, 189, 248, 0.6);
}

[data-theme="light"] .orb-2 {
  background: rgba(139, 92, 246, 0.5);
}

[data-theme="light"] .orb-3 {
  background: rgba(16, 185, 129, 0.4);
}

[data-theme="light"] .orb-4 {
  background: rgba(56, 189, 248, 0.4);
}

@keyframes floatOrb {
  0% {
    transform: translate(0, 0) scale(1);
  }

  100% {
    transform: translate(30px, -50px) scale(1.2);
  }
}

/* Level Select Screen Extras */
.mission-title {
  font-size: 3.5rem;
  position: relative;
  display: inline-block;
  padding-bottom: 5px;
  margin-top: 2rem;
}

.mission-title::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 10%;
  width: 80%;
  height: 4px;
  background: var(--accent-color);
  border-radius: 2px;
  box-shadow: 0 0 10px var(--accent-color), 0 0 20px var(--accent-color);
}

.pagination-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  width: 100%;
  max-width: 800px;
  margin: 3rem 0;
}

#btn-prev-page:disabled,
#btn-next-page:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
}

/* Sci-Fi Navigation Arrows */
.sci-fi-nav {
  font-family: monospace;
  font-size: 2.5rem;
  font-weight: bold;
  color: var(--accent-color);
  background: rgba(15, 23, 42, 0.6);
  border: 2px solid var(--accent-color);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.4), inset 0 0 10px rgba(56, 189, 248, 0.2);
  transition: all 0.3s ease;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.sci-fi-nav:hover:not(:disabled) {
  background: var(--accent-color);
  color: #fff;
  box-shadow: 0 0 25px rgba(56, 189, 248, 0.8), inset 0 0 15px rgba(255, 255, 255, 0.5);
  transform: scale(1.15) !important;
}

[data-theme="light"] .sci-fi-nav {
  background: rgba(255, 255, 255, 0.8);
  border: 2px solid #0ea5e9;
  color: #0ea5e9;
  box-shadow: 0 0 15px rgba(14, 165, 233, 0.3), inset 0 0 10px rgba(14, 165, 233, 0.1);
}

[data-theme="light"] .sci-fi-nav:hover:not(:disabled) {
  background: #0ea5e9;
  color: white;
  box-shadow: 0 0 25px rgba(14, 165, 233, 0.6), inset 0 0 15px rgba(255, 255, 255, 0.6);
}

/* Level Select Grid */
.level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1.5rem;
  width: 100%;

  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  padding: 2.5rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4), inset 0 0 20px rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .level-grid {
  background: rgba(255, 255, 255, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1), inset 0 0 20px rgba(255, 255, 255, 0.5);
}

.level-btn {
  width: 80px;
  height: 80px;
  display: flex;
  position: relative;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin: 0;
  padding: 0;
  border-radius: 12px;

  /* Glassmorphism base */
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
}

[data-theme="light"] .level-btn {
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  color: var(--text-primary);
}

.level-btn.completed {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.5);
  color: var(--success-color);
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.2);
}

[data-theme="light"] .level-btn.completed {
  background: rgba(16, 185, 129, 0.1);
}

/* Button Hover Glow and Pop */
.level-btn span:first-child {
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.level-btn:not(.locked):hover {
  transform: scale(1.15) translateY(-5px);
  z-index: 10;
}

.level-btn:not(.locked):hover span:first-child {
  transform: scale(1.3);
}

.level-btn.completed:hover {
  box-shadow: 0 10px 25px rgba(16, 185, 129, 0.4), 0 0 20px rgba(16, 185, 129, 0.6);
  border-color: #10b981;
}

.level-btn.current {
  animation: levelPulseCycle 2s infinite;
  border-color: #8b5cf6;
  background: rgba(139, 92, 246, 0.15);
  color: #c4b5fd;
  text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

[data-theme="light"] .level-btn.current {
  color: #6d28d9;
  text-shadow: none;
}

.level-btn.current:hover {
  animation: none;
  box-shadow: 0 10px 25px rgba(139, 92, 246, 0.6), 0 0 30px rgba(56, 189, 248, 0.8);
  border-color: #38bdf8;
}

@keyframes levelPulseCycle {
  0% {
    box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.7), inset 0 0 10px rgba(56, 189, 248, 0.3);
    border-color: #38bdf8;
  }

  50% {
    box-shadow: 0 0 20px 5px rgba(139, 92, 246, 0.6), inset 0 0 25px rgba(139, 92, 246, 0.4);
    border-color: #8b5cf6;
  }

  100% {
    box-shadow: 0 0 0 0 rgba(56, 189, 248, 0), inset 0 0 10px rgba(56, 189, 248, 0);
    border-color: #38bdf8;
  }
}

.level-btn.locked {
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-secondary);
  border-color: rgba(255, 255, 255, 0.05);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

[data-theme="light"] .level-btn.locked {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.05);
}

.level-icon {
  position: absolute;
  top: -10px;
  right: -10px;
  animation: floatLock 3s ease-in-out infinite;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: 50%;
  padding: 6px;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
}

[data-theme="light"] .level-icon {
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.15);
}

@keyframes floatLock {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-4px);
  }
}

/* 3D Silver Lock Styles */
.silver-lock {
  overflow: visible;
}

.silver-lock .lock-body {
  fill: url(#metalShineDark);
  stroke: #64748b;
}

.silver-lock .lock-shackle {
  stroke: #cbd5e1;
}

[data-theme="light"] .silver-lock .lock-body {
  fill: #cbd5e1;
  stroke: #94a3b8;
}

[data-theme="light"] .silver-lock .lock-shackle {
  stroke: #94a3b8;
}

.icon-check {
  filter: drop-shadow(0 0 5px rgba(16, 185, 129, 0.5));
}

/* Game Wrapper */
.game-wrapper {
  max-width: 1400px;
  background: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 1rem 2rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

header {
  text-align: center;
  margin-bottom: 0.5rem;
  width: 100%;
}

.header-top {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
}

.header-top .btn-secondary {
  position: absolute;
  left: 0;
}

h1 {
  font-size: 3rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-color), #818cf8);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -1px;
  margin-bottom: 1rem;
}

.stats-panel {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 0.5rem;
}

.stat-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.5rem 1.5rem;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent-color);
}

#game-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: 1.5rem;
  border-radius: 12px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  /* Transition setup */
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  height: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

#game-message.game-over {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
}

/* Confetti System */
.confetti {
  position: fixed;
  top: -20px;
  width: 12px;
  height: 12px;
  z-index: 9999;
  animation: confettiFall 3s linear forwards;
  opacity: 0.9;
  border-radius: 2px;
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg) scale(1);
  }

  100% {
    transform: translateY(110vh) rotate(720deg) scale(0.5);
    opacity: 0;
  }
}

#game-message.show {
  opacity: 1;
  transform: translateY(0);
  height: auto;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

#game-message-text {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--success-color);
}

.game-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: start;
  width: 100%;
}

.image-wrapper h3 {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  font-weight: 600;
  font-size: 1.25rem;
}

.image-container {
  position: relative;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: repeating-conic-gradient(#334155 0% 25%, transparent 0% 50%) 50% / 20px 20px;
  background-color: #1e293b;
  display: flex;
}

.image-container.interactive {
  cursor: crosshair;
  transition: border-color 0.3s ease;
}

.image-container.interactive:hover {
  border-color: var(--accent-color);
}

.image-container img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  pointer-events: auto;
}

.instruction {
  text-align: center;
  color: var(--accent-color);
  margin-top: 0.25rem;
  font-weight: 600;
  font-size: 1rem;
  animation: pulse 2s infinite;
}

/* Difference Marker Styles */
.difference-marker {
  position: absolute;
  border: 4px solid var(--success-color);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  /* Crucial for perfectly centering against left/top logic */
  box-shadow:
    0 0 15px rgba(16, 185, 129, 0.6),
    inset 0 0 15px rgba(16, 185, 129, 0.6);
  pointer-events: none;
  animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popIn {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.3);
  }

  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes pulse {
  0% {
    opacity: 0.8;
  }

  50% {
    opacity: 0.4;
  }

  100% {
    opacity: 0.8;
  }
}

/* Global Effects Container */
.global-effects {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

/* Start Screen Layout Container */
.start-screen-layout {
  min-height: 80vh;
  border-radius: 20px;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 10;
}

.smoke-bg {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at center, #1e293b 0%, transparent 50%),
    radial-gradient(circle at bottom right, #334155 0%, transparent 40%);
  filter: blur(60px);
  animation: smokeDrift 15s infinite alternate ease-in-out;
  z-index: 0;
  pointer-events: none;
  transition: background 0.3s;
}

[data-theme="light"] .smoke-bg {
  background: radial-gradient(circle at center, #e2e8f0 0%, transparent 50%),
    radial-gradient(circle at bottom right, #cbd5e1 0%, transparent 40%);
}

@keyframes smokeDrift {
  0% {
    transform: translate(0, 0) scale(1);
  }

  100% {
    transform: translate(10%, 10%) scale(1.2);
  }
}

.top-controls {
  position: absolute;
  top: 15px;
  right: 15px;
  display: flex;
  gap: 10px;
  z-index: 20;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.1) rotate(5deg);
}

[data-theme="light"] .icon-btn {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
  color: var(--text-primary);
}

[data-theme="light"] .icon-btn:hover {
  background: rgba(0, 0, 0, 0.1);
}

/* Auto Rainbow Rubber Band Title */
.auto-rainbow-title {
  font-family: 'Outfit', sans-serif;
  font-size: 4rem;
  font-weight: 800;
  margin: 0 0 0.25rem 0;
  z-index: 10;
  text-align: center;
  background: linear-gradient(to right, #ef4444, #f97316, #eab308, #22c55e, #3b82f6, #6366f1, #ef4444);
  background-size: 200% auto;
  color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
  animation: rainbowSweep 3s linear infinite, autoRubberBand 4s ease-in-out infinite;
}

@keyframes rainbowSweep {
  to {
    background-position: 200% center;
  }
}

@keyframes autoRubberBand {

  0%,
  40%,
  100% {
    transform: scaleX(1);
  }

  5% {
    transform: scale3d(1.15, 0.85, 1);
  }

  10% {
    transform: scale3d(0.85, 1.15, 1);
  }

  15% {
    transform: scale3d(1.05, 0.95, 1);
  }

  20% {
    transform: scale3d(0.95, 1.05, 1);
  }

  25% {
    transform: scale3d(1.02, 0.98, 1);
  }
}

/* Minimal Subtitle (Clean & Static Fade) */
.minimal-subtitle {
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 1.25rem;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  text-align: center;
  font-weight: 500;
  z-index: 10;
  opacity: 0;
  animation: simpleFadeIn 1s forwards ease-out;
  animation-delay: 0.5s;
}

@keyframes simpleFadeIn {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Floating Parallax Particles */
body:has(#start-screen.active) .parallax-particles {
  opacity: 1;
}

.parallax-particles {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.parallax-group {
  position: absolute;
  bottom: -150px;
  animation: floatUpParallax 15s infinite linear;
}

.parallax-group::before,
.parallax-group::after {
  display: block;
  position: absolute;
  font-size: 2rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.parallax-group::before {
  content: '?';
  color: rgba(56, 189, 248, 0.4);
}

.parallax-group::after {
  content: '🔍';
  font-size: 1.5rem;
  top: 30px;
  left: 40px;
}

[data-theme="light"] .parallax-group::before {
  color: rgba(14, 165, 233, 0.4);
}

.p-g1 {
  left: 10%;
  animation-duration: 12s;
  z-index: 1;
  transform: scale(0.6);
}

.p-g2 {
  left: 30%;
  animation-duration: 16s;
  animation-delay: -2s;
  z-index: 3;
  transform: scale(1.2);
}

.p-g3 {
  left: 50%;
  animation-duration: 20s;
  animation-delay: -5s;
  z-index: 2;
  transform: scale(0.9);
  filter: blur(1px);
}

.p-g4 {
  left: 70%;
  animation-duration: 14s;
  animation-delay: -1s;
  z-index: 4;
  transform: scale(1.5);
}

.p-g5 {
  left: 85%;
  animation-duration: 18s;
  animation-delay: -7s;
  z-index: 1;
  transform: scale(0.7);
}

.p-g6 {
  left: 20%;
  animation-duration: 22s;
  animation-delay: -4s;
  z-index: 5;
  transform: scale(1.8);
  filter: blur(2px);
}

@keyframes floatUpParallax {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 0;
  }

  10% {
    opacity: 1;
  }

  90% {
    opacity: 1;
  }

  100% {
    transform: translateY(-1200px) rotate(360deg);
    opacity: 0;
  }
}

/* Static Character Image */
.start-character-static {
  display: block;
  width: 18%;
  max-width: 250px;
  height: auto;
  margin: -6rem auto 0 auto;
  z-index: 10;
  filter: drop-shadow(0 15px 25px rgba(0, 0, 0, 0.4));
}

/* Theme Transition Overlay */
.theme-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: transparent;
  z-index: 9999;
  pointer-events: none;
  clip-path: circle(0px at 50% 50%);
}

/* Neon Jello Button Base */
.neon-jello-btn {
  padding: 1.2rem 3rem;
  font-size: 1.25rem;
  font-weight: 800;
  font-family: inherit;
  background-color: transparent;
  color: var(--text-primary);
  border: 2px solid #8b5cf6;
  border-radius: 8px;
  cursor: pointer;
  position: relative;
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease, text-shadow 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 10;
  letter-spacing: 2px;
  box-shadow: 0 0 15px #8b5cf6, inset 0 0 15px #8b5cf6;
  animation: neonCyclePulse 2s infinite alternate, jelloLoad 1s ease-out;
  margin-top: 3rem;
}

@keyframes neonCyclePulse {
  0% {
    box-shadow: 0 0 10px #3b82f6, inset 0 0 10px #3b82f6;
    border-color: #3b82f6;
    text-shadow: 0 0 5px #3b82f6;
  }

  100% {
    box-shadow: 0 0 25px #a855f7, inset 0 0 20px #a855f7;
    border-color: #a855f7;
    text-shadow: 0 0 10px #a855f7;
  }
}

@keyframes jelloLoad {

  0%,
  100% {
    transform: scale3d(1, 1, 1);
  }

  30% {
    transform: scale3d(1.25, 0.75, 1);
  }

  40% {
    transform: scale3d(0.75, 1.25, 1);
  }

  50% {
    transform: scale3d(1.15, 0.85, 1);
  }

  65% {
    transform: scale3d(0.95, 1.05, 1);
  }

  75% {
    transform: scale3d(1.05, 0.95, 1);
  }
}

/* Red Shake Hover */
.neon-jello-btn:hover {
  background-color: #ef4444;
  color: white;
  border-color: #ef4444;
  box-shadow: 0 0 35px rgba(239, 68, 68, 0.9), inset 0 0 15px rgba(239, 68, 68, 0.6);
  text-shadow: none;
  transform: scale(1.1);
  /* Explicitly scales button 10% in the core hover layout */
  animation: vibrateRedAlert 0.1s infinite;
}

@keyframes vibrateRedAlert {
  0% {
    transform: scale(1.1) translate(2px, 2px) rotate(1deg);
  }

  25% {
    transform: scale(1.1) translate(-2px, -2px) rotate(-1deg);
  }

  50% {
    transform: scale(1.1) translate(2px, -2px) rotate(1deg);
  }

  75% {
    transform: scale(1.1) translate(-2px, 2px) rotate(-1deg);
  }

  100% {
    transform: scale(1.1) translate(2px, 2px) rotate(1deg);
  }
}

@media (max-width: 968px) {
  .game-board {
    grid-template-columns: 1fr;
  }

  .game-wrapper {
    padding: 1.5rem;
  }

  h1 {
    font-size: 2.2rem;
  }

  .header-top {
    flex-direction: column;
    gap: 1rem;
  }

  .header-top .btn-secondary {
    position: static;
  }

  .level-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.audio-hint {
  position: absolute;
  bottom: 2vh;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  opacity: 0.8;
  animation: pulse 2s infinite;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

/* Mobile Adjustments */
@media (max-width: 768px) {

  /* Background Fix: Ensure no white gaps at bottom */
  body {
    height: 100vh !important;
    min-height: 100vh !important;
    overflow: hidden !important;
    background-attachment: fixed !important;
    background-size: cover !important;
  }

  /* --- Center Everything Vertically exactly as specified --- */
  #level-select-screen.active,
  #game-screen.active {
    height: 100vh !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 20px !important;
    box-sizing: border-box !important;
    margin: 0 !important;
  }

  /* --- Start Screen Adjustments --- */
  .start-character-static {
    width: 35%;
    max-width: 120px;
    margin: -1rem auto 0.5rem auto;
  }

  .auto-rainbow-title {
    font-size: 1.8rem;
    text-align: center;
  }

  /* --- Level Select Fix --- */
  #level-select-screen .mission-title {
    text-align: center;
    margin: 0 auto 2rem auto !important; /* Space so it doesn't touch buttons */
  }

  .pagination-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .level-grid {
    width: calc(100% - 40px) !important;
    max-width: 400px;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 15px !important;
    padding: 15px !important;
    margin: 0 auto !important;
  }

  .level-btn {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 1 / 1;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
  }

  .level-icon {
    top: 5px !important;
    right: 5px !important;
    transform: scale(0.85);
  }

  #btn-back-start {
    margin: auto auto 15px auto !important;
    display: block;
    text-align: center;
  }

  /* --- Game Screen Fix --- */
  .header-top {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    padding-top: 0;
    margin-bottom: 5px;
    gap: 0.5rem;
  }

  .header-top .btn-secondary {
    position: relative;
    margin-bottom: 0px;
  }

  /* The .stats-panel should be right below title and centered */
  .stats-panel {
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-top: 5px;
    margin-bottom: 15px;
  }

  .stat-box {
    padding: 0.4rem 1rem;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  h1 {
    font-size: 2rem;
    text-align: center;
    margin-bottom: 0;
  }

  /* Vertical Layout: Images stacked vertically and centered */
  .game-board {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 1.5rem !important;
    width: 100%;
    margin: 0 auto;
  }

  .image-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  .image-container {
    width: 100%;
    height: auto;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .image-container img {
    width: 100%;
    height: auto;
    max-height: 25vh; /* Keep strictly visible in compressed height layout */
    object-fit: contain;
    margin: 0 auto;
  }

  .top-controls {
    top: 10px;
    right: 10px;
    gap: 15px;
  }

  .icon-btn {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
  }
}

@media (max-width: 360px) {
  .level-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}