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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #0f0f13;
  color: #e8e8f0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Lobby ── */
#lobby {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

#lobby h1 {
  font-size: 2.4rem;
  letter-spacing: 2px;
  color: #a78bfa;
}

#nameInput {
  padding: 12px 18px;
  font-size: 1.1rem;
  border: 2px solid #3f3f5a;
  border-radius: 8px;
  background: #1a1a2e;
  color: #e8e8f0;
  width: 240px;
  outline: none;
  transition: border-color 0.2s;
}
#nameInput:focus { border-color: #a78bfa; }

button {
  padding: 12px 28px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: #7c3aed;
  color: #fff;
  transition: background 0.2s, transform 0.1s;
}
button:hover { background: #6d28d9; }
button:active { transform: scale(0.97); }
button:disabled { background: #3f3f5a; cursor: default; }

#lobbyStatus { color: #a0a0c0; font-size: 0.95rem; min-height: 1.2em; }

/* ── Game layout ── */
.hidden { display: none !important; }

#game {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  padding: 24px;
  width: 100%;
  max-width: 900px;
}

/* ── Left: board ── */
#left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  flex: 0 0 auto;
}

#matchInfo {
  font-size: 1rem;
  color: #a0a0c0;
}
#playerLabel { color: #a78bfa; font-weight: 700; }
#opponentLabel { color: #f97316; font-weight: 700; }

#statusBar {
  font-size: 1.1rem;
  font-weight: 600;
  min-height: 1.4em;
  color: #e8e8f0;
}

#board {
  display: grid;
  grid-template-columns: repeat(3, 110px);
  grid-template-rows: repeat(3, 110px);
  gap: 6px;
}

.cell {
  background: #1a1a2e;
  border: 2px solid #2e2e4a;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}
.cell:hover:not(.taken) { background: #252540; }
.cell.taken { cursor: default; }
.cell.X { color: #a78bfa; }
.cell.O { color: #f97316; }

#rematchBtn { margin-top: 4px; }

/* ── Right panel ── */
#right {
  display: flex;
  flex-direction: column;
  gap: 24px;
  flex: 1;
}

/* ── Leaderboard ── */
#leaderboardPanel h2 {
  font-size: 1.1rem;
  color: #a78bfa;
  margin-bottom: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

#leaderboardTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
#leaderboardTable th {
  text-align: left;
  padding: 4px 8px;
  color: #6060a0;
  font-weight: 600;
  border-bottom: 1px solid #2e2e4a;
}
#leaderboardTable td {
  padding: 6px 8px;
  border-bottom: 1px solid #1e1e38;
}
#leaderboardTable tr.me td { color: #a78bfa; font-weight: 700; }
#leaderboardTable tbody tr:first-child td { color: #fbbf24; }

/* ── QR ── */
#qrPanel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
#qrPanel p {
  font-size: 0.85rem;
  color: #6060a0;
  letter-spacing: 1px;
}
#qrCanvas {
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  width: 128px;
  height: 128px;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: 6px solid #fff;
}
