/* Tic Tac Toe Panel (draggable, same style as drawing board) */
.tictactoe-overlay {
  display: none;
  position: fixed;
  z-index: 2000;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.tictactoe-overlay.show {
  display: block;
  animation: tttFadeIn 0.2s ease;
}

@keyframes tttFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Tic Tac Toe Container */
.tictactoe-container {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  width: 320px;
  max-width: calc(100vw - 32px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.tictactoe-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  cursor: grab;
  user-select: none;
}

.tictactoe-header:active {
  cursor: grabbing;
}

.tictactoe-header h3 {
  margin: 0;
  font-size: 18px;
  color: #2c3e50;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tictactoe-close-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: #ecf0f1;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #7f8c8d;
  transition: all 0.2s;
}

.tictactoe-close-btn:hover {
  background: #e74c3c;
  color: #fff;
}

/* Scoreboard */
.tictactoe-scoreboard {
  display: flex;
  justify-content: space-around;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 10px;
}

.score-player {
  text-align: center;
}

.score-label {
  font-size: 12px;
  color: #7f8c8d;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.score-value {
  font-size: 28px;
  font-weight: 700;
  color: #2c3e50;
}

.score-player.you .score-value {
  color: #3498db;
}

.score-player.stranger .score-value {
  color: #e74c3c;
}

.score-divider {
  font-size: 20px;
  color: #bdc3c7;
  font-weight: 300;
}

/* Game Status */
.tictactoe-status {
  text-align: center;
  margin-bottom: 12px;
  font-size: 14px;
  color: #7f8c8d;
  min-height: 20px;
}

.tictactoe-status.your-turn {
  color: #27ae60;
  font-weight: 600;
}

.tictactoe-status.their-turn {
  color: #e67e22;
}

.tictactoe-status.winner {
  color: #3498db;
  font-weight: 600;
}

.tictactoe-status.loser {
  color: #e74c3c;
}

.tictactoe-status.draw {
  color: #9b59b6;
  font-weight: 600;
}

/* Game Board */
.tictactoe-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 8px;
  aspect-ratio: 1;
}

.tictactoe-cell {
  background: #ecf0f1;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  font-weight: 700;
  cursor: default;
  transition: background 0.15s, transform 0.1s;
  position: relative;
}

.tictactoe-cell.available {
  cursor: pointer;
}

.tictactoe-cell.available:hover {
  background: #e8e8e8;
}

/* Cell content */
.tictactoe-cell .cell-content {
  line-height: 1;
  transition: opacity 0.15s;
}

.tictactoe-cell .cell-content.x {
  color: #3498db;
}

.tictactoe-cell .cell-content.o {
  color: #e74c3c;
}

/* Preview on hover */
.tictactoe-cell .cell-preview {
  position: absolute;
  opacity: 0;
  line-height: 1;
  transition: opacity 0.15s;
}

.tictactoe-cell .cell-preview.x {
  color: #3498db;
}

.tictactoe-cell .cell-preview.o {
  color: #e74c3c;
}

.tictactoe-cell.available:hover .cell-preview {
  opacity: 0.3;
}

/* Winning cells */
.tictactoe-cell.winning {
  background: #d5f5e3;
  transform: scale(1.05);
}

.tictactoe-cell.winning .cell-content.x {
  color: #27ae60;
}

.tictactoe-cell.winning .cell-content.o {
  color: #27ae60;
}

/* Waiting for opponent */
.tictactoe-waiting {
  text-align: center;
  padding: 40px 20px;
  color: #7f8c8d;
}

.tictactoe-waiting .waiting-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #ecf0f1;
  border-top-color: #3498db;
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: tttSpin 1s linear infinite;
}

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

/* Invite message in chat */
.tictactoe-invite {
  color: #3498db;
  cursor: pointer;
  text-decoration: underline;
}

.tictactoe-invite:hover {
  color: #2980b9;
}

/* Mobile Responsive */
@media (max-width: 400px) {
  .tictactoe-container {
    padding: 16px;
    width: 290px;
  }

  .tictactoe-cell {
    font-size: 36px;
  }

  .score-value {
    font-size: 24px;
  }
}
