/* Adaptive layout — подключается после styles.css */

/* Компактная статистика в topbar — видна только ≤1180px */
.topbar-compact {
  display: none;
  align-items: center;
  gap: 10px;
  margin-left: 12px;
  margin-right: auto;
  min-width: 0;
}
.topbar-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  gap: 2px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
}
button.topbar-stat {
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s ease;
}
button.topbar-stat:hover {
  background: rgba(255, 255, 255, 0.06);
}
.topbar-stat-value {
  font-size: 15px;
  font-weight: 900;
  color: var(--gold);
  letter-spacing: 0.2px;
}
.topbar-stat-label {
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  white-space: nowrap;
}
.topbar-finish {
  flex-shrink: 0;
  white-space: nowrap;
  padding: 7px 12px;
  font-size: 11px;
}
.topbar-finish[hidden],
#btn-finish-top[hidden] {
  display: none !important;
}
.btn-icon-restart {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.btn-icon-restart:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.22);
}
.btn-icon-restart:active {
  transform: scale(0.94);
}

/* ≤1180: HUD скрыт, статистика и действия — в topbar */
@media (max-width: 1180px) {
  .hud {
    display: none !important;
  }
  .topbar-compact {
    display: flex;
  }
  .topbar {
    padding: 12px 14px;
    gap: 8px;
  }
  .brand-logo {
    height: 16px;
  }
  .pitch {
    width: 100%;
  }
  .hud-user {
    display: none !important;
  }
}

@media (min-width: 1000px) {
  .slot .card {
    width: clamp(72px, 8.6vmin, 104px);
  }
  .slot-bubble {
    width: clamp(68px, 8.6vmin, 96px);
  }
}

/* ≥770: шире расстановка, чуть компактнее карты — линии из 4–5 слотов не слипаются */
@media (min-width: 770px) {
  .slot .card {
    width: clamp(68px, 9.2vmin, 98px);
  }
  .slot-bubble {
    width: clamp(64px, 9.2vmin, 92px);
  }
  .slot-pos::before {
    width: 44px;
    height: 26px;
  }
  .slot-pos{
    font-size: 12px;
  }
  .slot-pos::before{
    width: 40px;
    height: 24px;
  }

}

@media (max-width: 620px) {
  .modal-cards { grid-template-columns: repeat(3, 1fr); }
  :root{
    --radius: 8px;
  }
  .formation-mini{
    aspect-ratio: 924 / 760;
    height: auto;
  }
  .pitch{
    background-position: 10% 10%;
  }
  .slot-bubble{
    margin-bottom: -4px;
  }
  .slot-pos {
    font-size: 12px;
  }
}


@media (max-width: 520px) {
  .topbar-compact {
    gap: 6px;
    margin-left: 6px;
  }
  .topbar-stat-value {
    font-size: 13px;
  }
  .topbar-stat-label {
    font-size: 7px;
  }
  .topbar-finish {
    padding: 6px 8px;
    font-size: 10px;
  }
  .btn-icon-restart {
    width: 32px;
    height: 32px;
  }
  .btn-collection-count {
    font-size: 11px;
  }
}

/* ≤500: поле ≤90vh, без растягивания фона */
@media (max-width: 500px) {
  .topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 8px 10px;
    padding-top: max(8px, env(safe-area-inset-top));
    gap: 4px;
    background: linear-gradient(
      180deg,
      rgba(7, 11, 16, 0.92) 0%,
      rgba(7, 11, 16, 0.72) 70%,
      rgba(7, 11, 16, 0) 100%
    );
    border-bottom: none;
    backdrop-filter: blur(8px);
  }
  .brand-logo {
    height: 14px;
  }
  .topbar-compact {
    gap: 4px;
    margin-left: 4px;
  }
  .topbar-stat {
    padding: 0 2px;
  }
  .topbar-stat-value {
    font-size: 12px;
  }
  .topbar-stat-label {
    font-size: 6px;
    letter-spacing: 0.2px;
  }
  .btn-icon-restart {
    width: 30px;
    height: 30px;
    border-radius: 8px;
  }
  .btn-collection {
    padding: 6px 8px;
    gap: 5px;
    border-radius: 10px;
  }
  .btn-collection svg {
    width: 16px;
    height: 16px;
  }
  .btn-collection-count {
    font-size: 10px;
  }

  #app,
  .game {
    height: 100%;
    min-height: 0;
  }
  .pitch-wrap {
    inset: 0;
    align-items: center;
    justify-content: center;
  }
  .pitch {
    width: 100%;
    height: min(90vh, calc(var(--max-vh, 100dvh) * 0.9));
    max-height: min(90vh, calc(var(--max-vh, 100dvh) * 0.9));
  }
  body.game-ready .pitch {
    background-size: cover;
    background-position: center top;
  }
  .game {
    padding-bottom: 0;
  }
  .slot {
    gap: 0;
  }
  .slot .card {
    width: clamp(44px, 12.2vw, 54px);
  }
  .slot-bubble {
    width: clamp(42px, 11.8vw, 52px);
    margin-bottom: -6px;
  }
  .slot-pos {
    font-size: 8px;
    margin-top: -2px;
  }
  .slot-pos::before {
    width: 28px;
    height: 16px;
  }
  .slot .card-stats {
    display: none;
  }
  .slot .card-name {
    font-size: 9cqw;
  }
  .pitch-formation {
    left: 6%;
    bottom: calc(var(--tray-peek, 72px) + 2%);
    font-size: clamp(13px, 4.6vw, 20px);
    opacity: 0.7;
  }

  .squad-tray {
    --tray-peek: 72px;
    border-radius: 14px 14px 0 0;
  }
  .squad-tray-hint {
    font-size: 11px;
    letter-spacing: 0.12em;
  }
  .music-player {
    max-width: min(150px, calc(100vw - 20px));
    padding: 5px 7px;
    gap: 5px;
    bottom: max(4px, env(safe-area-inset-bottom));
    left: max(4px, env(safe-area-inset-left));
    z-index: 11;
  }
  .music-title {
    font-size: 10px;
  }
  .music-artist {
    font-size: 9px;
  }
}

@media (max-width: 420px) {
  .modal-cards { grid-template-columns: repeat(2, 1fr); }
  .slot .card {
    width: clamp(44px, 12.2vw, 52px);
  }
  .slot-bubble {
    width: clamp(42px, 11.8vw, 50px);
  }
}
