/* ================= CSS Variables ================= */ 
:root {
  --primary-color: #4a90e2;
  --secondary-color: #50e3c2;
  --accent-color: #ff6b6b;
  --dark-color: #333;
  --light-color: #fff;
  --header-bg: linear-gradient(135deg, #4a90e2, #9013fe);
  --body-bg: linear-gradient(135deg, #f0f4f8, #d9e2ec);
  --font-family: 'Poppins', sans-serif;

  /* Tube & Ball sizes (adjust as needed) */
  --tube-width: 60px;
  --tube-height: 240px;
  --tube-margin: 8px;
  --tube-border: #ccc;
  --tube-radius: 35px;
  --ball-size: 50px;

  --transition-speed: 0.3s;
}

/* ============= GLOBAL RESET ============= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background: var(--body-bg);
  min-height: 100vh;
  color: var(--dark-color);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 10px;
}

/* ============= HEADER ============= */
header {
  background: var(--header-bg);
  color: var(--light-color);
  padding: 20px 0;
  box-shadow: 0 2px 5px rgba(0,0,0,0.15);
  width: 100%;
  text-align: center;
}

.header-container {
  width: 90%;
  max-width: 1200px;
  margin: 0 auto;
}

.game-title {
  font-size: 2.4rem;
  font-weight: 600;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.2);
  margin-bottom: 8px;
}

#score-summary {
  font-size: 1rem;
  opacity: 0.9;
}

/* ============= MENUS ============= */
.menu {
  margin: 40px auto;
  width: 90%;
  max-width: 400px;
  background: var(--light-color);
  padding: 30px;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  text-align: center;
  animation: fadeIn 0.5s ease-in-out;
}

.menu h2 {
  margin-bottom: 20px;
  font-size: 1.6rem;
  color: var(--primary-color);
}

.menu button {
  margin: 10px;
  padding: 10px 20px;
  background: var(--accent-color);
  border: none;
  border-radius: 5px;
  color: var(--light-color);
  font-size: 1rem;
  cursor: pointer;
  transition: background var(--transition-speed) ease, transform 0.2s ease;
}

.menu button:hover {
  background: #ff5252;
  transform: scale(1.05);
}

/* ============= GAME CONTAINER & TUBE ============= */
#game-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  padding: 20px;
  min-height: 300px;
  animation: fadeIn 0.5s ease-in-out;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.tube {
  position: relative;
  width: var(--tube-width);
  height: var(--tube-height);
  margin: var(--tube-margin);
  background: var(--light-color);
  border: 2px solid var(--tube-border);
  border-radius: var(--tube-radius);
  overflow: hidden;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  cursor: pointer;
  transition: transform var(--transition-speed), border-color var(--transition-speed);
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.tube:hover {
  transform: scale(1.05);
  border-color: var(--accent-color);
}

.tube.highlight {
  border-color: var(--accent-color);
  box-shadow: 0 0 12px rgba(255,107,107,0.7);
}

.tube.valid-target {
  border-color: var(--secondary-color);
}

/* ============= SELECTED GROUP ============= */
.tube .selected-group {
  position: absolute;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 10;
}

/* ============= BALL STYLES ============= */
.ball {
  width: var(--ball-size);
  height: var(--ball-size);
  border-radius: 50%;
  margin: 3px 0;
  background: gray;
  transition: transform var(--transition-speed);
  box-shadow: 0 3px 6px rgba(0,0,0,0.15);
}

/* color classes */
.ball.red    { background: #e74c3c; }
.ball.blue   { background: #3498db; }
.ball.green  { background: #2ecc71; }
.ball.yellow { background: #f1c40f; }
.ball.purple { background: #9b59b6; }
.ball.orange { background: #e67e22; }

/* ============= FANCY VANISH ANIMATION ============= */
@keyframes vanish {
  from {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
  to {
    transform: scale(0) rotate(720deg);
    opacity: 0;
  }
}
.vanish {
  animation: vanish 0.8s forwards;
}
.tube.vanish {
  animation: vanish 0.8s forwards;
}

/* ============= GAME CONTROLS & HUD ============= */
#game-controls {
  margin: 20px auto;
  width: 90%;
  max-width: 500px;
  background: rgba(255,255,255,0.95);
  padding: 15px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

#hud {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 10px;
}

#control-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
}

#control-buttons button {
  padding: 10px 18px;
  margin: 6px;
  background: var(--accent-color);
  border: none;
  border-radius: 5px;
  color: var(--light-color);
  font-size: 0.95rem;
  cursor: pointer;
  transition: background var(--transition-speed) ease, transform 0.2s ease;
}

#control-buttons button:hover {
  background: #ff5252;
  transform: scale(1.05);
}

/* ============= LEVEL COMPLETE OVERLAY ============= */
#level-complete-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.3s ease-in-out;
}

#level-complete-overlay.hidden {
  display: none;
}

.overlay-content {
  background: var(--light-color);
  padding: 30px 40px;
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 6px 12px rgba(0,0,0,0.2);
}

.overlay-content h2 {
  margin-bottom: 15px;
  font-size: 2rem;
  color: var(--primary-color);
}

.overlay-content p {
  margin-bottom: 20px;
  font-size: 1.1rem;
}

.overlay-content button {
  margin: 8px;
  padding: 10px 20px;
  background: var(--accent-color);
  border: none;
  border-radius: 5px;
  color: var(--light-color);
  font-size: 1rem;
  cursor: pointer;
  transition: background var(--transition-speed) ease, transform 0.2s ease;
}

.overlay-content button:hover {
  background: #ff5252;
  transform: scale(1.05);
}

/* ============= Animations ============= */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ============= RESPONSIVE QUERIES ============= */
/* Small Mobile Devices (max-width: 480px) */
@media (max-width: 480px) {
  /* Override CSS variables for smaller screens */
  :root {
    --tube-width: 50px;
    --tube-height: 160px; /* Adjusted from 200px to 160px */
    --tube-margin: 5px;
    --ball-size: 30px;
  }
  
  .game-title {
    font-size: 2rem;
  }
  .header-container {
    padding: 0 10px;
  }
  .tube {
    width: var(--tube-width) !important;
    height: var(--tube-height) !important;
    margin: var(--tube-margin) !important;
  }
  .ball {
    width: var(--ball-size) !important;
    height: var(--ball-size) !important;
    margin: 1px 0;
  }
  #game-container {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 10px;
  }
  #control-buttons button {
    padding: 8px 12px;
    font-size: 0.9rem;
  }
}

/* Tablets (min-width: 481px) and (max-width: 1024px) */
@media (min-width: 481px) and (max-width: 1024px) {
  .tube {
    width: 55px;
    height: 220px;
    margin: 6px;
  }
  .ball {
    width: 45px;
    height: 45px;
  }
  .game-title {
    font-size: 2.2rem;
  }
  #game-controls {
    max-width: 600px;
  }
}

/* Add to the CSS */
.hidden {
  display: none !important;
}

/* Larger screens (min-width: 1025px) {
   Optionally scale up if needed
}
