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

body {
  font-family: "Rajdhani", sans-serif;
  background: #000000; /* Pure black background like the image */
  color: #ffffff;
  overflow: hidden;
  min-height: 100vh;
  position: relative;
}

/* ===== BACKGROUND EFFECTS ===== */
#background-particles {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  background: radial-gradient(
      circle at 20% 80%,
      rgba(255, 107, 107, 0.08) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 80% 20%,
      rgba(78, 205, 196, 0.08) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 50% 50%,
      rgba(69, 183, 209, 0.05) 0%,
      transparent 70%
    );
  background-size: 100% 100%, 100% 100%, 100% 100%;
  animation: backgroundShift 20s ease-in-out infinite;
}

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

/* ===== CANVAS STYLING ===== */
canvas {
  position: fixed;
  top: 0;
  left: 0;
  z-index: -1;
  filter: drop-shadow(0 0 20px rgba(255, 107, 107, 0.15))
    drop-shadow(0 0 40px rgba(78, 205, 196, 0.1))
    drop-shadow(0 0 60px rgba(69, 183, 209, 0.05));
  border-radius: 0;
  background: rgba(0, 0, 0, 0.95); /* Pure black background like the image */
}

/* ===== GAME UI ===== */
.game-ui {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
}

.game-header {
  position: absolute;
  top: 30px;
  right: 30px;
  display: flex;
  align-items: center;
  pointer-events: auto;
}

/* ===== GAME TITLE ===== */
.game-title {
  position: absolute;
  top: 30px;
  left: 30px;
  pointer-events: auto;
  z-index: 10;
  display: none; /* Hide the game title on the game page */
}

.title-text {
  font-family: "Orbitron", monospace;
  font-size: 3rem;
  font-weight: 900;
  margin-bottom: 8px;
  letter-spacing: 4px;
  text-shadow: 0 0 30px rgba(255, 255, 255, 0.4);
}

.title-void {
  color: #00ff88; /* Bright green color like in the image */
}

.title-painter {
  color: #ff6b9d; /* Bright pink color like in the image */
}

.subtitle-text {
  font-family: "Rajdhani", sans-serif;
  font-size: 1.2rem;
  color: #ffffff;
  font-weight: 400;
  letter-spacing: 3px;
  text-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

/* ===== GAME STATS ===== */
.game-stats {
  display: flex;
  flex-direction: column; /* Changed to vertical layout */
  gap: 8px; /* Reduced gap for vertical layout */
  background: rgba(15, 15, 25, 0.6);
  backdrop-filter: blur(10px);
  padding: 8px 10px; /* Reduced padding for corner placement */
  border-radius: 15px;
  border: 1px solid rgba(0, 255, 136, 0.3);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), 0 0 10px rgba(0, 255, 136, 0.05);
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 1000;
  overflow: hidden;
  width: 100px; /* Reduced width for corner placement */
  opacity: 0.8;
}

/* ===== CONTROL BUTTONS ===== */
.control-buttons {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1000;
  pointer-events: auto;
  display: flex;
  gap: 8px;
}

.control-button {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(15, 15, 25, 0.6);
  backdrop-filter: blur(10px);
  border: 2px solid rgba(0, 255, 136, 0.3);
  color: #00ff88;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), 0 0 10px rgba(0, 255, 136, 0.05);
  font-size: 1.2rem;
  opacity: 0.8;
}

.control-button:hover {
  background: rgba(0, 255, 136, 0.15);
  border-color: rgba(0, 255, 136, 0.5);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3), 0 0 15px rgba(0, 255, 136, 0.1);
  transform: translateY(-2px);
  opacity: 1;
}

.control-button:active {
  transform: translateY(0);
}

.control-icon {
  filter: drop-shadow(0 0 8px currentColor);
}

/* Home button specific styles */
.home-button {
  border-color: rgba(78, 205, 196, 0.3);
  color: #4ecdc4;
}

.home-button:hover {
  background: rgba(78, 205, 196, 0.15);
  border-color: rgba(78, 205, 196, 0.5);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3), 0 0 15px rgba(78, 205, 196, 0.1);
}

/* Sound button specific styles */
.sound-button.muted {
  color: #ff6b6b;
  border-color: rgba(255, 107, 107, 0.3);
}

.sound-button.muted:hover {
  background: rgba(255, 107, 107, 0.15);
  border-color: rgba(255, 107, 107, 0.5);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3), 0 0 15px rgba(255, 107, 107, 0.1);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px; /* Reduced padding for compact corner layout */
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  border: 1px solid rgba(0, 255, 136, 0.2);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  width: 100%; /* Full width within container */
}

.stat-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(0, 255, 136, 0.4);
}

.stat-icon {
  font-size: 1rem;
  filter: drop-shadow(0 0 6px rgba(0, 255, 136, 0.4));
  color: #00ff88;
}

.stat-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1; /* Take remaining space */
}

.stat-label {
  font-size: 0.6rem;
  font-weight: 600;
  color: #a0a0a0;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.stat-value {
  font-size: 0.9rem;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 0 8px rgba(0, 255, 136, 0.4);
}

/* ===== POPUP STYLES ===== */
.game-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.game-popup.active {
  opacity: 1;
  visibility: visible;
}

.popup-content {
  background: linear-gradient(
    135deg,
    rgba(0, 0, 0, 0.95) 0%,
    rgba(10, 5, 15, 0.95) 50%,
    rgba(0, 0, 0, 0.95) 100%
  );
  border-radius: 20px;
  padding: 30px;
  max-width: 700px;
  width: 90%;
  border: 2px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  position: relative;
  overflow: hidden;
  transform: scale(0.8);
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.game-popup.active .popup-content {
  transform: scale(1);
}

.popup-content::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4);
  background-size: 200% 100%;
  animation: borderGlow 3s ease-in-out infinite;
}

/* ===== POPUP HEADER ===== */
.popup-header {
  text-align: center;
  margin-bottom: 20px;
}

.popup-title {
  font-family: "Orbitron", monospace;
  font-size: 2rem;
  font-weight: 900;
  background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
  letter-spacing: 2px;
}

.game-over-title {
  background: linear-gradient(45deg, #ff6b6b, #ff8e8e, #ff6b6b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.success-title {
  background: linear-gradient(45deg, #4ecdc4, #96ceb4, #4ecdc4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.title-underline {
  width: 100px;
  height: 3px;
  background: linear-gradient(90deg, #ff6b6b, #4ecdc4, #45b7d1);
  margin: 0 auto;
  border-radius: 2px;
  animation: underlineGlow 2s ease-in-out infinite;
}

@keyframes underlineGlow {
  0%,
  100% {
    box-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
  }
  50% {
    box-shadow: 0 0 20px rgba(78, 205, 196, 0.8);
  }
}

/* ===== POPUP BODY ===== */
.popup-body {
  margin-bottom: 30px;
}

.game-description {
  text-align: center;
  margin-bottom: 20px;
}

.description-text {
  font-size: 1rem;
  line-height: 1.5;
  color: #e0e0e0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Layout for side-by-side sections */
.sections-container {
  display: flex;
  gap: 25px;
  margin-bottom: 20px;
}

.how-to-play {
  flex: 1;
  margin-right: 15px;
}

.game-goals {
  flex: 1;
  margin-left: 15px;
}

/* ===== SECTION STYLES ===== */
.section-title {
  font-family: "Orbitron", monospace;
  font-size: 1.2rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 16px;
  text-align: center;
  letter-spacing: 1px;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
  position: relative;
  padding-bottom: 8px;
}

.section-title::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
}

.instructions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 0;
}

.instruction-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.instruction-item:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateX(3px);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.instruction-icon {
  font-size: 1.4rem;
  min-width: 50px;
  text-align: center;
  flex-shrink: 0;
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.3));
}

.instruction-text {
  font-size: 1rem;
  color: #f0f0f0;
  font-weight: 600;
  flex: 1;
  word-wrap: break-word;
  line-height: 1.4;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.goals-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.goal-item {
  padding: 6px 12px;
  background: rgba(78, 205, 196, 0.05);
  border-radius: 6px;
  border-left: 3px solid #4ecdc4;
  color: #e0e0e0;
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.goal-item:hover {
  background: rgba(78, 205, 196, 0.15);
  transform: translateX(3px);
}

/* ===== STATS DISPLAY ===== */
.final-stats,
.level-stats {
  margin-bottom: 20px;
}

.stat-display {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

/* Level complete specific layout - side by side */
#level-complete-screen .stat-display {
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.final-stat,
.level-stat {
  text-align: center;
  padding: 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: all 0.3s ease;
}

.final-stat:hover,
.level-stat:hover {
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.final-stat .stat-label,
.level-stat .stat-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: #a0a0a0;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.final-stat .stat-value,
.level-stat .stat-value {
  display: block;
  font-size: 1.3rem;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

/* ===== MESSAGE STYLES ===== */
.performance-message,
.celebration-message {
  text-align: center;
  margin-bottom: 15px;
}

.message-text {
  font-size: 1rem;
  color: #e0e0e0;
  font-weight: 500;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* ===== BUTTON STYLES ===== */
.popup-footer {
  text-align: center;
}

.game-button {
  position: relative;
  background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
  color: white;
  border: none;
  padding: 12px 25px;
  font-size: 1rem;
  font-weight: 700;
  font-family: "Orbitron", monospace;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  overflow: hidden;
  letter-spacing: 1px;
  text-transform: uppercase;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.game-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
  background: linear-gradient(45deg, #ff5252, #26a69a);
}

.game-button:active {
  transform: translateY(-1px);
}

.button-glow {
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  transition: left 0.5s ease;
}

.game-button:hover .button-glow {
  left: 100%;
}

/* ===== GAME OVER & LEVEL COMPLETE POPUPS ===== */
#game-over-screen .popup-content,
#level-complete-screen .popup-content {
  padding: 25px;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
  .title-text {
    font-size: 2rem;
    letter-spacing: 2px;
  }

  /* Mobile portrait mode - keep stats in corner but make them more compact */
  .game-stats {
    width: 90px !important;
    padding: 6px 8px !important;
    gap: 6px !important;
  }

  /* Control buttons on mobile */
  .control-buttons {
    position: fixed !important;
    top: 12px !important;
    left: 12px !important;
    z-index: 1000 !important;
    gap: 6px !important;
  }

  .control-button {
    width: 40px !important;
    height: 40px !important;
    font-size: 1rem !important;
  }

  .stat-item {
    padding: 3px 5px !important;
  }

  .stat-label {
    font-size: 0.5rem !important;
  }

  .stat-value {
    font-size: 0.8rem !important;
  }

  .stat-icon {
    font-size: 0.9rem !important;
  }

  .popup-content {
    padding: 30px 20px;
    margin: 20px;
    max-width: 95%;
    width: 95%;
  }

  .popup-title {
    font-size: 2rem;
  }

  .stat-display {
    grid-template-columns: 1fr;
  }

  .game-button {
    padding: 12px 25px;
    font-size: 1rem;
  }

  /* Stack sections vertically on mobile */
  .sections-container {
    flex-direction: column;
    gap: 15px;
  }

  .how-to-play,
  .game-goals {
    margin: 0;
  }

  /* Adjust instruction items for mobile */
  .instruction-item {
    gap: 10px;
    padding: 10px 12px;
  }

  .instruction-icon {
    min-width: 40px;
    font-size: 1.2rem;
  }

  .instruction-text {
    font-size: 0.9rem;
  }

  .section-title {
    font-size: 1.1rem;
    margin-bottom: 12px;
  }
}

@media (max-width: 480px) {
  .title-text {
    font-size: 1.5rem;
  }

  .game-stats {
    flex-direction: column;
    gap: 6px;
    padding: 12px 8px;
    width: 90px;
  }

  .popup-title {
    font-size: 1.5rem;
  }

  .section-title {
    font-size: 1.1rem;
  }

  /* Further adjust instruction items for very small screens */
  .instruction-item {
    gap: 8px;
    padding: 8px 10px;
  }

  .instruction-icon {
    min-width: 35px;
    font-size: 1rem;
  }

  .instruction-text {
    font-size: 0.85rem;
  }

  .section-title {
    font-size: 1rem;
    margin-bottom: 10px;
  }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.8;
  }
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-5px);
  }
}

.game-popup.active .popup-content {
  animation: fadeInUp 0.6s ease-out;
}

.stat-item {
  animation: fadeInUp 0.6s ease-out;
}

.stat-item:nth-child(1) {
  animation-delay: 0.1s;
}
.stat-item:nth-child(2) {
  animation-delay: 0.2s;
}
.stat-item:nth-child(3) {
  animation-delay: 0.3s;
}
.stat-item:nth-child(4) {
  animation-delay: 0.4s;
}

/* Add pulse animation to important stats */
.stat-value {
  animation: pulse 3s ease-in-out infinite;
}

/* ===== SCROLLBAR STYLING ===== */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(45deg, #ff5252, #26a69a);
}

/* ===== CIRCLE CONTROLLER ===== */
.circle-controller {
  position: fixed;
  bottom: 30px;
  left: 30px;
  width: 120px;
  height: 120px;
  z-index: 20;
  pointer-events: auto;
  display: none; /* Hidden by default, shown when game starts */
}

.controller-outer {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(15, 15, 25, 0.95);
  backdrop-filter: blur(15px);
  border: 2px solid rgba(0, 255, 136, 0.5);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4), 0 0 20px rgba(0, 255, 136, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.controller-outer:hover {
  border-color: rgba(0, 255, 136, 0.7);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4), 0 0 30px rgba(0, 255, 136, 0.2);
}

.controller-inner {
  position: absolute;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(
    45deg,
    rgba(0, 255, 136, 0.3),
    rgba(78, 205, 196, 0.3)
  );
  border: 2px solid rgba(0, 255, 136, 0.8);
  box-shadow: 0 4px 15px rgba(0, 255, 136, 0.3);
  transition: all 0.1s ease;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.controller-inner:active {
  cursor: grabbing;
  transform: scale(0.95);
  box-shadow: 0 2px 10px rgba(0, 255, 136, 0.4);
}

.controller-hint {
  position: absolute;
  bottom: -40px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
  white-space: nowrap;
  font-weight: 600;
  letter-spacing: 1px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* ===== RESPONSIVE CONTROLLER ===== */
@media (max-width: 768px) {
  .circle-controller {
    width: 100px;
    height: 100px;
    bottom: 20px;
    left: 20px;
  }

  .controller-inner {
    width: 50px;
    height: 50px;
  }

  .controller-hint {
    font-size: 0.7rem;
    bottom: -35px;
  }
}

@media (max-width: 480px) {
  .circle-controller {
    width: 90px;
    height: 90px;
    bottom: 15px;
    left: 15px;
  }

  .controller-inner {
    width: 45px;
    height: 45px;
  }

  .controller-hint {
    font-size: 0.65rem;
    bottom: -30px;
  }
}

/* ===== CONTROLLER ANIMATIONS ===== */
@keyframes controllerGlow {
  0%,
  100% {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4), 0 0 20px rgba(0, 255, 136, 0.1);
  }
  50% {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4), 0 0 30px rgba(0, 255, 136, 0.3);
  }
}

.controller-outer {
  animation: controllerGlow 3s ease-in-out infinite;
}

/* ===== TOUCH OPTIMIZATION ===== */
.circle-controller {
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.controller-inner {
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
