/* ===== CSS Variables ===== */
:root {
  --white: #ffffff;
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-gradient: linear-gradient(135deg, #2563eb, #3b82f6);
  --blue-gradient-dark: linear-gradient(135deg, #1d4ed8, #2563eb);
  --gold-300: #fde047;
  --gold-400: #facc15;
  --gold-500: #eab308;
  --gold-600: #f59e0b;
  --gold-gradient: linear-gradient(135deg, #f59e0b, #eab308);
  --gold-gradient-light: linear-gradient(135deg, #fbbf24, #f59e0b);
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --transition: 0.2s ease;
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 50%, #fef3c7 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--slate-800);
  padding: 16px;
  -webkit-font-smoothing: antialiased;
}

/* ===== Card Component ===== */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
  animation: slideUp 0.4s ease-out;
}

.card-header {
  background: var(--blue-gradient);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header__title {
  color: var(--white);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.card-header__badge {
  background: rgba(255, 255, 255, 0.2);
  color: var(--white);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  backdrop-filter: blur(4px);
}

.card-body {
  padding: 24px;
}

.card-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--slate-200);
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ===== Player Badges ===== */
.player-badges {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.player-badge {
  flex: 1;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  transition: all var(--transition);
  border: 2px solid transparent;
  position: relative;
}

.player-badge--0 {
  background: var(--blue-50);
  color: var(--blue-600);
  border-color: var(--blue-200);
}

.player-badge--1 {
  background: #fefce8;
  color: var(--gold-600);
  border-color: #fde68a;
}

.player-badge.active {
  transform: scale(1.03);
  box-shadow: var(--shadow-lg);
}

.player-badge--0.active {
  background: var(--blue-100);
  border-color: var(--blue-500);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.2);
  animation: pulse 2s ease-in-out infinite;
}

.player-badge--1.active {
  background: #fef9c3;
  border-color: var(--gold-500);
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.2);
  animation: pulse 2s ease-in-out infinite;
}

.player-badge__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
  margin-bottom: 2px;
}

.player-badge__name {
  font-size: 15px;
  font-weight: 700;
}

.player-badge__score {
  font-size: 13px;
  margin-top: 4px;
  opacity: 0.8;
}

/* ===== Board Container ===== */
.board-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

/* ===== Board Grid (TicTacToe, Connect4) ===== */
.board-grid {
  display: inline-grid;
  gap: 6px;
  padding: 8px;
  background: var(--slate-100);
  border-radius: var(--radius);
}

.cell {
  width: 52px;
  height: 52px;
  background: var(--white);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 800;
  cursor: pointer;
  transition: all var(--transition);
  border: 2px solid var(--slate-200);
  user-select: none;
}

.cell:hover:not(.occupied) {
  background: var(--blue-50);
  border-color: var(--blue-300);
  transform: scale(1.05);
}

.cell.occupied {
  cursor: default;
}

.cell.player0 {
  background: var(--blue-50);
  border-color: var(--blue-500);
  color: var(--blue-600);
}

.cell.player1 {
  background: #fefce8;
  border-color: var(--gold-500);
  color: var(--gold-600);
}

.cell.win {
  animation: pulse 0.6s ease-in-out infinite;
  border-color: var(--gold-400);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.4);
}

/* ===== Column Headers (Connect4) ===== */
.column-headers {
  display: inline-grid;
  gap: 6px;
  padding: 0 8px;
  margin-bottom: 4px;
}

.col-header-btn {
  width: 52px;
  height: 36px;
  background: var(--blue-gradient);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--white);
  font-size: 18px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.col-header-btn:hover:not(:disabled) {
  background: var(--blue-gradient-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.col-header-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.col-header-btn.full {
  background: var(--slate-300);
  cursor: not-allowed;
}

/* ===== Memory Match Grid ===== */
.memory-grid {
  display: inline-grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 8px;
}

.memory-card {
  width: 62px;
  height: 62px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  user-select: none;
  outline: none;
  border: 2px solid transparent;
}

.memory-card--hidden {
  background: var(--blue-gradient);
  color: var(--white);
  font-size: 22px;
}

.memory-card--hidden:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow);
}

.memory-card--revealed {
  background: var(--white);
  border-color: var(--slate-300);
  color: var(--slate-800);
}

.memory-card--matched {
  background: var(--gold-gradient-light);
  color: var(--white);
  border-color: var(--gold-500);
  cursor: default;
  animation: pulse 0.5s ease-in-out;
}

.memory-scores {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 600;
}

.memory-scores span {
  flex: 1;
  text-align: center;
  padding: 8px;
  border-radius: var(--radius-sm);
}

.memory-score-0 {
  background: var(--blue-50);
  color: var(--blue-600);
}

.memory-score-1 {
  background: #fefce8;
  color: var(--gold-600);
}

/* ===== Checkers ===== */
.checkers-board {
  display: inline-grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0;
  border: 3px solid var(--slate-700);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.checkers-cell {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.checkers-cell--light {
  background: #fef3c7;
}

.checkers-cell--dark {
  background: var(--slate-700);
}

.checkers-piece {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.15);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15);
}

.checkers-piece--0 {
  background: radial-gradient(circle at 35% 35%, #93c5fd, var(--blue-600));
  box-shadow: 0 3px 6px rgba(37, 99, 235, 0.4), inset 0 -3px 0 rgba(0, 0, 0, 0.2);
}

.checkers-piece--1 {
  background: radial-gradient(circle at 35% 35%, #fde68a, var(--gold-600));
  box-shadow: 0 3px 6px rgba(245, 158, 11, 0.4), inset 0 -3px 0 rgba(0, 0, 0, 0.2);
}

/* ===== Ludo Track ===== */
.ludo-track {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

.ludo-player {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ludo-player__label {
  width: 40px;
  font-size: 13px;
  font-weight: 700;
  text-align: right;
}

.ludo-player__bar {
  flex: 1;
  height: 24px;
  background: var(--slate-200);
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
}

.ludo-player__fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.5s ease;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--white);
  min-width: 0;
}

.ludo-player__fill--0 {
  background: var(--blue-gradient);
}

.ludo-player__fill--1 {
  background: var(--gold-gradient);
}

.ludo-player__pos {
  font-size: 13px;
  font-weight: 600;
  color: var(--slate-500);
  min-width: 40px;
}

/* ===== RPS Buttons ===== */
.rps-choices {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-bottom: 20px;
}

.rps-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3px solid var(--slate-200);
  background: var(--white);
  font-size: 32px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.rps-btn:hover:not(:disabled) {
  transform: scale(1.1);
  border-color: var(--blue-500);
  box-shadow: var(--shadow-lg);
}

.rps-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.rps-btn.selected {
  border-color: var(--blue-500);
  background: var(--blue-50);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.2);
}

.rps-reveal {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  font-size: 18px;
  font-weight: 600;
}

.rps-reveal__choice {
  font-size: 40px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--slate-100);
  min-width: 60px;
  text-align: center;
}

.rps-reveal__vs {
  color: var(--slate-400);
  font-size: 22px;
  font-weight: 800;
}

.rps-waiting {
  text-align: center;
  color: var(--slate-500);
  font-size: 14px;
  padding: 20px;
  animation: bounce 1.5s ease-in-out infinite;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--blue-gradient);
  color: var(--white);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
  background: var(--blue-gradient-dark);
}

.btn-gold {
  background: var(--gold-gradient);
  color: var(--white);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
}

.btn-gold:hover {
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--slate-300);
  color: var(--slate-600);
}

.btn-outline:hover {
  border-color: var(--blue-500);
  color: var(--blue-600);
  background: var(--blue-50);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== Result Overlay ===== */
.result-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.3s ease;
}

.result-overlay.hidden {
  display: none;
}

.result-modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  max-width: 320px;
  width: 90%;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.4s ease-out;
}

.result-modal__icon {
  font-size: 56px;
  margin-bottom: 16px;
  animation: bounce 0.8s ease-in-out;
}

.result-modal__title {
  font-size: 22px;
  font-weight: 700;
  color: var(--slate-800);
  margin-bottom: 8px;
}

.result-modal__subtitle {
  font-size: 14px;
  color: var(--slate-500);
  margin-bottom: 24px;
}

/* ===== Waiting / Lobby Screen ===== */
.lobby-screen {
  text-align: center;
  padding: 40px 24px;
}

.lobby-screen__icon {
  font-size: 48px;
  margin-bottom: 20px;
  animation: bounce 2s ease-in-out infinite;
}

.lobby-screen__title {
  font-size: 18px;
  font-weight: 700;
  color: var(--slate-700);
  margin-bottom: 8px;
}

.lobby-screen__subtitle {
  font-size: 14px;
  color: var(--slate-500);
  line-height: 1.5;
}

.lobby-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 40px 24px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--slate-200);
  border-top-color: var(--blue-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ===== Header ===== */
.app-header {
  text-align: center;
  margin-bottom: 16px;
}

.app-header__title {
  font-size: 28px;
  font-weight: 800;
  background: var(--blue-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.app-header__subtitle {
  font-size: 14px;
  color: var(--slate-500);
  margin-top: 4px;
}

/* ===== Animations ===== */
@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(37, 99, 235, 0);
  }
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes roll {
  0% {
    transform: rotate(0deg) scale(1);
  }
  50% {
    transform: rotate(360deg) scale(1.2);
  }
  100% {
    transform: rotate(720deg) scale(1);
  }
}

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

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

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

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

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

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

.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }

/* ===== Responsive ===== */
@media (max-width: 480px) {
  body {
    padding: 8px;
    align-items: flex-start;
    padding-top: 24px;
  }

  .card {
    border-radius: var(--radius);
  }

  .card-header {
    padding: 16px 20px;
  }

  .card-body {
    padding: 16px;
  }

  .card-footer {
    padding: 12px 16px;
  }

  .cell {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }

  .col-header-btn {
    width: 40px;
    height: 30px;
    font-size: 14px;
  }

  .memory-card {
    width: 48px;
    height: 48px;
    font-size: 22px;
  }

  .memory-grid {
    gap: 6px;
  }

  .board-grid {
    gap: 4px;
    padding: 6px;
  }

  .column-headers {
    gap: 4px;
    padding: 0 6px;
  }

  .rps-btn {
    width: 56px;
    height: 56px;
    font-size: 24px;
  }

  .checkers-cell {
    width: 30px;
    height: 30px;
  }

  .checkers-piece {
    width: 22px;
    height: 22px;
  }

  .player-badges {
    flex-direction: column;
    gap: 10px;
  }

  .ludo-player__label {
    width: 32px;
    font-size: 11px;
  }
}
