/* ═══════════════════════════════════════════════════════════════
   WhiteBoard Live — Responsive Styles (Mobile-First)
   ═══════════════════════════════════════════════════════════════ */

/* ─── Mobile Base (< 640px) ────────────────────────────────────── */
@media (max-width: 639px) {
  :root {
    --space-6: 1rem;
    --space-8: 1.5rem;
  }

  .container {
    padding: 0 var(--space-4);
  }

  .navbar {
    height: 56px;
    padding: 0 var(--space-4);
  }

  .navbar-brand {
    font-size: var(--font-size-lg);
  }

  .section-title {
    font-size: var(--font-size-2xl);
  }

  .section-subtitle {
    font-size: var(--font-size-md);
    margin-bottom: var(--space-6);
  }

  /* Homepage */
  .hero-title {
    font-size: clamp(2rem, 8vw, 3rem) !important;
  }

  .hero-description {
    font-size: var(--font-size-md) !important;
  }

  .hero-actions {
    flex-direction: column;
    gap: var(--space-3) !important;
  }

  .hero-actions .btn {
    width: 100%;
  }

  .games-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: var(--space-3) !important;
  }

  .game-card {
    padding: var(--space-4) !important;
  }

  .game-icon {
    font-size: 2rem !important;
  }

  .game-title {
    font-size: var(--font-size-md) !important;
  }

  .game-description {
    display: none !important;
  }

  /* Whiteboard */
  .wb-sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: var(--space-3);
    gap: var(--space-3);
    border-right: none;
    border-top: 1px solid var(--border);
    z-index: 200;
  }

  .tool-section {
    min-width: max-content;
  }

  .tool-section-title {
    display: none;
  }

  .tool-grid {
    grid-template-columns: repeat(6, 40px);
  }

  .tool-btn {
    aspect-ratio: 1;
    width: 40px;
  }

  .tool-btn span {
    display: none;
  }

  .color-palette {
    grid-template-columns: repeat(12, 28px);
  }

  #wb-canvas-wrap {
    margin-bottom: 100px;
  }

  /* XO */
  .xo-layout {
    padding: var(--space-4);
    gap: var(--space-4);
  }

  .xo-side {
    min-width: 100%;
  }

  .xo-cell {
    width: calc(28vw);
    height: calc(28vw);
    max-width: none;
    max-height: none;
    font-size: clamp(1.5rem, 7vw, 3rem);
  }

  /* Snake */
  .snake-layout {
    padding: var(--space-4);
    gap: var(--space-4);
  }

  .snake-side {
    min-width: 100%;
  }

  /* Chess */
  .chess-layout {
    padding: var(--space-3);
    gap: var(--space-3);
  }

  .chess-side {
    min-width: 100%;
  }

  .chess-cell {
    width: calc(100vw / 9);
    height: calc(100vw / 9);
    max-width: 40px;
    max-height: 40px;
    font-size: clamp(1rem, 5vw, 1.8rem);
  }

  .chess-board-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .chess-piece {
    font-size: clamp(0.9rem, 4.5vw, 1.6rem) !important;
  }

  /* Dots */
  .dots-layout {
    padding: var(--space-4);
    gap: var(--space-4);
  }

  .dots-side {
    min-width: 100%;
  }

  /* Board toolbar */
  .board-toolbar {
    padding: var(--space-2) var(--space-4);
  }

  .player-slots {
    gap: var(--space-2);
  }

  .player-slot {
    padding: var(--space-1) var(--space-3);
    font-size: var(--font-size-xs);
  }

  /* Modal */
  .modal {
    padding: var(--space-5);
  }

  /* Toast */
  #toast-container {
    bottom: var(--space-4);
  }

  [dir="rtl"] #toast-container {
    right: var(--space-4);
  }

  .toast {
    max-width: calc(100vw - 32px);
  }
}

/* ─── Tablet (640px–1023px) ────────────────────────────────────── */
@media (min-width: 640px) and (max-width: 1023px) {
  .games-grid {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  .xo-layout {
    flex-direction: column;
    align-items: center;
  }

  .xo-side {
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
    max-width: none;
  }

  .xo-cell {
    width: 25vw;
    height: 25vw;
  }

  .chess-cell {
    width: 9vw;
    height: 9vw;
    font-size: 5vw;
  }

  .snake-side {
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
    max-width: none;
  }
}

/* ─── Desktop (>= 1024px) ──────────────────────────────────────── */
@media (min-width: 1024px) {
  .games-grid {
    grid-template-columns: repeat(5, 1fr) !important;
  }
}

/* ─── Large Desktop (>= 1440px) ───────────────────────────────── */
@media (min-width: 1440px) {
  :root {
    --font-size-5xl: 4.5rem;
  }

  .chess-cell {
    width: 80px;
    height: 80px;
  }
}

/* ─── Dark Mode Preference (already dark, but keep for completeness) */
@media (prefers-color-scheme: dark) {
  /* Already dark theme */
}

/* ─── Reduced Motion ───────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── Touch Device Optimizations ──────────────────────────────── */
@media (hover: none) {
  .glass-card:hover {
    transform: none;
  }

  .btn:hover::before {
    opacity: 0;
  }

  .xo-cell:hover {
    transform: none;
    border-color: var(--border);
  }

  .game-card:hover .game-icon {
    transform: none;
  }
}

/* ─── Print Styles ─────────────────────────────────────────────── */
@media print {

  .navbar,
  .board-toolbar,
  .wb-sidebar {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }
}