* { margin: 0; padding: 0; box-sizing: border-box; }
body { background: #1a1a2e; color: #eee; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; min-height: 100vh; }

/* Auth Page */
.auth-container {
  display: flex; justify-content: center; align-items: center; min-height: 100vh;
}
.auth-box {
  background: #16213e; padding: 40px; border-radius: 16px; width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.auth-box h1 { text-align: center; color: #e94560; margin-bottom: 24px; font-size: 2rem; }
.auth-box input {
  width: 100%; padding: 12px 16px; margin-bottom: 12px; border: 2px solid #333;
  border-radius: 8px; background: #1a1a2e; color: #eee; font-size: 1rem; outline: none;
}
.auth-box input:focus { border-color: #e94560; }
.auth-box button {
  width: 100%; padding: 12px; border: none; border-radius: 8px; background: #e94560;
  color: #fff; font-size: 1.1rem; font-weight: bold; cursor: pointer; margin-top: 8px;
}
.auth-box button:hover { background: #c73e54; }
.auth-toggle { text-align: center; margin-top: 16px; color: #aaa; }
.auth-toggle a { color: #e94560; cursor: pointer; text-decoration: underline; }
.auth-error { color: #ff6b6b; text-align: center; margin-bottom: 12px; min-height: 20px; }

/* Lobby */
.lobby-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px; background: #16213e; border-bottom: 2px solid #333;
}
.lobby-header h1 { color: #e94560; font-size: 1.8rem; }
.lobby-header .user-info { display: flex; align-items: center; gap: 12px; }
.lobby-header .user-info span { color: #4ecca3; font-weight: bold; }
.logout-btn {
  padding: 8px 16px; background: #333; color: #eee; border: none; border-radius: 6px;
  cursor: pointer; font-size: 0.9rem;
}
.logout-btn:hover { background: #555; }

.game-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px; padding: 24px; max-width: 1100px; margin: 0 auto;
}
.game-card {
  background: #16213e; border-radius: 12px; padding: 24px; text-align: center;
  cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; border: 2px solid transparent;
}
.game-card:hover { transform: translateY(-4px); box-shadow: 0 8px 25px rgba(0,0,0,0.3); }
.game-card.snake { border-color: #4ecca3; }
.game-card.tictactoe { border-color: #e94560; }
.game-card.tetris { border-color: #f0a000; }
.game-card.pong { border-color: #00b4d8; }
.game-card.blockpuzzle { border-color: #ff6bf0; }
.game-card.chess { border-color: #c9a84c; }
.game-card h3 { font-size: 1.5rem; margin-bottom: 8px; }
.game-card.snake h3 { color: #4ecca3; }
.game-card.tictactoe h3 { color: #e94560; }
.game-card.tetris h3 { color: #f0a000; }
.game-card.pong h3 { color: #00b4d8; }
.game-card.blockpuzzle h3 { color: #ff6bf0; }
.game-card.chess h3 { color: #c9a84c; }
.game-card p { color: #aaa; font-size: 0.9rem; }

/* Room list modal */
.modal-overlay {
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.7); z-index: 100; justify-content: center; align-items: center;
}
.modal-overlay.active { display: flex; }
.modal {
  background: #16213e; border-radius: 12px; padding: 24px; width: 450px; max-height: 80vh;
  overflow-y: auto;
}
.modal h2 { color: #e94560; margin-bottom: 16px; }
.modal .close-btn {
  float: right; background: none; border: none; color: #aaa; font-size: 1.5rem;
  cursor: pointer; margin-top: -8px;
}
.modal .close-btn:hover { color: #fff; }
.create-room-btn {
  width: 100%; padding: 12px; background: #4ecca3; color: #1a1a2e; border: none;
  border-radius: 8px; font-size: 1rem; font-weight: bold; cursor: pointer; margin-bottom: 16px;
}
.create-room-btn:hover { background: #3dbb92; }
.room-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px; background: #1a1a2e; border-radius: 8px; margin-bottom: 8px;
}
.room-item .room-info { flex: 1; }
.room-item .room-name { font-weight: bold; }
.room-item .room-status { font-size: 0.85rem; color: #aaa; }
.room-item .join-btn {
  padding: 8px 16px; background: #e94560; color: #fff; border: none; border-radius: 6px;
  cursor: pointer; font-size: 0.9rem;
}
.room-item .join-btn:hover { background: #c73e54; }
.room-item .join-btn:disabled { background: #555; cursor: not-allowed; }
.no-rooms { text-align: center; color: #666; padding: 20px; }

/* Game page layout */
.game-page {
  display: flex; height: 100vh;
}
.game-area {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 20px; gap: 12px;
}
.game-area h2 { color: #e94560; font-size: 1.6rem; }
.game-area .game-info { color: #aaa; font-size: 0.95rem; }
.game-area .game-status {
  font-size: 1.2rem; min-height: 1.5rem; color: #4ecca3; font-weight: bold;
}

canvas { border: 2px solid #444; border-radius: 4px; background: #000; }

.back-btn {
  padding: 10px 24px; font-size: 1rem; background: #333; color: #eee; border: none;
  border-radius: 8px; cursor: pointer; margin-top: 8px;
}
.back-btn:hover { background: #555; }
.rematch-btn {
  padding: 10px 24px; font-size: 1rem; background: #4ecca3; color: #1a1a2e; border: none;
  border-radius: 8px; cursor: pointer; font-weight: bold; display: none;
}
.rematch-btn:hover { background: #3dbb92; }

/* Tic-Tac-Toe board */
.ttt-board { display: grid; grid-template-columns: repeat(3, 100px); gap: 6px; }
.ttt-cell {
  width: 100px; height: 100px; background: #16213e; border: none; border-radius: 8px;
  font-size: 2.5rem; font-weight: bold; color: #eee; cursor: pointer; transition: background 0.15s;
}
.ttt-cell:hover { background: #1a1a40; }
.ttt-cell.x { color: #e94560; }
.ttt-cell.o { color: #4ecca3; }

/* Dual board layout (tetris) */
.dual-board {
  display: flex; gap: 24px; align-items: flex-start;
}
.board-container { text-align: center; }
.board-container .player-label {
  font-size: 1rem; margin-bottom: 8px; color: #aaa;
}
.board-container .player-label.you { color: #4ecca3; font-weight: bold; }
.board-container .board-stats { font-size: 0.9rem; color: #888; margin-top: 4px; }

/* Chat widget */
.chat-panel {
  width: 280px; background: #16213e; display: flex; flex-direction: column;
  border-left: 2px solid #333;
}
.chat-header {
  padding: 12px 16px; background: #0f3460; font-weight: bold; font-size: 1rem;
  border-bottom: 2px solid #333;
}
.chat-messages {
  flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px;
}
.chat-msg { font-size: 0.85rem; }
.chat-msg .chat-user { color: #4ecca3; font-weight: bold; }
.chat-msg .chat-text { color: #ddd; }
.chat-msg .chat-time { color: #666; font-size: 0.75rem; }
.chat-input-area { display: flex; padding: 8px; border-top: 2px solid #333; }
.chat-input-area input {
  flex: 1; padding: 8px 12px; background: #1a1a2e; border: 1px solid #333;
  border-radius: 6px 0 0 6px; color: #eee; outline: none; font-size: 0.9rem;
}
.chat-input-area button {
  padding: 8px 16px; background: #e94560; color: #fff; border: none;
  border-radius: 0 6px 6px 0; cursor: pointer; font-size: 0.9rem;
}

/* Waiting screen */
.waiting-msg {
  font-size: 1.3rem; color: #f0a000; animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Score display for pong */
.score-display { font-size: 1.3rem; color: #e94560; }

/* Block Puzzle */
.bp-top-bar {
  display: flex; gap: 32px; margin-bottom: 8px;
}
.bp-stat { text-align: center; }
.bp-stat-label { font-size: 0.8rem; color: #888; text-transform: uppercase; letter-spacing: 1px; }
.bp-stat-value { font-size: 1.6rem; font-weight: bold; color: #eee; }
.bp-rating { color: #4ecca3; }
.bp-shapes {
  display: flex; gap: 12px; margin-top: 12px; justify-content: center;
}
.bp-shape-slot {
  width: 120px; height: 120px; background: #16213e; border: 2px solid #333;
  border-radius: 8px; cursor: pointer; transition: border-color 0.15s;
}
.bp-shape-slot:hover { border-color: #4ecca3; }

/* Chess */
.chess-setup-overlay {
  display: flex; justify-content: center; align-items: center;
  min-height: 100vh; padding: 20px;
}
.chess-setup-box {
  background: #16213e; padding: 32px; border-radius: 16px; width: 620px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4); text-align: center;
}
.chess-setup-box h2 { color: #c9a84c; margin-bottom: 24px; font-size: 1.8rem; }
.chess-bots {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 24px;
}
.chess-bot-card {
  width: 105px; padding: 12px 8px; background: #1a1a2e; border: 2px solid #333;
  border-radius: 10px; cursor: pointer; transition: border-color 0.15s, transform 0.15s;
  text-align: center;
}
.chess-bot-card:hover { border-color: #c9a84c; transform: translateY(-2px); }
.chess-bot-card.selected { border-color: #c9a84c; background: #1e2a4a; }
.chess-bot-emoji { font-size: 2rem; margin-bottom: 4px; }
.chess-bot-name { font-weight: bold; color: #eee; font-size: 0.85rem; }
.chess-bot-rating { color: #c9a84c; font-size: 0.8rem; font-weight: bold; }
.chess-bot-quote { color: #888; font-size: 0.7rem; margin-top: 4px; font-style: italic; }
.chess-color-choice {
  display: flex; gap: 10px; justify-content: center; margin-bottom: 20px;
}
.chess-color-btn {
  padding: 10px 20px; background: #1a1a2e; border: 2px solid #333;
  border-radius: 8px; color: #eee; cursor: pointer; font-size: 1rem;
  transition: border-color 0.15s;
}
.chess-color-btn:hover { border-color: #c9a84c; }
.chess-color-btn.selected { border-color: #c9a84c; background: #1e2a4a; }
.chess-play-btn {
  padding: 12px 48px; background: #c9a84c; color: #1a1a2e; border: none;
  border-radius: 8px; font-size: 1.1rem; font-weight: bold; cursor: pointer;
  margin-bottom: 12px;
}
.chess-play-btn:hover { background: #d4b85e; }
.chess-opponent-bar, .chess-player-bar {
  display: flex; align-items: center; gap: 12px; padding: 6px 12px;
  background: #16213e; border-radius: 6px; min-width: 480px;
  font-size: 0.9rem;
}
.chess-player-name { font-weight: bold; color: #eee; }
.chess-captured { color: #aaa; font-size: 1.1rem; letter-spacing: 2px; }
.chess-controls { display: flex; gap: 8px; margin-top: 8px; }
.chess-history-panel {
  width: 220px; background: #16213e; display: flex; flex-direction: column;
  border-left: 2px solid #333;
}
.chess-moves {
  flex: 1; overflow-y: auto; padding: 8px 12px; font-size: 0.85rem;
  font-family: monospace;
}
.chess-move-row { padding: 3px 0; color: #ddd; }
.chess-move-num { color: #888; display: inline-block; width: 28px; }
.chess-move-white { display: inline-block; width: 60px; color: #eee; }
.chess-move-black { display: inline-block; width: 60px; color: #aaa; }
