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

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

body::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(circle at 20% 50%, rgba(0, 255, 0, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(0, 255, 0, 0.05) 0%, transparent 50%);
  pointer-events: none;
}

.screen {
  display: none;
  width: 100%;
  height: 100vh;
  justify-content: center;
  align-items: center;
}

.screen.active {
  display: flex;
}

/* Menu Styles */
.menu-container {
  text-align: center;
  padding: 40px;
  max-width: 500px;
  width: 90%;
  background: rgba(0, 0, 0, 0.9);
  border: 2px solid #0f0;
  box-shadow: 0 0 10px rgba(0, 255, 0, 0.25), inset 0 0 10px rgba(0, 255, 0, 0.05);
  font-family: 'Courier New', monospace;
}

h1 {
  font-size: 4.5rem;
  margin-bottom: 2rem;
  color: #0f0;
  text-shadow: 0 0 5px #0f0, 0 0 10px #0f0, 0 0 15px #0f0;
  letter-spacing: 0.8rem;
  font-weight: 900;
  font-family: 'Courier New', monospace;
}

h2 {
  font-size: 2rem;
  margin-bottom: 1.5rem;
  color: #0f0;
  font-weight: 600;
  text-shadow: 0 0 2.5px #0f0;
  font-family: 'Courier New', monospace;
}

.button-group {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 20px;
}

.menu-btn {
  padding: 16px 36px;
  font-size: 1.1rem;
  background: #000;
  color: #0f0;
  border: 2px solid #0f0;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  box-shadow: 0 0 5px rgba(0, 255, 0, 0.25);
  position: relative;
  overflow: hidden;
  font-family: 'Courier New', monospace;
}

.menu-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0, 255, 0, 0.3), transparent);
  transition: left 0.5s;
}

.menu-btn:hover::before {
  left: 100%;
}

.menu-btn:hover {
  background: rgba(0, 255, 0, 0.1);
  box-shadow: 0 0 10px rgba(0, 255, 0, 0.4);
}

.menu-btn:active {
  transform: scale(0.98);
}

.menu-btn.keyboard-selected {
  background: rgba(0, 255, 0, 0.1);
  box-shadow: 0 0 10px rgba(0, 255, 0, 0.4), 0 0 0 2px #0f0;
}

.menu-btn.secondary {
  background: transparent;
  color: #0f0;
  border: 2px solid rgba(0, 255, 0, 0.5);
  box-shadow: none;
}

.menu-btn.secondary:hover {
  background: rgba(0, 255, 0, 0.05);
  border-color: #0f0;
  box-shadow: 0 0 5px rgba(0, 255, 0, 0.25);
}

.menu-btn.secondary.keyboard-selected {
  background: rgba(0, 255, 0, 0.1);
  border-color: #0f0;
  box-shadow: 0 0 7.5px rgba(0, 255, 0, 0.3), 0 0 0 2px #0f0;
}

/* Input Styles */
input[type="text"] {
  width: 100%;
  padding: 16px 20px;
  font-size: 1.1rem;
  margin-bottom: 15px;
  background: #000;
  border: 2px solid rgba(0, 255, 0, 0.5);
  color: #0f0;
  text-align: center;
  text-transform: uppercase;
  transition: all 0.3s ease;
  font-family: 'Courier New', monospace;
}

input[type="text"]:focus {
  outline: none;
  border-color: #0f0;
  background: rgba(0, 255, 0, 0.05);
  box-shadow: 0 0 5px rgba(0, 255, 0, 0.25);
}

input[type="text"]::placeholder {
  color: rgba(0, 255, 0, 0.5);
  text-transform: none;
}

.error-message {
  color: #f00;
  margin-top: 10px;
  font-size: 0.9rem;
  background: rgba(255, 0, 0, 0.1);
  padding: 8px 12px;
  border: 1px solid #f00;
  font-family: 'Courier New', monospace;
}

.error-message:empty {
  display: none;
  padding: 0;
  margin: 0;
}

/* Room Code Display */
.room-code-container {
  margin: 30px 0;
}

.room-code {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: 0.8rem;
  background: #000;
  padding: 24px;
  margin: 15px 0;
  border: 3px solid #0f0;
  box-shadow: 0 0 10px rgba(0, 255, 0, 0.25), inset 0 0 5px rgba(0, 255, 0, 0.05);
  font-family: 'Courier New', monospace;
}

#lobbyStatus {
  font-size: 1.2rem;
  margin: 20px 0;
  color: #0f0;
  animation: pulse 2s ease-in-out infinite;
  font-family: 'Courier New', monospace;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; text-shadow: 0 0 2.5px #0f0; }
  50% { opacity: 1; text-shadow: 0 0 5px #0f0; }
}

#playerNameDisplay {
  font-size: 1rem;
  color: rgba(0, 255, 0, 0.7);
  margin-bottom: 20px;
  font-family: 'Courier New', monospace;
}

/* Game Screen */
#gameScreen {
  flex-direction: column;
  background: #000;
}

#gameInfo {
  display: flex;
  justify-content: space-between;
  width: 800px;
  max-width: 100%;
  padding: 20px;
  position: absolute;
  top: 0;
  z-index: 10;
}

.player-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f0;
  text-shadow: 0 0 5px #0f0;
  background: rgba(0, 0, 0, 0.8);
  padding: 8px 20px;
  border: 2px solid #0f0;
  font-family: 'Courier New', monospace;
}

#gameCanvas {
  display: block;
  background: #000;
  border: 3px solid #0f0;
  max-width: 100%;
  height: auto;
  box-shadow: 0 0 15px rgba(0, 255, 0, 0.25);
}

/* Mobile Controls */
.mobile-controls {
  display: none;
  position: absolute;
  bottom: 30px;
  gap: 30px;
  z-index: 10;
}

/* Show mobile controls on touch devices */
@media (hover: none) and (pointer: coarse) {
  #gameScreen .mobile-controls {
    display: flex !important;
  }
}

.mobile-btn {
  width: 80px;
  height: 80px;
  font-size: 2rem;
  background: rgba(0, 0, 0, 0.8);
  color: #0f0;
  border: 2px solid #0f0;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  box-shadow: 0 0 7.5px rgba(0, 255, 0, 0.25);
  transition: all 0.2s ease;
  font-family: 'Courier New', monospace;
}

.mobile-btn:active {
  background: rgba(0, 255, 0, 0.2);
  transform: scale(0.95);
  box-shadow: 0 0 10px rgba(0, 255, 0, 0.4);
}

/* Game Over Screen */
#gameOverScreen .menu-container {
  max-width: 600px;
}

#gameOverMessage {
  font-size: 1.5rem;
  margin: 20px 0;
  line-height: 1.8;
  white-space: pre-line;
  color: #0f0;
  font-family: 'Courier New', monospace;
}

#playAgainSection {
  margin-top: 30px;
}

#playAgainSection p {
  font-size: 1.3rem;
  margin-bottom: 20px;
  font-weight: 600;
  color: #0f0;
  font-family: 'Courier New', monospace;
}

/* Responsive Design */
@media (max-width: 850px) {
  #gameCanvas {
    width: 100vw !important;
    height: auto !important;
  }

  #gameInfo {
    width: 100%;
    padding: 10px 15px;
  }

  .player-name {
    font-size: 1.2rem;
  }

  h1 {
    font-size: 3rem;
    letter-spacing: 0.3rem;
  }

  .room-code {
    font-size: 2rem;
    letter-spacing: 0.3rem;
    padding: 15px;
  }
}

@media (max-width: 600px) {
  h1 {
    font-size: 2.5rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  .menu-btn {
    font-size: 1rem;
    padding: 12px 24px;
  }

  .player-name {
    font-size: 1rem;
  }

  #gameOverMessage {
    font-size: 1.2rem;
  }

  .mobile-btn {
    width: 70px;
    height: 70px;
    font-size: 1.8rem;
  }

  .room-code {
    font-size: 1.8rem;
  }
}

@media (max-height: 700px) {
  h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
  }

  .menu-btn {
    padding: 10px 20px;
  }

  .button-group {
    gap: 10px;
  }
}

/* Prevent text selection */
canvas {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Loading/transition effects */
.screen {
  animation: fadeIn 0.4s ease-out, slideUp 0.4s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
  }
  to {
    transform: translateY(0);
  }
}
