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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

#app {
  background: white;
  border-radius: 16px;
  padding: 32px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.screen { display: none; }
.screen.active { display: block; }

h1, h2 { text-align: center; margin-bottom: 24px; color: #333; }

input {
  width: 100%;
  padding: 12px;
  margin-bottom: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
}

input:focus { outline: none; border-color: #667eea; }

button {
  width: 100%;
  padding: 12px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 8px;
}

button:hover { background: #5568d3; }
button:disabled { background: #ccc; cursor: not-allowed; }

.auth-tabs { display: flex; margin-bottom: 16px; }

.tab {
  flex: 1;
  background: #f0f0f0;
  color: #666;
  margin: 0;
  border-radius: 0;
}

.tab:first-child { border-radius: 8px 0 0 8px; }
.tab:last-child { border-radius: 0 8px 8px 0; }
.tab.active { background: #667eea; color: white; }

.error { color: #e74c3c; text-align: center; margin-top: 8px; }

.user-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
}

.lobby-actions { margin-bottom: 16px; }

.join-room { display: flex; gap: 8px; }
.join-room input { margin: 0; }
.join-room button { width: auto; }

#rooms-list { margin-top: 16px; }

.room-item {
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 24px 0;
  max-width: 300px;
  margin-left: auto;
  margin-right: auto;
}

.cell {
  aspect-ratio: 1;
  background: #f8f9fa;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 36px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
}

.cell:hover { background: #e9ecef; border-color: #667eea; }
.cell.x { color: #667eea; }
.cell.o { color: #764ba2; }
.cell.taken { cursor: not-allowed; }

#game-status {
  text-align: center;
  margin: 12px 0;
  font-size: 16px;
  font-weight: bold;
}

#players-info {
  text-align: center;
  color: #666;
  font-size: 14px;
}

#history-list { margin-top: 16px; }

.history-item {
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
  margin-bottom: 8px;
}

.history-item .result { font-weight: bold; margin-bottom: 4px; }
.history-item .date { color: #999; font-size: 12px; }

#back-lobby-btn { margin-bottom: 16px; }
#restart-btn { max-width: 200px; margin: 16px auto; display: block; }
#leave-btn { width: auto; margin-bottom: 16px; }
#history-link { display: block; text-align: center; margin-top: 16px; color: #667eea; }
