/* ===== ROOT & VARIABLES ===== */
:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: rgba(30, 41, 59, 0.9);
  --bg-input: rgba(255, 255, 255, 0.08);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-primary: #667eea;
  --accent-secondary: #764ba2;
  --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --x-color: #667eea;
  --o-color: #f5576c;
  --draw-color: #10b981;
  --win-gradient: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
  --border-subtle: rgba(255, 255, 255, 0.1);
  --border-light: rgba(255, 255, 255, 0.15);
  --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 15px 30px rgba(0, 0, 0, 0.4);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== BASE STYLES ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  min-height: 100vh;
  color: var(--text-primary);
  overflow-x: hidden;
}

/* ===== GAME WRAPPER ===== */
.game-wrapper {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 20px;
  padding-bottom: 100px;
}

.game-container {
  max-width: 900px;
  width: 100%;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-subtle);
  backdrop-filter: blur(10px);
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== HEADER ===== */
.header {
  text-align: center;
  margin-bottom: 28px;
}

.title {
  font-size: 2.8rem;
  font-weight: 700;
  margin-bottom: 8px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.title-icon {
  color: var(--accent-primary);
  -webkit-text-fill-color: initial;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1.15rem;
  font-weight: 400;
}

.welcome-user {
  color: var(--accent-primary);
  font-size: 1rem;
  font-weight: 600;
  margin-top: 8px;
}

/* ===== NAME ENTRY MODAL ===== */
.name-entry-modal {
  max-width: 400px;
}

.name-entry-input {
  margin: 20px 0;
}

.name-entry-input input {
  width: 100%;
  padding: 14px 18px;
  background: var(--bg-input);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  color: white;
  font-size: 1.1rem;
  text-align: center;
  transition: var(--transition-normal);
}

.name-entry-input input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.name-entry-input input::placeholder {
  color: var(--text-muted);
}

.name-error {
  color: #f87171;
  font-size: 0.9rem;
  margin-top: 8px;
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* ===== PLAYER O SETUP (Local Mode) ===== */
.player-o-setup {
  margin-top: 20px;
  padding: 15px;
  background: rgba(15, 23, 42, 0.5);
  border-radius: var(--radius-md);
  animation: slideDown 0.3s ease;
}

.name-input-group {
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
}

.name-input-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
}

.name-input-group input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  color: white;
  font-size: 1rem;
  transition: var(--transition-normal);
  text-align: center;
}

.name-input-group input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.name-input-group input::placeholder {
  color: var(--text-muted);
}

/* ===== MODE SELECTOR ===== */
.mode-selector {
  background: rgba(15, 23, 42, 0.8);
  padding: 20px;
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  border: 1px solid var(--border-subtle);
}

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

.mode-btn {
  padding: 12px 22px;
  border: 2px solid var(--accent-primary);
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition-normal);
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 155px;
}

.mode-btn:hover {
  background: rgba(102, 126, 234, 0.15);
  transform: translateY(-2px);
}

.mode-btn.active {
  background: var(--accent-gradient);
  color: white;
  border-color: transparent;
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* ===== ONLINE CONTROLS ===== */
.online-controls {
  margin-top: 20px;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.room-controls {
  display: flex;
  flex-direction: column;
  gap: 15px;
  align-items: center;
}

.room-btn {
  padding: 12px 24px;
  background: var(--accent-gradient);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-normal);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
}

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

.room-btn.leave-btn {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 2px solid rgba(239, 68, 68, 0.3);
}

.room-btn.leave-btn:hover {
  background: rgba(239, 68, 68, 0.3);
}

.join-room {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 400px;
}

.join-room input {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  color: white;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-align: center;
}

.join-room input::placeholder {
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: normal;
}

.join-room input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.room-info {
  background: rgba(255, 255, 255, 0.05);
  padding: 20px;
  border-radius: var(--radius-md);
  text-align: center;
}

.room-info p {
  margin: 8px 0;
  color: var(--text-secondary);
}

.room-code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-weight: 700;
  color: var(--accent-primary);
  background: rgba(102, 126, 234, 0.15);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 1.2rem;
  letter-spacing: 3px;
  margin: 0 8px;
}

.copy-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  vertical-align: middle;
  transition: var(--transition-fast);
}

.copy-btn:hover {
  color: var(--accent-primary);
}

.room-status {
  font-size: 0.9rem;
}

.player-info {
  font-weight: 600;
}

.opponent-info {
  font-weight: 500;
  color: var(--o-color) !important;
}

/* ===== GAME STATUS ===== */
.game-status {
  text-align: center;
  padding: 20px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  border: 1px solid var(--border-subtle);
}

.status-row {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-bottom: 12px;
  font-size: 1rem;
}

.highlight {
  color: var(--accent-primary);
}

.status-message {
  font-size: 1.4rem;
  font-weight: 600;
  color: white;
  margin: 0;
}

/* ===== TIMER DISPLAY ===== */
.timer-display {
  margin: 12px 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.timer-display.warning {
  color: #f59e0b;
  animation: pulse 0.5s ease-in-out infinite;
}

.timer-display.critical {
  color: #ef4444;
  animation: pulse 0.3s ease-in-out infinite;
}

/* ===== AI CONTROLS ===== */
.ai-controls-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.ai-controls-inner {
  background: rgba(15, 23, 42, 0.8);
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  width: 348px; /* Same width as board */
}

.ai-controls-inner label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  font-weight: 600;
}

.difficulty-buttons {
  display: flex;
  gap: 10px;
}

.diff-btn {
  flex: 1;
  padding: 12px 14px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-normal);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.9rem;
}

.diff-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
}

.diff-btn.active {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

/* ===== SCOREBOARD ===== */
.scoreboard-container {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.scoreboard {
  background: rgba(15, 23, 42, 0.8);
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  width: 348px;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.score-item {
  text-align: center;
  padding: 12px 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.score-item.x-score {
  border-color: rgba(102, 126, 234, 0.3);
}

.score-item.o-score {
  border-color: rgba(245, 87, 108, 0.3);
}

.score-item.draw-score {
  border-color: rgba(16, 185, 129, 0.3);
}

.score-label {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 4px;
  font-weight: 500;
}

.score-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: white;
}

/* ===== COLOR CLASSES ===== */
.x-color { color: var(--x-color); }
.o-color { color: var(--o-color); }
.draw-color { color: var(--draw-color); }

/* ===== GAME BOARD ===== */
.board-container {
  display: flex;
  justify-content: center;
  margin-bottom: 28px;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  background: rgba(15, 23, 42, 0.8);
  padding: 20px;
  border-radius: var(--radius-xl);
  border: 2px solid var(--border-light);
  box-shadow: var(--shadow-md);
}

.cell {
  width: 100px;
  height: 100px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-lg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
  font-size: 3rem;
  font-weight: bold;
  -webkit-tap-highlight-color: transparent;
}

.cell:hover:not(.disabled) {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-3px);
  border-color: var(--accent-primary);
}

.cell:active:not(.disabled) {
  transform: translateY(-1px);
}

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

.cell.x {
  color: var(--x-color);
  text-shadow: 0 0 15px rgba(102, 126, 234, 0.6);
  animation: popIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.cell.o {
  color: var(--o-color);
  text-shadow: 0 0 15px rgba(245, 87, 108, 0.6);
  animation: popIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes popIn {
  0% { transform: scale(0); opacity: 0; }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

.cell.winning {
  background: var(--win-gradient);
  border-color: #f6d365;
  animation: pulse 1.5s infinite;
  color: #1e293b !important;
  text-shadow: none !important;
}

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

/* ===== ACTION BUTTONS ===== */
.action-buttons {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

.action-btn {
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-normal);
  display: flex;
  align-items: center;
  gap: 10px;
  -webkit-tap-highlight-color: transparent;
}

.action-btn.primary {
  background: var(--accent-gradient);
  color: white;
}

.action-btn.primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.action-btn.secondary {
  background: rgba(245, 87, 108, 0.15);
  color: var(--o-color);
  border: 2px solid rgba(245, 87, 108, 0.3);
}

.action-btn.secondary:hover {
  background: rgba(245, 87, 108, 0.25);
  transform: translateY(-3px);
}

.action-btn.icon-btn {
  padding: 14px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.action-btn.icon-btn.active {
  background: rgba(102, 126, 234, 0.2);
  color: var(--accent-primary);
}

.action-btn.icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* ===== LEADERBOARD ===== */
.leaderboard-container {
  margin-top: 16px;
  animation: slideDown 0.3s ease;
}

.leaderboard-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.leaderboard-tab {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-normal);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.leaderboard-tab:hover {
  background: rgba(255, 255, 255, 0.12);
}

.leaderboard-tab.active {
  background: var(--accent-gradient);
  color: white;
}

.leaderboard-content {
  background: rgba(15, 23, 42, 0.5);
  border-radius: var(--radius-md);
  padding: 16px;
}

.leaderboard-list {
  max-height: 300px;
  overflow-y: auto;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  transition: var(--transition-normal);
}

.leaderboard-item:last-child {
  margin-bottom: 0;
}

.leaderboard-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.leaderboard-item.current-user {
  border: 2px solid var(--accent-primary);
  background: rgba(102, 126, 234, 0.1);
}

.leaderboard-rank {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.leaderboard-rank.gold {
  background: linear-gradient(135deg, #ffd700, #ffb347);
  color: #1e293b;
}

.leaderboard-rank.silver {
  background: linear-gradient(135deg, #c0c0c0, #a8a8a8);
  color: #1e293b;
}

.leaderboard-rank.bronze {
  background: linear-gradient(135deg, #cd7f32, #b8860b);
  color: #1e293b;
}

.leaderboard-rank.normal {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
}

.leaderboard-name {
  flex: 1;
  font-weight: 600;
  color: var(--text-primary);
}

.leaderboard-score {
  font-weight: 700;
  color: var(--accent-primary);
  font-size: 1.1rem;
}

.leaderboard-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 20px;
}

/* ===== SECTION TOGGLES ===== */
.section-toggle {
  margin-bottom: 20px;
}

.toggle-btn {
  width: 100%;
  padding: 16px 20px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: var(--transition-normal);
  -webkit-tap-highlight-color: transparent;
}

.toggle-btn:hover {
  background: rgba(15, 23, 42, 0.95);
  border-color: var(--accent-primary);
}

.toggle-btn i:last-child {
  margin-left: auto;
}

/* ===== ACHIEVEMENTS ===== */
.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 16px;
  animation: slideDown 0.3s ease;
}

.achievement-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  transition: var(--transition-normal);
}

.achievement-card.locked {
  opacity: 0.5;
}

.achievement-card.unlocked {
  border-color: rgba(102, 126, 234, 0.4);
}

.achievement-card:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.08);
}

.achievement-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  font-size: 1.2rem;
}

.achievement-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.achievement-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.achievement-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ===== ACHIEVEMENT TOAST ===== */
.achievement-toast {
  position: fixed;
  top: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: rgba(30, 41, 59, 0.98);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  z-index: 3000;
  animation: toastIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes toastIn {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.achievement-toast-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.3rem;
}

.achievement-toast-content {
  display: flex;
  flex-direction: column;
}

.achievement-toast-title {
  font-size: 0.8rem;
  color: var(--draw-color);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.achievement-toast-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: white;
}

/* ===== HISTORY ===== */
.history-list {
  margin-top: 16px;
  animation: slideDown 0.3s ease;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.history-date {
  color: var(--text-muted);
  min-width: 90px;
}

.history-result {
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}

.history-result.win {
  background: rgba(102, 126, 234, 0.2);
  color: var(--x-color);
}

.history-result.lose {
  background: rgba(245, 87, 108, 0.2);
  color: var(--o-color);
}

.history-result.draw {
  background: rgba(16, 185, 129, 0.2);
  color: var(--draw-color);
}

.history-mode {
  color: var(--text-secondary);
}

.history-moves {
  color: var(--text-muted);
}

.no-history {
  text-align: center;
  color: var(--text-muted);
  padding: 20px;
}

/* ===== STATS DISPLAY ===== */
.stats-display {
  margin-bottom: 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.stat-item {
  text-align: center;
  padding: 16px 12px;
  background: rgba(15, 23, 42, 0.8);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.stat-value {
  display: block;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--accent-primary);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== INSTRUCTIONS ===== */
.instructions {
  padding: 24px;
  background: rgba(15, 23, 42, 0.8);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--accent-primary);
  margin-bottom: 24px;
}

.instructions h3 {
  color: var(--text-secondary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
}

.instructions ul {
  list-style: none;
}

.instructions li {
  padding: 8px 0;
  color: var(--text-muted);
  position: relative;
  padding-left: 22px;
  font-size: 0.95rem;
}

.instructions li:before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--accent-primary);
}

/* ===== FOOTER ===== */
.footer {
  text-align: center;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.footer p {
  margin: 8px 0;
}

.footer a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: var(--transition-fast);
}

.footer a:hover {
  text-decoration: underline;
  color: #8b9cf4;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn 0.3s ease;
  padding: 20px;
}

.modal-content {
  background: var(--bg-card);
  padding: 40px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-lg);
  text-align: center;
  max-width: 400px;
  width: 100%;
  animation: scaleIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes scaleIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  background: var(--accent-gradient);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: white;
}

.modal-icon.spinning i {
  animation: spin 1s linear infinite;
}

.modal-icon.declined {
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

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

.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.modal-message {
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-size: 1.05rem;
}

.modal-submessage {
  color: var(--text-muted);
  margin-bottom: 24px;
  font-size: 0.95rem;
}

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

.modal-btn {
  padding: 14px 32px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-normal);
  display: flex;
  align-items: center;
  gap: 8px;
  -webkit-tap-highlight-color: transparent;
}

.modal-btn.accept {
  background: var(--accent-gradient);
  color: white;
}

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

.modal-btn.decline {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 2px solid rgba(239, 68, 68, 0.3);
}

.modal-btn.decline:hover {
  background: rgba(239, 68, 68, 0.3);
  transform: translateY(-2px);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .title {
      font-size: 2.2rem;
  }
  
  .cell {
      width: 85px;
      height: 85px;
      font-size: 2.5rem;
  }
  
  .scoreboard {
      width: 295px;
  }
  
  .ai-controls-inner {
      width: 295px;
  }
}

@media (max-width: 768px) {
  .game-container {
      padding: 20px;
  }
  
  .title {
      font-size: 1.9rem;
  }
  
  .mode-buttons {
      flex-direction: column;
      align-items: center;
  }
  
  .mode-btn {
      width: 100%;
      max-width: 280px;
      justify-content: center;
  }
  
  .cell {
      width: 75px;
      height: 75px;
      font-size: 2rem;
  }
  
  .scoreboard {
      width: 261px;
  }
  
  .ai-controls-inner {
      width: 261px;
  }
  
  .action-buttons {
      flex-direction: column;
      align-items: center;
  }
  
  .action-btn {
      width: 100%;
      max-width: 280px;
      justify-content: center;
  }
  
  .stats-grid {
      grid-template-columns: repeat(2, 1fr);
  }
  
  .status-row {
      flex-direction: column;
      gap: 8px;
  }
  
  .history-item {
      flex-wrap: wrap;
      gap: 8px;
  }
  
  .achievements-grid {
      grid-template-columns: 1fr;
  }
  
  .achievement-toast {
      right: 12px;
      left: 12px;
      top: 12px;
  }
  
  .modal-buttons {
      flex-direction: column;
  }
  
  .modal-btn {
      width: 100%;
      justify-content: center;
  }
  
  .leaderboard-tabs {
      flex-direction: column;
  }
}

@media (max-width: 480px) {
  .game-wrapper {
      padding: 10px;
  }
  
  .game-container {
      padding: 16px;
  }
  
  .title {
      font-size: 1.4rem;
  }
  
  .cell {
      width: 60px;
      height: 60px;
      font-size: 1.6rem;
  }
  
  .board {
      padding: 12px;
      gap: 8px;
  }
  
  .scoreboard {
      width: 208px;
  }
  
  .ai-controls-inner {
      width: 208px;
  }
  
  .difficulty-buttons {
      flex-direction: column;
  }
  
  .join-room {
      flex-direction: column;
  }
  
  .stats-grid {
      grid-template-columns: repeat(2, 1fr);
  }
  
  .stat-value {
      font-size: 1.4rem;
  }
  
  .modal-content {
      padding: 24px;
  }
  
  .modal-icon {
      width: 60px;
      height: 60px;
      font-size: 1.5rem;
  }
  
  .modal-title {
      font-size: 1.2rem;
  }
}

/* ===== SCROLLBAR ===== */
.leaderboard-list::-webkit-scrollbar {
  width: 6px;
}

.leaderboard-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
}

.leaderboard-list::-webkit-scrollbar-thumb {
  background: var(--accent-primary);
  border-radius: 3px;
}

.leaderboard-list::-webkit-scrollbar-thumb:hover {
  background: var(--accent-secondary);
}
