/* ═══════════════════════════════════════
   LOBBY BROWSER (main menu)
   ═══════════════════════════════════════ */

.screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow-y: auto;
  background: #f0f1f4;
}

.menu-bg-cats {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.menu-bg-cat {
  position: absolute;
  user-select: none;
  -webkit-user-drag: none;
  opacity: 0.28;
  filter: drop-shadow(0 10px 28px rgba(0, 0, 0, 0.1));
}

.menu-bg-cat--left {
  left: max(-3%, -24px);
  bottom: -4%;
  width: min(36vw, 600px);
  height: auto;
}

.menu-bg-cat--right {
  right: max(-3%, -24px);
  bottom: -4%;
  width: min(36vw, 600px);
  height: auto;
  opacity: 0.28;
}

#lobby-browser.screen {
  overflow-y: auto;
  overflow-x: hidden;
}

.browser-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1180px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 20px 28px 16px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.browser-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}

.patches-menu-btn {
  flex-shrink: 0;
}

.browser-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.12));
}

.brand-logo-sm {
  width: 40px;
  height: 40px;
  filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.1));
}

.brand-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: #111;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.brand-sub {
  font-size: 0.85rem;
  color: #888;
  margin-top: 3px;
}

.browser-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 20px;
  flex: 1;
  min-height: 0;
  align-items: stretch;
}

.browser-primary,
.browser-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  min-height: 0;
}

.browser-sidebar {
  position: sticky;
  top: 20px;
  align-self: start;
}

.browser-lobbies {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 240px;
}

.browser-lobbies .section-header-row {
  flex-shrink: 0;
}

.browser-lobbies .lobby-list {
  flex: 1;
  min-height: 120px;
  max-height: calc(100vh - 300px);
  overflow-y: auto;
  padding-right: 2px;
}

.browser-leaderboard {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.browser-leaderboard .leaderboard-list {
  flex: 1;
  max-height: min(360px, calc(100vh - 420px));
  overflow-y: auto;
}

#lobby-browser .panel-card {
  background: rgba(255, 255, 255, 0.32);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-color: rgba(232, 232, 232, 0.65);
}

.section-label-inline {
  margin: 0;
}

.profile-wins-sidebar {
  margin-top: 14px;
  margin-bottom: 0;
  padding-top: 12px;
  border-top: 1px solid #efefef;
}

.browser-section {
  /* panel-card applied in HTML */
}

.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.lobby-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lobby-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid #e4e4e4;
  border-radius: 10px;
  transition: border-color 0.15s, background 0.15s;
}

.lobby-list-item:hover {
  border-color: #c8c8c8;
}

.lobby-list-main {
  flex: 1;
  min-width: 0;
}

.lobby-list-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #111;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lobby-list-meta {
  font-size: 0.78rem;
  color: #888;
}

.lobby-list-empty {
  padding: 28px 16px;
  text-align: center;
  color: #aaa;
  font-size: 0.88rem;
}

.leaderboard-table-head,
.leaderboard-row {
  display: grid;
  grid-template-columns: 36px 1fr 64px;
  align-items: center;
  gap: 8px;
}

.leaderboard-table-head {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #999;
  padding: 0 8px 8px;
  border-bottom: 1px solid #ececec;
  margin-bottom: 4px;
}

.leaderboard-table-head span:last-child,
.leaderboard-row .lb-wins {
  text-align: right;
}

.leaderboard-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 280px;
  overflow-y: auto;
}

.leaderboard-row {
  padding: 8px;
  border-radius: 8px;
  font-size: 0.88rem;
  color: #333;
}

.leaderboard-row-me {
  background: #eef6ff;
  font-weight: 600;
}

.leaderboard-row .lb-rank {
  color: #888;
  font-weight: 700;
}

.leaderboard-row .lb-wins {
  font-weight: 700;
  color: #2563eb;
}

.leaderboard-empty {
  padding: 20px 8px;
  text-align: center;
  color: #aaa;
  font-size: 0.85rem;
}

.profile-wins {
  margin: 14px 0 0;
  font-size: 0.85rem;
  color: #666;
  border-top: 1px solid #ececec;
  padding-top: 12px;
}

.browser-footer {
  margin-top: 16px;
  flex-shrink: 0;
}

.browser-footer .status-bar {
  text-align: left;
  padding-left: 0;
  padding-right: 0;
}

/* ── Patch notes modal ── */
body.modal-open {
  overflow: hidden;
}

.patches-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
}

.patches-modal.hidden {
  display: none;
}

.patches-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
}

.patches-modal-panel {
  position: relative;
  z-index: 1;
  width: min(1100px, 100%);
  max-height: min(80vh, 800px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e4e4e4;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.patches-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid #efefef;
  flex-shrink: 0;
}

.patches-modal-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #111;
}

.patches-modal-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: #f4f4f4;
  color: #555;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.patches-modal-close:hover {
  background: #eaeaea;
  color: #222;
}

.patches-modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
}

.patches-modal-footer {
  padding: 12px 18px 16px;
  border-top: 1px solid #efefef;
  flex-shrink: 0;
}

.patch-card + .patch-card {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #efefef;
}

.patch-card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.patch-badges {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  flex-shrink: 0;
}

.patch-version {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 800;
  color: #fff;
  background: #3498db;
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: 0.04em;
}

.patch-new-badge {
  font-size: 0.62rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #f39c12, #e67e22);
  padding: 3px 7px;
  border-radius: 6px;
  letter-spacing: 0.08em;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(230, 126, 34, 0.35);
}

.patch-card-new .patch-title {
  padding-right: 4px;
}

.patch-title {
  font-size: 1rem;
  font-weight: 700;
  color: #222;
  line-height: 1.2;
}

.patch-date {
  display: block;
  margin-top: 3px;
  font-size: 0.78rem;
  color: #999;
}

.patch-section + .patch-section {
  margin-top: 12px;
}

.patch-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.patch-list {
  margin: 0;
  padding-left: 18px;
  color: #444;
}

.patch-list li {
  font-size: 0.86rem;
  line-height: 1.45;
  margin-bottom: 5px;
}

.patch-list li:last-child {
  margin-bottom: 0;
}

/* ═══════════════════════════════════════
   IN-LOBBY SCREEN
   ═══════════════════════════════════════ */

#lobby.screen {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.lobby-wrap {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 100vh;
  background: transparent;
}

/* Top bar */
.lobby-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(228, 228, 228, 0.9);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.lobby-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.lobby-topbar-info {
  min-width: 0;
}

.lobby-room-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: #111;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.lobby-room-sub {
  font-size: 0.78rem;
  color: #999;
  margin-top: 2px;
}

.lobby-topbar-right {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-shrink: 0;
}

.lobby-player-field {
  width: 220px;
}

.lobby-player-field .field-label {
  margin-bottom: 4px;
}

.lobby-ready-btn {
  height: 40px;
  padding: 0 24px;
  font-size: 0.95rem;
  align-self: flex-end;
}

/* Body grid */
.lobby-body {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  padding: 16px 24px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.lobby-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  min-width: 0;
}

.col-header {
  flex-shrink: 0;
}

.col-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #222;
  line-height: 1.2;
}

.col-hint {
  font-size: 0.78rem;
  color: #999;
  margin-top: 2px;
  line-height: 1.3;
}

.loadout-panel,
.teams-panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

#lobby .lobby-body .panel-card {
  background: rgba(255, 255, 255, 0.38);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-color: rgba(232, 232, 232, 0.65);
}

/* Loadout items */
.loadout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

.loadout-section + .loadout-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #efefef;
}

.loadout-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #444;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.loadout-section-badge {
  font-size: 0.7rem;
  font-weight: 500;
  color: #9b59b6;
  background: #f5eefc;
  padding: 2px 8px;
  border-radius: 20px;
}

.loadout-section-active .loadout-item {
  border-color: #e0d0f0;
}

.loadout-section-active .loadout-item:hover:not(:disabled) {
  border-color: #9b59b6;
  background: #faf7fc;
}

.loadout-section-active .loadout-item.selected {
  border-color: #9b59b6;
  background: #f5eefc;
  box-shadow: 0 0 0 2px rgba(155, 89, 182, 0.15);
}

.loadout-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  padding: 12px;
  border: 1px solid #e4e4e4;
  border-radius: 10px;
  background: #fafafa;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  width: 100%;
}

.loadout-item:hover:not(:disabled) {
  border-color: #3498db;
  background: #f0f7ff;
}

.loadout-item.selected {
  border-color: #3498db;
  background: #eef6ff;
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.15);
}

.loadout-item:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.loadout-section-active .loadout-item.has-ability-info {
  padding-right: 28px;
}

.loadout-section-active .loadout-item .ability-info-btn {
  border-color: #d8c8e8;
}

.loadout-section-active .loadout-item .ability-info-btn:hover {
  border-color: #9b59b6;
  color: #9b59b6;
  background: #faf7fc;
}

.loadout-item-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.loadout-item-name {
  font-size: 0.88rem;
  font-weight: 700;
  color: #222;
}

.loadout-item-desc {
  font-size: 0.75rem;
  color: #888;
  line-height: 1.35;
}

.loadout-counter {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #efefef;
  font-size: 0.8rem;
  font-weight: 600;
  color: #666;
}

/* Footer status */
.lobby-footer {
  flex-shrink: 0;
  background: #fff;
  border-top: 1px solid #e4e4e4;
  padding: 0;
}

.lobby-footer .status-bar {
  padding: 10px 24px;
}

/* ═══════════════════════════════════════
   TEAMS BOARD
   ═══════════════════════════════════════ */

.lobby-board {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.lobby-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.teams-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.team-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.team-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #333;
  padding-bottom: 5px;
  border-bottom: 1px solid #efefef;
}

.team-header-title {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.team-limit-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: #888;
  background: #f0f0f0;
  padding: 2px 7px;
  border-radius: 999px;
}

.team-limit-control {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.team-limit-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: #777;
}

.team-limit-select {
  padding: 4px 8px;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  background: #fff;
  color: #333;
  cursor: pointer;
}

.team-limit-select:hover {
  border-color: #3498db;
}

.player-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.player-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f7f7f7;
  border: 1px solid #ebebeb;
  min-height: 44px;
}

.player-slot.unassigned-slot {
  background: #fafafa;
  border-style: dashed;
  border-color: #ddd;
}

.player-slot.unassigned-slot.occupied {
  border-style: solid;
  background: #f3f3f3;
}

.player-slot.team-slot.empty.pickable {
  cursor: pointer;
  border-style: dashed;
  border-color: #ccc;
  background: #fafafa;
}

.player-slot.team-slot.empty.pickable:hover {
  background: #eef6ff;
  border-color: #3498db;
}

.player-slot.team-slot.locked {
  opacity: 0.55;
  background: #f1f1f1;
  border-style: dashed;
  border-color: #ddd;
  cursor: not-allowed;
}

.player-status.locked-slot {
  color: #999;
  font-weight: 600;
}

.player-slot.my-slot {
  border-color: #3498db !important;
  background: #eef6ff;
  box-shadow: 0 0 0 1px rgba(52, 152, 219, 0.2);
}

.player-info {
  flex: 1;
  min-width: 0;
}

.player-team {
  font-size: 0.68rem;
  color: #aaa;
  margin-bottom: 1px;
}

.player-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-name-host {
  display: flex;
  align-items: center;
  gap: 4px;
}

.host-star {
  color: #f1c40f;
  font-size: 0.95em;
  line-height: 1;
  flex-shrink: 0;
  text-shadow: 0 0 1px rgba(180, 130, 0, 0.35);
}

.host-name {
  font-weight: 800;
  color: #222;
}

.player-status {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  flex-shrink: 0;
}

.player-status.waiting {
  background: #f0f0f0;
  color: #888;
}

.player-status.ready {
  background: #e8f8ef;
  color: #27ae60;
}

.player-status.empty-slot {
  background: transparent;
  color: #ccc;
}

.unassigned-section {
  padding-top: 12px;
  border-top: 1px solid #efefef;
}

.unassigned-header {
  margin-bottom: 8px;
}

.unassigned-pool {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.unassigned-pool .player-slot {
  width: 100%;
}

.plus-slot {
  cursor: pointer;
  border-style: dashed !important;
  border-color: #bbb !important;
  background: #fafafa !important;
  justify-content: center;
  min-height: 40px;
  padding: 6px;
}

.plus-slot:hover {
  background: #eef6ff !important;
  border-color: #3498db !important;
}

.plus-slot-icon {
  font-size: 1.4rem;
  font-weight: 300;
  color: #aaa;
  line-height: 1;
  user-select: none;
}

.plus-slot:hover .plus-slot-icon {
  color: #3498db;
}

.unassigned-empty {
  font-size: 0.82rem;
  color: #bbb;
  padding: 6px 0;
  text-align: center;
}

/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */

@media (max-width: 900px) {
  .browser-wrap {
    padding: 16px;
  }

  .browser-main {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .browser-primary,
  .browser-sidebar {
    display: contents;
  }

  .browser-profile { order: 1; }
  .browser-create { order: 2; }
  .browser-lobbies { order: 3; }
  .browser-leaderboard { order: 4; }

  .browser-sidebar {
    position: static;
  }

  .browser-lobbies .lobby-list {
    max-height: none;
  }

  .browser-leaderboard .leaderboard-list {
    max-height: 280px;
  }

  .lobby-body {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }

  .lobby-topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .lobby-topbar-right {
    align-items: stretch;
  }

  .lobby-player-field {
    width: 100%;
  }

  .lobby-ready-btn {
    width: 100%;
    align-self: stretch;
  }
}

@media (max-width: 480px) {
  .browser-wrap {
    padding: 12px;
  }

  .browser-top {
    flex-wrap: wrap;
  }

  .brand-title {
    font-size: 1.4rem;
  }

  .lobby-topbar,
  .lobby-body {
    padding-left: 14px;
    padding-right: 14px;
  }

  .loadout-grid {
    grid-template-columns: 1fr 1fr;
  }

  .input-row {
    flex-direction: column;
  }
}
