:root {
    /* Light theme variables */
    --bg-color-light: #f0f0f0;
    --text-color-light: #333;
    --container-bg-light: #fff;
    --container-shadow-light: rgba(0, 0, 0, 0.1);
    --table-color-light: #8B4513;
    --btn-color-light: #3498db;
    --btn-hover-light: #2980b9;
    --btn-disabled-light: #95a5a6;
    --counter-color-light: #e74c3c;
    --player1-color-light: #3498db;
    --player2-color-light: #e74c3c;
    --ball-color-light: #2ecc71;
    --floor-color-light: #95a5a6;
    --game-over-bg-light: rgba(0, 0, 0, 0.7);
    --game-over-text-light: white;
    --restart-btn-light: #2ecc71;
    
    /* Dark theme variables */
    --bg-color-dark: #1a1a1a;
    --text-color-dark: #f0f0f0;
    --container-bg-dark: #2c2c2c;
    --container-shadow-dark: rgba(0, 0, 0, 0.3);
    --table-color-dark: #a05c2c;
    --btn-color-dark: #2980b9;
    --btn-hover-dark: #3498db;
    --btn-disabled-dark: #5c6364;
    --counter-color-dark: #e74c3c;
    --player1-color-dark: #2980b9;
    --player2-color-dark: #c0392b;
    --ball-color-dark: #27ae60;
    --floor-color-dark: #5c6364;
    --game-over-bg-dark: rgba(0, 0, 0, 0.85);
    --game-over-text-dark: #f0f0f0;
    --restart-btn-dark: #27ae60;
}

/* Apply theme variables based on data-theme attribute */
[data-theme="light"] {
    --bg-color: var(--bg-color-light);
    --text-color: var(--text-color-light);
    --container-bg: var(--container-bg-light);
    --container-shadow: var(--container-shadow-light);
    --table-color: var(--table-color-light);
    --btn-color: var(--btn-color-light);
    --btn-hover: var(--btn-hover-light);
    --btn-disabled: var(--btn-disabled-light);
    --counter-color: var(--counter-color-light);
    --player1-color: var(--player1-color-light);
    --player2-color: var(--player2-color-light);
    --ball-color: var(--ball-color-light);
    --floor-color: var(--floor-color-light);
    --game-over-bg: var(--game-over-bg-light);
    --game-over-text: var(--game-over-text-light);
    --restart-btn: var(--restart-btn-light);
}

[data-theme="dark"] {
    --bg-color: var(--bg-color-dark);
    --text-color: var(--text-color-dark);
    --container-bg: var(--container-bg-dark);
    --container-shadow: var(--container-shadow-dark);
    --table-color: var(--table-color-dark);
    --btn-color: var(--btn-color-dark);
    --btn-hover: var(--btn-hover-dark);
    --btn-disabled: var(--btn-disabled-dark);
    --counter-color: var(--counter-color-dark);
    --player1-color: var(--player1-color-dark);
    --player2-color: var(--player2-color-dark);
    --ball-color: var(--ball-color-dark);
    --floor-color: var(--floor-color-dark);
    --game-over-bg: var(--game-over-bg-dark);
    --game-over-text: var(--game-over-text-dark);
    --restart-btn: var(--restart-btn-dark);
}

body {
    font-family: 'Arial', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
}

/* Start screen styles */
.start-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg-color);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  transition: opacity 0.5s ease;
}

.start-content {
  text-align: center;
  padding: 2rem;
  border-radius: 10px;
  background-color: var(--container-bg);
  box-shadow: 0 10px 25px var(--container-shadow);
  max-width: 500px;
}

.start-content h2 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.start-content p {
  font-size: 1.2rem;
  margin-bottom: 2rem;
  line-height: 1.5;
}

.start-button {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background-color: var(--ball-color);
  border: none;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 auto;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
}

.start-button span {
  color: white;
  font-weight: bold;
  font-size: 1.5rem;
  text-transform: uppercase;
}

.start-button:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.start-button:active {
  transform: scale(0.95);
}

@keyframes flicker {
  0%, 100% {
    opacity: 0.5;
    transform: translateY(0) scale(1);
  }
  25% {
    opacity: 0.8;
    transform: translateY(-5px) scale(1.2);
  }
  50% {
    opacity: 0.6;
    transform: translateY(-8px) scale(0.9);
  }
  75% {
    opacity: 0.9;
    transform: translateY(-12px) scale(1.1);
  }
}

/* Hide the game container initially */
.game-container {
  display: none;
}

/* Show the game container when active */
.game-container.active {
  display: block;
}

.game-container {
    width: 1200px;
    height: 700px; /* Changed from 500px to 700px */
    position: relative;
    background-color: var(--container-bg);
    border-radius: 10px;
    box-shadow: 0 10px 25px var(--container-shadow);
    overflow: hidden;
    transition: background-color 0.3s, box-shadow 0.3s;
}

.table {
    position: absolute;
    bottom: 150px; /* Changed back to 150px to align with players */
    left: 200px;
    width: 800px;
    height: 20px;
    background-color: var(--table-color);
    border-radius: 5px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    border: 1px solid #5d2906;
    transition: background-color 0.3s;
}

#player1 {
    left: 20px;
    background-color: var(--player1-color);
    border-radius: 10px 10px 0 0;
}

#player2 {
    right: 20px;
    background-color: var(--player2-color);
    border-radius: 10px 10px 0 0;
}

.ball {
    position: absolute;
    width: 15px;
    height: 15px;
    background-color: var(--ball-color);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: background-color 0.3s;
}

.controls {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 800px;
}

.sliders {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 400px;
    margin-bottom: 15px;
    gap: 15px;
}

.slider-container {
    width: 100%;
}

.slider {
    width: 100%;
    height: 10px;
    -webkit-appearance: none;
    appearance: none;
    background: #ddd;
    border-radius: 5px;
    outline: none;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.slider:hover {
    opacity: 1;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--btn-color);
    cursor: pointer;
    transition: background-color 0.3s;
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--btn-color);
    cursor: pointer;
    transition: background-color 0.3s;
}

.bounce-btn {
    padding: 10px 20px;
    font-size: 18px;
    background-color: var(--btn-color);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.bounce-btn:hover:not(:disabled) {
    background-color: var(--btn-hover);
}

.bounce-btn:disabled {
    background-color: var(--btn-disabled);
    cursor: not-allowed;
}

.status {
    font-size: 20px;
    font-weight: bold;
    margin-top: 10px;
    height: 30px;
}

.counter {
    font-size: 24px;
    font-weight: bold;
    color: var(--counter-color);
}

.game-over {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: auto;
  max-width: 500px;
  height: auto;
  padding: 30px 40px;
  background-color: var(--container-bg);
  border-radius: 15px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: var(--text-color);
  font-size: 24px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  z-index: 100;
  text-align: center;
  display: none;
}
.game-over-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--game-over-bg);
  z-index: 90;
  display: none;
}

.restart-btn {
  margin-top: 25px;
  padding: 12px 25px;
  font-size: 18px;
  background-color: var(--restart-btn);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.3s, transform 0.2s;
  font-weight: bold;
}
.restart-btn:hover {
  background-color: var(--btn-hover);
  transform: scale(1.05);
}

#gameOverText {
  margin-bottom: 15px;
  line-height: 1.4;
}

.floor {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background-color: var(--floor-color);
    transition: background-color 0.3s;
}

.trajectory-point {
    position: absolute;
    width: 4px;
    height: 4px;
    background-color: rgba(255, 0, 0, 0.8);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
}

/* Theme toggle switch styles */
.theme-switch-container {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
}

.theme-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
    margin: 0 10px;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider-switch {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    -webkit-transition: .4s;
    transition: .4s;
    border-radius: 34px;
}

.slider-switch:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider-switch {
    background-color: #2980b9;
}

input:focus + .slider-switch {
    box-shadow: 0 0 1px #2980b9;
}

input:checked + .slider-switch:before {
    -webkit-transform: translateX(26px);
    -ms-transform: translateX(26px);
    transform: translateX(26px);
}

.theme-icon {
    font-size: 24px;
}

.sun-icon {
    color: #f39c12;
}

.moon-icon {
    color: #f0f0f0;
}

.bounce-number {
    position: absolute;
    font-size: 24px;
    font-weight: bold;
    color: white;
    background-color: var(--counter-color);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
    transform: translate(-50%, -50%);
    z-index: 10;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

.bounce-requirement {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 24px;
    font-weight: bold;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 8px 15px;
    border-radius: 10px;
    z-index: 10;
}


.in-game-controls {
    position: absolute;
    bottom: 170px;;
    left: 50px;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 15px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 300px;
    transition: opacity 0.3s ease;
    z-index: 10;
    color: white;
}
  
/* Make sliders more visible in the game */
.in-game-controls .sliders {
    width: 100%;
    margin-bottom: 10px;
}
  
.in-game-controls .slider-container {
    margin-bottom: 10px;
}
  
.in-game-controls .slider {
    background: #555;
}
  
.in-game-controls .slider::-webkit-slider-thumb {
    background: var(--player1-color);
}
  
.in-game-controls .slider::-moz-range-thumb {
    background: var(--player1-color);
}
  
/* Make the bounce button stand out */
.in-game-controls .bounce-btn {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    font-weight: bold;
    background-color: var(--player1-color);
}
  
/* Hide this element by default - JavaScript will show/hide it */
.in-game-controls.hidden {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}
  
/* Remove the original controls container that was outside the game */
.controls {
    display: none;
}

.player-img {
    position: absolute;
    top: 0;
    width: 100%;  /* Makes the image take the full width of the player div */
    height: auto;  /* Maintains aspect ratio */
    max-height: 200px;  /* Ensures the image isn't taller than the player div */
    object-fit: contain;  /* Ensures the entire image is visible */
    z-index: 2;  /* Places the image on top of the colored rectangle */
    background-color: transparent;
}

/* Update the player styles to ensure proper layering */
.player {
    position: absolute;
    bottom: 0px;
    width: 150px;
    height: 200px;
    transition: background-color 0.3s;
    overflow: visible;  /* Allows the image to potentially extend beyond the div if needed */
}   

.game-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 20px 30px;
    border-radius: 10px;
    font-size: 32px;
    font-weight: bold;
    text-align: center;
    opacity: 0;
    transition: opacity 0.5s ease;
    z-index: 100;
    pointer-events: none;
    min-width: 300px;
  }
  
  .game-message.show {
    opacity: 1;
  }

  @keyframes letterBounce {
    0% { transform: translateY(50px); opacity: 0; }
    60% { transform: translateY(-10px); opacity: 1; } 
    80% { transform: translateY(5px); opacity: 1; }
    100% { transform: translateY(0); opacity: 1; }
  }
  
  .game-message .letter-animated {
    display: inline-block;
    animation: letterBounce 0.5s forwards;
    opacity: 0;
  }
  
  /* Make subsequent letters appear with delay */
  .game-message .letter-animated:nth-child(1) { animation-delay: 0.1s; }
  .game-message .letter-animated:nth-child(2) { animation-delay: 0.2s; }
  .game-message .letter-animated:nth-child(3) { animation-delay: 0.3s; }
  .game-message .letter-animated:nth-child(4) { animation-delay: 0.4s; }
  .game-message .letter-animated:nth-child(5) { animation-delay: 0.5s; }

/* Aiming arrow styles */
.aim-arrow {
    position: absolute;
    height: 6px;
    background-color: transparent;
    transform-origin: left center;
    border: 2px solid white;
    border-radius: 3px;
    z-index: 5;
    pointer-events: none;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.7);
}

.aim-arrow-fill {
    position: absolute;
    height: 100%;
    background-color: var(--player1-color);
    border-radius: 1px;
    width: 0%; /* Will be animated from 0-100% */
    left: 0;
    top: 0;
}

.aim-arrow::after {
    content: '';
    position: absolute;
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 10px solid white;
}

/* When mouse is held down, show a pulsing effect on the arrow */
@keyframes pulse {
    0% { box-shadow: 0 0 5px rgba(255, 255, 255, 0.5); }
    50% { box-shadow: 0 0 15px rgba(255, 255, 255, 0.8); }
    100% { box-shadow: 0 0 5px rgba(255, 255, 255, 0.5); }
}

.aim-arrow.charging {
    animation: pulse 1s infinite;
}

/* Cursor changes for the game container */
.game-container.player-turn {
    cursor: crosshair;
}

.game-container.charging {
    cursor: grabbing;
}

.game-container.not-player-turn {
    cursor: default;
}

/* Make the hidden class also work for the arrow */
.hidden {
    display: none !important;
}

/* Optionally, apply different fill colors based on power levels */
.power-low .aim-arrow-fill {
    background-color: #3498db; /* Blue for low power */
}

.power-medium .aim-arrow-fill {
    background-color: #f39c12; /* Orange for medium power */
}

.power-high .aim-arrow-fill {
    background-color: #e74c3c; /* Red for high power */
}

/* Achievement popup styles */
.achievement-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 2000;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.achievement-popup.hidden {
  opacity: 0;
  pointer-events: none;
}

.popup-content {
  background-color: var(--container-bg);
  border-radius: 10px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  color: var(--text-color);
  transform: scale(1);
  transition: transform 0.3s ease;
}

.achievement-popup.hidden .popup-content {
  transform: scale(0.8);
}

.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background-color: var(--ball-color);
  color: white;
}

.popup-header h3 {
  margin: 0;
  font-size: 1.2rem;
}

.close-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.close-btn:hover {
  transform: scale(1.2);
}

.popup-body {
  padding: 20px;
}

.popup-body p {
  font-size: 1.1rem;
  margin-top: 0;
  margin-bottom: 20px;
  text-align: center;
}

.share-container {
  display: flex;
  margin-bottom: 10px;
}

#shareText {
  flex: 1;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 5px 0 0 5px;
  font-size: 0.9rem;
  background-color: var(--bg-color);
  color: var(--text-color);
}

.copy-btn {
  padding: 10px 15px;
  background-color: var(--btn-color);
  color: white;
  border: none;
  border-radius: 0 5px 5px 0;
  cursor: pointer;
  font-weight: bold;
  transition: background-color 0.2s;
}

.copy-btn:hover {
  background-color: var(--btn-hover);
}

.copy-message {
  text-align: center;
  color: var(--player1-color);
  font-size: 0.9rem;
  height: 20px;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.copy-message.hidden {
  opacity: 0;
}

/* Winner share box styles */
#winnerShareBox {
  margin-top: 20px;
  text-align: center;
  width: 100%;
}

#winnerShareBox p {
  margin-bottom: 10px;
  font-size: 16px;
}

#winnerShareBox .share-container {
  display: flex;
  margin-bottom: 10px;
}

#winnerShareText {
  flex: 1;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 5px 0 0 5px;
  font-size: 0.9rem;
  background-color: var(--bg-color);
  color: var(--text-color);
}

#copyWinnerText {
  padding: 10px 15px;
  background-color: var(--btn-color);
  color: white;
  border: none;
  border-radius: 0 5px 5px 0;
  cursor: pointer;
  font-weight: bold;
  transition: background-color 0.2s;
}

#copyWinnerText:hover {
  background-color: var(--btn-hover);
}

#winnerCopyMessage {
  text-align: center;
  color: var(--player1-color);
  font-size: 0.9rem;
  height: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#winnerCopyMessage.visible {
  opacity: 1;
}

/* Portfolio link styles */
.portfolio-link-container {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 100;
}

.portfolio-link {
  display: inline-block;
  background-color: var(--btn-color);
  color: white;
  padding: 10px 15px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: bold;
  font-size: 16px;
  transition: background-color 0.3s, transform 0.2s;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.portfolio-link:hover {
  background-color: var(--btn-hover);
  transform: scale(1.05);
}

.portfolio-link:active {
  transform: scale(0.95);
}

/* Adjust the theme toggle position to make space for the new button */
.theme-switch-container {
  position: relative;
  z-index: 100;
}

/* Make sure the button is visible on the start screen too */
#startScreen .portfolio-link-container {
  position: fixed;
}