* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: #0a0a1a;
  color: #e0e0f0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}
#app {
  width: 100%;
  max-width: 860px;
  padding: 16px;
}
.screen { display: none; }
.screen.active { display: flex; flex-direction: column; align-items: center; }
.hidden { display: none !important; }

/* Lobby */
.title { text-align: center; margin-bottom: 32px; }
.title h1 {
  font-size: 2.8rem;
  background: linear-gradient(135deg, #44ff88, #44ffff, #4488ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 30px rgba(68,255,136,0.3);
}
.subtitle { color: #8888aa; margin-top: 8px; font-size: 1rem; }
.lobby-box {
  background: rgba(20,20,40,0.8);
  border: 1px solid #333355;
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 400px;
  backdrop-filter: blur(10px);
}
input {
  width: 100%;
  padding: 12px 16px;
  background: #12122a;
  border: 1px solid #333355;
  border-radius: 8px;
  color: #e0e0f0;
  font-size: 1rem;
  outline: none;
  transition: border 0.2s;
  margin-bottom: 12px;
}
input:focus { border-color: #44ff88; box-shadow: 0 0 12px rgba(68,255,136,0.2); }
.btn {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn.primary { background: #44ff88; color: #0a0a1a; }
.btn.primary:hover { background: #66ffaa; box-shadow: 0 0 20px rgba(68,255,136,0.4); }
.btn.secondary { background: #333355; color: #e0e0f0; }
.btn.secondary:hover { background: #444466; }
.btn.danger { background: #ff4466; color: white; }
.btn.danger:hover { background: #ff6688; }
.btn-group { display: flex; gap: 12px; margin-bottom: 12px; }
.btn-group .btn { flex: 1; }
#joinRow { display: flex; gap: 8px; margin-top: 8px; }
#joinRow input { flex: 1; margin-bottom: 0; }
#joinRow .btn { flex-shrink: 0; }
.error { color: #ff4466; margin-top: 12px; font-size: 0.9rem; }
.footer { margin-top: 24px; text-align: center; color: #666688; font-size: 0.85rem; }

/* Room */
.room-header {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; max-width: 500px;
  padding: 16px; background: rgba(20,20,40,0.8); border: 1px solid #333355;
  border-radius: 12px; margin-bottom: 16px;
}
#roomTitle { font-size: 1.1rem; font-weight: 600; }
#roomIdDisplay { color: #44ff88; }
#playerCount { color: #8888aa; }
.room-body { width: 100%; max-width: 500px; }
.player-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.player-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: rgba(20,20,40,0.6);
  border: 1px solid #2a2a4a; border-radius: 10px;
}
.player-dot {
  width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
}
.player-name { flex: 1; font-size: 1rem; }
.room-actions { display: flex; gap: 12px; }
.room-actions .btn { flex: 1; }

/* Game */
.game-header { width: 100%; margin-bottom: 8px; }
.scoreboard {
  display: flex; gap: 16px; flex-wrap: wrap;
  padding: 8px 12px; background: rgba(20,20,40,0.8);
  border: 1px solid #333355; border-radius: 8px;
}
.score-item {
  font-size: 0.85rem; display: flex; align-items: center; gap: 6px;
}
.score-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.score-name { color: #aaaacc; }
.score-pts { font-weight: 600; }
.game-body { position: relative; }
#gameCanvas {
  width: 100%; height: auto; max-width: 800px;
  border: 1px solid #333355; border-radius: 8px;
  display: block;
  background: #0d0d1a;
}
.game-footer { margin-top: 8px; }
.mobile-controls {
  display: none;
  flex-direction: column; align-items: center; gap: 4px;
}
.dir-row { display: flex; gap: 4px; }
.dir-btn {
  width: 60px; height: 60px; border: 1px solid #444466;
  background: rgba(20,20,40,0.8); color: #44ff88;
  font-size: 1.3rem; border-radius: 12px; cursor: pointer;
  user-select: none; -webkit-user-select: none;
}
.dir-btn:active { background: #44ff88; color: #0a0a1a; }

/* Overlay */
.overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.7);
  display: flex; justify-content: center; align-items: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}
.overlay.hidden { display: none; }
.overlay-content {
  background: #14142a; border: 1px solid #444466;
  border-radius: 16px; padding: 32px; max-width: 400px; width: 90%;
  text-align: center;
}
.overlay-content h2 { font-size: 1.8rem; margin-bottom: 16px; }
.overlay-content .btn { margin: 8px; }

/* Responsive */
@media (max-width: 600px) {
  .title h1 { font-size: 2rem; }
  .lobby-box { padding: 20px; }
  .mobile-controls { display: flex; }
  .dir-btn { width: 50px; height: 50px; font-size: 1.1rem; }
}