/* ============================================================
   Treasure Escape - Responsive Layout Stylesheet
   Stage 2: Core Match-3 Engine
   ============================================================ */

@media (max-width: 900px) {
  body {
    flex-direction: column;
    justify-content: flex-start;
    padding: 16px;
    min-height: 100vh;
  }

  .grid {
    margin-left: 0;
    margin-top: 16px;
  }

  .scoreBoard {
    margin-top: 16px;
    margin-left: 0;
    width: 100%;
    max-width: 560px;
    min-height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-around;
    padding: 12px 16px;
  }

  .score-section, .moves-section {
    width: auto;
  }
}

@media (max-width: 600px) {
  .grid {
    display: grid;
    grid-template-columns: repeat(8, 41px);
    grid-template-rows: repeat(8, 41px);
    width: 328px;
    height: 328px;
    padding: 4px;
    box-sizing: content-box;
  }

  .grid-tile, .grid > div {
    width: 41px;
    height: 41px;
  }

  .gem-wrapper {
    width: 32px;
    height: 32px;
  }

  .gem-svg {
    width: 32px;
    height: 32px;
  }

  /* Responsive Tutorial Button Row on Small Screens */
  .tutorial-button-row {
    flex-direction: column-reverse;
    gap: 10px;
    align-items: stretch;
  }

  .tutorial-nav-group {
    width: 100%;
    justify-content: space-between;
  }

  .tutorial-nav-group .modal-btn {
    flex: 1;
  }

  #btnTutorialSkipBottom {
    width: 100%;
  }

  /* Responsive How to Play Top Bar on Small Screens */
  .how-to-play-top-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .how-to-play-top-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .scoreBoard {
    width: 100%;
    max-width: 336px;
    padding: 10px;
  }

  .scoreBoard h1 {
    font-size: 24px;
  }

  .scoreBoard h2 {
    font-size: 20px;
  }
}

@media (max-width: 500px) {
  .leaderboard-modal-content,
  .profile-modal-content,
  .achievements-modal-content,
  .share-modal-content,
  .settings-modal-content {
    padding: 16px 12px;
    max-width: 96vw;
  }

  .leaderboard-table-header,
  .leaderboard-entry-row {
    grid-template-columns: 44px 1fr 50px 75px;
    padding: 6px 8px;
    font-size: 11px;
  }

  .lb-col-rank {
    font-size: 11px;
  }

  .lb-col-score {
    font-size: 11px;
  }

  .modal-btn {
    padding: 10px 14px;
    font-size: 12px;
  }

  .menu-btn {
    padding: 10px 18px;
    font-size: 13px;
  }

  .level-map-grid {
    grid-template-columns: 1fr;
  }
}
