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

body {
  font-family: "Courier New", monospace;
  background: #000;
  color: #fff;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

.game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  max-width: 1200px;
  max-height: 800px;
  background: #111;
  border: 2px solid #333;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #000 0%, #111 100%);
  display: block;
}

.ui-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

.score-display {
  position: absolute;
  top: 20px;
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.score,
.distance {
  background: rgba(0, 0, 0, 0.8);
  padding: 10px 15px;
  border: 1px solid #333;
  font-size: 16px;
  font-weight: bold;
}

.next-ability-container {
  position: absolute;
  top: 20px;
  right: 20px;
  margin-bottom: 10px;
}

.next-ability {
  background: rgba(0, 0, 0, 0.8);
  padding: 10px 15px;
  border: 1px solid #00ff00;
  color: #00ff00;
  font-size: 16px;
  font-weight: bold;
}

.active-abilities {
  position: absolute;
  top: 80px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-width: 200px;
}

.active-ability {
  background: rgba(0, 0, 0, 0.9);
  border: 1px solid #fff;
  padding: 8px 12px;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: abilityAppear 0.5s ease-out;
}

.active-ability.expiring {
  border-color: #ff4444;
  animation: abilityExpire 1s ease-in-out infinite;
}

.available-abilities {
  position: absolute;
  bottom: 20px;
  left: 20px;
  display: flex;
  flex-direction: row;
  gap: 10px;
  max-width: 600px;
  flex-wrap: wrap;
}

.available-ability {
  background: rgba(0, 0, 0, 0.9);
  border: 2px solid #00ff00;
  padding: 12px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  pointer-events: all;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  min-width: 100px;
  text-align: center;
  animation: abilityAppear 0.5s ease-out;
}

.available-ability:hover {
  background: rgba(0, 255, 0, 0.2);
  transform: scale(1.05);
  box-shadow: 0 0 15px rgba(0, 255, 0, 0.5);
}

.available-ability:active {
  transform: scale(0.95);
}

.available-ability-icon {
  font-size: 20px;
  margin-bottom: 2px;
}

.available-ability-name {
  font-size: 12px;
  font-weight: bold;
  line-height: 1.2;
}

.mobile-controls {
  position: absolute;
  bottom: 30px;
  right: 30px;
  left: auto;
  transform: none;
  display: none;
  pointer-events: all;
}

.mobile-swap-btn {
  background: rgba(0, 0, 0, 0.9);
  border: 3px solid #fff;
  color: #fff;
  padding: 20px 30px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  border-radius: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 120px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.mobile-swap-btn:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.1);
  border-color: #00ff00;
}

.swap-icon {
  font-size: 24px;
  animation: swapIconPulse 2s ease-in-out infinite;
}

.swap-text {
  font-size: 14px;
  letter-spacing: 2px;
}

@keyframes swapIconPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

.ability-selection,
.theme-selection-screen {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.95);
  border: 3px solid #00ff00;
  padding: 30px;
  text-align: center;
  pointer-events: all;
  display: none;
  animation: selectionAppear 0.8s ease-out;
  box-shadow: 0 0 50px rgba(0, 255, 0, 0.3);
  max-height: 90vh;
  overflow-y: auto;
}

.leaderboard-screen,
.name-input-screen {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.95);
  border: 3px solid #00ff00;
  padding: 30px;
  text-align: center;
  pointer-events: all;
  display: none;
  animation: selectionAppear 0.8s ease-out;
  box-shadow: 0 0 50px rgba(0, 255, 0, 0.3);
  max-height: 90vh;
  overflow-y: auto;
  min-width: 400px;
}

.selection-header h2,
.theme-selection-screen h2 {
  font-size: 2rem;
  margin-bottom: 10px;
  color: #00ff00;
  text-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
}

.leaderboard-screen h2,
.name-input-screen h2 {
  font-size: 2rem;
  margin-bottom: 10px;
  color: #00ff00;
  text-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
}

.selection-header p,
.theme-selection-screen p {
  margin-bottom: 30px;
  opacity: 0.8;
}

.leaderboard-screen p,
.name-input-screen p {
  margin-bottom: 20px;
  opacity: 0.8;
}

.ability-options,
.theme-options {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.leaderboard-list {
  margin: 20px 0;
  text-align: left;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.leaderboard-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  margin: 8px 0;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid #333;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.leaderboard-entry:hover {
  background: rgba(0, 255, 0, 0.1);
  border-color: #00ff00;
}

.leaderboard-entry.highlight {
  background: rgba(0, 255, 0, 0.2);
  border-color: #00ff00;
  animation: highlightPulse 2s ease-in-out;
}

.leaderboard-rank {
  font-size: 1.2rem;
  font-weight: bold;
  color: #00ff00;
  min-width: 40px;
}

.leaderboard-name {
  flex: 1;
  font-size: 1.1rem;
  margin: 0 20px;
  text-align: left;
}

.leaderboard-score {
  font-size: 1.1rem;
  font-weight: bold;
  color: #fff;
  min-width: 80px;
  text-align: right;
}

.leaderboard-date {
  font-size: 0.9rem;
  opacity: 0.6;
  min-width: 100px;
  text-align: right;
}

.empty-leaderboard {
  text-align: center;
  opacity: 0.6;
  font-style: italic;
  padding: 40px 20px;
}

#playerNameInput {
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid #333;
  color: #fff;
  padding: 15px 20px;
  font-size: 1.2rem;
  font-family: inherit;
  border-radius: 8px;
  margin: 20px 0;
  width: 100%;
  max-width: 300px;
  text-align: center;
}

#playerNameInput:focus {
  outline: none;
  border-color: #00ff00;
  background: rgba(0, 255, 0, 0.1);
}

#playerNameInput::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

#clearLeaderboardBtn {
  background: #ff4444;
  color: #fff;
  margin-top: 20px;
}

#clearLeaderboardBtn:hover {
  background: #cc3333;
}

.ability-option,
.theme-option {
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid #fff;
  padding: 20px;
  width: 200px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  padding-bottom: 25px; /* Adjusted for progress bar */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.theme-option {
  padding-bottom: 20px; /* No progress bar */
}

.ability-option:hover,
.theme-option:hover {
  border-color: #00ff00;
  background: rgba(0, 255, 0, 0.1);
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

.ability-option.selected,
.theme-option.selected {
  border-color: #00ff00;
  background: rgba(0, 255, 0, 0.2);
  /* animation: abilitySelect 0.5s ease-out; */
}

.ability-progress-container {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 5px; /* Height of the bar */
  background: rgba(0, 0, 0, 0.5);
  overflow: hidden;
  border-bottom-left-radius: 8px; /* Match parent border-radius */
  border-bottom-right-radius: 8px; /* Match parent border-radius */
}

.ability-progress-bar {
  height: 100%;
  width: 0%;
  background: #00ff00; /* Green color */
  transition: width 0.05s linear; /* Smooth filling */
}

.ability-name,
.theme-name {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 10px;
  color: #fff;
}

.ability-description,
.theme-description {
  font-size: 12px;
  opacity: 0.8;
  line-height: 1.4;
}

.ability-icon,
.theme-icon {
  width: 40px;
  height: 40px;
  margin: 0 auto 15px;
  background: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #000;
}

.theme-icon {
  margin-bottom: 0;
}

.start-screen,
.game-over-screen,
.settings-screen {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  background: rgba(0, 0, 0, 0.95);
  padding: 40px;
  border: 2px solid #fff;
  pointer-events: all;
  border-radius: 15px;
  max-height: 90vh;
  overflow-y: auto;
  /* Added for centering buttons */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px; /* Space between elements */
}

.game-over-screen,
.ability-selection,
.settings-screen,
.theme-selection-screen,
.leaderboard-screen,
.name-input-screen {
  display: none;
}

.start-screen {
  display: flex; /* Changed to flex */
}

.start-screen h1 {
  font-size: 3rem;
  margin-bottom: 20px;
  letter-spacing: 4px;
}

.ability-hint {
  color: #00ff00;
  font-weight: bold;
  margin: 10px 0;
}

.start-screen p,
.game-over-screen p,
.settings-screen p {
  font-size: 1.2rem;
  margin-bottom: 30px;
  opacity: 0.8;
}

.controls {
  margin: 30px 0;
}

.control-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin: 10px 0;
}

.key {
  background: #fff;
  color: #000;
  padding: 8px 16px;
  border-radius: 4px;
  font-weight: bold;
  font-size: 14px;
}

button {
  background: #fff;
  color: #000;
  border: none;
  padding: 15px 30px;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  pointer-events: all;
  border-radius: 8px;
  /* Ensure buttons are not full width when parent is flex */
  width: auto;
  max-width: 100%;
}

button:hover {
  background: #ddd;
  transform: scale(1.05);
}

.game-over-screen h2,
.settings-screen h2 {
  font-size: 2.5rem;
  margin-bottom: 20px;
  color: #ff4444;
}

.settings-screen h2 {
  color: #00ff00; /* Green for settings header */
}

.final-stats {
  margin: 20px 0;
}

.final-stats p {
  margin: 10px 0;
  font-size: 1.1rem;
}

.instructions {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  opacity: 0.6;
}

.key-hint {
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 8px;
  border-radius: 3px;
  font-weight: bold;
}

.hidden {
  display: none !important;
}

/* Settings specific styles */
.settings-screen .setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 20px;
  width: 100%; /* Ensure setting items take full width for alignment */
  max-width: 400px; /* Limit width for better readability */
}

.settings-screen .setting-item label {
  font-size: 1.1rem;
  white-space: nowrap;
}

.settings-screen .setting-item input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  height: 8px;
  background: #333;
  border-radius: 5px;
  outline: none;
  opacity: 0.7;
  transition: opacity .2s;
}

.settings-screen .setting-item input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #00ff00;
  cursor: pointer;
}

.settings-screen .setting-item input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #00ff00;
  cursor: pointer;
}

.settings-screen .setting-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: #00ff00; /* Green checkbox */
}

/* In-game settings button */
.in-game-settings-btn {
  position: absolute;
  top: 20px;
  left: 50%; /* Center horizontally */
  transform: translateX(-50%); /* Center horizontally */
  background: rgba(0, 0, 0, 0.8);
  border: 1px solid #333;
  color: #fff;
  padding: 10px 15px;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 8px;
  pointer-events: all; /* Make it clickable */
  z-index: 11; /* Ensure it's above other UI elements */
  display: none; /* Hidden by default, shown when game is playing */
}

.in-game-settings-btn:hover {
  background: rgba(0, 0, 0, 0.9);
  border-color: #00ff00;
  transform: translateX(-50%) scale(1.05);
}

/* Photo Theme Camera/Canvas styles */
.camera-preview-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 15px;
  width: 100%;
  max-width: 250px; /* Limit width for better display */
}

#cameraVideo {
  width: 100%;
  height: auto;
  background: #000;
  border: 2px solid #00ff00;
  border-radius: 8px;
  display: block;
  object-fit: cover; /* Ensure video fills the space */
}

#photoCanvas {
  display: none; /* Hidden by default, used for capturing */
}

#takePhotoBtn {
  background: #00ff00;
  color: #000;
  padding: 10px 20px;
  font-size: 1rem;
  font-weight: bold;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.2s;
  width: auto;
  max-width: 150px;
}

#takePhotoBtn:hover {
  background: #00cc00;
}

/* Device-specific visibility */
.mobile-only {
  display: none;
}

.desktop-only {
  display: block;
}

/* Animations */
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

@keyframes abilityAppear {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.8);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes abilityExpire {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes selectionAppear {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes abilitySelect {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
    background: rgba(0, 255, 0, 0.4);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes highlightPulse {
  0%,
  100% {
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.6);
  }
}

.shake {
  animation: shake 0.3s ease-in-out;
}

/* Special Effects */
.rainbow-mode {
  animation: rainbow 0.5s linear infinite;
}

@keyframes rainbow {
  0% {
    filter: hue-rotate(0deg);
  }
  100% {
    filter: hue-rotate(360deg);
  }
}

.glitch-effect {
  animation: glitch 0.3s ease-in-out infinite;
}

@keyframes glitch {
  0%,
  100% {
    transform: translate(0);
  }
  20% {
    transform: translate(-2px, 2px);
  }
  40% {
    transform: translate(-2px, -2px);
  }
  60% {
    transform: translate(2px, 2px);
  }
  80% {
    transform: translate(2px, -2px);
  }
}

.neon-glow {
  box-shadow: 0 0 20px currentColor, inset 0 0 20px currentColor;
}

.pixelate {
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

.name-input-screen button {
  margin: 8px 5px;
  min-width: 120px;
}

#newHighScore {
  color: #00ff00;
  font-size: 1.4rem;
  font-weight: bold;
}

/* Mobile-specific styles */
@media (max-width: 768px), (pointer: coarse) {
  .mobile-only {
    display: flex;
  }

  .desktop-only {
    display: none;
  }

  .mobile-controls {
    display: block !important;
  }

  .start-screen,
  .game-over-screen,
  .ability-selection,
  .settings-screen,
  .theme-selection-screen {
    padding: 20px 15px;
    width: 95%;
    max-width: 400px;
    gap: 10px; /* Reduced gap for mobile */
  }

  .leaderboard-screen,
  .name-input-screen {
    padding: 20px 15px;
    width: 95%;
    max-width: 350px;
    min-width: auto;
  }

  .name-input-screen h2 {
    font-size: 1.6rem;
    margin-bottom: 15px;
  }

  .name-input-screen p {
    font-size: 1rem;
    margin-bottom: 15px;
  }

  #playerNameInput {
    font-size: 1rem;
    padding: 12px 15px;
    width: 90%;
    max-width: 250px;
  }

  .name-input-screen button {
    padding: 12px 20px;
    font-size: 1rem;
    margin: 5px;
  }

  .ability-options,
  .theme-options {
    flex-direction: column;
    align-items: center;
    gap: 15px;
  }

  .ability-option,
  .theme-option {
    width: 100%;
    max-width: 280px;
    padding: 15px;
    padding-bottom: 20px; /* Adjusted for mobile progress bar */
  }

  .start-screen h1 {
    font-size: 2.2rem;
    margin-bottom: 10px; /* Reduced from 15px */
  }

  .start-screen p {
    font-size: 1rem;
    margin-bottom: 15px; /* Reduced from 20px */
  }

  .controls {
    margin: 15px 0; /* Reduced from 20px */
  }

  .score-display {
    top: 10px;
    left: 10px;
  }

  .next-ability-container {
    top: 10px;
    right: 10px;
  }

  .next-ability {
    font-size: 14px;
    padding: 8px 12px;
  }

  .active-abilities {
    top: 70px;
    right: 10px;
    max-width: 150px;
  }

  .active-ability {
    font-size: 10px;
    padding: 6px 8px;
  }

  .available-abilities {
    bottom: 10px;
    left: 10px;
    max-width: calc(100% - 160px);
  }

  .available-ability {
    min-width: 80px;
    padding: 8px 12px;
    font-size: 12px;
  }

  .available-ability-icon {
    font-size: 16px;
  }

  .available-ability-name {
    font-size: 10px;
  }

  button {
    padding: 18px 35px;
    font-size: 1.3rem;
  }

  .selection-header h2 {
    font-size: 1.8rem;
  }

  .ability-name {
    font-size: 14px;
  }

  .ability-description {
    font-size: 11px;
  }

  .settings-screen .setting-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }

  .settings-screen .setting-item input[type="range"] {
    width: 100%;
  }

  .in-game-settings-btn {
    top: 10px;
    padding: 8px 12px;
    font-size: 16px;
  }

  .camera-preview-container {
    max-width: 250px;
  }

  .leaderboard-entry {
    padding: 10px 15px;
    flex-direction: column;
    text-align: center;
    gap: 5px;
  }

  .leaderboard-rank {
    min-width: auto;
  }

  .leaderboard-name {
    margin: 0;
    text-align: center;
  }

  .leaderboard-score,
  .leaderboard-date {
    min-width: auto;
    text-align: center;
  }

  .leaderboard-date {
    font-size: 0.8rem;
  }

  #playerNameInput {
    font-size: 1.1rem;
    padding: 12px 15px;
  }
}

/* Extra small phones */
@media (max-width: 480px) {
  .start-screen h1 {
    font-size: 1.6rem; /* Further reduced */
  }

  .start-screen p {
    font-size: 0.9rem; /* Further reduced */
  }

  .controls {
    margin: 10px 0; /* Further reduced */
  }

  .mobile-swap-btn {
    padding: 15px 25px;
    font-size: 16px;
    min-width: 100px;
  }

  .swap-icon {
    font-size: 20px;
  }

  .swap-text {
    font-size: 12px;
  }

  .available-abilities {
    max-width: calc(100% - 140px);
  }

  .available-ability {
  }

  .swap-text {
    font-size: 12px;
  }

  .available-abilities {
    max-width: calc(100% - 140px);
  }

  .available-ability {
    min-width: 70px;
    padding: 6px 8px;
  }

  .available-ability-name {
    font-size: 9px;
  }

  button {
    padding: 12px 25px; /* Smaller buttons */
    font-size: 1.1rem;
  }

  #settingsBtn {
    margin-top: 10px; /* Reduced margin */
  }
}
