/* Mobile-first responsive styles */

/* Base responsive typography */
@media screen and (max-width: 768px) {
  :root {
    font-size: 14px; /* Slightly smaller base font size for mobile */
  }
}

/* Responsive layout */
@media screen and (max-width: 768px) {
  .games {
    grid-template-columns: 1fr; /* Single column on mobile */
    gap: 1rem;
    padding: 0.5rem;
  }
  
  .game-card {
    min-height: 150px; /* Slightly smaller cards on mobile */
    margin: 0.5rem 0;
  }
  
  .flip-front,
  .flip-back {
    padding: 1rem; /* Reduced padding on mobile */
  }
  
  .game-card h2 {
    font-size: 1.2rem; /* Slightly smaller heading on mobile */
    margin-bottom: 0.5rem;
  }
  
  .hint {
    font-size: 0.7rem; /* Smaller hint text on mobile */
  }
}

/* Adjust header for mobile */
@media screen and (max-width: 480px) {
  .site-header h1 {
    font-size: 1.8rem;
    padding: 0 1rem;
  }
  
  .tagline {
    font-size: 0.9rem;
    padding: 0 1rem;
  }
  
  .site-footer nav {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .back-to-top {
    margin-top: 1rem;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  .game-card {
    min-height: 140px; /* Slightly smaller for touch devices */
  }
  
  /* Replace hover with active state for touch devices */
  .game-card:active .flip-inner {
    transform: rotateY(180deg);
  }
  
  /* Show hint text more prominently on touch devices */
  .hint {
    opacity: 0.8;
    font-size: 0.8rem;
  }
}

/* Landscape mode adjustments */
@media screen and (max-width: 768px) and (orientation: landscape) {
  .games {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .game-card {
    min-height: 120px;
  }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .flip-inner {
    transition: none !important;
  }
  
  .game-card:active .flip-inner,
  .game-card:hover .flip-inner {
    transform: none !important;
  }
  
  .flip-back {
    display: none !important;
  }
}

/* Browser compatibility fixes */
@supports not (display: grid) {
  .games {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .game-card {
    flex: 0 1 300px;
    margin: 0.5rem;
  }
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
  .game-card {
    -webkit-transform: translateZ(0);
  }
}

/* IE 10+ specific fixes */
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
  .games {
    display: flex;
    flex-wrap: wrap;
  }
  
  .game-card {
    flex: 0 1 300px;
    margin: 0.5rem;
  }
  
  .flip-inner {
    display: none; /* Fallback for IE which doesn't support 3D transforms well */
  }
  
  .game-card > a {
    display: block;
    height: 100%;
    padding: 1rem;
  }
}
