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

:root {
  --neon: #00ff88;
  --neon-dim: #00cc6a;
  --neon-blue: #00ccff;
  --bg: #0a0a0a;
  --surface: #141414;
  --text: #e0e0e0;
  --text-dim: #666;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Press Start 2P', monospace;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 850px;
  padding: 20px;
  gap: 20px;
  text-align: center;
}

.screen.active {
  display: flex;
}

.title {
  font-size: 4rem;
  color: var(--neon);
  text-shadow: 0 0 20px var(--neon), 0 0 40px var(--neon), 0 0 80px var(--neon);
  letter-spacing: 0.3em;
}

.subtitle {
  font-size: 0.9rem;
  color: var(--neon-blue);
  letter-spacing: 0.5em;
  margin-top: -10px;
}

.glow {
  color: var(--neon);
  text-shadow: 0 0 10px var(--neon), 0 0 30px var(--neon);
  font-size: 1.2rem;
}

.menu-buttons {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.75rem;
  padding: 14px 28px;
  background: transparent;
  color: var(--neon);
  border: 2px solid var(--neon);
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
}

.btn:hover {
  background: var(--neon);
  color: var(--bg);
  box-shadow: 0 0 15px var(--neon);
}

.btn-secondary {
  color: var(--text-dim);
  border-color: var(--text-dim);
}

.btn-secondary:hover {
  background: var(--text-dim);
  color: var(--bg);
  box-shadow: 0 0 10px var(--text-dim);
}

.btn-small {
  font-size: 0.6rem;
  padding: 10px 18px;
}

input[type="text"] {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.8rem;
  padding: 12px 16px;
  background: var(--surface);
  color: var(--neon);
  border: 2px solid var(--neon-dim);
  text-align: center;
  width: 260px;
  outline: none;
  text-transform: uppercase;
}

input[type="text"]::placeholder {
  color: var(--text-dim);
  font-size: 0.6rem;
}

input[type="text"]:focus {
  border-color: var(--neon);
  box-shadow: 0 0 10px var(--neon-dim);
}

#join-form, #create-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.hidden {
  display: none !important;
}

/* Room code */
.room-code-container {
  margin: 10px 0;
}

.label {
  font-size: 0.6rem;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.room-code {
  font-size: 3rem;
  color: var(--neon);
  letter-spacing: 0.4em;
  text-shadow: 0 0 15px var(--neon);
}

.share-options {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.qr-container canvas {
  border: 3px solid var(--neon-dim);
  border-radius: 4px;
}

/* Loading dots */
.dots-loading span {
  font-size: 2rem;
  color: var(--neon);
  animation: blink 1.4s infinite both;
}

.dots-loading span:nth-child(2) { animation-delay: 0.2s; }
.dots-loading span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0; }
  40% { opacity: 1; }
}

/* Game header */
.game-header {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 800px;
  padding: 8px 0;
  font-size: 0.65rem;
}

.player-name.left { color: var(--neon); }
.player-name.right { color: var(--neon-blue); }

.game-score {
  color: var(--text);
  font-size: 0.8rem;
}

.canvas-wrapper {
  position: relative;
  width: 100%;
  max-width: 800px;
}

canvas {
  width: 100%;
  height: auto;
  display: block;
  border: 2px solid var(--neon-dim);
  background: var(--bg);
}

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  color: var(--neon);
  text-shadow: 0 0 30px var(--neon);
  background: rgba(10, 10, 10, 0.7);
  z-index: 10;
}

/* Touch controls */
.touch-controls {
  display: flex;
  gap: 20px;
  margin-top: 10px;
}

.touch-btn {
  font-size: 2rem;
  width: 80px;
  height: 80px;
  background: var(--surface);
  color: var(--neon);
  border: 2px solid var(--neon-dim);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.touch-btn:active {
  background: var(--neon-dim);
  color: var(--bg);
}

/* Game over */
.final-score {
  font-size: 1.5rem;
  color: var(--text);
  margin: 10px 0;
}

/* Leaderboard */
.section-title {
  font-size: 0.7rem;
  color: var(--neon-blue);
  margin-bottom: 12px;
  letter-spacing: 0.2em;
}

#leaderboard-section, #gameover-leaderboard {
  margin-top: 20px;
  width: 100%;
  max-width: 500px;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.55rem;
}

.leaderboard-table th {
  color: var(--neon-dim);
  padding: 8px 6px;
  border-bottom: 1px solid var(--neon-dim);
  text-align: left;
}

.leaderboard-table td {
  padding: 6px;
  border-bottom: 1px solid #222;
}

.leaderboard-table tr:nth-child(even) {
  background: var(--surface);
}

.leaderboard-empty {
  font-size: 0.55rem;
  color: var(--text-dim);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: #ff4444;
  color: white;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.55rem;
  padding: 12px 24px;
  border-radius: 4px;
  z-index: 100;
  animation: fadeInOut 3s ease-in-out;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translateX(-50%) translateY(20px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  85% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(20px); }
}

/* Responsive */
@media (max-width: 600px) {
  .title { font-size: 2.5rem; }
  .subtitle { font-size: 0.6rem; }
  .room-code { font-size: 2rem; }
  .btn { font-size: 0.6rem; padding: 10px 18px; }
  input[type="text"] { width: 200px; font-size: 0.65rem; }
  .game-header { font-size: 0.5rem; }
  .overlay { font-size: 2.5rem; }
}
