:root {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --surface-hover: #252540;
  --text: #e0e0e0;
  --text-white: #fff;
  --text-muted: #888;
  --text-dim: #aaa;
  --text-dimmer: #666;
  --border-dim: #333;
  --border-dark: #444;
  --primary: #6c5ce7;
  --primary-hover: #7d6ff0;
  --red: #e74c3c;
  --red-dark: #c0392b;
  --blue: #3498db;
  --green: #27ae60;
  --green-light: #2ecc71;
  --green-bg: #1e3a1e;
  --gold: #ffd700;
  --yellow: #f1c40f;
  --orange: #f39c12;
  --vs-color: #555;
}

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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.container {
  max-width: 500px;
  width: 100%;
  padding: 20px;
}

h1 {
  text-align: center;
  font-size: 1.8rem;
  margin: 20px 0 6px;
  color: var(--text-white);
}

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

.lobby {
  text-align: center;
}

.lobby input {
  background: var(--surface);
  border: 1px solid var(--border-dim);
  color: var(--text-white);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 1rem;
  width: 100%;
  max-width: 300px;
  margin: 8px auto;
  display: block;
}

.lobby input::placeholder {
  color: var(--text-dimmer);
}

.lobby button {
  background: var(--primary);
  color: var(--text-white);
  border: none;
  padding: 12px 32px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  margin-top: 8px;
}

.lobby button:hover {
  background: var(--primary-hover);
}

.lobby button:disabled {
  background: var(--border-dark);
  cursor: not-allowed;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 12px;
}

.player-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-info img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.player-info .name {
  font-weight: 600;
  font-size: 0.9rem;
}

.player-info .mark {
  font-size: 0.75rem;
  font-weight: 700;
}

.player-info .mark.x {
  color: var(--red);
}

.player-info .mark.o {
  color: var(--blue);
}

.player-info .score {
  font-size: 0.85rem;
  color: var(--gold);
}

.player-info.active {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  border-radius: 8px;
}

.vs {
  color: var(--vs-color);
  font-weight: 700;
  font-size: 0.85rem;
}

.round-badge {
  text-align: center;
  background: var(--surface);
  border-radius: 8px;
  padding: 8px 16px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  max-width: 320px;
  margin: 0 auto 16px;
}

.cell {
  aspect-ratio: 1;
  background: var(--surface);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  user-select: none;
}

.cell:hover:not(.taken) {
  background: var(--surface-hover);
}

.cell:active:not(.taken) {
  transform: scale(0.95);
}

.cell.taken {
  cursor: default;
}

.cell .x {
  color: var(--red);
}

.cell .o {
  color: var(--blue);
}

.cell.win-cell {
  background: var(--green-bg);
}

.turn-indicator {
  text-align: center;
  font-size: 1rem;
  margin-bottom: 16px;
  color: var(--text-dim);
}

.turn-indicator strong {
  color: var(--text-white);
}

.game-message {
  text-align: center;
  padding: 16px;
  background: var(--surface);
  border-radius: 10px;
  margin: 12px 0;
  font-size: 1rem;
}

.game-message.win {
  border: 1px solid var(--green);
  color: var(--green-light);
}

.game-message.lose {
  border: 1px solid var(--red-dark);
  color: var(--red);
}

.game-message.draw {
  border: 1px solid var(--orange);
  color: var(--yellow);
}

.game-message button {
  background: var(--primary);
  color: var(--text-white);
  border: none;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 0.95rem;
  cursor: pointer;
  margin-top: 12px;
}

.game-message button:hover {
  background: var(--primary-hover);
}

.waiting {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
}

.waiting .spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-dark);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}