/* ============================================
   CrossMath.co - Responsive Styles
   Mobile-first approach
   ============================================ */

/* --- Base / Mobile (<480px) --- */
.games-grid {
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}

.puzzle-cell {
  --cell-size: 36px;
  --cell-font: 0.85rem;
}

.tile-2048 {
  --tile-size: 56px;
  --tile-font: 1rem;
}

.game-header {
  flex-wrap: wrap;
}

.game-title {
  font-size: 1rem;
}

h1, .page-title {
  font-size: 1.2rem;
}

h2 {
  font-size: 1.15rem;
}

.modal-content {
  padding: 20px;
  margin: 12px;
}

.container {
  padding: 0 12px;
}

.site-header {
  padding: 8px 12px;
  padding-top: calc(8px + env(safe-area-inset-top));
}

.game-container {
  padding: 12px;
  padding-top: 64px;
}

.sprint-question {
  font-size: 1.5rem;
}

.quick-game-question {
  font-size: 1.4rem;
}

.mathler-cell {
  width: 36px;
  height: 36px;
  font-size: 0.9rem;
}

.mathler-key {
  width: 32px;
  height: 32px;
  font-size: 0.78rem;
}

.make24-card {
  width: 46px;
  height: 46px;
  font-size: 1.05rem;
}

/* Touch targets minimum 44x44 */
.btn,
.dir-btn,
.mathler-key,
.puzzle-cell,
.sumplete-cell,
.make24-card,
.quick-game-option {
  min-height: 36px;
  min-width: 36px;
}

.btn,
.dir-btn,
.game-back-btn {
  min-height: 44px;
  min-width: 44px;
}

/* Safe area insets */
.game-container {
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.site-header {
  padding-left: calc(12px + env(safe-area-inset-left));
  padding-right: calc(12px + env(safe-area-inset-right));
}

/* --- Small phones (min-width: 375px) - minor tweaks --- */
@media (min-width: 375px) {
  .mathler-cell {
    width: 38px;
    height: 38px;
  }

  .mathler-key {
    width: 34px;
    height: 34px;
  }
}

/* --- Large phones / Small tablets (min-width: 480px) --- */
@media (min-width: 480px) {
  .puzzle-cell {
    --cell-size: 40px;
    --cell-font: 0.95rem;
  }

  .tile-2048 {
    --tile-size: 62px;
    --tile-font: 1.1rem;
  }

  .games-grid {
    gap: 10px;
  }

  .container {
    padding: 0 16px;
  }

  h1, .page-title {
    font-size: 1.35rem;
  }

  .sprint-question {
    font-size: 1.75rem;
  }

  .quick-game-question {
    font-size: 1.6rem;
  }

  .mathler-cell {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }

  .mathler-key {
    width: 36px;
    height: 36px;
    font-size: 0.85rem;
  }

  .make24-card {
    width: 52px;
    height: 52px;
    font-size: 1.2rem;
  }

  .game-container {
    padding: 16px;
    padding-top: 70px;
  }

  .modal-content {
    padding: 24px;
  }
}

/* --- Tablets (min-width: 768px) --- */
@media (min-width: 768px) {
  .games-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }

  .puzzle-cell {
    --cell-size: 46px;
    --cell-font: 1rem;
  }

  .tile-2048 {
    --tile-size: 72px;
    --tile-font: 1.3rem;
  }

  .container {
    padding: 0 24px;
  }

  h1, .page-title {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1.3rem;
  }

  .site-header {
    padding: 12px 24px;
    padding-top: calc(12px + env(safe-area-inset-top));
  }

  .game-container {
    padding: 20px;
    padding-top: 76px;
    max-width: 560px;
  }

  .game-header {
    flex-wrap: nowrap;
  }

  .game-title {
    font-size: 1.2rem;
  }

  .sprint-question {
    font-size: 2rem;
  }

  .quick-game-question {
    font-size: 1.8rem;
  }

  .mathler-cell {
    width: 44px;
    height: 44px;
  }

  .mathler-key {
    width: 40px;
    height: 40px;
  }

  .make24-card {
    width: 58px;
    height: 58px;
    font-size: 1.3rem;
  }

  .modal-content {
    max-width: 420px;
  }

  .game-card {
    padding: 20px;
  }

  .game-card-name {
    font-size: 1.05rem;
  }

  .game-card-desc {
    font-size: 0.82rem;
  }

  .profile-bar {
    padding: 14px 18px;
  }
}

/* --- Desktop (min-width: 1024px) --- */
@media (min-width: 1024px) {
  .games-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
  }

  .container {
    padding: 0 32px;
  }

  .puzzle-cell {
    --cell-size: 50px;
    --cell-font: 1.1rem;
  }

  .tile-2048 {
    --tile-size: 80px;
    --tile-font: 1.5rem;
  }

  .site-header {
    padding: 12px 32px;
  }

  .game-container {
    max-width: 600px;
  }

  .game-card:hover {
    transform: scale(1.03);
  }

  .mathler-cell {
    width: 48px;
    height: 48px;
    font-size: 1.1rem;
  }

  .mathler-key {
    width: 42px;
    height: 42px;
    font-size: 0.9rem;
  }

  .modal-content {
    max-width: 440px;
    padding: 28px;
  }

  .quick-game-options {
    max-width: 360px;
  }
}

/* --- Wide Desktop (min-width: 1280px) --- */
@media (min-width: 1280px) {
  .container {
    padding: 0 40px;
  }

  .games-grid {
    gap: 16px;
  }
}

/* --- Numeric input hints --- */
input[inputmode="numeric"],
input[type="number"] {
  -moz-appearance: textfield;
}

input[inputmode="numeric"]::-webkit-inner-spin-button,
input[inputmode="numeric"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Print Styles --- */
@media print {
  .site-header,
  .game-actions,
  .game-back-btn,
  .dir-buttons,
  .mathler-keyboard,
  .make24-ops,
  .btn,
  .modal-overlay,
  .level-up-overlay,
  .confetti-particle,
  .hint-counter {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
    min-height: auto;
  }

  .game-container {
    padding-top: 0;
  }

  .puzzle-cell {
    border-color: #ccc;
    color: #000;
    background: #fff;
  }

  .game-card {
    border-color: #ddd;
    background: #fff;
    break-inside: avoid;
  }
}
