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

body {
  background: #111;
  color: #fff;
  font-family: 'Courier New', monospace;
  overflow-y: auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 20px;
  -webkit-user-select: none;
  user-select: none;
}

/* Modal */
.modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  overflow-y: auto;
  padding: 20px 0;
}

.modal.hidden { display: none; }

.modal-content {
  background: #222;
  padding: 40px;
  border-radius: 12px;
  text-align: center;
  border: 2px solid #444;
  max-width: 400px;
}

.modal-content h2 {
  font-size: 2rem;
  margin-bottom: 10px;
  color: #0f0;
}

.modal-content p {
  margin-bottom: 20px;
  color: #aaa;
}

.modal-content input {
  background: #333;
  border: 1px solid #555;
  color: #fff;
  padding: 12px 16px;
  font-size: 1.1rem;
  font-family: inherit;
  border-radius: 6px;
  width: 250px;
  margin-bottom: 16px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.modal-content input:focus {
  outline: none;
  border-color: #0f0;
}

.modal-content button {
  background: #0f0;
  color: #000;
  border: none;
  padding: 12px 32px;
  font-size: 1.1rem;
  font-family: inherit;
  font-weight: bold;
  border-radius: 6px;
  cursor: pointer;
}

#join-btn:hover {
  background: #0d0;
}

#spectate-btn {
  background: transparent;
  color: #888;
  border: 1px solid #555;
  padding: 10px 32px;
  font-size: 0.95rem;
  font-family: inherit;
  border-radius: 6px;
  cursor: pointer;
  margin-top: 8px;
}

#spectate-btn:hover {
  color: #fff;
  border-color: #888;
}

.instructions {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid #444;
  text-align: left;
  font-size: 0.85rem;
}

.instructions h3 {
  color: #0f0;
  font-size: 1rem;
  margin-bottom: 10px;
  text-align: center;
}

.instructions ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.instructions li {
  margin-bottom: 6px;
  color: #aaa;
}

.instructions kbd {
  background: #333;
  border: 1px solid #555;
  border-radius: 3px;
  padding: 2px 5px;
  font-family: monospace;
  font-size: 0.8rem;
  color: #0f0;
}

/* Game Container */
#game-container {
  display: none;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 850px;
  padding: 10px;
}

#game-container.active {
  display: flex;
}

/* Status Bar */
#status-bar {
  background: #222;
  padding: 8px 20px;
  border-radius: 6px;
  margin-bottom: 10px;
  font-size: 0.95rem;
  text-align: center;
  min-height: 36px;
}

#status-text.playing { color: #0f0; }
#status-text.queued { color: #ff0; }
#status-text.spectating { color: #aaa; }
#status-text.eliminated { color: #f44; }

/* Canvas */
#canvas-wrapper {
  position: relative;
  width: 100%;
  max-width: 800px;
  aspect-ratio: 4 / 3;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  border: 2px solid #333;
  border-radius: 4px;
  background: #000;
}

/* Player Labels */
.player-label {
  position: absolute;
  top: 8px;
  font-size: 0.85rem;
  color: #aaa;
  pointer-events: none;
}

.player-label.left { left: 10px; }
.player-label.right { right: 10px; }

/* Mobile Controls */
#mobile-controls {
  display: none;
  gap: 20px;
  margin-top: 16px;
  width: 100%;
  max-width: 400px;
}

.control-btn {
  flex: 1;
  height: 70px;
  font-size: 2rem;
  background: #222;
  color: #fff;
  border: 2px solid #444;
  border-radius: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.control-btn:active {
  background: #0f0;
  color: #000;
  border-color: #0f0;
}

/* Panels (Waiting Room + Leaderboard) */
#panels {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  width: 100%;
  max-width: 800px;
}

/* Waiting Room */
#queue-panel {
  flex: 1;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 16px;
  min-width: 0;
}

#queue-panel h3 {
  text-align: center;
  margin-bottom: 12px;
  color: #ff0;
}

#queue-list {
  list-style: none;
  padding: 0;
}

#queue-list li {
  padding: 5px 10px;
  font-size: 0.9rem;
  border-bottom: 1px solid #333;
}

#queue-list li:last-child {
  border-bottom: none;
}

#queue-list .queue-position {
  color: #888;
  margin-right: 6px;
}

#queue-list .queue-empty {
  color: #555;
  text-align: center;
  font-style: italic;
}

/* Leaderboard */
#leaderboard-panel {
  flex: 1;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 16px;
  min-width: 0;
}

#leaderboard-panel h3 {
  text-align: center;
  margin-bottom: 12px;
  color: #0f0;
}

#leaderboard-table {
  width: 100%;
  border-collapse: collapse;
}

#leaderboard-table th,
#leaderboard-table td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid #333;
}

#leaderboard-table th {
  color: #888;
  font-size: 0.8rem;
  text-transform: uppercase;
}

#leaderboard-table td {
  font-size: 0.9rem;
}

#leaderboard-table tr:first-child td {
  color: #ffd700;
}

/* GitHub Bar */
#github-bar {
  position: fixed;
  top: 14px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 200;
}

#github-icon {
  color: #666;
  line-height: 0;
  transition: color 0.2s;
}

#github-icon:hover {
  color: #fff;
}

/* Responsive */
@media (max-width: 768px) {
  #mobile-controls {
    display: flex;
  }

  body {
    justify-content: flex-start;
    padding-top: 10px;
  }

  #status-bar {
    font-size: 0.85rem;
  }

  .modal-content {
    padding: 24px;
    margin: 16px;
  }

  .modal-content input {
    width: 100%;
  }

  #panels {
    flex-direction: column;
  }

  .instructions {
    font-size: 0.75rem;
    margin-top: 20px;
    padding-top: 16px;
  }

  .instructions h3 {
    font-size: 0.9rem;
    margin-bottom: 8px;
  }

  .instructions li {
    margin-bottom: 4px;
  }

  .instructions kbd {
    font-size: 0.7rem;
    padding: 1px 4px;
  }
}

@media (min-width: 769px) {
  #mobile-controls {
    display: none;
  }
}
