:root{
  --bg: #050a17;
  --bg-soft: #0a1226;
  --panel: #0d1730;
  --card: #10193a;
  --card-border: rgba(90, 140, 255, 0.14);
  --primary: #2f6bff;
  --primary-2: #1748d1;
  --accent: #22e6ff;
  --accent-soft: rgba(34, 230, 255, 0.12);
  --text: #eaf2ff;
  --text-muted: #7c8db5;
  --text-faint: #4c5c82;
  --danger: #ff5c7a;
  --danger-soft: rgba(255, 92, 122, 0.12);
  --success: #2fe6a8;
  --radius: 16px;
}

* { box-sizing: border-box; }

* {
  scrollbar-width: thin;
  scrollbar-color: var(--accent) var(--bg-soft);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-soft);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--accent), var(--primary));
  border-radius: 6px;
  border: 2px solid var(--bg-soft);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  height: 100%;
  overflow-x: hidden;
}

#app { min-height: 100vh; position: relative; }

.mono { font-family: 'JetBrains Mono', monospace; }
.display { font-family: 'Space Grotesk', sans-serif; }

/* ---------- Background network canvas ---------- */
#netCanvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.55;
}

/* ---------- Layout ---------- */
.hidden { display: none !important; }

.auth-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}

@media (max-width: 900px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .brand-panel { min-height: 260px; padding: 40px 32px !important; }
}

/* ---------- Brand panel ---------- */
.brand-panel {
  padding: 64px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
}

.brand-top { display: flex; align-items: center; gap: 14px; }

.brand-top img {
  width: 46px;
  height: 46px;
  filter: drop-shadow(0 0 18px rgba(34,230,255,0.45));
}

.brand-name {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.brand-mid { max-width: 480px; }

.brand-headline {
  font-size: 44px;
  line-height: 1.12;
  font-weight: 700;
  margin: 0 0 18px 0;
  background: linear-gradient(120deg, #ffffff 30%, #9fd8ff 70%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Form panel ---------- */
.form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: linear-gradient(180deg, var(--card), var(--bg-soft));
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 36px 32px 30px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.45), 0 0 0 1px rgba(255,255,255,0.02) inset;
}

.eyes-widget {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 22px;
  height: 34px;
}

.eyes-widget .eye {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #f2f6ff;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(5,16,34,0.15), 0 2px 8px rgba(0,0,0,0.25);
  transform: scaleY(0.08);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.eyes-widget.peeking .eye {
  transform: scaleY(1);
}

.eyes-widget .pupil {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #051022;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transition: transform 0.2s ease, opacity 0.2s ease;
  opacity: 0;
}

.eyes-widget.peeking .pupil {
  opacity: 1;
  transform: translate(-50%, -50%) translateY(6px);
}

.eyes-widget.peeking.peek-left .pupil { transform: translate(-50%, -50%) translate(-4px, 6px); }
.eyes-widget.peeking.peek-right .pupil { transform: translate(-50%, -50%) translate(4px, 6px); }

.tabs {
  display: flex;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 28px;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 0;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: white;
  box-shadow: 0 4px 14px rgba(47,107,255,0.4);
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 7px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.4px;
}

.field input, .field select {
  width: 100%;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 14.5px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  appearance: none;
  -webkit-appearance: none;
}

.field select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M0 0l5 6 5-6z' fill='%237c8db5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 34px;
  cursor: pointer;
}

.field textarea {
  width: 100%;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 14.5px;
  font-family: 'Inter', sans-serif;
  outline: none;
  resize: vertical;
  min-height: 80px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34,230,255,0.12);
}

/* чекбоксы/радио не должны получать стиль текстового поля (иначе рисуются
   как пустой растянутый пилл без видимой галочки) */
.field input[type="checkbox"], .field input[type="radio"],
.inline-field input[type="checkbox"], .inline-field input[type="radio"] {
  width: auto;
  flex: 0 0 auto;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  border-radius: 0;
  appearance: auto;
  -webkit-appearance: auto;
}

.field .hint {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 6px;
}

.submit-btn {
  width: 100%;
  padding: 13px 0;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: #051022;
  font-weight: 600;
  font-size: 15px;
  font-family: 'Space Grotesk', sans-serif;
  cursor: pointer;
  margin-top: 6px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 8px 24px rgba(34,230,255,0.25);
}

.submit-btn:hover { transform: translateY(-1px); }
.submit-btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.submit-btn.danger {
  background: linear-gradient(135deg, var(--danger), #c73a56);
  color: #fff;
  box-shadow: 0 8px 24px rgba(255,92,122,0.25);
}

.settings-section-wrap {
  max-width: 480px;
}

.settings-card {
  padding: 20px 22px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--card-border);
  margin-bottom: 16px;
}

.settings-card.danger-card {
  border-color: rgba(255,92,122,0.3);
}

.form-msg {
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 14px;
  display: none;
}

.form-msg.error {
  display: block;
  background: rgba(255,92,122,0.1);
  color: var(--danger);
  border: 1px solid rgba(255,92,122,0.25);
}

.form-msg.success {
  display: block;
  background: rgba(47,230,168,0.1);
  color: var(--success);
  border: 1px solid rgba(47,230,168,0.25);
}

/* ---------- Cookie banner ---------- */
.cookie-banner {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 0);
  z-index: 50;
  width: min(560px, calc(100% - 32px));
  background: linear-gradient(180deg, #101d40, #0b1530);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  display: flex;
  gap: 16px;
  align-items: center;
  animation: rise 0.5s cubic-bezier(.2,.8,.2,1);
}

@keyframes rise {
  from { opacity: 0; transform: translate(-50%, 30px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.cookie-icon {
  width: 38px; height: 38px; flex-shrink: 0;
  border-radius: 10px;
  background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}

.cookie-text { flex: 1; }
.cookie-text b { display:block; font-size: 14px; margin-bottom: 2px; }
.cookie-text span { font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }

.cookie-actions { display: flex; gap: 8px; flex-shrink: 0; }

.cookie-actions button {
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
}

.cookie-accept {
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: #051022;
}

.cookie-decline {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--card-border) !important;
}

@media (max-width: 560px) {
  .cookie-banner { flex-direction: column; align-items: stretch; }
  .cookie-actions { justify-content: flex-end; }
}

/* ---------- Main page ---------- */
.main-page {
  position: relative;
  z-index: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 40px;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg);
  border-bottom: 1px solid var(--card-border);
}

.main-header .left { display: flex; align-items: center; gap: 12px; }
.main-header .left img { width: 32px; height: 32px; }
.main-header .left b { font-family: 'Space Grotesk', sans-serif; letter-spacing: 0.4px; }

.main-header .right { display: flex; align-items: center; gap: 16px; }

.username-pill {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(34,230,255,0.25);
  padding: 6px 12px;
  border-radius: 100px;
}

.logout-btn {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.logout-btn:hover { color: var(--text); border-color: var(--accent); }

.main-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* ---------- Side navigation ---------- */
.side-nav {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 14px 24px;
}

.side-nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 15.5px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.side-nav-btn:hover {
  color: var(--text);
  background: rgba(255,255,255,0.03);
}

.side-nav-btn.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(34,230,255,0.25);
  font-weight: 600;
}

.side-nav-icon {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  flex-shrink: 0;
}

.side-nav-icon-emoji {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.nav-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #ff4d4f;
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  flex-shrink: 0;
}

.nav-badge.hidden {
  display: none;
}

/* ---------- Search subnav (второй столбец кнопок правее основного меню) ---------- */
.search-subnav {
  width: 200px;
  flex-shrink: 0;
  border-left: 1px solid var(--card-border);
}

.search-subnav.hidden { display: none; }

/* ---------- Content area ---------- */
.content-area {
  flex: 1;
  padding: 32px 40px;
  border-left: 1px solid var(--card-border);
  overflow-y: auto;
}

.content-placeholder {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(20px, 3vw, 28px);
  color: var(--text-muted);
}

/* toast for logout etc */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 60;
  background: var(--card);
  border: 1px solid var(--card-border);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.4);
  animation: rise 0.35s ease;
}

/* ---------- Header action buttons ---------- */
.header-btn {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: color 0.15s ease, border-color 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.header-btn:hover { color: var(--text); border-color: var(--accent); }

.header-btn-icon {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  flex-shrink: 0;
}

.admin-btn {
  color: var(--danger);
  border-color: rgba(255,92,122,0.35);
  background: var(--danger-soft);
}

.admin-btn:hover { color: #ffd7de; border-color: var(--danger); }

.header-icon-btn {
  position: relative;
  padding: 8px;
}

.header-icon-btn .nav-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  margin-left: 0;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(3,7,18,0.65);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

#viewProfileModal {
  z-index: 75;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(180deg, var(--card), var(--bg-soft));
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 28px 26px 24px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.5);
  position: relative;
  animation: rise 0.3s cubic-bezier(.2,.8,.2,1);
}

.modal-card.wide { max-width: 640px; }

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--text-faint);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.modal-close:hover { color: var(--text); }

.modal-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 19px;
  font-weight: 600;
  margin: 0 0 4px 0;
}

.modal-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 20px 0;
  line-height: 1.5;
}

.modal-section + .modal-section {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--card-border);
}

.modal-section-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}

.readonly-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13.5px;
  padding: 8px 0;
  border-bottom: 1px dashed rgba(255,255,255,0.06);
}

.readonly-row span:first-child { color: var(--text-muted); }
.readonly-row span:last-child { font-family: 'JetBrains Mono', monospace; }

.eea-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 100px;
}

.eea-badge.yes {
  color: var(--success);
  background: rgba(47,230,168,0.1);
  border: 1px solid rgba(47,230,168,0.3);
}

.eea-badge.no {
  color: var(--danger);
  background: rgba(255,92,122,0.1);
  border: 1px solid rgba(255,92,122,0.3);
}

.inline-field {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
}

.inline-field input, .inline-field select, .inline-field textarea {
  flex: 1 1 120px;
  min-width: 0;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

.inline-field textarea {
  resize: vertical;
  min-height: 70px;
}

.inline-field select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path d='M0 0l5 6 5-6z' fill='%237c8db5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
  cursor: pointer;
}

.inline-field input:focus, .inline-field select:focus, .inline-field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34,230,255,0.12);
}

.inline-field button {
  flex-shrink: 0;
  border: none;
  border-radius: 10px;
  padding: 0 16px;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: #051022;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  font-family: 'Space Grotesk', sans-serif;
}

.inline-field button:disabled { opacity: 0.6; cursor: not-allowed; }

.modal-msg {
  font-size: 12.5px;
  padding: 8px 10px;
  border-radius: 8px;
  margin-top: 10px;
  display: none;
}

.modal-msg.error {
  display: block;
  background: rgba(255,92,122,0.1);
  color: var(--danger);
  border: 1px solid rgba(255,92,122,0.25);
}

.modal-msg.success {
  display: block;
  background: rgba(47,230,168,0.1);
  color: var(--success);
  border: 1px solid rgba(47,230,168,0.25);
}

.hidden-panel { display: none; }

/* ---------- Friends section ---------- */
.friends-section {
  padding: 28px 32px;
  overflow-y: auto;
  height: 100%;
  box-sizing: border-box;
}

.friends-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.friends-header h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 22px;
  color: var(--text);
  margin: 0;
}

.friends-search-box {
  position: relative;
  width: min(320px, 100%);
}

.friends-search-box input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 38px 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 14px;
}

.friends-search-box input:focus { outline: none; border-color: var(--accent); }

.friends-search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.friends-filter-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.friends-filter-row > div {
  width: min(220px, 100%);
}

.friends-subheader {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 18px 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.friends-count {
  color: var(--text-faint);
  font-family: 'JetBrains Mono', monospace;
}

.friends-requests-wrap { margin-bottom: 8px; }

.friends-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.friends-empty {
  color: var(--text-muted);
  font-size: 13.5px;
  padding: 14px 0;
}

.friend-card, .friend-request-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--card-border);
  cursor: pointer;
  transition: border-color 0.15s;
}

.friend-card:hover { border-color: var(--accent); }

.friend-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: #04101f;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-family: 'Space Grotesk', sans-serif;
  flex-shrink: 0;
}

.friend-avatar.small { width: 32px; height: 32px; font-size: 13px; }
.friend-avatar.large { width: 64px; height: 64px; font-size: 22px; }

.friend-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }

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

.friend-nick {
  font-weight: 600;
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
}

.friend-club {
  font-size: 12.5px;
  color: var(--text-muted);
}

.friend-flag {
  display: inline-flex;
  vertical-align: middle;
  margin-left: 4px;
}

.friend-flag .flag-icon,
.flag-icon {
  width: 18px;
  height: 13px;
  object-fit: cover;
  border-radius: 2px;
  vertical-align: middle;
}

.friend-mini-status {
  font-size: 12px;
  color: var(--accent);
  white-space: nowrap;
}

.friend-card-arrow {
  color: var(--text-faint);
  font-size: 18px;
}

/* ---------- Highlights feed ---------- */
.highlights-feed {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 560px;
  margin: 0 auto;
}

.highlight-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  overflow: hidden;
}

.highlight-video {
  display: block;
  width: 100%;
  max-height: 520px;
  background: #000;
}

.highlight-body {
  padding: 14px 16px 16px;
}

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

.highlight-author {
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
  color: var(--accent);
  cursor: pointer;
}

.highlight-author:hover { text-decoration: underline; }

.highlight-time {
  font-size: 11.5px;
  color: var(--text-faint);
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}

.highlight-description {
  font-size: 13.5px;
  color: var(--text);
  margin: 0 0 12px;
  white-space: pre-wrap;
}

.highlight-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.highlight-reactions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.reaction-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: var(--bg-soft);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.reaction-btn:hover { border-color: var(--accent); color: var(--text); }

.reaction-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.highlight-comments-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 5px 8px;
}

.highlight-comments-btn:hover { color: var(--text); }

.highlight-load-more {
  display: block;
  margin: 4px auto 0;
}

/* ---------- Highlight detail modal ---------- */
.highlight-detail-video {
  display: block;
  width: 100%;
  max-height: 60vh;
  background: #000;
  border-radius: 10px;
  margin-bottom: 14px;
}

.highlight-detail-description {
  font-size: 13.5px;
  color: var(--text);
  margin: 0 0 14px;
  white-space: pre-wrap;
}

.highlight-comment-form {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.highlight-comment-form input {
  flex: 1;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 13.5px;
}

.highlight-comment-form input:focus { outline: none; border-color: var(--accent); }

.highlight-comments-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 260px;
  overflow-y: auto;
}

.highlight-comment {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-soft);
  border: 1px solid var(--card-border);
}

.highlight-comment-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 3px;
}

.highlight-comment-author {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--accent);
  cursor: pointer;
}

.highlight-comment-author:hover { text-decoration: underline; }

.highlight-comment-time {
  font-size: 11px;
  color: var(--text-faint);
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}

.highlight-comment-content {
  font-size: 13px;
  color: var(--text);
  white-space: pre-wrap;
}

/* ---------- My highlights grid ---------- */
.my-highlights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}

.my-highlight-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  overflow: hidden;
}

.my-highlight-card video {
  display: block;
  width: 100%;
  max-height: 220px;
  background: #000;
}

.my-highlight-card-body {
  padding: 10px 12px 12px;
}

.my-highlight-description {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0 0 8px;
  max-height: 54px;
  overflow: hidden;
}

.my-highlight-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ---------- Search post form + feed (чаты анкет поиска) ---------- */
.search-post-form {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 22px;
}

.search-post-form .field { margin-bottom: 12px; }
.search-post-form .field:last-of-type { margin-bottom: 14px; }

.search-cooldown-hint {
  font-size: 12.5px;
  color: var(--text-faint);
  margin: -6px 0 14px;
}

.search-post-card {
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--card-border);
}

.search-post-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.search-post-user {
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
  color: var(--accent);
  cursor: pointer;
}

.search-post-user:hover { text-decoration: underline; }

.search-post-time {
  font-size: 11.5px;
  color: var(--text-faint);
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}

.search-post-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.search-post-row b { color: var(--text); font-weight: 600; }

.search-post-criteria {
  font-size: 13.5px;
  color: var(--text);
  white-space: pre-wrap;
}

.search-type-badge {
  display: inline-block;
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(34,230,255,0.25);
  font-weight: 600;
  margin-bottom: 8px;
}

/* ---------- Messages / chats ---------- */
.messages-section {
  display: flex;
  height: 100%;
  box-sizing: border-box;
  gap: 24px;
}

.messages-sidebar {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.messages-sidebar-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 20px;
  margin: 0 0 16px 0;
}

.chats-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.chat-item:hover { background: rgba(255,255,255,0.03); }

.chat-item.active {
  background: var(--accent-soft);
  border-color: rgba(34,230,255,0.3);
}

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

.chat-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.chat-item-nick {
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-preview {
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-unread {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: #04101f;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  flex-shrink: 0;
}

.messages-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: var(--card);
  overflow: hidden;
}

.messages-empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 20px;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--card-border);
  flex-shrink: 0;
}

.chat-header-user { display: flex; align-items: center; gap: 10px; min-width: 0; }

.chat-header-texts { min-width: 0; }

.chat-header-nick {
  font-weight: 600;
  font-family: 'Space Grotesk', sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-status {
  font-size: 12px;
  color: var(--accent);
  height: 16px;
}

.chat-header-actions { display: flex; gap: 8px; flex-shrink: 0; }

.chat-action-btn {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

.chat-action-btn:hover { color: var(--text); border-color: var(--accent); }
.chat-action-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.chat-action-btn.danger { color: var(--danger); border-color: rgba(255,92,122,0.3); }
.chat-action-btn.danger:hover { border-color: var(--danger); }

.chat-action-btn.primary {
  color: var(--accent);
  border-color: rgba(34,230,255,0.35);
}
.chat-action-btn.primary:hover { border-color: var(--accent); }
.chat-action-btn.hidden { display: none; }

.chat-action-btn.active-block {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-soft);
}

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-bubble {
  max-width: 65%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.8px;
  line-height: 1.45;
  word-break: break-word;
}

.chat-bubble.own {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: #04101f;
  border-bottom-right-radius: 4px;
}

.chat-bubble.other {
  align-self: flex-start;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--card-border);
  border-bottom-left-radius: 4px;
}

.chat-bubble-time {
  display: block;
  font-size: 10px;
  opacity: 0.65;
  margin-top: 3px;
  text-align: right;
}

.chat-greeting {
  margin: auto;
  color: var(--text-muted);
  font-size: 13.5px;
}

.chat-input-row {
  display: flex;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--card-border);
  flex-shrink: 0;
}

.chat-input-row input {
  flex: 1;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  outline: none;
}

.chat-input-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34,230,255,0.12);
}

.chat-input-row button {
  flex-shrink: 0;
  border: none;
  border-radius: 10px;
  padding: 0 20px;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: #051022;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  font-family: 'Space Grotesk', sans-serif;
}

.chat-input-row button:disabled { opacity: 0.6; cursor: not-allowed; }

.news-card {
  position: relative;
  padding: 16px 18px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--card-border);
}

.news-card-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
  margin-bottom: 4px;
}

.news-card-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.news-card-content {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
}

.news-read-more {
  display: inline-block;
  margin-top: 8px;
  padding: 0;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
}

.news-read-more:hover { text-decoration: underline; }

.news-card.pinned {
  border-color: rgba(90, 200, 250, 0.4);
  background: linear-gradient(180deg, rgba(90, 200, 250, 0.06), var(--card));
}

.news-pinned-badge {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 11px;
  font-weight: 700;
  color: #5ac8fa;
}

.news-card-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.news-pin-btn { margin-top: 0; }

.leagues-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.league-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 22px;
  min-height: 140px;
  padding: 20px 22px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--card-border);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}

.league-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.league-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.league-card-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  word-break: break-word;
}

.league-subscribe-btn {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.league-subscribe-btn:hover { background: var(--accent); color: #fff; }

.league-subscribe-btn.subscribed {
  background: var(--accent);
  color: #fff;
}

.league-card-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.league-card-preview {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
  overflow-wrap: break-word;
  word-break: break-word;
}

.league-card-time {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.league-news-card {
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--card-border);
  overflow: hidden;
}

.league-news-card-image {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: cover;
}

.league-news-card-body {
  padding: 16px 18px;
}

.league-news-card-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
  margin-bottom: 8px;
}

.league-news-card-content {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
}

.league-news-card-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
}

.league-news-source-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.league-news-source-link:hover { text-decoration: underline; }

.league-news-card-time {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.notification-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--card-border);
}

.notification-card.unread {
  border-color: rgba(255,77,79,0.35);
}

.notification-card.unread::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff4d4f;
  flex-shrink: 0;
}

.notification-message {
  flex: 1;
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
}

.notification-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.notifications-bulk-actions {
  display: flex;
  gap: 10px;
}

.friend-action-btn {
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--card-border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.friend-action-btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: #04101f;
  border: none;
}

.friend-action-btn.muted:hover { color: var(--text); border-color: var(--accent); }

.friend-action-btn.danger {
  color: var(--danger);
  border-color: rgba(255,92,122,0.35);
  background: var(--danger-soft);
}

.friend-action-btn.danger:hover { color: #ffd7de; border-color: var(--danger); }

.friend-action-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.friend-sub { font-size: 12px; margin-top: 2px; }
.friend-sub.muted { color: var(--danger); }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--danger-soft);
  color: var(--accent);
  border: 1px solid var(--card-border);
  vertical-align: middle;
}

.friend-status-label {
  font-size: 13px;
  color: var(--success);
  font-weight: 600;
}

/* ============================================================
   Admin page (full screen)
   ============================================================ */
.admin-page {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 40px;
  border-bottom: 1px solid var(--card-border);
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg);
}

.admin-header .left { display: flex; align-items: center; gap: 12px; }
.admin-header .left img { width: 32px; height: 32px; }
.admin-header .left b { font-family: 'Space Grotesk', sans-serif; letter-spacing: 0.4px; }

.admin-header .right {
  display: flex;
  align-items: center;
  gap: 18px;
}

.admin-label {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 1.5px;
  color: var(--danger);
  text-shadow: 0 0 18px rgba(255,92,122,0.45);
  border: 1px solid rgba(255,92,122,0.4);
  background: var(--danger-soft);
  padding: 8px 16px;
  border-radius: 8px;
  text-transform: uppercase;
}

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  border: 1px solid var(--card-border);
  padding: 8px 14px;
  border-radius: 8px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.back-link:hover { color: var(--text); border-color: var(--accent); }

.admin-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.admin-card {
  width: 100%;
  max-width: 440px;
  background: linear-gradient(180deg, var(--card), var(--bg-soft));
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 34px 32px 28px;
  box-shadow: 0 30px 80px rgba(0,0,0,0.45), 0 0 0 1px rgba(255,255,255,0.02) inset;
}

/* ряд карточек панели администратора: держим их у левого верхнего угла
   admin-body и раскладываем в ряд с переносом на маленьких экранах */
.admin-panels {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 24px;
  margin-right: auto;
  align-self: flex-start;
}

.admin-card-wide {
  max-width: 480px;
}

/* ---------- About us page (full screen) ---------- */
.about-body {
  flex: 1;
  padding: 48px 40px 60px;
  box-sizing: border-box;
}

.about-hero {
  text-align: center;
  max-width: 700px;
  margin: 0 auto 48px;
}

.about-hero h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(30px, 5vw, 48px);
  margin: 0 0 12px;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.about-hero p {
  color: var(--text-muted);
  font-size: 15px;
  margin: 0;
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.about-card {
  background: linear-gradient(180deg, var(--card), var(--bg-soft));
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 26px 24px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.about-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
}

.about-card-icon-img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 16px;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(34,230,255,0.15);
}

.about-card-role {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

.about-card-desc {
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
}

.about-card-handles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.about-card-handles:empty {
  display: none;
}

.about-loading {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  padding: 60px 0;
}

.news-result {
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-muted);
}

.news-result-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 14.5px;
  color: var(--text);
  margin-bottom: 2px;
}

.news-result-meta {
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 8px;
}

.news-result-content {
  white-space: pre-wrap;
  word-break: break-word;
}

.admin-card-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--danger-soft);
  border: 1px solid rgba(255,92,122,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 16px;
}

.admin-card h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 6px 0;
}

.admin-card p.sub {
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.55;
  margin: 0 0 22px 0;
}

.access-denied {
  text-align: center;
  max-width: 420px;
}

.access-denied .icon {
  font-size: 40px;
  margin-bottom: 14px;
}

.access-denied h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 21px;
  color: var(--danger);
  margin: 0 0 8px 0;
}

.access-denied p {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
  margin: 0 0 22px 0;
}

/* ============================================================
   Custom select (стилизованный выпадающий список)
   ============================================================ */
.custom-select-root {
  position: relative;
  width: 100%;
  font-family: 'Inter', sans-serif;
  user-select: none;
}

.inline-field .custom-select-root { flex: 1; }

.custom-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.custom-select-root.open .custom-select-trigger {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34,230,255,0.12);
}

.custom-select-value {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.custom-select-value.is-placeholder { color: var(--text-faint); }

.custom-select-arrow {
  flex-shrink: 0;
  color: var(--accent);
  font-size: 11px;
  transition: transform 0.15s ease;
}

.custom-select-root.open .custom-select-arrow { transform: rotate(180deg); }

.custom-select-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 80;
  background: linear-gradient(180deg, var(--card), var(--bg-soft));
  border: 1px solid var(--card-border);
  border-radius: 10px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.55);
  padding: 6px;
  animation: dropdownRise 0.15s ease;
}

@keyframes dropdownRise {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.custom-select-search {
  width: 100%;
  box-sizing: border-box;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 7px;
  padding: 8px 10px;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
}

.custom-select-search:focus {
  outline: none;
  border-color: var(--accent);
}

.custom-select-options {
  max-height: 240px;
  overflow-y: auto;
}

.custom-select-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 13.5px;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.2px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.custom-select-option:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.custom-select-option.selected {
  background: rgba(34,230,255,0.14);
  color: var(--accent);
  font-weight: 600;
}

.custom-select-empty {
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text-faint);
}

.custom-select-flag {
  width: 18px;
  height: 13px;
  object-fit: cover;
  border-radius: 2px;
  flex-shrink: 0;
}

.custom-select-value {
  display: flex;
  align-items: center;
  gap: 8px;
}

.custom-select-value .custom-select-flag { margin: 0; }

.custom-select-options::-webkit-scrollbar { width: 6px; }
.custom-select-options::-webkit-scrollbar-thumb {
  background: rgba(34,230,255,0.25);
  border-radius: 4px;
}

/* ---------- Modal safety: never taller than the viewport ---------- */
.modal-card {
  max-height: 88vh;
  overflow-y: auto;
}

/* ---------- Mobile layout ---------- */
.chat-back-btn { display: none; }

@media (max-width: 768px) {
  /* Main app header */
  .main-header {
    padding: 14px 16px;
    flex-wrap: wrap;
    gap: 10px;
  }
  .main-header .right {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
  }
  .header-btn, .logout-btn {
    padding: 7px 11px;
    font-size: 12.5px;
  }
  .username-pill { font-size: 11px; padding: 5px 10px; }

  /* Admin panel header */
  .admin-header {
    padding: 14px 16px;
    flex-wrap: wrap;
    gap: 10px;
  }
  .admin-header .right { flex-wrap: wrap; gap: 10px; }
  .admin-body { padding: 16px; }

  /* Side navigation becomes a horizontally scrollable top bar */
  .main-body {
    flex-direction: column;
    min-height: 0;
  }
  .side-nav {
    width: 100%;
    flex-direction: row;
    flex-shrink: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--card-border);
  }
  .side-nav-btn {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 13px;
  }
  .side-nav-icon { width: 20px; height: 20px; }

  .search-subnav {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding: 8px 10px;
    border-left: none;
    border-bottom: 1px solid var(--card-border);
  }
  .search-subnav .side-nav-btn {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 13px;
  }

  .content-area {
    padding: 18px 16px;
    border-left: none;
  }

  /* Messages: single-pane on mobile — list, then chat with a back button */
  .messages-section { gap: 0; }
  .messages-sidebar { width: 100%; }
  .messages-main { display: none; }
  .messages-section.chat-open .messages-sidebar { display: none; }
  .messages-section.chat-open .messages-main { display: flex; }

  .chat-back-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: transparent;
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    width: 34px;
    height: 34px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
  }

  .chat-bubble { max-width: 82%; }

  /* Admin cards stack full-width */
  .admin-panels { width: 100%; }
  .admin-card, .admin-card-wide { max-width: 100%; }
}

@media (max-width: 420px) {
  .main-header .left b { display: none; }
}

/* ---------- Arena: standings table (лиги) ---------- */
.arena-standings-wrap {
  overflow-x: auto;
}

.arena-standings-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
}

.arena-standings-table th,
.arena-standings-table td {
  padding: 9px 10px;
  text-align: center;
  border-bottom: 1px solid var(--card-border);
  color: var(--text-muted);
  white-space: nowrap;
}

.arena-standings-table th {
  color: var(--text);
  font-weight: 600;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.arena-standings-table .arena-standings-team-col {
  text-align: left;
  color: var(--text);
  font-weight: 500;
}

.arena-standings-table tbody tr:hover {
  background: rgba(255,255,255,0.03);
}

/* ---------- Arena: tournament bracket (кубки) ---------- */
/* ---------- Arena: tournament bracket (кубки) ---------- */
.arena-bracket-champion {
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 14px;
}

/* ============================================================
   НОВАЯ СЕТКА (Grid) — Финал ровно по центру справа
   ============================================================ */
.arena-bracket {
  display: grid;
  grid-template-columns: 1fr 1fr;
  /* Просто 2 строки с минимальной высотой. Браузер сам подтянет их друг к другу. */
  grid-template-rows: min-content min-content; 
  gap: 24px 40px;
  padding: 10px 0;
  /* align-items: center;  ← можно вообще убрать, если оно мешает */
  justify-items: center;
  width: 100%;
}

/* Контейнер для обычных раундов (полуфиналы, 1/4 и т.д.) */
.arena-bracket-grid-match {
  grid-column: 1;
  grid-row: auto; /* Автоматически заполняет строки */
  width: 100%;
  display: flex;
  justify-content: center;
}

/* Контейнер для ФИНАЛА (растягивается на 2 строки по центру) */
.arena-bracket-grid-final {
  grid-column: 2;
  grid-row: 1 / 2; /* Он займёт только 1 строку, а браузер поставит его ровно по центру из-за justify-items: center; */
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

/* Карточка самого раунда */
.arena-bracket-round {
  background: rgba(255,255,255,0.02);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 16px;
  width: 100%;
  max-width: 380px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

/* Подсветка текущего раунда */
.arena-bracket-round.is-active-round {
  border-color: rgba(34, 230, 255, 0.2);
  background: var(--accent-soft);
}

/* Стили для финала (чтобы выделить его) */
.arena-bracket-round.is-final {
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(34, 230, 255, 0.15);
  background: linear-gradient(180deg, rgba(34, 230, 255, 0.05), transparent);
}

/* Заголовок раунда */
.arena-bracket-round-title {
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.arena-round-active-badge {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #0b0f14;
  background: var(--accent);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}

/* Список матчей внутри раунда */
.arena-bracket-round-matches {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

/* Кнопки действий под раундом */
.arena-bracket-round-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.arena-bracket-round-actions .submit-btn,
.arena-bracket-round-actions .friend-action-btn {
  flex: 1;
  min-width: 0;
}

.arena-round-action-msg {
  margin-top: 6px;
}

/* ============================================================
   Адаптив для мобильных устройств (всё в одну колонку)
   ============================================================ */
@media (max-width: 720px) {
  .arena-bracket {
    grid-template-columns: 1fr; /* Одна колонка */
    grid-template-rows: auto auto auto; /* Строки */
    gap: 16px;
  }
  
  .arena-bracket-grid-match {
    grid-column: 1;
    grid-row: auto;
  }
  
  /* На мобилке финал становится просто последним элементом */
  .arena-bracket-grid-final {
    grid-column: 1;
    grid-row: auto;
  }
}

/* ---------- Arena: match card (общий вид и для кубка, и для лиги) ---------- */
.arena-match-card {
  position: relative;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.02);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.arena-match-card.is-clickable {
  cursor: pointer;
}

.arena-match-card.is-clickable:hover {
  border-color: var(--accent);
  background: rgba(255,255,255,0.04);
}

.arena-match-card.is-expanded {
  border-color: var(--accent);
}

.arena-match-team {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  color: var(--text-muted);
  font-size: 14px;
}

.arena-match-team-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.arena-match-score {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text);
  flex-shrink: 0;
}

.arena-match-team-winner {
  color: var(--accent);
  font-weight: 600;
}

.arena-match-team-winner .arena-match-score {
  color: var(--accent);
}

.arena-match-status {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 4px;
}

.arena-match-fill-toggle {
  margin-top: 8px;
  width: 100%;
  animation: arenaFillFade 0.15s ease;
}

@keyframes arenaFillFade {
  from { opacity: 0; transform: translateY(-2px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Список матчей тура для обычной лиги - той же карточной вёрсткой,
   что и в кубке, только в колонку под таблицей. */
.arena-match-list-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* ---------- Лидеры (leaders) ---------- */
.leaders-grid {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.leaders-table-wrap {
  overflow-x: auto;
}

.leaders-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
}

.leaders-table th,
.leaders-table td {
  padding: 8px 12px;
  text-align: center;
  border-bottom: 1px solid var(--card-border);
  color: var(--text-muted);
  white-space: nowrap;
}

.leaders-table th {
  color: var(--text);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.leaders-table .leaders-player-col {
  text-align: left;
  color: var(--accent);
  font-weight: 500;
}

.leaders-table .leaders-team-col {
  text-align: left;
  color: var(--text);
}

.leaders-table tbody tr:hover {
  background: rgba(255,255,255,0.03);
}

.leaders-table td b {
  color: var(--text);
  font-size: 15px;
}

@media (max-width: 600px) {
  .leaders-table th,
  .leaders-table td {
    padding: 6px 8px;
    font-size: 12px;
  }
}