/* ==========================================================
   BLITZ TRACKER — Responsive Breakpoints
   Mobile-first: base is 320px portrait
   New layout: viewport-fill game board,
   compact inactive panel, dominant active timer
   ========================================================== */

/* ── BASE (320px — small phone portrait) ── */

/* Teams & settings stack on mobile */
.bt-setup__teams,
.bt-setup__settings-grid {
  grid-template-columns: 1fr;
}

/* Long label hidden on small screens, short shown */
.bt-bar__label {
  display: none;
}

.bt-bar__label--short {
  display: inline;
}

/* ── 420px — standard phones ── */

@media (min-width: 420px) {
  /* Show TD button full labels, hide short */
  .bt-bar__btn--wide .bt-bar__label {
    display: inline;
  }

  .bt-bar__label--short {
    display: none;
  }
}

/* ── 480px — larger phones ── */

@media (min-width: 480px) {
  .bt-setup {
    padding: var(--space-6) var(--space-6);
  }

  /* Restore 2-column teams & settings */
  .bt-setup__teams {
    grid-template-columns: 1fr 1fr;
  }

  .bt-setup__settings-grid {
    grid-template-columns: 1fr 1fr;
  }

  /* Show all labels in secondary bar */
  .bt-bar__label {
    display: inline;
  }

  .bt-bar__label--short {
    display: none;
  }

  /* icon-cell buttons can show labels beneath */
  .bt-bar__btn--icon-cell .bt-bar__label {
    display: block;
  }

  .bt-bar {
    padding: var(--space-2) var(--space-4);
  }

  .bt-panel--active .bt-panel__name {
    font-size: var(--text-2xl);
    max-width: 70%;
  }

  .bt-panel--active .bt-panel__score {
    font-size: var(--text-5xl);
  }

  .bt-panel--inactive .bt-panel__name {
    max-width: 7rem;
    font-size: var(--text-base);
  }

  .bt-panel--inactive .bt-panel__score {
    font-size: var(--text-3xl);
  }

  .bt-panel--inactive .bt-timer__digits {
    font-size: var(--text-2xl);
  }
}

/* ── 768px — tablets ── */

@media (min-width: 768px) {
  .bt-setup {
    padding: var(--space-8) var(--space-6);
  }

  .bt-setup__title {
    font-size: var(--text-4xl);
  }

  .bt-game-header {
    padding: var(--space-2) var(--space-4);
    min-height: 40px;
  }

  .bt-game-header__half,
  .bt-game-header__turn {
    font-size: var(--text-base);
  }

  .bt-halftime,
  .bt-end {
    padding: var(--space-12) var(--space-8);
    max-width: 600px;
  }

  .bt-halftime__team-score,
  .bt-end__team-score {
    font-size: 4rem;
  }

  .bt-modal__box {
    padding: var(--space-8);
  }

  /* Secondary bar can be more spacious */
  .bt-bar__secondary {
    gap: var(--space-1);
  }

  /* Inactive panel gets more info on tablet */
  .bt-panel--inactive .bt-panel__turn {
    display: inline;
    margin-left: var(--space-2);
  }

  .bt-panel--inactive .bt-panel__info {
    display: flex;
    gap: var(--space-2);
    align-items: center;
  }
}

/* ── LANDSCAPE — side-by-side panels ── */

@media (orientation: landscape) and (min-height: 300px) and (max-width: 1023px) {
  .bt-panels {
    flex-direction: row;
  }

  .bt-panels__divider {
    width: 2px;
    height: auto;
    margin: var(--space-3) 0;
    background: linear-gradient(180deg, transparent, var(--gold-500), transparent);
  }

  /* Both panels get column layout in landscape */
  .bt-panel--active,
  .bt-panel--inactive {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: var(--space-2) var(--space-3);
  }

  .bt-panel--inactive {
    opacity: 0.75;
  }

  .bt-panel--inactive .bt-panel__header {
    flex-direction: row;
    justify-content: center;
    width: 100%;
  }

  .bt-panel--inactive .bt-panel__timer {
    margin: var(--space-1) 0;
    text-align: center;
  }

  .bt-panel--inactive .bt-timer__digits {
    font-size: clamp(1.25rem, 4vw, var(--text-3xl));
    display: block;
  }

  .bt-panel--inactive .bt-timer__label {
    display: block;
    font-size: 0.625rem;
  }

  .bt-panel--inactive .bt-panel__info {
    display: flex;
    justify-content: center;
    gap: var(--space-3);
  }

  .bt-panel--inactive .bt-panel__turn {
    display: inline;
  }

  .bt-panel--active .bt-timer__digits {
    font-size: clamp(1.5rem, 6vw, var(--text-4xl));
  }

  .bt-panel--active .bt-panel__score {
    font-size: var(--text-3xl);
  }

  /* Compact bar in landscape */
  .bt-bar {
    max-width: 600px;
    margin: 0 auto;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
}

/* ── 1024px — desktop ── */

@media (min-width: 1024px) {
  .bt-app {
    max-width: 900px;
  }

  #btGameBoard.bt-screen--active {
    height: calc(100vh - var(--header-height, 62px));
    height: calc(100dvh - var(--header-height, 62px));
  }

  .bt-panels {
    flex-direction: row;
    min-height: 400px;
  }

  .bt-panels__divider {
    width: 2px;
    height: auto;
    margin: var(--space-4) 0;
    background: linear-gradient(180deg, transparent, var(--gold-500), transparent);
  }

  /* Both panels get full column layout on desktop */
  .bt-panel--active,
  .bt-panel--inactive {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: var(--space-4);
    opacity: 1;
  }

  .bt-panel--inactive .bt-panel__header {
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
  }

  .bt-panel--inactive .bt-panel__name {
    font-size: var(--text-xl);
    max-width: 70%;
  }

  .bt-panel--inactive .bt-panel__score {
    font-size: var(--text-4xl);
  }

  .bt-panel--inactive .bt-panel__timer {
    text-align: center;
    margin: var(--space-2) 0;
  }

  .bt-panel--inactive .bt-timer__digits {
    font-size: var(--text-3xl);
    display: block;
  }

  .bt-panel--inactive .bt-timer__label {
    display: block;
  }

  .bt-panel--inactive .bt-panel__info {
    display: flex;
    justify-content: space-between;
    width: 100%;
  }

  .bt-panel--inactive .bt-panel__turn {
    display: inline;
  }

  .bt-panel--active .bt-timer__digits {
    font-size: 4rem;
  }

  .bt-panel--active .bt-panel__score {
    font-size: var(--text-5xl);
  }

  .bt-panel--active .bt-panel__name {
    font-size: var(--text-2xl);
    max-width: 70%;
  }

  .bt-bar {
    position: static;
    max-width: 700px;
    margin: var(--space-4) auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    border-top: 1px solid var(--border-subtle);
  }

  .bt-halftime__scores,
  .bt-end__scores {
    gap: var(--space-10);
  }
}

/* ── Short screens — compact everything ── */

@media (max-height: 500px) {
  .bt-bar {
    padding: var(--space-1) var(--space-2);
    gap: 2px;
  }

  .bt-bar__primary .bt-bar__btn:first-child {
    min-height: 44px;
  }

  .bt-bar__btn--icon-cell {
    min-height: 36px;
  }

  .bt-game-header {
    min-height: 28px;
    padding: 2px var(--space-2);
  }

  .bt-game-header__half,
  .bt-game-header__turn {
    font-size: var(--text-xs);
  }

  .bt-timeline {
    padding: 2px var(--space-2);
  }
}

/* ── Roster cards: smaller screens ── */

@media (max-width: 380px) {
  .bt-roster-picker__grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: var(--space-2);
  }

  .bt-rcard {
    padding: var(--space-2);
  }

  .bt-rcard__logo {
    width: 36px;
    height: 36px;
  }

  .bt-rcard__logo--empty {
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
  }

  .bt-rcard__name {
    font-size: var(--text-xs);
  }

  .bt-invite-panel__code {
    font-size: var(--text-2xl);
    letter-spacing: 0.15em;
  }
}

/* ── Roster cards: tablet+ ── */

@media (min-width: 768px) {
  .bt-roster-picker__grid,
  .bt-search-panel__results {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .bt-rcard__logo {
    width: 56px;
    height: 56px;
  }

  .bt-rcard__logo--empty {
    width: 56px;
    height: 56px;
  }
}

/* ── Create panel: small phones ── */

@media (max-width: 479px) {
  .bt-create-panel__race-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .bt-pos-row {
    flex-wrap: wrap;
    gap: var(--space-1);
  }

  .bt-pos-row__info {
    flex-basis: 100%;
  }

  .bt-pos-row__controls {
    margin-left: auto;
  }
}

/* ── Create panel: tablet+ ── */

@media (min-width: 768px) {
  .bt-create-panel__race-grid {
    grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
  }

  .bt-race-card__icon {
    width: 3rem;
    height: 3rem;
  }
}
