/* ==========================================================================
   MathClash — mobile layout fixes + merged "Duels" tab styling
   Loaded AFTER the main stylesheet (see index.html).
   ========================================================================== */

/* 0. 1v1 / 2v2 switcher shown at the top of the "Duels" tab.
   Same look as the existing Leaderboard sub-switcher (Points / Duels / Pairs),
   but it stays horizontal on phones. */
.duel-kind-switch {
  display: flex;
  gap: 8px;
  margin: 0 0 16px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0a1324ad;
}
.duel-kind-btn {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  padding: 8px 11px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: .78rem;
  font-weight: 800;
  white-space: nowrap;
  transition: color .2s, background .2s, border-color .2s;
}
.duel-kind-btn:hover {
  color: var(--text);
}
.duel-kind-btn.active {
  color: var(--text);
  background: #4d8dff1f;
  border-color: #4d8dff80;
}

/* 1. ROOT CAUSE of the cut-off Live Standings + Practice focus cards.
   .arena-side-stack is a grid with no column definition, so its single
   column was sized by the leaderboard table's 410-430px min-width and grew
   wider than the phone screen. Pin the column to the available width. */
.arena-side-stack {
  grid-template-columns: minmax(0, 1fr);
}
.arena-side-stack > * {
  min-width: 0;
  max-width: 100%;
}

@media (max-width: 600px) {

  /* 2. Top bar: keep Log out (and everything else) inside the screen. */
  .navbar {
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
  }
  .brand-lockup {
    flex: 0 1 auto;
    min-width: 0;
  }
  .nav-right {
    flex: 1 1 auto;
    flex-wrap: nowrap;
    justify-content: flex-end;
    width: auto;
    min-width: 0;
    gap: 6px;
  }
  /* Keyboard shortcuts are of no use on a touch screen. */
  .shortcut-button {
    display: none;
  }
  .navbar .btn-ghost,
  .navbar .sound-btn {
    flex: none;
    width: 40px;
    min-width: 40px;
    min-height: 40px;
    padding: 8px;
  }
  .streak-badge {
    flex: 0 1 auto;
    min-width: 0;
    min-height: 40px;
    white-space: nowrap;
  }

  /* 3. Live Standings card: make the table fit instead of scrolling sideways. */
  .leaderboard-card {
    padding: 18px 14px 12px;
  }
  .leaderboard-card .lb-header {
    margin-bottom: 12px;
  }
  .leaderboard-card .lb-table {
    min-width: 0;
    table-layout: fixed;
  }
  .leaderboard-card .lb-table th,
  .leaderboard-card .lb-table td {
    padding-left: 5px;
    padding-right: 5px;
  }
  .leaderboard-card .lb-table th:nth-child(1) { width: 30px; }
  .leaderboard-card .lb-table th:nth-child(3) { width: 58px; }
  .leaderboard-card .lb-table th:nth-child(4) { width: 62px; }
  .leaderboard-card .lb-table td.player {
    overflow: hidden;
  }
  .leaderboard-card .player-cell {
    min-width: 0;
    gap: 6px;
  }
  .leaderboard-card .player-profile-trigger {
    min-width: 0;
    gap: 6px;
  }
  .leaderboard-card .player-profile-trigger .rank-badge {
    flex: none;
  }
  .leaderboard-card .player-profile-trigger > span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .leaderboard-card .rank-medal {
    flex: none;
  }

  /* 4. Practice focus card: let topic names wrap instead of being cut. */
  .focus-topic span {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    line-height: 1.2;
  }

  /* 5. Game mode tabs (Daily Challenge | Duels | Leaderboard | Streaks):
        a 2x2 grid with full labels, no mid-word breaks. */
  .mode-selector-track {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
  }
  .mode-tab {
    width: auto;
    min-width: 0;
    min-height: 44px;
    padding: 9px 8px;
    font-size: .8rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow-wrap: normal;
    word-break: normal;
  }
  /* The sliding underline assumes one row of equal columns; the active tab is
     already highlighted with a border, so hide it on phones. */
  .mode-selector-indicator {
    display: none;
  }

  /* 6. Problem card header: restore the intended layout
        (stars + timer on one row, challenge counter underneath). */
  .problem-header {
    grid-template-columns: 1fr auto;
  }
  .problem-header .stars {
    grid-area: 2 / 1;
  }
  .problem-header .timer {
    grid-area: 2 / 2 / span 2;
    align-self: center;
    justify-self: end;
  }
  .problem-header .challenge-pill {
    grid-area: 3 / 1;
    justify-self: start;
  }
}

/* Very small phones (iPhone SE / 320px wide) */
@media (max-width: 350px) {
  .brand-lockup {
    font-size: .92rem;
    gap: 5px;
  }
  .navbar .btn-ghost,
  .navbar .sound-btn {
    width: 36px;
    min-width: 36px;
  }
  .streak-badge {
    padding-left: 7px;
    padding-right: 7px;
  }
}
