/* General Styles */
body {
  margin: 0;
  font-family: 'Roboto', 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;
}

*, *::before, *::after {
  box-sizing: inherit;
}

#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: flex-start;
  padding-top: 350px;
}

#start-screen #background-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  top: 0;
  left: 0;
  z-index: -1;
}

/* Meme Coins Container - place it behind other elements */
#meme-coins-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* Feeds Container */
#feeds-container {
  position: relative;
  height: 50px; /* Matches the feeds' height to reserve space */
  margin-bottom: 20px;
  z-index: 2;
}

/* SOL Price Feed */
#sol-price-feed {
  background-color: rgba(0, 0, 0, 0.7);
  padding: 10px 20px;
  border-radius: 5px;
  font-size: 24px;
  color: #eaeaea;
  text-align: center;
  width: 300px; /* Keeps it fixed and immovable */
  height: 50px; /* Increased to prevent clipping */
  display: flex; /* Centers content vertically and horizontally */
  align-items: center;
  justify-content: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  position: absolute;
  top: 0;
  left: 13%;
  z-index: 3;
}

/* SOL Trending Feed */
#sol-trending-feed {
  background-color: rgba(0, 0, 0, 0.7);
  padding: 10px 20px;
  border-radius: 5px;
  font-size: 24px;
  color: #eaeaea;
  text-align: center;
  height: 50px; /* Increased to prevent clipping */
  display: flex; /* Centers content vertically and horizontally */
  align-items: center;
  justify-content: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  position: absolute;
  top: 0;
  left: calc(13% + 300px + 20px);
  z-index: 3;
}

@keyframes pulse-green {
  0% { background-color: rgba(0, 255, 0, 0.5); }
  100% { background-color: rgba(0, 0, 0, 0.7); }
}

@keyframes pulse-red {
  0% { background-color: rgba(255, 0, 0, 0.5); }
  100% { background-color: rgba(0, 0, 0, 0.7); }
}

/* Navigation Menu - ensure it’s on top */
#nav-menu {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
}

#nav-menu button {
  flex: 1 1 auto;
  min-width: 150px;
  max-width: 200px;
  padding: 15px 20px;
  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;
  height: calc(90vw * (9 / 16));
  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;
}

@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; }
}

#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: transparent !important;
  z-index: 1;
}

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;
  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 {
  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 {
  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 {
  font-size: 12px;
  color: gray;
  text-align: center;
  margin-top: 20px;
  padding: 10px;
}

#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 */
#leaderboard-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(13, 13, 13, 0.95);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  overflow-y: auto;
}

#leaderboard-content {
  background-color: #1a1a1a;
  padding: 20px;
  border-radius: 10px;
  width: 90%;
  max-width: 800px;
  text-align: center;
  color: #FFD700;
  font-family: 'Press Start 2P', cursive;
  position: relative;
  box-sizing: border-box;
  margin: 20px 0;
}

#leaderboard-content h2 {
  font-size: 32px;
  margin-bottom: 20px;
  color: #FFD700;
  text-shadow: 2px 2px 4px #000000;
}

#leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 0 auto;
  max-width: 600px;
  max-height: 450px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  touch-action: pan-y;
}

#leaderboard-list::-webkit-scrollbar {
  display: none;
}

#leaderboard-list li {
  margin: 10px 0;
  font-size: 20px;
  padding: 10px;
  background-color: rgba(255, 255, 255, 0.1);
  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;
  position: relative;
  z-index: 1003;
}

#leaderboard-list li:hover {
  background-color: rgba(255, 215, 0, 0.2);
}

#back-to-menu-leaderboard {
  margin-top: 30px;
  margin-bottom: 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;
  z-index: 1004;
}

#back-to-menu-leaderboard:hover {
  background-color: #2b2b2b;
}

#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;
}

#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;
}

.hidden { display: none !important; }
.flex-center { display: flex !important; justify-content: center; align-items: center; }

/* Responsive Styles */
@media (max-width: 767px) {
  #start-screen {
    width: 90%;
    max-width: 400px;
    height: auto;
    padding-bottom: 0;
    margin: auto;
    position: relative;
    max-height: none;
    padding-top: 20px;
  }

  #start-screen #background-video {
    object-fit: cover;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
  }

  #feeds-container {
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  #sol-price-feed,
  #sol-trending-feed {
    position: static;
    transform: none;
    font-size: 18px;
    padding: 8px 16px;
    width: 100%;
    max-width: 100%;
    margin-bottom: 10px;
    white-space: normal;
    word-wrap: break-word;
  }

  #nav-menu {
    flex-direction: column;
    align-items: center;
  }

  #nav-menu button {
    width: 80%;
    max-width: 250px;
    min-width: 0;
  }

  #game-container {
    width: 90vw;
    height: calc(90vw * (9 / 16));
    max-width: 95%;
    max-height: 95vh;
  }

  #end-content h1 { font-size: 36px; }
  #end-content p { font-size: 18px; }
  #player-name, #solana-address { font-size: 16px; }
  #end-buttons button { padding: 8px 16px; font-size: 14px; width: 80%; max-width: 100%; }

  .grid-container { grid-template-columns: 1fr; }
  .grid-item { padding: 15px; margin-bottom: 20px; width: 100%; max-width: 100%; }

  html, body { touch-action: manipulation; }

  #leaderboard-content { width: 100%; max-width: 90%; margin: 50px 0; }
  #leaderboard-list { font-size: 16px; max-height: 350px; }
  #back-to-menu-leaderboard { margin-top: 20px; margin-bottom: 20px; }

  .grid-item code {
    display: block;
    width: 100%;
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-all;
    font-size: 11px;
    padding: 0 5px;
    box-sizing: border-box;
  }
}

/* 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;
  font-size: 24px;
  background-color: rgba(0, 0, 0, 0.5);
  padding: 5px 15px;
  border-radius: 5px;
  z-index: 100;
}

/* Giveaway Popup Styles */
#popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(13, 13, 13, 0.8);
  display: none;
  z-index: 1001;
}

#giveaway-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: #1a1a1a;
  padding: 40px 30px;
  border-radius: 10px;
  box-shadow: 0 0 20px rgba(0,0,0,0.7);
  width: 90%;
  max-width: 500px;
  z-index: 1002;
  display: none;
  color: #eaeaea;
  font-family: 'Roboto', Arial, sans-serif;
  box-sizing: border-box;
}

#giveaway-popup:not(.hidden) { display: block; }

#giveaway-popup .popup-content { position: relative; }

#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;
}

#giveaway-popup .close-button:hover { color: #ff0000; }

#giveaway-popup h2 {
  font-size: 32px;
  margin-bottom: 30px;
  color: #FFD700;
  text-align: center;
}

#giveaway-popup ol.eligibility-requirements {
  font-size: 18px;
  margin-bottom: 20px;
  color: #cccccc;
  padding-left: 20px;
}

#giveaway-popup ol.eligibility-requirements li { margin-bottom: 10px; }

#giveaway-popup ol.eligibility-requirements li::marker {
  color: #FFD700;
  font-weight: bold;
}

#retweet-button {
  margin-top: 10px;
  padding: 15px 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 ease;
  font-family: 'Roboto', Arial, sans-serif;
}

#retweet-button:hover { background-color: #2b2b2b; }

/* Meme Coins Container */
.meme-coin-wrapper {
  position: absolute;
}

/* Meme Coin Card Styles */
.meme-coin-card {
  position: relative;
  width: 100px;
  height: 100px;
  display: block;
  pointer-events: auto;
  z-index: 1; /* Above background but below feeds */
  transition: all 0.3s ease;
}

.meme-coin-card .card-content {
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  border: 1px solid #444;
  border-radius: 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 12px;
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
  padding: 5px;
}

.meme-coin-card img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 5px;
}

.meme-coin-card p {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  margin: 2px 0;
  font-size: 10px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8); /* Improved readability */
}

.meme-coin-card:hover .card-content {
  background-color: rgba(0, 0, 0, 0.9);
  cursor: pointer;
}

.meme-coin-card.positive-glow {
  box-shadow: 0 0 5px rgba(0, 255, 0, 0.5); /* Subtle glow for non-expanded state */
}

.meme-coin-card.negative-glow {
  box-shadow: 0 0 5px rgba(255, 0, 0, 0.5); /* Subtle glow for non-expanded state */
}

.meme-coin-card.enlarged {
  position: fixed;
  top: 40%; /* Positioned higher on the screen */
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200px; /* Reduced width for compactness */
  max-width: 90vw;
  height: auto;
  max-height: 80vh;
  overflow-y: auto;
  z-index: 100;
  animation: none;
  background-color: rgba(0, 0, 0, 0.9);
  border-radius: 10px;
  box-shadow: 0 0 20px rgba(0,0,0,0.5); /* Default shadow for no price change */
}

.meme-coin-card.enlarged .card-content {
  height: auto;
  padding: 10px 2px 5px 2px; /* Reduced left and right padding */
}

.meme-coin-card.enlarged .expanded-info {
  display: block;
}

.meme-coin-card .expanded-info {
  display: none;
  width: 100%;
  box-sizing: border-box;
  padding: 5px;
  font-size: 12px;
  text-align: center;
}

.meme-coin-card .expanded-info p {
  white-space: normal;
  overflow-wrap: break-word;
  line-height: 1.4;
  margin: 5px 0;
  font-size: 12px;
  color: #eaeaea;
  text-shadow: none;
}

.meme-coin-card .expanded-info a {
  color: #00adb5;
  text-decoration: none;
  display: block;
  margin-top: 10px;
  text-align: center;
}

.meme-coin-card .expanded-info a:hover {
  text-decoration: underline;
}

/* Glow Animations for Expanded Cards */
@keyframes pulse-green-glow {
  0% {
    border: 4px solid rgba(0, 255, 0, 1);
    box-shadow: 0 0 10px 5px rgba(0, 255, 0, 0.7);
  }
  50% {
    border: 6px solid rgba(0, 255, 0, 1);
    box-shadow: 0 0 15px 10px rgba(0, 255, 0, 0.9);
  }
  100% {
    border: 4px solid rgba(0, 255, 0, 1);
    box-shadow: 0 0 10px 5px rgba(0, 255, 0, 0.7);
  }
}

@keyframes pulse-red-glow {
  0% {
    border: 4px solid rgba(255, 0, 0, 1);
    box-shadow: 0 0 10px 5px rgba(255, 0, 0, 0.7);
  }
  50% {
    border: 6px solid rgba(255, 0, 0, 1);
    box-shadow: 0 0 15px 10px rgba(255, 0, 0, 0.9);
  }
  100% {
    border: 4px solid rgba(255, 0, 0, 1);
    box-shadow: 0 0 10px 5px rgba(255, 0, 0, 0.7);
  }
}

.meme-coin-card.enlarged.positive-glow {
  animation: pulse-green-glow 2s infinite;
}

.meme-coin-card.enlarged.negative-glow {
  animation: pulse-red-glow 2s infinite;
}

/* Responsive Adjustments for Meme Coin Card */
@media (max-width: 767px) {
  .meme-coin-card {
    width: 80px;
    height: 80px;
  }
  .meme-coin-card .card-content {
    font-size: 10px;
    padding: 3px;
  }
  .meme-coin-card img {
    width: 30px;
    height: 30px;
  }
  .meme-coin-card p {
    font-size: 8px;
  }
  .meme-coin-card.enlarged {
    width: 180px; /* Slightly narrower for small screens */
  }
  .meme-coin-card.enlarged .card-content {
    padding: 8px 2px 3px 2px;
  }
  .meme-coin-card .expanded-info p {
    font-size: 10px;
  }
}

/* Animations */
@keyframes scroll-down {
  0% { top: -100px; }
  100% { top: calc(100% + 100px); }
}

@keyframes scroll-right {
  0% { left: -80px; }
  100% { left: calc(100% + 80px); }
}