/* === General Styles === */
body {
  margin: 0;
  font-family: 'Cinzel Decorative', cursive, Arial, sans-serif;
  background-color: #0d0d0d;
  color: #eaeaea;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
}

/* Apply box-sizing to all elements */
*, *::before, *::after {
  box-sizing: inherit;
}

/* Background Video */
#page-background-video {
  position: fixed;
  top: 0;
  left: 0;
  min-width: 100%;
  min-height: 100%;
  width: auto;
  height: auto;
  z-index: -999;
  object-fit: cover;
  filter: contrast(0.8) brightness(1.2) saturate(0.9);
  pointer-events: none;
}

/* Start Screen */
#start-screen {
  position: relative;
  width: 800px;
  max-width: 95%;
  height: 600px;
  max-height: 95vh;
  margin: auto;
  overflow: hidden;
  border: 2px solid #444444;
  border-radius: 10px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Ensure the welcome video covers the entire start screen */
#start-screen #background-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  top: 0;
  left: 0;
  z-index: -1;
}

/* Navigation Menu */
#nav-menu {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 2;
}

/* Navigation Buttons */
#nav-menu button {
  margin: 10px 0;
  padding: 15px 20px;
  width: 250px;
  max-width: 90%;
  background-color: #1a1a1a;
  color: #eaeaea;
  border: 2px solid #444444;
  border-radius: 5px;
  cursor: pointer;
  font-size: 18px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  box-sizing: border-box;
}

#nav-menu button:hover {
  background-color: #2b2b2b;
}

/* Game Container */
#game-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90vw;  /* Change as needed for responsiveness */
  height: calc(90vw * (9 / 16));  /* Keep 16:9 aspect ratio */
  max-width: 95%;
  max-height: 95vh;
  border: 2px solid #444444;
  border-radius: 10px;
  animation: glow 5s infinite;
  z-index: 1;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Glowing Border Keyframes */
@keyframes glow {
  0% {
    box-shadow: 0 0 20px #444444;
    border-color: #444444;
  }
  25% {
    box-shadow: 0 0 20px #555555;
    border-color: #555555;
  }
  50% {
    box-shadow: 0 0 20px #666666;
    border-color: #666666;
  }
  75% {
    box-shadow: 0 0 20px #555555;
    border-color: #555555;
  }
  100% {
    box-shadow: 0 0 20px #444444;
    border-color: #444444;
  }
}

/* Game Canvas */
#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: transparent !important; /* Ensure transparency */
  z-index: 1; /* Set z-index higher than the background video */
}

/* Prevent scrolling when game is active */
body.playing-game {
  overflow: hidden;
}

/* End Screen */
#end-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(13, 13, 13, 0.95);
  display: none; /* Hidden by default */
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#end-content {
  text-align: center;
  background-color: #1a1a1a;
  padding: 20px;
  border-radius: 10px;
  width: 90%;
  max-width: 500px;
}

#end-content h1 {
  font-size: 48px;
  margin-bottom: 20px;
  color: #eaeaea;
}

#end-content p {
  font-size: 24px;
  margin-bottom: 20px;
  color: #cccccc;
}

#player-name,
#solana-address { /* Added Solana Address Input */
  padding: 10px;
  font-size: 18px;
  margin-bottom: 20px;
  width: 80%;
  max-width: 300px;
  background-color: #0d0d0d;
  color: #eaeaea;
  border: 2px solid #444444;
  border-radius: 5px;
}

#end-buttons {
  margin-top: 20px;
}

#end-buttons button {
  margin: 5px;
  padding: 10px 20px;
  width: 200px;
  max-width: 90%;
  background-color: #1a1a1a;
  color: #eaeaea;
  border: 2px solid #444444;
  border-radius: 5px;
  cursor: pointer;
  box-sizing: border-box;
}

#end-buttons button:hover {
  background-color: #2b2b2b;
}

/* Content Section */
#content {
  display: none;
  width: 90%;
  max-width: 1200px;
  margin: 40px auto;
}

/* Grid Container */
.grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.grid-item {
  background-color: #1a1a1a;
  padding: 20px;
  border-radius: 10px;
}

.grid-item h2 {
  color: #e94560;
  margin-bottom: 10px;
}

.grid-item p,
.grid-item ul {
  margin-bottom: 10px;
  color: #cccccc;
}

.grid-item ul {
  list-style-type: none;
  padding: 0;
}

.grid-item ul li {
  margin-bottom: 5px;
}

.grid-item ul li a {
  color: #00adb5;
  text-decoration: none;
}

.grid-item ul li a:hover {
  text-decoration: underline;
}

/* Legal Disclaimer */
.legal-disclaimer {
  font-size: 12px;
  color: gray;
  text-align: center;
  margin-top: 20px;
  padding: 10px;
}

/* Back to Menu Button */
#back-button-container {
  text-align: center;
  margin-top: 20px;
}

#back-to-menu-button {
  padding: 10px 20px;
  width: 200px;
  max-width: 90%;
  background-color: #1a1a1a;
  color: #eaeaea;
  border: 2px solid #444444;
  border-radius: 5px;
  cursor: pointer;
}

#back-to-menu-button:hover {
  background-color: #2b2b2b;
}

/* Orientation Warning */
#orientation-warning {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(13, 13, 13, 0.9);
  color: white;
  text-align: center;
  padding-top: 50%;
  font-size: 24px;
  z-index: 1000;
}

/* Leaderboard Styles */
/* Removed #leaderboard and added #leaderboard-container to match index.html */
#leaderboard-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(13, 13, 13, 0.95);
  display: none; /* Hidden by default */
  /* Removed 'display: flex' to prevent overriding */
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

#leaderboard-content {
  background-color: #1a1a1a;
  padding: 20px;
  border-radius: 10px;
  width: 90%;
  max-width: 800px; /* Increased max-width for larger displays */
  text-align: center;
  color: #FFD700; /* Gold color for text */
  font-family: 'Press Start 2P', cursive; /* Retro font */
  position: relative;
  box-sizing: border-box;
}

/* Leaderboard Header */
#leaderboard-content h2 {
  font-size: 32px;
  margin-bottom: 20px;
  color: #FFD700;
  text-shadow: 2px 2px 4px #000000;
}

/* Leaderboard List */
#leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 0 auto; /* Center the list within the container */
  max-width: 600px; /* Adjust as needed */
}

/* Leaderboard Entry */
#leaderboard-list li {
  margin: 10px 0;
  font-size: 20px;
  padding: 10px;
  background-color: rgba(255, 255, 255, 0.1); /* Semi-transparent background */
  border-radius: 5px;
  border: 2px solid #333333;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
  color: #FFD700;
  font-family: 'Press Start 2P', cursive; /* Retro font */
  position: relative; /* Added for z-index */
  z-index: 1003; /* Ensure it's above the ::after pseudo-element */
}

/* Leaderboard Entry Hover Effect */
#leaderboard-list li:hover {
  background-color: rgba(255, 215, 0, 0.2); /* Goldish hover effect */
}

/* Close Leaderboard Button */
#back-to-menu-leaderboard {
  margin-top: 20px;
  padding: 10px 20px;
  background-color: #1a1a1a;
  color: #eaeaea;
  border: 2px solid #444444;
  border-radius: 5px;
  cursor: pointer;
  font-size: 18px;
  box-sizing: border-box;
  transition: background-color 0.3s;
  position: relative; /* Added */
  z-index: 1004; /* Higher than leaderboard-list li */
}

#back-to-menu-leaderboard:hover {
  background-color: #2b2b2b;
}

/* Retro TV Effects for Leaderboard */
#leaderboard-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(255, 255, 255, 0.05) 2px,
    rgba(255, 255, 255, 0.05) 4px
  );
  pointer-events: none;
  z-index: 1001;
}

/* Adding slight chromatic aberration */
#leaderboard-content::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  width: calc(100% + 4px);
  height: calc(100% + 4px);
  background: rgba(255, 0, 0, 0.02);
  mix-blend-mode: screen;
  z-index: 1002;
  pointer-events: none; /* Added to allow clicks through the overlay */
}

/* Retro-style Fonts */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

/* Utility Classes for Visibility */
.hidden {
  display: none !important;
}

.flex-center {
  display: flex !important;
  justify-content: center;
  align-items: center;
}

/* Responsive Styles */
@media (max-width: 767px) {
  /* Start Screen adjustments for mobile */
  #start-screen {
    width: 90%;
    max-width: 400px;
    height: 0;
    padding-bottom: 100%;
    margin: auto;
    position: relative;
    max-height: none;
  }

  #start-screen #background-video {
    object-fit: cover;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
  }

  #nav-menu {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 0;
  }

  #nav-menu button {
    padding: 10px 12px;
    font-size: 16px;
    width: 80%;
    max-width: 100%;
  }

  #game-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90vw;  /* Adjusted for responsiveness */
    height: calc(90vw * (9 / 16));  /* Maintain 16:9 aspect ratio */
    max-width: 95%;
    max-height: 95vh;
    border: 2px solid #444444;
    border-radius: 10px;
    animation: glow 5s infinite;
    z-index: 1;  /* Ensure it's above background video */
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  /* Removed display: none; from #gameCanvas to allow the game to be playable */
  #gameCanvas {
    /* display: none; */ /* Removed to enable game interactions */
  }

  #end-content h1 {
    font-size: 36px;
  }

  #end-content p {
    font-size: 18px;
  }

  #player-name,
  #solana-address { /* Ensure Solana address input is responsive */
    font-size: 16px;
  }

  #end-buttons button {
    padding: 8px 16px;
    font-size: 14px;
    width: 80%;
    max-width: 100%;
  }

  .grid-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .grid-item {
    padding: 15px;
    margin-bottom: 20px;
  }

  html, body {
    touch-action: manipulation;
  }

  /* Leaderboard Styles */
  #leaderboard-content {
    width: 100%;
    max-width: 90%;
  }

  #leaderboard-list li {
    font-size: 16px;
  }
}

/* Click Overlay */
#click-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: auto;
  background: transparent;
  z-index: 100;
}

/* Score and Time Display */
#score-time {
  position: absolute;
  top: 10px;
  right: 10px;
  text-shadow: 1px 1px 2px #000000; /* Subtle shadow for contrast */
  font-size: 24px;
  background-color: rgba(0, 0, 0, 0.5);
  padding: 5px 15px; /* 5px top/bottom, 15px left/right */
  border-radius: 5px;
  z-index: 100;
}

/* === Giveaway Popup Styles === */

/* Overlay for Giveaway Popup */
#popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(13, 13, 13, 0.8); /* Semi-transparent dark background */
  display: none; /* Hidden by default */
  z-index: 1001; /* Above all other elements except the popup */
}

/* Giveaway Popup Container */
#giveaway-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: #1a1a1a;
  padding: 40px 30px; /* Increased padding for better spacing */
  border-radius: 10px;
  box-shadow: 0 0 20px rgba(0,0,0,0.7);
  width: 90%;
  max-width: 500px;
  z-index: 1002; /* Above the overlay */
  display: none; /* Hidden by default */
  color: #eaeaea;
  font-family: 'Cinzel Decorative', cursive, Arial, sans-serif;
  box-sizing: border-box; /* Ensure padding doesn't affect total width */
}

/* Make the popup visible when not hidden */
#giveaway-popup:not(.hidden) {
  display: block;
}

/* Popup Content */
#giveaway-popup .popup-content {
  position: relative; /* Establish a positioning context for absolute children */
}

/* Close (Exit) Button */
#giveaway-popup .close-button {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 24px;
  color: #eaeaea;
  cursor: pointer;
  transition: color 0.3s;
  background: none;
  border: none;
  font-weight: bold;
}

/* Close Button Hover Effect */
#giveaway-popup .close-button:hover {
  color: #ff0000; /* Red color on hover */
}

/* Giveaway Popup Header */
#giveaway-popup h2 {
  font-size: 32px;
  margin-bottom: 30px;
  color: #FFD700; /* Gold color for emphasis */
  text-align: center; /* Center the giveaway text */
}

/* Eligibility Requirements (Numbered List) */
#giveaway-popup ol.eligibility-requirements {
  font-size: 18px;
  margin-bottom: 20px;
  color: #cccccc;
  padding-left: 20px; /* Indent the list */
}

#giveaway-popup ol.eligibility-requirements li {
  margin-bottom: 10px;
}

/* Optional: Custom Number Styling */
#giveaway-popup ol.eligibility-requirements li::marker {
  color: #FFD700; /* Gold color for numbers */
  font-weight: bold;
}

/* Retweet Section */
#giveaway-popup .retweet-section p {
  font-size: 18px;
  margin-bottom: 10px;
  color: #cccccc;
  text-align: center; /* Center any additional text */
}

#giveaway-popup .retweet-section ul {
  list-style-type: disc; /* Bullet points */
  padding-left: 40px; /* Indent the list */
  margin-bottom: 20px;
  color: #00adb5; /* Light blue for links */
}

#giveaway-popup .retweet-section ul li {
  margin-bottom: 10px;
}

#giveaway-popup .retweet-section ul li a {
  color: #00adb5;
  text-decoration: none;
}

#giveaway-popup .retweet-section ul li a:hover {
  text-decoration: underline;
}

/* Retweet Button */
#giveaway-popup #retweet-button {
  margin-top: 10px;
  padding: 10px 20px;
  background-color: #FFD700; /* Gold color */
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-family: 'Open Sans', sans-serif; /* Matches the popup font */
  color: #000; /* Black text for contrast */
  transition: background-color 0.3s ease;
  font-size: 16px;
}

#giveaway-popup #retweet-button:hover {
  background-color: #FFA500; /* Orange color on hover */
}

/* Responsive Styles for Giveaway Popup */
@media (max-width: 767px) {
  #giveaway-popup {
    padding: 20px 20px; /* Adjust padding for smaller screens */
  }

  #giveaway-popup h2 {
    font-size: 24px;
    margin-bottom: 20px;
  }

  #giveaway-popup ol.eligibility-requirements,
  #giveaway-popup .retweet-section p,
  #giveaway-popup .retweet-section ul {
    font-size: 16px;
  }

  #giveaway-popup .close-button {
    font-size: 20px;
  }

  #giveaway-popup #retweet-button {
    font-size: 14px;
    padding: 8px 16px;
  }
}

/* --- Clean Font Class for Giveaway Popup --- */
.clean-font {
  font-family: 'Open Sans', sans-serif; /* Applies Open Sans font */
  color: #eaeaea; /* Ensures text is visible against dark backgrounds */
}

/* Retweet Button Styling */
/* Removed duplicate #retweet-button styles to prevent conflicts */

/* Retro-style Fonts Override for Popup */
#giveaway-popup .pixel-text {
  font-family: 'Open Sans', sans-serif; /* Override to Open Sans */
}

/* === Additional Fixes === */

/* Ensure the "Back to Menu" button is above all overlays */
#back-to-menu-leaderboard {
  position: relative; /* Establish positioned context */
  z-index: 1004; /* Higher than ::after pseudo-element */
}

/* Ensure leaderboard-list items are below the button */
#leaderboard-list li {
  position: relative;
  z-index: 1003; /* Below the Back to Menu button */
}

/* Ensure no other elements are overlapping the leaderboard */
#leaderboard-container,
#leaderboard-content,
#leaderboard-container::before,
#leaderboard-content::after,
#back-to-menu-leaderboard {
  pointer-events: auto;
}

/* Prevent ::after pseudo-element from blocking interactions */
#leaderboard-content::after {
  pointer-events: none; /* Allow clicks to pass through */
}

/* Retweet Button Styling */
#retweet-button {
  margin-top: 10px; /* Adjusted to align with other buttons */
  padding: 15px 20px; /* Consistent padding with navigation and other buttons */
  background-color: #1a1a1a; /* Same background color as other buttons */
  color: #eaeaea; /* Same text color as other buttons */
  border: 2px solid #444444; /* Consistent border with other buttons */
  border-radius: 5px; /* Rounded corners matching other buttons */
  cursor: pointer; /* Pointer cursor on hover */
  font-size: 18px; /* Font size consistent with other buttons */
  box-sizing: border-box; /* Ensure padding doesn't affect total width */
  transition: background-color 0.3s ease; /* Smooth transition on hover */
  font-family: 'Cinzel Decorative', cursive, Arial, sans-serif; /* Match the general font family */
}

#retweet-button:hover {
  background-color: #2b2b2b; /* Hover effect matching other buttons */
}
