/* General Page Styling */
body {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: #000;
  font-family: Arial, sans-serif;
  text-align: center;
}

/* Game Container - Forces Portrait Mode */
.thirty-sec-game {
  position: relative;
  width: 100%;
  height: 100%;
  aspect-ratio: 9 / 16; /* Forces portrait aspect ratio */
  margin: 0 auto;
  background: black;
  color: white;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Background Image Container */
.thirty-sec-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  z-index: 1;
}

/* Overlay for Countdown, Game, and End Screens */
.thirty-sec-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 2;
}

/* HUD (Score & Timer) */
.thirty-sec-hud {
  position: absolute;
  background: rgba(0, 0, 0, 0.7);
  top: 0px;
  left: 0;
  right: 0;
  padding: 14px;
  z-index: 100;
  text-align: center;
}

#gameContainer {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Border Timer Styling */
.thirty-sec-border-timer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
}

.border-top, .border-right, .border-bottom, .border-left {
  position: absolute;
  background: var(--main-color);
  transition: width 0.1s linear, height 0.1s linear;
}

/* Borders start hidden */
.border-top, .border-bottom {
  height: 8px;
  width: 0;
}

.border-left, .border-right {
  width: 8px;
  height: 0;
}

/* Positioning */
.border-top { top: 0; left: 0; }
.border-right { top: 0; right: 0; }
.border-bottom { bottom: 0; right: 0; }
.border-left { bottom: 0; left: 0; }

/* Warning Effect for Last 3 Seconds (Alarm Glow) */
.warning .border-top,
.warning .border-right,
.warning .border-bottom,
.warning .border-left {
  background: #f00 !important;
  animation: alarmGlow 1.5s ease-in-out infinite !important;
}

@keyframes alarmGlow {
  0% {
    box-shadow: 0 0 20px #f00;
    opacity: 1;
  }
  50% {
    box-shadow: 0 0 50px #f00;
    opacity: 0.3;
  }
  100% {
    box-shadow: 0 0 20px #f00;
    opacity: 1;
  }
}

/* Score Display */
.thirty-sec-stats {
  display: flex;
  justify-content: space-between;
  font-size: 18px;
  font-weight: bold;
}

/* Game Area (Where Game Elements Appear) */
.thirty-sec-game-area {
  position: absolute;
  top: 48px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  z-index: 3; /* Ensure game area is above overlay */
  /* Remove background transparency which may cause ghosting */
  background: transparent;
}

/* Score Popup Effect */
.score-popup {
  position: absolute;
  font-size: 22px;
  font-weight: bold;
  color: var(--main-color);
  text-shadow: 0 0 10px var(--main-color);
  animation: fadeOut 1s ease-in-out forwards;
  z-index: 10; /* Keep score popups above other elements */
}

/* Score Fade Effect */
@keyframes fadeOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-20px); }
}

/* Game Over Screen */
.thirty-sec-game-over {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 28px;
  font-weight: bold;
  background: rgba(0, 0, 0, 0.9);
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  z-index: 5;
}

.thirty-sec-game-over button {
  margin-top: 12px;
  padding: 12px;
  font-size: 18px;
  cursor: pointer;
  background: var(--main-color);
  color: black;
  border: none;
  border-radius: 5px;
  font-weight: bold;
}

.thirty-sec-game-over .thirty-sec-reset-highscore {
  font-size: 14px;
  border: 2px solid var(--main-color);
  background: transparent;
  color: var(--main-color);
  padding: 5px 10px;
  margin-top: 25px;
  cursor: pointer;
  display: block;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
} 

/* Style for the leave game button - add this after the reset-highscore button styles */
.thirty-sec-game-over .thirty-sec-leave-game {
  font-size: 18px;
  background: #f44336; /* Red color to make it stand out */
  color: white;
  padding: 12px;
  margin-top: 12px;
  cursor: pointer;
  border: none;
  border-radius: 5px;
  font-weight: bold;
  display: block;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

/* Game Cover & Countdown Start Screen */  
button.thirty-sec-play-button {
  position: absolute;
  bottom: 20%;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px;
  font-size: 18px;
  cursor: pointer;
  background: var(--main-color);
  color: black;
  border: none;
  border-radius: 5px;
  font-weight: bold;
  width: 40%;
  
  /* Animation properties */
  animation: pulse 2s infinite;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  z-index: 101; /* Ensure play button is clickable */
}

@keyframes pulse {
  0% {
    transform: translateX(-50%) scale(1);
    box-shadow: 0 0 0 0 rgba(var(--main-color-rgb), 0.8);
  }
  70% {
    transform: translateX(-50%) scale(1.05);
    box-shadow: 0 0 0 15px rgba(var(--main-color-rgb), 0.1);
  }
  100% {
    transform: translateX(-50%) scale(1);
    box-shadow: 0 0 0 0 rgba(var(--main-color-rgb), 0);
  }
}

button.thirty-sec-play-button:hover {
  transform: translateX(-50%) scale(1.1);
  box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}

button.thirty-sec-play-button:active {
  transform: translateX(-50%) scale(0.95);
}

.thirty-sec-start-screen {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.countdown-text {
  font-size: 72px;
  margin-bottom: 20px;
  color: #fff;
  z-index: 100;
}

@keyframes countdownPulse {
  0% { transform: scale(0.5); }
  100% { transform: scale(4); }
}

.thirty-sec-confirmation-dialog {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.confirmation-content {
  background: rgba(0, 0, 0, 0.9);
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  max-width: 80%;
  color: var(--main-color);
}

.confirmation-buttons {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 20px;
}

.confirmation-buttons button {
  padding: 10px 20px;
  font-size: 16px;
  cursor: pointer;
  background: var(--main-color);
  color: black;
  border: none;
  border-radius: 5px;
}

.confirmation-buttons .confirm-no {
  background: #333;
  color: white;
}

/* Media queries for different device sizes */
@media (min-width: 768px) {
  /* For tablets and larger - don't worry about orientation */
  #gameContainer {
    max-width: 80vh; /* Limit width for larger screens */
  }
}

/* Style for the share button */
.thirty-sec-game-over .thirty-sec-share {
  font-size: 18px;
  background: color-mix(in srgb, var(--main-color) 40%, white);
  color: black;
  padding: 12px;
  margin-top: 12px;
  cursor: pointer;
  border: none;
  border-radius: 5px;
  font-weight: bold;
  display: block;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

/* Style for the share dialog */
.thirty-sec-share-dialog {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.share-content {
  background: rgba(0, 0, 0, 0.9);
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  max-width: 80%;
  color: white;
}

.share-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 20px 0;
}

.share-buttons button {
  padding: 10px 20px;
  font-size: 16px;
  cursor: pointer;
  border: none;
  border-radius: 5px;
}

.share-twitter {
  background: #1e1e1e;
  color: white;
}

.share-cancel {
  background: #333;
  color: white;
  padding: 10px 20px;
  font-size: 14px;
  cursor: pointer;
  border: none;
  border-radius: 5px;
  margin-top: 10px;
}

.share-facebook {
  background: #1877F2;
  color: white;
}

.share-whatsapp {
  background: #25D366;
  color: white;
}

.share-telegram {
  background: #0088cc;
  color: white;
}

.share-reddit {
  background: #ff4500;
  color: white;
}

.share-snapchat {
  background: #FFFC00;
  color: black;
}

.share-linkedin {
  background: #0A66C2;
  color: white;
}

.share-discord {
  background: #5865F2;
  color: white;
}