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

body {
  min-height: 100vh; /* Changed to 100vh to fill the screen */
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 30%, #2d006e 0%, #0d0221 100%);
  font-family: 'Press Start 2P', 'Lato', 'Arial', sans-serif;
  padding: 16px; /* Add some padding for small screens */
}

/* Rain Animation - No changes needed */
#rain-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.rain-image {
  position: absolute;
  width: 50px;
  height: 50px;
  opacity: 0.8;
  animation-name: rain;
  animation-timing-function: linear;
}

@keyframes rain {
  0% {
    transform: translateY(-60px) rotate(0deg);
    opacity: 0;
  }
  10% { opacity: 1; }
  100% {
    transform: translateY(110vh) rotate(360deg);
    opacity: 0;
  }
}

/* Popup - No changes needed in base styles */
#popup {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(6px);
  display: none;
  justify-content: center;
  align-items: center;
  transition: background 0.3s;
  z-index: 100; /* Increased z-index to ensure it's on top */
}

.popup-content {
  background: linear-gradient(135deg, #ff00cc 0%, #3333ff 100%);
  border: 6px solid #fff700;
  border-radius: 24px;
  box-shadow: 0 0 32px 8px #00fff7aa, 0 0 0 4px #fff700;
  padding: 36px 32px 28px 32px;
  font-family: 'Press Start 2P', cursive;
  text-align: center;
  color: #fff700;
  font-size: 1.1rem;
  letter-spacing: 1px;
  text-shadow: 2px 2px 0 #000, 0 0 8px #fff;
  opacity: 0.97;
  max-width: 90vw;
  min-width: 260px;
}

#popup-text {
  margin-bottom: 24px;
  font-size: 1.2rem;
  color: #fff;
  text-shadow: 2px 2px 0 #000, 0 0 8px #fff, 0 0 16px #ff00cc;
}

#close-popup {
  font-family: 'Press Start 2P', cursive;
  background: linear-gradient(90deg, #ff00cc 0%, #3333ff 100%);
  color: #fff700;
  border: 3px solid #fff700;
  border-radius: 12px;
  padding: 12px 36px;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 0 12px 2px #ff00cc88;
  text-shadow: 2px 2px 0 #000, 0 0 8px #fff;
  transition: transform 0.1s, box-shadow 0.1s;
}

#close-popup:active {
  transform: scale(0.96);
  box-shadow: 0 0 8px 2px #fff70088;
}

/* Main Layout */
#main-layout {
  display: flex;
  align-items: center; /* Changed to center for better vertical alignment */
  justify-content: center;
  width: 100%; /* Changed from 100vw to 100% */
  gap: 32px;
}

#spin_the_wheel {
  /* Removed margin-top */
  display: inline-block;
  position: relative;
  padding: 24px; /* Reduced padding for a tighter fit */
  background: linear-gradient(135deg, rgba(255,0,204,0.8) 0%, rgba(51,51,255,0.8) 100%);
  border: 8px solid #fff700;
  border-radius: 32px;
  box-shadow: 0 0 40px 10px #ff00cc88, 0 0 0 8px #00fff7;
}

#wheel {
  display: block;
  /* Use viewport width for responsive scaling, with a max size */
  width: 45vw;
  height: 45vw;
  max-width: 550px;
  max-height: 550px;
  min-width: 280px; /* Set a minimum size for very small screens */
  min-height: 280px;
  background: #222;
  border: 8px solid #00fff7;
  border-radius: 50%;
  box-shadow: 0 0 32px 8px #00fff7aa, 0 0 0 4px #fff700;
  margin: 0 auto;
}

#spinButton {
  font-family: 'Press Start 2P', 'Lato', 'Arial', sans-serif;
  font-size: 1.2rem;
  color: #fff700;
  background: linear-gradient(90deg, #ff00cc 0%, #3333ff 100%);
  border: 4px solid #fff700;
  border-radius: 50%;
  padding: 18px 24px; /* Adjusted padding */
  box-shadow: 0 0 16px 4px #ff00cc88;
  cursor: pointer;
  text-shadow: 2px 2px 0 #000, 0 0 8px #fff;
  transition: transform 0.1s, box-shadow 0.1s;
  letter-spacing: 2px;
  position: absolute;
  /* Center the button properly */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 25%; /* Adjust width and height for better scaling */
  height: 25%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2;
  word-break: break-word;
  text-align: center;
  line-height: 1;
}

#spinButton:active {
  transform: translate(-50%, -50%) scale(0.96); /* Keep transform on active */
  box-shadow: 0 0 8px 2px #fff70088;
}

#spinButton::after {
  content: "";
  position: absolute;
  /* Position relative to the parent container */
  top: 50%;
  left: 100%; /* Position it to the right of the button */
  transform: translateY(-50%);
  /* Create the triangle shape */
  border: 16px solid transparent;
  border-left-color: #fff700;
  border-right: 0;
  filter: drop-shadow(0 0 6px #fff700cc);
  z-index: 3;
}

/* Add Prize Section - No changes needed */
#add-prize-section {
  background: linear-gradient(135deg, #222 60%, #3333ff 100%);
  border: 3px solid #fff700;
  border-radius: 18px;
  box-shadow: 0 0 16px 2px #00fff7aa;
  padding: 18px 16px 14px 16px;
  min-width: 160px;
  max-width: 180px;
  margin-top: 80px;
  font-family: 'Press Start 2P', 'Lato', 'Arial', sans-serif;
  color: #fff700;
  font-size: 0.8rem;
  text-align: center;
}
#add-prize-section h3 {
  margin-bottom: 10px;
  font-size: 1rem;
  color: #fff;
  text-shadow: 0 0 6px #00fff7;
  letter-spacing: 1px;
}
#add-prize-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#add-prize-form input[type="text"] {
  padding: 6px 8px;
  border-radius: 6px;
  border: 2px solid #00fff7;
  background: #111;
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
}
#add-prize-form input[type="color"] {
  width: 32px;
  height: 32px;
  border: none;
  margin: 0 auto;
  background: none;
  cursor: pointer;
}
#add-prize-form button {
  margin-top: 4px;
  padding: 7px 0;
  border-radius: 8px;
  border: 2px solid #fff700;
  background: linear-gradient(90deg, #ff00cc 0%, #3333ff 100%);
  color: #fff700;
  font-family: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  text-shadow: 1px 1px 0 #000, 0 0 4px #fff;
  transition: background 0.15s, transform 0.1s;
}
#add-prize-form button:active {
  transform: scale(0.97);
  background: #3333ff;
}


/* Chat container - desktop and tablet */
#chat-container {
  position: fixed;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 350px;
  height: 70vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, #222 0%, #3333ff 100%);
  border: 4px solid #fff700;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 0 24px 4px #00fff7aa, 0 0 0 2px #fff700;
  font-family: 'Press Start 2P', cursive;
  z-index: 10;
}

/* Scrollable chat messages */
#chat {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  background: #111;
  color: #fff700;
  font-size: 0.8rem;
  text-shadow: 1px 1px 0 #000;
}
#chat div {
  font-family: 'Cairo', 'Arial', sans-serif;
  font-size: 1rem;
  text-align: right;
  margin-bottom: 6px;
  background: rgba(255, 0, 204, 0.2);
  padding: 4px 8px;
  border-radius: 8px 8px 0 8px;
}

/* Inputs and send button */
#chat-input {
  display: flex;
  border-top: 2px solid #fff700;
  background: #222;
}
#chat-input input#message {
  flex: 1;
  padding: 6px;
  border: none;
  background: #111;
  color: #fff700;
}
#chat-input button {
  padding: 0 12px;
  background: #ff00cc;
  color: #fff700;
  border: none;
  cursor: pointer;
}

/* Chat header */
#chat-header { 
  background: #ff00cc; 
  text-align: center; 
  color: #fff700; 
  padding: 8px 0; 
  text-shadow: 2px 2px 0 #000; 
  font-size: 0.9rem; 
  letter-spacing: 1px; 
}
/* RESPONSIVE STYLES */

/* Medium screens (tablets) */
@media (max-width: 900px) {
  #main-layout {
    flex-direction: column;
    align-items: center;
    gap: 24px;
  }
  #add-prize-section {
    margin-top: 0;
    margin-bottom: 16px;
    order: -1; /* Move the add prize section above the wheel */
  }
  #sidebar {
    /* On tablets, hide the sidebar or make it smaller. Here we hide it. */
    display: none;
  }
  #wheel {
    /* Give the wheel more space on tablets */
    width: 60vw;
    height: 60vw;
  }
}

/* Small screens (mobiles) */
@media (max-width: 600px) {
  body {
      /* Remove grid layout on mobile to allow natural scrolling */
      display: block;
      padding-top: 32px;
  }
  #spin_the_wheel {
    padding: 12px;
    border-width: 6px;
  }
  #wheel {
    /* The wheel should take up most of the screen width */
    width: 85vw;
    height: 85vw;
    min-width: 0; /* Override the desktop min-width */
    min-height: 0;
    border-width: 6px;
  }
  #spinButton {
    font-size: 1rem;
    padding: 12px;
    border-width: 3px;
    width: 30%; /* Make button slightly larger relative to the wheel */
    height: 30%;
  }
  #spinButton::after {
    /* Scale down the pointer arrow */
    border-width: 12px;
    border-left-color: #fff700;
    border-right: 0;
  }
  .popup-content {
    padding: 24px;
    font-size: 1rem;
  }
  #popup-text {
    font-size: 1.1rem;
  }
  #chat-container {
    position: static;
    transform: none;
    margin-top: 5%;
    height: 200px;
  }
}
