/* =====================================================================
   PAC-MAN MULTIPLAYER -- Complete Stylesheet
   Dark theme, gold accents, responsive, all screens
   ===================================================================== */

/* ----- Reset & Base ----- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #fff;
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Custom scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #111; }
::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #666; }

/* ----- App Container ----- */
#app {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

/* ----- Screen System ----- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  padding: 20px;
}

.screen.active {
  display: flex;
}

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 28px;
  border: 2px solid #FFD700;
  background: transparent;
  color: #FFD700;
  font-size: 16px;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, transform 0.1s, box-shadow 0.2s;
  text-transform: uppercase;
  letter-spacing: 1px;
  gap: 8px;
}

.btn:hover {
  background: #FFD700;
  color: #000;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  background: transparent;
  color: #FFD700;
  box-shadow: none;
}

.btn-primary {
  background: #FFD700;
  color: #000;
}

.btn-primary:hover {
  background: #FFE44D;
  box-shadow: 0 0 25px rgba(255, 215, 0, 0.4);
}

.btn-danger {
  border-color: #FF4444;
  color: #FF4444;
}

.btn-danger:hover {
  background: #FF4444;
  color: #fff;
}

.btn-small {
  padding: 6px 14px;
  font-size: 12px;
  border-width: 1px;
  border-radius: 5px;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  font-size: 20px;
}

.btn-back {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 10;
}

/* ----- Mode / Toggle Buttons ----- */
.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-toggle {
  padding: 8px 18px;
  border: 1px solid #555;
  background: #1a1a2e;
  color: #aaa;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-toggle:hover {
  border-color: #FFD700;
  color: #FFD700;
}

.btn-toggle.active {
  border-color: #FFD700;
  background: rgba(255, 215, 0, 0.15);
  color: #FFD700;
}

/* ----- Inputs ----- */
.input {
  background: #111;
  border: 1px solid #444;
  color: #fff;
  padding: 10px 14px;
  font-size: 15px;
  border-radius: 6px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}

.input:focus {
  border-color: #FFD700;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.15);
}

.input::placeholder {
  color: #555;
}

/* ----- Labels ----- */
.label {
  display: block;
  font-size: 13px;
  color: #888;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ----- Cards / Panels ----- */
.panel {
  background: #0d0d1a;
  border: 1px solid #222;
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  max-width: 500px;
}

/* ===================================================================
   SCREEN 1: WELCOME / HOME
   =================================================================== */
#screen-welcome {
  justify-content: center;
  gap: 24px;
}

.welcome-title {
  font-size: 56px;
  font-weight: 900;
  color: #FFD700;
  text-shadow: 0 0 30px rgba(255, 215, 0, 0.5), 0 4px 8px rgba(0,0,0,0.5);
  letter-spacing: 4px;
  text-align: center;
  line-height: 1;
  animation: titlePulse 3s ease-in-out infinite;
}

@keyframes titlePulse {
  0%, 100% { text-shadow: 0 0 30px rgba(255, 215, 0, 0.5); }
  50% { text-shadow: 0 0 50px rgba(255, 215, 0, 0.8), 0 0 80px rgba(255, 215, 0, 0.3); }
}

.welcome-subtitle {
  color: #888;
  font-size: 14px;
  text-align: center;
  margin-top: -12px;
}

.name-input-wrap {
  width: 100%;
  max-width: 320px;
}

.name-input-wrap .input {
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 1px;
}

/* Color picker */
.color-picker {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.color-swatch {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  position: relative;
}

.color-swatch:hover {
  transform: scale(1.15);
}

.color-swatch.selected {
  border-color: #FFD700;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
  transform: scale(1.1);
}

.color-swatch.selected::after {
  content: '';
  position: absolute;
  inset: 6px;
  border: 2px solid rgba(0,0,0,0.5);
  border-radius: 50%;
}

.welcome-buttons {
  display: flex;
  gap: 16px;
  margin-top: 8px;
}

.welcome-browse {
  color: #888;
  font-size: 13px;
  cursor: pointer;
  transition: color 0.2s;
  text-decoration: underline;
  text-underline-offset: 3px;
  background: none;
  border: none;
}

.welcome-browse:hover {
  color: #FFD700;
}

.welcome-settings {
  position: absolute;
  top: 16px;
  right: 16px;
}

/* ===================================================================
   SCREEN 2: CREATE ROOM
   =================================================================== */
#screen-create {
  padding-top: 60px;
  gap: 16px;
}

.create-title {
  font-size: 28px;
  font-weight: 700;
  color: #FFD700;
  margin-bottom: 4px;
}

.form-group {
  width: 100%;
  max-width: 480px;
  margin-bottom: 14px;
}

.form-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mode-btn {
  padding: 12px 8px;
  text-align: center;
  font-size: 12px;
  border: 1px solid #333;
  background: #111;
  color: #aaa;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-btn:hover {
  border-color: #FFD700;
  color: #FFD700;
}

.mode-btn.active {
  border-color: #FFD700;
  background: rgba(255, 215, 0, 0.12);
  color: #FFD700;
}

.mode-btn-name {
  font-weight: 700;
  font-size: 13px;
}

.mode-btn-desc {
  font-size: 10px;
  color: #666;
  margin-top: 4px;
}

.mode-btn.active .mode-btn-desc {
  color: #aa8800;
}

/* Player count slider */
.player-slider-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
}

.player-slider-wrap input[type="range"] {
  flex: 1;
  accent-color: #FFD700;
  height: 6px;
}

.player-count-val {
  color: #FFD700;
  font-weight: 700;
  font-size: 18px;
  min-width: 30px;
  text-align: center;
}

/* Visibility toggle */
.vis-toggle {
  display: flex;
  border: 1px solid #444;
  border-radius: 6px;
  overflow: hidden;
}

.vis-toggle button {
  flex: 1;
  padding: 8px 16px;
  border: none;
  background: #111;
  color: #888;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.vis-toggle button.active {
  background: rgba(255, 215, 0, 0.15);
  color: #FFD700;
}

/* Conditional sections */
.conditional-section {
  display: none;
  margin-top: 10px;
}

.conditional-section.show {
  display: block;
}

/* ===================================================================
   SCREEN 3: JOIN ROOM
   =================================================================== */
#screen-join {
  padding-top: 60px;
  gap: 16px;
}

.join-title {
  font-size: 28px;
  font-weight: 700;
  color: #FFD700;
  margin-bottom: 4px;
}

/* Tab bar */
.tab-bar {
  display: flex;
  border-bottom: 2px solid #222;
  width: 100%;
  max-width: 500px;
}

.tab-btn {
  flex: 1;
  padding: 10px;
  background: none;
  border: none;
  color: #666;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  margin-bottom: -2px;
}

.tab-btn:hover {
  color: #ccc;
}

.tab-btn.active {
  color: #FFD700;
  border-bottom-color: #FFD700;
}

.tab-content {
  display: none;
  width: 100%;
  max-width: 500px;
}

.tab-content.active {
  display: block;
}

/* Room code input boxes */
.code-input-wrap {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 24px 0;
}

.code-box {
  width: 52px;
  height: 62px;
  background: #111;
  border: 2px solid #444;
  border-radius: 8px;
  color: #FFD700;
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  font-family: 'Courier New', monospace;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  caret-color: transparent;
}

.code-box:focus {
  border-color: #FFD700;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.25);
}

.code-box.filled {
  border-color: #FFD700;
}

.join-code-error {
  color: #FF4444;
  font-size: 13px;
  text-align: center;
  min-height: 20px;
  margin-top: 8px;
}

/* Public rooms table */
.rooms-table-wrap {
  width: 100%;
  max-height: 400px;
  overflow-y: auto;
  margin-top: 12px;
}

.rooms-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.rooms-table th {
  text-align: left;
  padding: 8px 10px;
  color: #888;
  font-weight: 600;
  border-bottom: 1px solid #333;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
  position: sticky;
  top: 0;
  background: #0d0d1a;
}

.rooms-table td {
  padding: 10px;
  border-bottom: 1px solid #1a1a2e;
  color: #ccc;
}

.rooms-table tr:hover td {
  background: rgba(255, 215, 0, 0.04);
}

.rooms-empty {
  text-align: center;
  color: #555;
  padding: 40px 20px;
  font-size: 14px;
}

/* Password modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 5000;
}

.modal-overlay.show {
  display: flex;
}

.modal {
  background: #1a1a2e;
  border: 2px solid #FFD700;
  border-radius: 12px;
  padding: 24px;
  width: 360px;
  max-width: 90vw;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: #FFD700;
  margin-bottom: 16px;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

/* ===================================================================
   SCREEN 4: LOBBY
   =================================================================== */
#screen-lobby {
  padding: 20px;
  gap: 0;
}

.lobby-layout {
  display: flex;
  width: 100%;
  max-width: 900px;
  height: calc(100vh - 40px);
  gap: 16px;
}

.lobby-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.lobby-sidebar {
  width: 280px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}

/* Room code display */
.room-code-display {
  text-align: center;
  padding: 16px;
  background: #0d0d1a;
  border: 1px solid #222;
  border-radius: 12px;
}

.room-code-label {
  font-size: 12px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.room-code-value {
  font-size: 42px;
  font-weight: 900;
  color: #FFD700;
  letter-spacing: 8px;
  font-family: 'Courier New', monospace;
  margin: 8px 0;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

.room-code-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
}

.copy-btn {
  position: relative;
}

.copy-tooltip {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  background: #22c55e;
  color: #fff;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.copy-tooltip.show {
  opacity: 1;
}

/* Room settings summary */
.room-settings-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
}

.setting-badge {
  padding: 4px 10px;
  background: #111;
  border: 1px solid #333;
  border-radius: 4px;
  font-size: 12px;
  color: #aaa;
}

.setting-badge strong {
  color: #FFD700;
}

/* Player list */
.player-list {
  flex: 1;
  overflow-y: auto;
  min-height: 100px;
}

.player-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  transition: background 0.2s;
  position: relative;
}

.player-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.player-item-color {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
}

.player-item-name {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
}

.player-item-you {
  color: #FFD700;
  font-size: 11px;
  font-weight: 700;
  margin-left: 4px;
}

.player-item-host {
  font-size: 16px;
  margin-left: 4px;
}

.player-item-ready {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.player-item-ready.ready {
  background: rgba(34, 197, 94, 0.2);
  color: #22c55e;
}

.player-item-ready.not-ready {
  background: rgba(255, 255, 255, 0.05);
  color: #555;
}

.player-item-kick {
  opacity: 0;
  transition: opacity 0.2s;
  background: none;
  border: 1px solid #FF4444;
  color: #FF4444;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
}

.player-item:hover .player-item-kick {
  opacity: 1;
}

/* Lobby action bar */
.lobby-actions {
  display: flex;
  gap: 10px;
  padding: 12px 0;
}

.lobby-actions .btn {
  flex: 1;
}

/* Waiting indicator */
.waiting-indicator {
  text-align: center;
  color: #666;
  font-size: 13px;
  padding: 8px;
}

.waiting-dots::after {
  content: '';
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
  100% { content: ''; }
}

/* Chat */
.chat-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #0d0d1a;
  border: 1px solid #222;
  border-radius: 10px;
  overflow: hidden;
  min-height: 200px;
}

.chat-title {
  padding: 8px 12px;
  font-size: 12px;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid #222;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}

.chat-msg {
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.chat-msg-system {
  color: #666;
  font-style: italic;
  font-size: 12px;
}

.chat-msg-name {
  font-weight: 700;
}

.chat-msg-text {
  color: #ccc;
}

.chat-input-wrap {
  display: flex;
  border-top: 1px solid #222;
}

.chat-input-wrap .input {
  border: none;
  border-radius: 0;
  font-size: 13px;
  padding: 10px 12px;
}

.chat-send-btn {
  background: #1a1a2e;
  border: none;
  color: #FFD700;
  padding: 0 14px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.chat-send-btn:hover {
  background: #2a2a3e;
}

.chat-rate-limit {
  color: #FF4444;
  font-size: 11px;
  padding: 0 12px 4px;
  display: none;
}

.chat-rate-limit.show {
  display: block;
}

/* ===================================================================
   SCREEN 5: IN-GAME
   =================================================================== */
#screen-game {
  padding: 0;
  flex-direction: row;
  overflow: hidden;
}

.game-layout {
  display: flex;
  width: 100%;
  height: 100%;
}

.game-canvas-wrap {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  min-width: 0;
}

#game-canvas {
  display: block;
  image-rendering: pixelated;
}

.game-sidebar {
  width: 220px;
  background: #0a0a14;
  border-left: 1px solid #222;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

/* Timer (for timed modes) */
.game-timer {
  text-align: center;
  font-size: 28px;
  font-weight: 900;
  color: #FFD700;
  padding: 12px;
  font-family: 'Courier New', monospace;
  letter-spacing: 2px;
}

.game-timer.danger {
  color: #FF4444;
  animation: timerFlash 0.5s ease-in-out infinite alternate;
}

@keyframes timerFlash {
  from { opacity: 1; }
  to { opacity: 0.6; }
}

/* In-game notifications (top center) */
.game-notifications {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 100;
  pointer-events: none;
}

/* Quick chat */
.quick-chat-bar {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 100;
}

.quick-chat-btn {
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid #444;
  border-radius: 4px;
  color: #aaa;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
}

.quick-chat-btn:hover {
  border-color: #FFD700;
  color: #FFD700;
}

/* Exit confirmation */
.exit-confirm {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 200;
}

.exit-confirm.show {
  display: flex;
}

.exit-confirm-box {
  background: #1a1a2e;
  border: 2px solid #FFD700;
  border-radius: 12px;
  padding: 28px 32px;
  text-align: center;
}

.exit-confirm-text {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
  color: #FFD700;
}

.exit-confirm-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ===================================================================
   SCREEN 6: SPECTATOR OVERLAY
   =================================================================== */
.spectator-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 150;
  display: none;
}

.spectator-overlay.active {
  display: block;
}

.spectator-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 220px; /* sidebar width */
  height: 36px;
  background: rgba(0, 0, 0, 0.8);
  border-bottom: 1px solid #FFD700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  pointer-events: all;
}

.spectator-label {
  color: #FFD700;
  font-size: 14px;
  font-weight: 700;
}

.spectator-nav {
  background: none;
  border: 1px solid #FFD700;
  color: #FFD700;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.spectator-nav:hover {
  background: #FFD700;
  color: #000;
}

.spectator-watermark {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 215, 0, 0.15);
  font-size: 18px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 4px;
  pointer-events: none;
}

/* ===================================================================
   SCREEN 7: RESULTS
   =================================================================== */
#screen-results {
  justify-content: flex-start;
  padding-top: 30px;
  gap: 16px;
}

.results-winner {
  text-align: center;
  margin-bottom: 12px;
}

.results-crown {
  font-size: 16px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 3px;
  margin-bottom: 4px;
}

.results-winner-name {
  font-size: 40px;
  font-weight: 900;
  text-shadow: 0 0 30px currentColor;
  animation: winnerGlow 2s ease-in-out infinite;
}

@keyframes winnerGlow {
  0%, 100% { text-shadow: 0 0 30px currentColor; }
  50% { text-shadow: 0 0 50px currentColor, 0 0 80px currentColor; }
}

.results-teams {
  display: flex;
  gap: 24px;
  justify-content: center;
  margin: 12px 0;
}

.results-team {
  text-align: center;
  padding: 12px 24px;
  border-radius: 10px;
  border: 1px solid #333;
}

.results-team-a {
  border-color: rgba(255, 215, 0, 0.3);
}

.results-team-b {
  border-color: rgba(0, 221, 255, 0.3);
}

.results-team-label {
  font-size: 14px;
  font-weight: 700;
  display: block;
}

.results-team-a .results-team-label { color: #FFD700; }
.results-team-b .results-team-label { color: #00DDFF; }

.results-team-score {
  font-size: 32px;
  font-weight: 900;
  display: block;
}

.results-team-a .results-team-score { color: #FFD700; }
.results-team-b .results-team-score { color: #00DDFF; }

.results-table-wrap {
  width: 100%;
  max-width: 700px;
  overflow-x: auto;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.results-table th {
  text-align: left;
  padding: 10px 12px;
  color: #888;
  font-weight: 600;
  border-bottom: 2px solid #333;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}

.results-table td {
  padding: 12px;
  border-bottom: 1px solid #1a1a2e;
  color: #ccc;
}

.results-row-winner td {
  background: rgba(255, 215, 0, 0.08);
  color: #FFD700;
  font-weight: 700;
}

.results-row-you td {
  background: rgba(255, 255, 255, 0.03);
}

.results-rank {
  font-size: 18px;
  font-weight: 900;
  color: #FFD700;
  width: 40px;
}

.results-player {
  display: flex;
  align-items: center;
  gap: 8px;
}

.results-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.results-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

/* Results chat */
.results-chat {
  width: 100%;
  max-width: 700px;
  margin-top: 12px;
}

/* ===================================================================
   SCOREBOARD SIDEBAR (in-game)
   =================================================================== */
.sb-title {
  text-align: center;
  color: #FFD700;
  font-size: 13px;
  font-weight: 700;
  padding: 10px;
  border-bottom: 1px solid #222;
  letter-spacing: 1px;
}

.sb-player {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid #111;
  transition: background 0.2s;
}

.sb-player.sb-you {
  background: rgba(255, 215, 0, 0.06);
  border-left: 2px solid #FFD700;
}

.sb-player.sb-dead {
  opacity: 0.4;
}

.sb-player.sb-dead .sb-name {
  text-decoration: line-through;
}

.sb-rank {
  font-size: 11px;
  color: #666;
  font-weight: 700;
  min-width: 22px;
}

.sb-color {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sb-info {
  flex: 1;
  min-width: 0;
}

.sb-name {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-you-tag {
  color: #FFD700;
  font-size: 9px;
  font-weight: 700;
  margin-left: 4px;
}

.sb-score {
  font-size: 11px;
  color: #aaa;
}

.sb-meta {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.sb-level {
  font-size: 10px;
  color: #666;
}

.sb-lives {
  display: flex;
  gap: 2px;
}

.sb-life {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: currentColor;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
}

.sb-lives-extra {
  font-size: 9px;
  color: #888;
}

.sb-dead-tag {
  font-size: 9px;
  color: #FF4444;
  font-weight: 700;
}

/* ===================================================================
   TOAST NOTIFICATIONS
   =================================================================== */
#toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 340px;
}

.toast {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  pointer-events: all;
  cursor: pointer;
  opacity: 0;
  transform: translateX(100%);
  transition: opacity 0.3s, transform 0.3s;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.toast-show {
  opacity: 1;
  transform: translateX(0);
}

.toast-exit {
  opacity: 0;
  transform: translateX(100%);
}

.toast-success {
  background: #166534;
  border-left: 3px solid #22c55e;
}

.toast-error {
  background: #7f1d1d;
  border-left: 3px solid #ef4444;
}

.toast-info {
  background: #1e3a5f;
  border-left: 3px solid #3b82f6;
}

.toast-warning {
  background: #713f12;
  border-left: 3px solid #FFD700;
}

/* ===================================================================
   RECONNECTING OVERLAY
   =================================================================== */
.reconnect-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 8000;
  flex-direction: column;
  gap: 16px;
}

.reconnect-overlay.show {
  display: flex;
}

.reconnect-text {
  color: #FFD700;
  font-size: 22px;
  font-weight: 700;
}

.reconnect-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #333;
  border-top-color: #FFD700;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.reconnect-attempt {
  color: #888;
  font-size: 13px;
}

/* ===================================================================
   SETTINGS MODAL (from audio-controls.js)
   =================================================================== */
/* Handled dynamically by SettingsManager, but we style overrides */

/* ===================================================================
   RESPONSIVE
   =================================================================== */
@media (max-width: 768px) {
  .welcome-title {
    font-size: 36px;
  }

  .lobby-layout {
    flex-direction: column;
    height: auto;
  }

  .lobby-sidebar {
    width: 100%;
    max-height: 300px;
  }

  .room-code-value {
    font-size: 32px;
    letter-spacing: 5px;
  }

  .game-sidebar {
    width: 180px;
  }

  .spectator-bar {
    right: 180px;
  }

  .code-box {
    width: 42px;
    height: 52px;
    font-size: 22px;
  }

  .results-table {
    font-size: 12px;
  }

  .welcome-buttons {
    flex-direction: column;
    width: 100%;
    max-width: 280px;
  }

  .welcome-buttons .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .welcome-title {
    font-size: 28px;
  }

  .game-sidebar {
    width: 140px;
  }

  .spectator-bar {
    right: 140px;
  }

  .mode-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .code-box {
    width: 36px;
    height: 46px;
    font-size: 20px;
  }

  .code-input-wrap {
    gap: 6px;
  }
}

/* ===================================================================
   ANIMATIONS
   =================================================================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes slideDown {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.anim-fade-in {
  animation: fadeIn 0.3s ease-out;
}

.anim-slide-up {
  animation: slideUp 0.3s ease-out;
}

/* Green flash for copy */
@keyframes greenFlash {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.copy-flash {
  animation: greenFlash 0.6s ease-out;
}
