body {
  margin: 0;
  font-family: 'Segoe UI', sans-serif;
  background: linear-gradient(135deg, #ff9a9e, #fecfef, #fecfef, #a8edea);
  color: #333;
  min-height: 100vh;
}

header {
  padding: 20px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  text-align: center;
}

h1 {
  margin: 0;
  font-size: 2rem;
  color: #333;
}

.back-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 15px;
  background: #ff6b6b;
  color: #fff;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.3s ease;
}

.back-btn:hover {
  background: #ff5252;
}

main {
  padding: 20px;
  max-width: 800px;
  margin: 0 auto;
}

.game-container {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

/* Mode Selection */
.mode-selection {
  text-align: center;
}

.mode-selection h2 {
  margin-bottom: 30px;
  font-size: 2rem;
  color: #333;
}

.mode-buttons {
  display: flex;
  gap: 30px;
  justify-content: center;
  flex-wrap: wrap;
}

.mode-btn {
  background: linear-gradient(145deg, #ffffff, #f0f0f0);
  border: 3px solid transparent;
  border-radius: 20px;
  padding: 30px;
  width: 250px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.mode-btn:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
  border-color: #ff6b6b;
}

.mode-icon {
  font-size: 3rem;
  margin-bottom: 15px;
}

.mode-btn h3 {
  margin: 0 0 10px 0;
  font-size: 1.4rem;
  color: #333;
}

.mode-btn p {
  margin: 0;
  color: #666;
  font-size: 0.9rem;
}

/* Difficulty Selection */
.difficulty-selection {
  text-align: center;
}

.difficulty-selection h2 {
  margin-bottom: 30px;
  font-size: 2rem;
  color: #333;
}

.difficulty-buttons {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 30px;
}

.difficulty-btn {
  background: linear-gradient(145deg, #ffffff, #f0f0f0);
  border: 3px solid transparent;
  border-radius: 15px;
  padding: 25px 20px;
  width: 180px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
}

.difficulty-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 25px rgba(0, 0, 0, 0.15);
}

.difficulty-btn.easy:hover { border-color: #4caf50; }
.difficulty-btn.medium:hover { border-color: #ff9800; }
.difficulty-btn.hard:hover { border-color: #f44336; }

.difficulty-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

.difficulty-btn h3 {
  margin: 0 0 8px 0;
  font-size: 1.2rem;
}

.difficulty-btn p {
  margin: 0;
  color: #666;
  font-size: 0.8rem;
}

.back-btn-small {
  background: #666;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.3s ease;
}

.back-btn-small:hover {
  background: #555;
}

/* Game Area */
.game-area {
  text-align: center;
}

.game-info {
  margin-bottom: 30px;
}

.player-info {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 30px;
  margin-bottom: 20px;
}

.player-card {
  background: rgba(255, 255, 255, 0.8);
  padding: 20px;
  border-radius: 15px;
  min-width: 120px;
  transition: all 0.3s ease;
  border: 3px solid transparent;
}

.player-card.active {
  border-color: #ff6b6b;
  background: rgba(255, 107, 107, 0.1);
  transform: scale(1.05);
}

.player-symbol {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

.player-name {
  font-weight: bold;
  margin-bottom: 5px;
  font-size: 1.1rem;
}

.player-score {
  font-size: 1.5rem;
  font-weight: bold;
  color: #ff6b6b;
}

.vs-indicator {
  font-size: 1.5rem;
  font-weight: bold;
  color: #666;
  padding: 0 20px;
}

.game-status {
  margin-bottom: 20px;
}

#currentPlayer {
  font-size: 1.3rem;
  font-weight: bold;
  color: #333;
  margin-bottom: 10px;
}

#gameMessage {
  font-size: 1rem;
  color: #666;
  min-height: 24px;
}

.game-controls {
  display: flex;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
}

.control-btn {
  background: #ff6b6b;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.control-btn:hover {
  background: #ff5252;
  transform: translateY(-2px);
}

/* Game Board */
.board-container {
  position: relative;
  display: flex;
  justify-content: center;
}

.game-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: #333;
  padding: 8px;
  border-radius: 15px;
  max-width: 300px;
  width: 100%;
}

.cell {
  aspect-ratio: 1;
  background: white;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.cell:hover:not(.filled) {
  background: #f0f0f0;
  transform: scale(0.95);
}

.cell.filled {
  cursor: not-allowed;
}

.cell.x {
  color: #ff6b6b;
  animation: placeX 0.3s ease-out;
}

.cell.o {
  color: #4ecdc4;
  animation: placeO 0.3s ease-out;
}

.cell.winning {
  background: #ffd700 !important;
  animation: winPulse 0.6s ease-in-out infinite;
}

/* Win Line */
.win-line {
  position: absolute;
  background: #ffd700;
  border-radius: 4px;
  transform-origin: center;
  animation: drawLine 0.5s ease-out;
  z-index: 10;
}

.win-line.horizontal {
  height: 8px;
  width: 284px;
}

.win-line.vertical {
  width: 8px;
  height: 284px;
}

.win-line.diagonal {
  height: 8px;
  width: 400px;
}

/* AI Thinking Animation */
.ai-thinking {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.thinking-content {
  background: white;
  padding: 30px;
  border-radius: 15px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.thinking-spinner {
  width: 50px;
  height: 50px;
  border: 5px solid #f3f3f3;
  border-top: 5px solid #ff6b6b;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

.thinking-text {
  font-size: 1.2rem;
  font-weight: bold;
  color: #333;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(5px);
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: white;
  padding: 40px;
  border-radius: 20px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.4s ease-out;
}

.result-icon {
  font-size: 4rem;
  margin-bottom: 20px;
}

.modal-content h2 {
  margin: 0 0 15px 0;
  font-size: 1.8rem;
  color: #333;
}

#resultMessage {
  font-size: 1.1rem;
  color: #666;
  margin-bottom: 30px;
}

.modal-buttons {
  display: flex;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  padding: 12px 25px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn.primary {
  background: #ff6b6b;
  color: white;
}

.btn.primary:hover {
  background: #ff5252;
  transform: translateY(-2px);
}

.btn:not(.primary) {
  background: #f0f0f0;
  color: #333;
}

.btn:not(.primary):hover {
  background: #e0e0e0;
}

/* Utility Classes */
.hidden {
  display: none !important;
}

/* Animations */
@keyframes placeX {
  0% {
    transform: scale(0) rotate(0deg);
    opacity: 0;
  }
  50% {
    transform: scale(1.2) rotate(180deg);
  }
  100% {
    transform: scale(1) rotate(180deg);
    opacity: 1;
  }
}

@keyframes placeO {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes winPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

@keyframes drawLine {
  0% {
    transform: scale(0, 1);
    opacity: 0;
  }
  100% {
    transform: scale(1, 1);
    opacity: 1;
  }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes modalSlideIn {
  0% {
    transform: translateY(-100px);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .mode-buttons {
    flex-direction: column;
    align-items: center;
  }
  
  .mode-btn {
    width: 100%;
    max-width: 300px;
  }
  
  .difficulty-buttons {
    flex-direction: column;
    align-items: center;
  }
  
  .player-info {
    flex-direction: column;
    gap: 15px;
  }
  
  .vs-indicator {
    order: -1;
    padding: 0;
  }
  
  .game-controls {
    flex-direction: column;
    align-items: center;
  }
  
  .control-btn {
    width: 200px;
  }
}

/* Timer Container Styles */
.timer-container {
  background: rgba(255, 255, 255, 0.95);
  padding: 20px;
  border-radius: 15px;
  margin: 20px 0;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
}

.timer-mode-selector {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.timer-mode-btn {
  padding: 8px 16px;
  border: 2px solid #ddd;
  border-radius: 8px;
  background: white;
  color: #666;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
}

.timer-mode-btn:hover {
  border-color: #ff6b6b;
  color: #ff6b6b;
}

.timer-mode-btn.active {
  background: linear-gradient(135deg, #ff6b6b, #ff8a80);
  color: white;
  border-color: #ff6b6b;
}

.timer-display {
  margin-bottom: 20px;
}

.current-timer {
  text-align: center;
  margin-bottom: 20px;
}

.timer-label {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 5px;
}

.timer-value {
  font-size: 2rem;
  font-weight: bold;
  color: #333;
  margin-bottom: 10px;
  transition: color 0.3s ease;
}

.timer-progress {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.timer-progress-fill {
  height: 100%;
  background: #4CAF50;
  border-radius: 10px;
  transition: width 1s ease, background-color 0.5s ease;
  box-shadow: 0 0 10px rgba(76, 175, 80, 0.3);
}

.player-timers {
  display: flex;
  gap: 20px;
  justify-content: center;
}

.player-timer {
  text-align: center;
  padding: 15px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  min-width: 120px;
}

.player-timer.active {
  background: linear-gradient(135deg, #4CAF50, #81C784);
  color: white;
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.player-timer.low-time {
  background: linear-gradient(135deg, #ff4757, #ff6b7a);
  color: white;
  animation: pulse 1s infinite;
}

.timer-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.timer-control-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.9rem;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.timer-control-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.timer-control-btn:active {
  transform: translateY(0);
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 4px 15px rgba(255, 71, 87, 0.3);
  }
  50% {
    box-shadow: 0 6px 25px rgba(255, 71, 87, 0.6);
    transform: scale(1.02);
  }
}

@media (max-width: 480px) {
  .game-container {
    padding: 20px;
  }
  
  .cell {
    font-size: 2.5rem;
  }
  
  .modal-content {
    padding: 30px 20px;
  }
  
  .modal-buttons {
    flex-direction: column;
  }
  
  .btn {
    width: 100%;
  }
  
  .timer-container {
    margin: 10px 0;
    padding: 15px;
  }
  
  .timer-mode-selector {
    flex-direction: column;
    align-items: center;
  }
  
  .timer-mode-btn {
    width: 100%;
    max-width: 200px;
  }
  
  .player-timers {
    flex-direction: column;
    align-items: center;
  }
  
  .timer-controls {
    flex-direction: column;
    align-items: center;
  }
  
  .timer-control-btn {
    width: 100%;
    max-width: 200px;
  }
}