/* Flying Snipers — app shell layout (MEGA-RECODE phase 3) */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Custom scrollbar — site-wide brand purple */
html {
  -webkit-text-size-adjust: 100%;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb-hover) var(--scrollbar-track);
}

body,
.ui-scrollbar,
.skins-preview {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb-hover) var(--scrollbar-track);
}

.ui-scrollbar,
.skins-preview {
  scrollbar-gutter: stable;
}

*::-webkit-scrollbar {
  width: var(--scrollbar-size);
  height: var(--scrollbar-size);
}

*::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 99px;
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--scrollbar-thumb-hover), var(--scrollbar-thumb));
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  background-clip: padding-box;
  transition: background 0.15s ease;
}

*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--scrollbar-thumb-active), var(--scrollbar-thumb-hover));
}

*::-webkit-scrollbar-thumb:active {
  background: var(--scrollbar-thumb-active);
}

*::-webkit-scrollbar-corner {
  background: transparent;
}

body.app {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-main);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  max-width: 100vw;
}

body.app.no-scroll { overflow: hidden; }

#app-root {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
img { display: block; max-width: 100%; }

/* ===== APP GRID ===== */
.app-shell {
  display: flex;
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--topbar-h);
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.sidebar-brand-img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 48px;
  margin-inline: auto;
  object-fit: contain;
  object-position: center;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r);
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--sidebar-active);
  color: var(--text);
}

.nav-item.active .nav-icon {
  color: var(--orange-2);
}

.nav-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: inherit;
}

.nav-icon-svg {
  width: 20px;
  height: 20px;
  display: block;
}

.nav-item.active .nav-icon-svg {
  color: var(--orange-2);
}

.bottom-nav .nav-icon-svg {
  width: 22px;
  height: 22px;
}

.nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--orange-bg);
  color: var(--orange-2);
}

/* ===== MAIN ===== */
.app-main {
  margin-left: var(--sidebar-w);
  width: calc(100vw - var(--sidebar-w));
  max-width: calc(100vw - var(--sidebar-w));
  height: 100dvh;
  min-height: 100dvh;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
}

.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  z-index: 50;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 20px;
  box-sizing: border-box;
  background: var(--bg-main);
  overflow: visible;
}

.topbar-left {
  display: none;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.topbar-filters {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  overflow: visible;
}

.topbar-filters:empty {
  display: none;
}

.topbar-filters .filters-panel {
  padding: 0;
  margin: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  width: 100%;
  height: 100%;
  overflow-x: auto;
  overflow-y: visible;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  margin-left: auto;
}

.topbar-guest,
.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-user[hidden],
.topbar-guest[hidden] {
  display: none !important;
}

.balance-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}

.balance-pill:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.balance-pill:disabled {
  opacity: 0.55;
  cursor: default;
}

.coin-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(145deg, #ffd54a, #f59e0b);
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.15);
  flex-shrink: 0;
}

.topbar-icon-btn {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  display: grid;
  place-items: center;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.topbar-icon-btn:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
}

.topbar-icon-svg {
  width: 18px;
  height: 18px;
  display: block;
}

.friends-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--orange);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: grid;
  place-items: center;
}

.friends-badge[hidden] {
  display: none !important;
}

.friends-badge--alert {
  background: #e07070;
}

.profile-friends-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.profile-friends-subtab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.profile-friends-subtab:hover {
  color: var(--text);
  border-color: rgba(139, 92, 246, 0.35);
}

.profile-friends-subtab.is-active {
  color: var(--text);
  border-color: rgba(139, 92, 246, 0.55);
  background: rgba(139, 92, 246, 0.12);
}

.profile-friends-subtab-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--orange);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
}

.profile-friends-hint {
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
}

.friend-row--request {
  align-items: center;
}

.friend-row-actions {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
  margin-left: auto;
}

.profile-friend-btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.profile-friend-search-add.is-pending {
  opacity: 0.85;
}

.friends-wrap {
  position: relative;
}

.friends-drop {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(300px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: 0 16px 48px rgba(0,0,0,0.45);
  z-index: 120;
  overflow: hidden;
}

.friends-drop[hidden] { display: none !important; }

.friends-drop-head {
  padding: 0;
  border-bottom: 1px solid var(--line);
}

.friends-drop-tabs {
  display: flex;
  gap: 0;
}

.friends-drop-tab {
  flex: 1;
  margin: 0;
  padding: 11px 10px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  text-decoration: none;
  color: var(--dim);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.friends-drop-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
}

.friends-drop-tab.is-active {
  color: var(--text);
  border-bottom-color: var(--orange);
}

.friends-drop-tab--link.is-active {
  border-bottom-color: transparent;
}

.friends-list {
  max-height: 360px;
  overflow-y: auto;
}

.friends-drop-requests {
  background: rgba(139, 92, 246, 0.08);
  border-bottom: 1px solid var(--line);
}

.friends-drop-requests-label,
.friends-drop-friends-label {
  padding: 8px 14px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dim);
}

.friends-drop-empty {
  padding: 16px 14px;
}

.friend-row--topbar-request {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.friend-row--topbar-request:last-child {
  border-bottom: 0;
}

.friend-row--topbar-request .friend-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.friend-row-icon-actions {
  display: flex;
  flex-shrink: 0;
  gap: 6px;
}

.friend-action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.12s;
}

.friend-action-icon:hover:not(:disabled) {
  transform: translateY(-1px);
}

.friend-action-icon:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.friend-action-icon--accept {
  color: #6db892;
  border-color: rgba(109, 184, 146, 0.35);
}

.friend-action-icon--accept:hover:not(:disabled) {
  background: rgba(109, 184, 146, 0.12);
}

.friend-action-icon--decline {
  color: #e07070;
  border-color: rgba(224, 112, 112, 0.35);
}

.friend-action-icon--decline:hover:not(:disabled) {
  background: rgba(224, 112, 112, 0.1);
}

.friends-drop-friends .friend-row--link {
  display: flex;
}

.friend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.friend-row:last-child { border-bottom: 0; }

.friend-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.friend-info {
  flex: 1;
  min-width: 0;
}

.friend-info strong {
  display: block;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.friend-info span {
  font-size: 11px;
  color: var(--dim);
}

.friend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dim);
  flex-shrink: 0;
}

.friend-dot.on { background: var(--ok); }

.profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  max-width: 180px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.profile-chip:focus-visible {
  outline: 2px solid var(--orange-2);
  outline-offset: 2px;
}

.profile-chip:hover {
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.profile-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--orange-2), var(--orange));
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.profile-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 520px) {
  .profile-name { display: none; }
  .profile-chip { padding: 4px; border-radius: 50%; }
  .balance-pill span:last-child { font-size: 12px; }
}

.menu-toggle {
  width: 40px;
  height: 40px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 18px;
}

.btn-login {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--r);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  font-size: 13px;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s;
}

.btn-login:hover {
  border-color: var(--muted);
  background: var(--surface-2);
}

.btn-login.steam {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}

.btn-login.steam:hover {
  background: var(--orange-2);
  border-color: var(--orange-2);
  color: #fff;
}

.btn-login-steam-icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.btn-login-steam-icon {
  display: block;
  width: 22px;
  height: 22px;
  object-fit: contain;
}

#page-content {
  flex: 1;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  padding-top: var(--topbar-h);
  -webkit-overflow-scrolling: touch;
}

.content {
  flex: 1;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding: 20px 20px 32px;
  box-sizing: border-box;
  overflow-x: hidden;
}

.content--servers {
  flex: 1;
  min-height: 0;
  padding: 16px 20px 20px;
}

@media (min-width: 1200px) {
  .content { padding: 24px 24px 36px; }
  .content--servers { padding: 16px 24px 24px; }
}


/* ===== BOTTOM NAV MOBILE ===== */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-h);
  background: var(--sidebar);
  border-top: 1px solid var(--line);
  z-index: 100;
  padding: 0 8px;
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-inner {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: space-around;
}

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  font-weight: 600;
  color: var(--dim);
  padding: 8px 12px;
}

.bottom-nav a.active { color: var(--orange-2); }

/* ===== RESPONSIVE ===== */
@media (max-width: 899px) {
  .sidebar {
    transform: translateX(-100%);
    width: min(300px, 85vw);
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 99;
  }

  .sidebar-backdrop.show { display: block; }

  .app-main {
    margin-left: 0;
    width: 100%;
    max-width: 100vw;
  }

  .topbar {
    left: 0;
  }

  .topbar-left { display: flex; }

  .bottom-nav { display: block; }

  #page-content {
    padding-bottom: var(--bottom-nav-h);
  }

  .content { padding: 16px; }
  .content--servers { padding: 12px 16px 16px; }
}

@media (min-width: 900px) and (max-width: 1100px) {
  :root { --sidebar-w: var(--sidebar-collapsed); }

  .app-main {
    margin-left: var(--sidebar-w);
    width: calc(100vw - var(--sidebar-w));
    max-width: calc(100vw - var(--sidebar-w));
  }

  .sidebar-brand-text,
  .nav-item span:not(.nav-icon):not(.nav-badge) { display: none; }

  .sidebar-brand {
    justify-content: center;
    padding: 8px 6px;
  }

  .sidebar-brand-img {
    max-width: 52px;
    max-height: 44px;
    object-fit: cover;
    object-position: center;
  }

  .nav-item { justify-content: center; padding: 12px; }
  .nav-badge { display: none; }
}

/* toast + modal */
.toasts {
  position: fixed;
  bottom: calc(16px + var(--bottom-nav-h));
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 360px;
}

@media (min-width: 900px) {
  .toasts { bottom: 16px; }
}

.toast {
  padding: 12px 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  font-size: 13px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  pointer-events: auto;
}

.toast.ok { border-color: rgba(74,222,128,0.35); }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.overlay.open { display: flex; }

.dialog {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 24px;
}

.dialog h3 { font-size: 20px; font-weight: 800; margin-bottom: 8px; }
.dialog p { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; }

.dialog .btn-ghost {
  height: 38px;
  padding: 0 16px;
  border-radius: var(--r);
  border: 1px solid var(--line);
}

.dialog .btn-fire {
  height: 38px;
  padding: 0 16px;
  border-radius: var(--r);
  background: var(--orange);
  color: #fff;
  font-weight: 700;
}
