/* ============ TBE ACADEMY — black/red esports HUD ============ */
:root {
  --bg: #070708;
  --panel: #121214;
  --panel-2: #1a1a1e;
  --line: #26262c;
  --red: #e8112d;
  --red-2: #ff4655;
  --red-deep: #9c0c1f;
  --red-glow: rgba(232, 17, 45, .45);
  --text: #f2f2f4;
  --muted: #9a9aa3;
  --ok: #2ecc71;
  --warn: #f5a623;
  --radius: 14px;
  --cut: 12px; /* срез угла — фирменный элемент */
  --font-display: 'Russo One', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

/* Фон: background.gif (положи файл в webapp/assets/) + затемнение.
   Если гифки нет — остаётся чистый тёмный градиент. */
#bg-layer {
  position: fixed; inset: 0; z-index: -1;
  background:
    linear-gradient(180deg, rgba(7,7,8,.88) 0%, rgba(7,7,8,.94) 60%, #070708 100%),
    url('assets/background.gif') center / cover no-repeat,
    radial-gradient(1200px 500px at 50% -10%, rgba(232,17,45,.14), transparent 60%),
    var(--bg);
}

/* ---------- Шапка ---------- */
#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 12px;
  background: linear-gradient(180deg, rgba(7,7,8,.96), rgba(7,7,8,.75));
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
#topbar::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--red) 30%, var(--red-2) 50%, var(--red) 70%, transparent);
  opacity: .9;
}
.brand {
  font-family: var(--font-display);
  font-size: 17px; letter-spacing: .12em; text-transform: uppercase;
  display: flex; align-items: center; gap: 8px;
}
.brand-mark { color: var(--red-2); font-size: 20px; }
.role-chip {
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--red-2); border: 1px solid var(--red-deep);
  padding: 4px 10px; border-radius: 999px;
  background: rgba(232,17,45,.08);
}
.role-chip:empty { display: none; }

/* ---------- Каркас ---------- */
#app { max-width: 980px; margin: 0 auto; padding: 16px 14px 96px; }
.screen { display: none; animation: fadein .25s ease; }
.screen.active { display: block; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .screen { animation: none; } }

.center-box { text-align: center; padding: 80px 20px; }
.big-emoji { font-size: 52px; margin-bottom: 14px; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.5; }

h1.title, h2.title {
  font-family: var(--font-display);
  text-transform: uppercase; letter-spacing: .06em;
  font-size: 20px; margin: 6px 0 4px;
}
.subtitle { color: var(--muted); font-size: 13px; margin-bottom: 16px; }

.loader {
  width: 42px; height: 42px; margin: 0 auto 16px;
  border: 3px solid var(--line); border-top-color: var(--red);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Кнопки (главный акцент дизайна) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-display); font-size: 14px;
  text-transform: uppercase; letter-spacing: .08em;
  color: #fff; border: none; cursor: pointer;
  padding: 14px 22px; width: 100%;
  background: linear-gradient(180deg, var(--red-2), var(--red) 55%, var(--red-deep));
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
  box-shadow: 0 0 22px var(--red-glow), inset 0 1px 0 rgba(255,255,255,.25);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.btn:active { transform: scale(.97); filter: brightness(1.15); }
.btn.secondary {
  background: var(--panel-2);
  border: 0; box-shadow: inset 0 0 0 1px var(--line);
  color: var(--text);
}
.btn.ghost {
  background: transparent; box-shadow: inset 0 0 0 1px var(--red-deep);
  color: var(--red-2);
}
.btn.small { padding: 9px 14px; font-size: 12px; width: auto; }
.btn.danger { background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--red-deep); color: var(--red-2); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-row { display: flex; gap: 10px; margin-top: 10px; }
.btn-row .btn { flex: 1; }

/* ---------- Карточки ---------- */
.card {
  background: linear-gradient(180deg, var(--panel), var(--panel) 70%, #0e0e10);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  position: relative;
}
.card.accent { border-color: var(--red-deep); box-shadow: 0 0 18px rgba(232,17,45,.12); }

/* ---------- Сетка игр ---------- */
.games-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.game-card {
  position: relative; overflow: hidden; cursor: pointer;
  background: linear-gradient(160deg, var(--panel-2), #0d0d0f);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 14px 14px;
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.game-card:active { transform: scale(.97); }
.game-card:hover { border-color: var(--red-deep); box-shadow: 0 0 20px rgba(232,17,45,.18); }
.game-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--red), transparent);
}
.game-card .g-icon { width: 46px; height: 46px; margin-bottom: 10px; color: var(--red-2); }
.game-card .g-icon svg { width: 100%; height: 100%; }
.game-card .g-name {
  font-family: var(--font-display); font-size: 18px; letter-spacing: .06em;
}
.game-card .g-tag { color: var(--muted); font-size: 11.5px; margin-top: 4px; line-height: 1.35; }
.game-card .g-count {
  margin-top: 10px; display: inline-block;
  font-size: 11px; font-weight: 600; color: var(--red-2);
  border: 1px solid var(--red-deep); border-radius: 999px; padding: 3px 9px;
  background: rgba(232,17,45,.07);
}

/* ---------- Кураторы ---------- */
.curator-card { display: flex; gap: 14px; align-items: center; cursor: pointer; }
.ava {
  width: 56px; height: 56px; border-radius: 12px; flex-shrink: 0;
  background: var(--panel-2) center/cover no-repeat;
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 20px; color: var(--red-2);
}
.ava.big { width: 92px; height: 92px; font-size: 34px; border-radius: 16px; }
.curator-card .c-info { flex: 1; min-width: 0; }
.curator-card .c-name { font-weight: 700; font-size: 15px; }
.curator-card .c-bio { color: var(--muted); font-size: 12.5px; margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.chev { color: var(--red-2); font-size: 20px; }

/* ---------- Форма ---------- */
label.f-label { display: block; font-size: 12px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted); margin: 14px 0 6px; }
label.f-label b { color: var(--red-2); }
input.f-input, textarea.f-input, select.f-input {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; color: var(--text); font-family: var(--font-body);
  font-size: 14px; padding: 12px 13px; outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea.f-input { min-height: 74px; resize: vertical; }
.f-input:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(232,17,45,.15); }

/* ---------- Статусы ---------- */
.badge { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px; letter-spacing: .04em; }
.badge.new { color: var(--warn); background: rgba(245,166,35,.1); border: 1px solid rgba(245,166,35,.4); }
.badge.accepted { color: var(--ok); background: rgba(46,204,113,.1); border: 1px solid rgba(46,204,113,.4); }
.badge.declined { color: var(--red-2); background: rgba(232,17,45,.08); border: 1px solid var(--red-deep); }

.app-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.qa { margin-top: 10px; font-size: 13px; line-height: 1.5; }
.qa b { color: var(--muted); font-weight: 600; }

/* ---------- Чат ---------- */
.chat-layout { display: flex; gap: 12px; height: calc(100vh - 200px); min-height: 380px; }
.chat-pane {
  flex: 1; display: flex; flex-direction: column; min-width: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.chat-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--line); background: var(--panel-2);
}
.chat-head .ava { width: 36px; height: 36px; font-size: 14px; border-radius: 9px; }
.chat-head .ch-name { font-weight: 700; font-size: 14px; flex: 1; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 78%; padding: 9px 13px; border-radius: 13px; font-size: 14px; line-height: 1.4; word-wrap: break-word; }
.msg.theirs { align-self: flex-start; background: var(--panel-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.mine {
  align-self: flex-end; color: #fff;
  background: linear-gradient(180deg, var(--red-2), var(--red-deep));
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 12px rgba(232,17,45,.25);
}
.msg .m-ts { display: block; font-size: 10px; opacity: .6; margin-top: 3px; text-align: right; }
.chat-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: var(--panel-2); }
.chat-input input {
  flex: 1; background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); padding: 11px 13px; font-size: 14px; outline: none;
}
.chat-input input:focus { border-color: var(--red); }
.chat-send {
  width: 46px; border: none; border-radius: 10px; cursor: pointer; font-size: 17px; color: #fff;
  background: linear-gradient(180deg, var(--red-2), var(--red-deep));
  box-shadow: 0 0 14px var(--red-glow);
}

/* Сайдбар выбора чата — справа (широкие экраны) */
.chat-side {
  width: 240px; flex-shrink: 0; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px; order: 2;
}
.chat-item {
  display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 10px;
  cursor: pointer; transition: background .12s ease;
}
.chat-item:hover { background: var(--panel-2); }
.chat-item.sel { background: rgba(232,17,45,.1); box-shadow: inset 0 0 0 1px var(--red-deep); }
.chat-item .ava { width: 40px; height: 40px; font-size: 15px; border-radius: 10px; }
.chat-item .ci-info { flex: 1; min-width: 0; }
.chat-item .ci-name { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .ci-last { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread-dot {
  min-width: 19px; height: 19px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: var(--red); color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 10px var(--red-glow); padding: 0 5px;
}

/* мобильный: сайдбар как выезжающая панель справа */
#side-toggle { display: none; }
@media (max-width: 719px) {
  .chat-side {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 40;
    width: 78%; max-width: 320px; border-radius: 0; order: 0;
    transform: translateX(105%); transition: transform .2s ease;
    padding-top: 60px;
  }
  .chat-side.open { transform: none; box-shadow: -10px 0 40px rgba(0,0,0,.6); }
  #side-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--red-deep);
    background: rgba(232,17,45,.08); color: var(--red-2); font-size: 17px; cursor: pointer;
  }
  .chat-layout { height: calc(100vh - 190px); }
}
#side-overlay { position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.5); display: none; }
#side-overlay.open { display: block; }

/* ---------- Нижняя навигация ---------- */
#bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around;
  background: linear-gradient(0deg, #0a0a0c 60%, rgba(10,10,12,.92));
  border-top: 1px solid var(--line);
  padding: 8px 6px calc(10px + env(safe-area-inset-bottom));
  backdrop-filter: blur(8px);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--muted); font-size: 10.5px; font-weight: 600; letter-spacing: .03em;
  background: none; border: none; cursor: pointer; padding: 4px 12px; position: relative;
}
.nav-item .n-ico { font-size: 20px; line-height: 1; }
.nav-item.active { color: var(--red-2); }
.nav-item.active::before {
  content: ''; position: absolute; top: -9px; left: 50%; transform: translateX(-50%);
  width: 26px; height: 3px; border-radius: 2px;
  background: var(--red); box-shadow: 0 0 10px var(--red-glow);
}
.nav-item .n-badge {
  position: absolute; top: 0; right: 4px;
  min-width: 16px; height: 16px; border-radius: 999px;
  background: var(--red); color: #fff; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

/* ---------- Статистика (админ) ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 12px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; text-align: center;
}
.stat .s-num { font-family: var(--font-display); font-size: 26px; color: var(--red-2); }
.stat .s-lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: 3px; }

/* ---------- Тост ---------- */
#toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  background: var(--panel-2); border: 1px solid var(--red-deep); color: var(--text);
  padding: 11px 18px; border-radius: 12px; font-size: 13.5px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 60;
  box-shadow: 0 8px 30px rgba(0,0,0,.5), 0 0 16px rgba(232,17,45,.15);
  max-width: 88%; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 13px; font-weight: 600;
  background: none; border: none; cursor: pointer; padding: 4px 0; margin-bottom: 8px;
}
.back-link:hover { color: var(--red-2); }

/* Чипы мультивыбора игр */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-family: var(--font-display); font-size: 12px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); background: var(--panel-2); border: 1px solid var(--line);
  padding: 9px 14px; border-radius: 999px; cursor: pointer;
  transition: all .12s ease;
}
.chip.sel {
  color: #fff; border-color: var(--red-deep);
  background: linear-gradient(180deg, rgba(232,17,45,.35), rgba(232,17,45,.12));
  box-shadow: 0 0 12px rgba(232,17,45,.2);
}

.divider { height: 1px; background: var(--line); margin: 14px 0; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; font-size: 14px; }
.empty .big-emoji { font-size: 40px; margin-bottom: 10px; }
