:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-border: #2a2a2a;
  --text: #e0e0e0;
  --text-muted: #666666;
  --accent: #00ffff;
  --accent-dim: #007777;
  --p1-color: #00ffff;
  --p2-color: #ff00ff;
  --goal-scored: #00ff88;
  --goal-conceded: #ff4444;
  --warning: #ffaa00;
  --radius: 6px;
  --font-display: 'Press Start 2P', monospace;
  --font-body: 'Geist Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'Geist Mono', monospace;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

.screen {
  display: none;
  align-items: center;
  justify-content: center;
  height: 100vh;
  width: 100vw;
  position: absolute;
  top: 0;
  left: 0;
}

.screen.active { display: flex; }

/* Lobby */
.lobby-container {
  text-align: center;
  max-width: 480px;
  width: 90%;
}

.lobby-container h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
  color: var(--text);
}

.accent { color: var(--accent); }

.subtitle {
  color: var(--text-muted);
  margin-bottom: 32px;
  font-size: 0.9rem;
}

.name-input { margin-bottom: 24px; }

.name-input input {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 1rem;
  width: 100%;
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
}

.name-input input:focus { border-color: var(--accent); }

.lobby-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.btn {
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 1rem;
  cursor: pointer;
  flex: 1;
  transition: opacity 0.15s;
}

.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn.primary {
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
}

.btn.secondary {
  background: #333;
  color: var(--text);
}

.btn.ai {
  background: none;
  border: 1px solid var(--p2-color);
  color: var(--p2-color);
  font-weight: 600;
}

/* Invite section */
.invite-section {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 24px;
}

.invite-label {
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 8px;
}

.invite-link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.room-url {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  word-break: break-all;
  flex: 1;
  text-align: left;
}

.btn-small {
  flex: 0 !important;
  padding: 6px 12px;
  font-size: 0.8rem;
  white-space: nowrap;
}

.hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 8px;
}

.hint kbd {
  background: #333;
  border: 1px solid #555;
  border-radius: 3px;
  padding: 1px 6px;
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 0.8rem;
}

/* How to play */
.how-to-play {
  text-align: left;
  margin-bottom: 24px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
}

.how-to-play h2 {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

.how-to-play ul {
  list-style: none;
  padding: 0;
}

.how-to-play li {
  font-size: 0.85rem;
  color: var(--text);
  padding: 4px 0;
  line-height: 1.5;
}

.how-to-play kbd {
  background: #333;
  border: 1px solid #555;
  border-radius: 3px;
  padding: 1px 6px;
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 0.8rem;
}

/* Rooms */
.rooms-section h2 {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.room-list {
  max-height: 240px;
  overflow-y: auto;
}

.empty-state {
  color: #444;
  padding: 24px;
}

.room-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: border-color 0.15s;
}

.room-card:hover { border-color: var(--accent); }
.room-card .room-info { text-align: left; }
.room-card .room-players { color: var(--text-muted); font-size: 0.85rem; }
.room-card .join-label { color: var(--accent); font-size: 0.85rem; font-weight: 600; }

/* Game */
#game {
  flex-direction: column;
  background: var(--bg);
  position: relative;
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 24px;
  z-index: 10;
  pointer-events: none;
}

.hud-player {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: #aaa;
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-score {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--text);
}

.hud-target {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

#gameCanvas {
  display: block;
  margin: auto;
  background: var(--bg);
}

.btn-quit {
  position: absolute;
  top: 36px;
  right: 12px;
  z-index: 15;
  background: none;
  border: 1px solid #333;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.7rem;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 0.1em;
  transition: color 0.15s, border-color 0.15s;
}

.btn-quit:hover {
  color: var(--goal-conceded);
  border-color: var(--goal-conceded);
}

/* CRT scanline overlay */
.crt-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 5;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.05) 0px,
      rgba(0, 0, 0, 0.05) 1px,
      transparent 1px,
      transparent 4px
    );
  mix-blend-mode: multiply;
}

.crt-overlay::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.3) 100%);
  pointer-events: none;
}

/* Overlays */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  pointer-events: none;
}

.overlay.hidden { display: none; }

.overlay-text {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 20px rgba(0, 255, 255, 0.5), 0 0 40px rgba(0, 255, 255, 0.2);
}

.overlay-text.scored {
  color: var(--goal-scored);
  text-shadow: 0 0 20px rgba(0, 255, 136, 0.5);
}

.overlay-text.conceded {
  color: var(--goal-conceded);
  text-shadow: 0 0 20px rgba(255, 68, 68, 0.5);
}

/* Game Over */
.gameover-container { text-align: center; }

.gameover-container h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  margin-bottom: 8px;
}

.final-score {
  font-family: var(--font-mono);
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 24px;
}

.gameover-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 8px;
}

.hidden { display: none !important; }

/* Toast */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--goal-conceded);
  color: #fff;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  z-index: 100;
  animation: fadeIn 0.2s;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Input shake */
.name-input input.shake {
  animation: inputShake 0.4s;
  border-color: var(--goal-conceded);
}

@keyframes inputShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
