/* ════════════════════════════════════════════════════════════════════════
   TorroSite — базовый слой: токены, ресет, оболочка (хедер/футер), кнопки,
   формы, утилиты, адаптив. Тёмное фэнтези, золото/багрянец. Mobile-first.
   Без внешних ресурсов: системные шрифты, иконки — inline SVG.
   ════════════════════════════════════════════════════════════════════════ */

:root {
  /* Палитра */
  --bg:        #0a0805;
  --bg-soft:   #100c07;
  --panel:     #16110b;
  --panel-2:   #1e1810;
  --line:      rgba(212, 175, 55, 0.14);
  --line-soft: rgba(212, 175, 55, 0.08);

  --gold:      #d4af37;
  --gold-hi:   #f0d27a;
  --gold-dim:  #b8894f;
  --crimson:   #e94560;

  --text:      #ece6da;
  --muted:     #9d927e;
  --faint:     #6f6757;
  --ok:        #66cf8a;
  --err:       #ef6b6b;

  /* Размеры */
  --shell: 1140px;
  --r: 12px;
  --r-sm: 8px;
  --gap: clamp(16px, 3vw, 28px);

  /* Шрифты (системные, self-host не нужен) */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;

  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --glow: 0 0 24px rgba(212, 175, 55, 0.18);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* Стандартный HTML-способ спрятать элемент. !important — чтобы `display` у .btn/др. классов
   его не перебивал (иначе element.hidden = true не работает). Единый паттерн скрытия по сайту. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(1100px 520px at 50% -8%, rgba(212, 175, 55, 0.10), transparent 60%),
    radial-gradient(900px 600px at 100% 0%, rgba(233, 69, 96, 0.05), transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-soft) 100%);
  background-attachment: fixed;
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; }
input { font: inherit; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; }

::selection { background: rgba(212, 175, 55, 0.28); color: #fff; }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }

/* ── Утилиты ── */
.container { width: 100%; max-width: var(--shell); margin-inline: auto; padding-inline: clamp(16px, 4vw, 32px); }
.site-main { flex: 1 0 auto; width: 100%; }

.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 200;
  background: var(--gold); color: #1a1206; padding: 8px 14px; border-radius: var(--r-sm);
  font-weight: 600; transition: top .2s;
}
.skip-link:focus { top: 12px; }

.route-error {
  max-width: 480px; margin: 80px auto; text-align: center;
  color: var(--err); padding: 24px; border: 1px solid rgba(239, 107, 107, .3);
  border-radius: var(--r); background: rgba(239, 107, 107, .06);
}

/* Появление при скролле */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ── Кнопки ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: var(--r-sm); font-weight: 600; letter-spacing: .2px;
  border: 1px solid transparent; transition: transform .15s ease, box-shadow .2s ease, background .2s, border-color .2s, color .2s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 8px 16px; font-size: .92rem; }
.btn-gold {
  background: linear-gradient(135deg, var(--gold-hi), var(--gold-dim));
  color: #1c1305; box-shadow: 0 6px 18px rgba(212, 175, 55, .18);
}
.btn-gold:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(212, 175, 55, .32); }
.btn-ghost { border-color: rgba(212, 175, 55, .4); color: var(--gold-hi); background: rgba(212, 175, 55, .04); }
.btn-ghost:hover { border-color: var(--gold); background: rgba(212, 175, 55, .12); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

/* ════════════════ Хедер ════════════════ */
/* Верхняя панель = шапка + под-меню кабинета. Липнет и прокручивается ЕДИНЫМ блоком. */
.topbar { position: sticky; top: 0; z-index: 100; }
.site-header {
  position: relative;
  background: rgba(10, 8, 5, 0.72);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.hdr-inner {
  max-width: var(--shell); margin-inline: auto;
  padding: 12px clamp(16px, 4vw, 32px);
  display: flex; align-items: center; gap: 20px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark { display: inline-flex; filter: drop-shadow(0 0 6px rgba(212, 175, 55, .35)); }
.brand-word { font-family: var(--font-display); font-size: 1.45rem; font-weight: 700; letter-spacing: 1px; color: var(--text); }
.brand-accent { color: var(--gold); }

.hdr-right { margin-left: auto; display: flex; align-items: center; gap: 18px; }

/* Счётчик онлайна (зелёный кружок + total) */
.online-counter {
  display: inline-flex; align-items: center; gap: 6px; color: var(--muted);
  font-size: .9rem; padding: 4px 8px; border-radius: 999px;
  transition: color .2s, background .2s;
}
.online-counter:hover { color: var(--text); background: rgba(255, 255, 255, .04); }
.oc-dot { filter: drop-shadow(0 0 4px rgba(34, 197, 94, .7)); }
.oc-dot circle { animation: ocPulse 2s ease-in-out infinite; }
.oc-num { font-weight: 600; }
@keyframes ocPulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

.nav-desktop { display: flex; align-items: center; gap: 22px; }
.nav-link { color: var(--muted); font-weight: 500; transition: color .2s; position: relative; padding: 4px 0; }
.nav-link:hover { color: var(--text); }
.nav-link::after {
  content: ''; position: absolute; left: 0; bottom: -2px; height: 2px; width: 0;
  background: linear-gradient(90deg, var(--gold), transparent); transition: width .25s;
}
.nav-link:hover::after { width: 100%; }
/* Активная страница — подсвеченная кнопка (десктоп-навигация) */
.nav-link.is-active { color: var(--gold-hi); }
.nav-link.is-active::after { width: 100%; }
.online-counter.is-active { color: var(--gold-hi); }

/* Под-меню личного кабинета (личные разделы — отдельно от общей шапки портала). */
.acctnav { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.acctnav-link { padding: 10px 18px; color: var(--muted); text-decoration: none; font-size: .96rem; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .15s, border-color .15s; }
.acctnav-link:hover { color: var(--text); }
.acctnav-link.active { color: var(--gold-hi); border-bottom-color: var(--gold); }
/* Слот под-меню кабинета в ОБОЛОЧКЕ (постоянный, между шапкой и контентом).
   Не перерисовывается при смене раздела — свапается только контент под ним. */
.acct-subnav { border-bottom: 1px solid var(--line); background: var(--bg-soft); }
.acct-subnav[hidden] { display: none; }
.acct-subnav .acctnav { margin-bottom: 0; border-bottom: none; }

.nav-auth { display: flex; align-items: center; gap: 10px; margin-left: 8px; }
.user-chip {
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 6px 12px; border-radius: 999px; font-size: .9rem; font-weight: 600;
  color: var(--gold-hi); border: 1px solid var(--line); background: rgba(212, 175, 55, .06);
  text-decoration: none; cursor: pointer; display: inline-block; transition: border-color .2s, background .2s;
}
a.user-chip:hover { border-color: var(--gold); background: rgba(212, 175, 55, .14); }
.user-chip .uc-ico { margin-right: 5px; }
.user-name { cursor: default; }  /* имя аккаунта — просто текст, не кликабельно */
/* Кнопка профиля на текущей странице кабинета */
.user-chip.is-active { border-color: var(--gold); background: rgba(212, 175, 55, .18); box-shadow: 0 0 0 1px var(--gold) inset; }

/* Бургер (скрыт на десктопе) */
.burger { display: none; flex-direction: column; gap: 5px; padding: 8px; }
.burger span { width: 24px; height: 2px; background: var(--gold-hi); border-radius: 2px; transition: transform .25s, opacity .2s; }
.burger.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger.active span:nth-child(2) { opacity: 0; }
.burger.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Мобильное меню: drawer на уровне <body> (вне backdrop-filter хедера) ── */
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 140;
  background: rgba(0, 0, 0, .55);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity .25s ease;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; z-index: 150;
  height: 100vh; height: 100dvh; width: min(82vw, 330px);
  display: flex; flex-direction: column; overflow-y: auto;
  padding: 18px 20px calc(20px + env(safe-area-inset-bottom));
  background: linear-gradient(160deg, var(--panel-2), var(--bg));
  border-left: 1px solid var(--line); box-shadow: -24px 0 60px rgba(0, 0, 0, .5);
  transform: translateX(100%); visibility: hidden;
  transition: transform .28s ease, visibility 0s linear .28s;
}
.drawer.open { transform: none; visibility: visible; transition: transform .28s ease, visibility 0s; }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; padding-bottom: 14px; border-bottom: 1px solid var(--line);
}
.drawer-head .brand-word { font-size: 1.2rem; }
.drawer-close {
  width: 40px; height: 40px; font-size: 1.2rem; color: var(--muted);
  border-radius: 8px; transition: color .2s, background .2s;
}
.drawer-close:hover { color: var(--gold-hi); background: rgba(212, 175, 55, .08); }
.drawer-nav { display: flex; flex-direction: column; }
.drawer-link {
  padding: 14px 4px; color: var(--text); font-size: 1.06rem;
  border-bottom: 1px solid var(--line-soft); transition: color .2s;
}
.drawer-link:hover { color: var(--gold-hi); }
.drawer-link.is-active { color: var(--gold-hi); font-weight: 700; border-left: 3px solid var(--gold); padding-left: 10px; }
.drawer-auth { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.drawer-auth .user-chip { text-align: center; max-width: none; }

/* Блокировка скролла страницы под открытым меню */
html.nav-lock, html.nav-lock body { overflow: hidden; }

/* Drawer не нужен на десктопе */
@media (min-width: 721px) { .drawer, .drawer-backdrop { display: none; } }

/* ════════════════ Футер ════════════════ */
.site-footer {
  flex-shrink: 0; margin-top: 80px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .25));
}
.ftr-inner {
  max-width: var(--shell); margin-inline: auto;
  padding: 48px clamp(16px, 4vw, 32px) 28px;
  display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 32px;
}
.ftr-col h4 { font-size: .95rem; color: var(--gold-hi); margin-bottom: 14px; letter-spacing: .5px; }
.ftr-col a, .ftr-muted { display: block; color: var(--muted); padding: 4px 0; transition: color .2s; }
.ftr-col a:hover { color: var(--text); }
.ftr-brand .brand-word { font-size: 1.3rem; }
.ftr-tag { color: var(--faint); margin-top: 10px; max-width: 240px; font-size: .92rem; }
.ftr-bottom {
  max-width: var(--shell); margin-inline: auto;
  padding: 18px clamp(16px, 4vw, 32px); border-top: 1px solid var(--line-soft);
  color: var(--faint); font-size: .85rem; text-align: center;
}

/* ════════════════ Формы (общие) ════════════════ */
.field { margin-bottom: 18px; }
.field label { display: block; color: var(--muted); font-size: .9rem; margin-bottom: 7px; font-weight: 500; }
.field input {
  width: 100%; padding: 12px 14px; color: var(--text);
  background: rgba(0, 0, 0, .28); border: 1px solid var(--line);
  border-radius: var(--r-sm); transition: border-color .2s, box-shadow .2s;
}
.field input::placeholder { color: var(--faint); }
.field input:focus { outline: none; border-color: var(--gold-dim); box-shadow: 0 0 0 3px rgba(212, 175, 55, .12); }
.field .hint { display: block; margin-top: 6px; color: var(--faint); font-size: .82rem; }

.form-msg { padding: 12px 14px; border-radius: var(--r-sm); margin-bottom: 16px; font-size: .92rem; display: none; }
.form-msg.show { display: block; }
.form-msg.error { background: rgba(239, 107, 107, .1); color: var(--err); border: 1px solid rgba(239, 107, 107, .25); }
.form-msg.ok { background: rgba(102, 207, 138, .1); color: var(--ok); border: 1px solid rgba(102, 207, 138, .25); }

/* ════════════════ Адаптив ════════════════ */
@media (max-width: 860px) {
  .ftr-inner { grid-template-columns: 1fr 1fr; gap: 28px; }
}
@media (max-width: 720px) {
  .nav-desktop { display: none; }
  .burger { display: flex; }
  /* Полоса под-меню кабинета уезжает в бургер-меню (см. #drawerAcct в drawer). */
  .acct-subnav { display: none; }
}
@media (max-width: 480px) {
  .ftr-inner { grid-template-columns: 1fr; gap: 24px; }
  .brand-word { font-size: 1.25rem; }
}

/* Уважение к настройке «меньше движения» */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
}

/* ── Попап «Играть»: приложения экосистемы (Хаб / NC / Робраузер) ── */
.apps-menu { position: relative; display: inline-flex; }
.apps-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--r-sm);
  border: 1px solid rgba(212, 175, 55, .4); color: var(--gold-hi);
  background: rgba(212, 175, 55, .06); font: inherit; font-size: .92rem; font-weight: 600;
  cursor: pointer; transition: border-color .2s, background .2s;
}
.apps-btn:hover { border-color: var(--gold); background: rgba(212, 175, 55, .14); }
.apps-caret { font-size: .7em; transition: transform .2s; }
.apps-menu.open .apps-caret { transform: rotate(180deg); }
.apps-popup {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 120;
  min-width: 250px; padding: 6px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow);
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity .15s ease, transform .15s ease, visibility .15s;
}
.apps-menu.open .apps-popup { opacity: 1; visibility: visible; transform: translateY(0); }
.apps-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r-sm);
  color: var(--text); text-decoration: none; transition: background .15s;
}
.apps-item:hover { background: rgba(212, 175, 55, .10); }
.apps-item-ico { font-size: 1.4rem; line-height: 1; }
.apps-item-text { display: flex; flex-direction: column; line-height: 1.25; }
.apps-item-text b { font-weight: 600; font-size: .95rem; }
.apps-item-text i { font-style: normal; font-size: .78rem; color: var(--muted); }
@media (max-width: 560px) { .apps-label { display: none; } }

/* ── Список приложений внутри мобильного drawer (сворачиваемый) ── */
.drawer-apps { border-bottom: 1px solid var(--line-soft); margin: 4px 0 10px; padding-bottom: 10px; }
.drawer-apps-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 12px 6px; font: inherit; font-size: 1.05rem; font-weight: 600;
  color: var(--gold-hi); background: none; border: none; cursor: pointer; text-align: left;
}
.drawer-apps-btn .apps-caret { margin-left: auto; font-size: .8em; transition: transform .2s; }
.drawer-apps.open .drawer-apps-btn .apps-caret { transform: rotate(180deg); }
.drawer-apps-list { display: none; flex-direction: column; padding-left: 4px; }
.drawer-apps.open .drawer-apps-list { display: flex; }
.drawer-app {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 8px; color: var(--text); text-decoration: none; border-radius: var(--r-sm);
}
.drawer-app:hover { background: rgba(212, 175, 55, .10); }
.drawer-app i { font-style: normal; color: var(--muted); font-size: .85em; }

/* На мобиле (<=720) хедер-попап приложений скрыт — список живёт в drawer.
   Правило В КОНЦЕ файла: побеждает базовое .apps-menu { display:inline-flex } по порядку. */
@media (max-width: 720px) { .apps-menu { display: none; } }

/* блок партнёров на главной */
.partner-card{display:flex;gap:20px;align-items:center;justify-content:space-between;
  flex-wrap:wrap;padding:20px 24px;border:1px solid rgba(226,190,108,.28);
  border-radius:14px;background:rgba(24,20,34,.55)}
.partner-card h4{margin:0 0 6px;color:#e2be6c;font-size:1.05rem}
.partner-card p{margin:0;max-width:60ch;color:#b0a8c4;font-size:.94rem;line-height:1.5}

/* пункты меню для игр, которые ещё не открыты */
.apps-item--soon,.drawer-app--soon{opacity:.62;cursor:default}
.apps-item--soon i,.drawer-app--soon i{color:#b08d3c;font-style:normal;font-size:.82em}
.ftr-soon{opacity:.62}
.card-tag--soon{background:rgba(176,141,60,.18);border-color:rgba(226,190,108,.42);color:#e2be6c}
