/* Интеллект-Арена — общий стиль.
   Идея: студия телевикторины ночью. Глубокий индиго, прожектор сверху,
   золото — только для главного (таймер, основная кнопка), команды — бирюза и коралл. */

@import url('https://fonts.googleapis.com/css2?family=Unbounded:wght@500;700;800&family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  --ink: #0f1b3d;
  --ink-2: #16234d;
  --ink-3: #1f2f64;
  --line: #2c3f80;
  --line-soft: #233568;
  --paper: #f2f4fb;
  --mute: #a3aeda;
  --mute-2: #7d89b8;
  --gold: #ffc24b;
  --gold-deep: #e39b12;
  --team1: #35d3c1;
  --team2: #ff6f91;
  --ok: #4ade80;
  --bad: #ff7a7a;
  --wait: #ffc24b;
  --r-s: 8px;
  --r-m: 14px;
  --r-l: 22px;
  --display: "Unbounded", "Segoe UI", system-ui, sans-serif;
  --body: "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--paper);
  background:
    radial-gradient(1100px 520px at 50% -180px, #263a82 0%, rgba(38, 58, 130, 0) 65%),
    var(--ink);
  background-attachment: fixed;
}
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.2; margin: 0 0 .6em; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.6rem, 3.5vw, 2.4rem); }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
small, .small { font-size: .86rem; }
.mute { color: var(--mute); }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ── Шапка ── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 12px clamp(14px, 3vw, 32px);
  background: rgba(15, 27, 61, .86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--paper); font-family: var(--display); font-weight: 800; font-size: 1.02rem; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--gold) 0 75%, rgba(255, 194, 75, .2) 75% 100%);
  position: relative;
}
.brand-mark::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--ink); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { color: var(--mute); padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: .95rem; }
.nav a:hover { color: var(--paper); text-decoration: none; background: var(--ink-3); }
.nav a.active { color: var(--ink); background: var(--paper); }
.topbar .spacer { flex: 1; }
.userchip { display: flex; align-items: center; gap: 10px; color: var(--paper); font-weight: 600; }
.bell { position: relative; background: none; border: 0; color: var(--paper); cursor: pointer; padding: 6px; font-size: 1.15rem; }
.bell .dot { position: absolute; top: 2px; right: 0; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: var(--team2); color: #fff; font-size: .7rem; font-weight: 800; display: grid; place-items: center; }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  .nav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .userchip .nick { display: none; }
}

/* ── Раскладка ── */
.page { max-width: 1180px; margin: 0 auto; padding: clamp(16px, 3vw, 32px); }
.page.narrow { max-width: 760px; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }

.panel {
  background: var(--ink-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-l);
  padding: clamp(16px, 2.4vw, 24px);
}
.panel.flat { background: transparent; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head h2, .panel-head h3 { margin: 0; }

/* ── Кнопки и поля ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--ink-3); color: var(--paper);
  font: 700 .95rem/1 var(--body); cursor: pointer;
  transition: background .15s, transform .05s, border-color .15s;
  white-space: nowrap;
}
.btn:hover { background: #283b78; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #241800; }
.btn.primary:hover { background: #ffd06e; }
.btn.ok { background: rgba(74, 222, 128, .14); border-color: rgba(74, 222, 128, .5); color: var(--ok); }
.btn.ok:hover { background: rgba(74, 222, 128, .25); }
.btn.bad { background: rgba(255, 122, 122, .12); border-color: rgba(255, 122, 122, .5); color: var(--bad); }
.btn.bad:hover { background: rgba(255, 122, 122, .24); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 32px; padding: 0 12px; font-size: .85rem; }
.btn.lg { min-height: 54px; padding: 0 26px; font-size: 1.05rem; }
.btn.block { width: 100%; }

label.field { display: block; }
label.field > span { display: block; font-size: .86rem; color: var(--mute); margin-bottom: 6px; font-weight: 600; }
input[type=text], input[type=password], input[type=number], input[type=search], input[type=datetime-local], select, textarea {
  width: 100%;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  padding: 11px 14px;
  font: 500 1rem/1.4 var(--body);
}
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(255, 194, 75, .18); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; }
.check input { width: 18px; height: 18px; accent-color: var(--gold); }

/* ── Вкладки ── */
.tabs { display: flex; gap: 6px; padding: 4px; background: var(--ink); border: 1px solid var(--line-soft); border-radius: 999px; overflow-x: auto; }
.tabs button {
  flex: 0 0 auto; border: 0; background: transparent; color: var(--mute);
  padding: 9px 16px; border-radius: 999px; font: 700 .92rem/1 var(--body); cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
}
.tabs button.active { background: var(--paper); color: var(--ink); }
.tabs .count { background: var(--team2); color: #fff; border-radius: 999px; padding: 2px 7px; font-size: .75rem; }

/* ── Таблицы ── */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .8rem; color: var(--mute); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: rgba(255, 255, 255, .03); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Метки ── */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--ink-3); color: var(--mute); white-space: nowrap; }
.badge.ok { background: rgba(74, 222, 128, .14); color: var(--ok); }
.badge.bad { background: rgba(255, 122, 122, .14); color: var(--bad); }
.badge.wait { background: rgba(255, 194, 75, .14); color: var(--wait); }
.badge.live { background: var(--team2); color: #fff; }
.badge.t1 { background: rgba(53, 211, 193, .15); color: var(--team1); }
.badge.t2 { background: rgba(255, 111, 145, .15); color: var(--team2); }
.chip { display: inline-block; padding: 4px 10px; border-radius: var(--r-s); background: var(--ink); border: 1px solid var(--line); font-size: .86rem; margin: 2px 4px 2px 0; }

.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: var(--ink-3); display: inline-grid; place-items: center; font-weight: 800; font-size: .9rem; color: var(--mute); flex: 0 0 auto; }
.avatar.lg { width: 84px; height: 84px; font-size: 1.8rem; }

.t1c { color: var(--team1); }
.t2c { color: var(--team2); }

.empty { text-align: center; color: var(--mute); padding: 28px 12px; }

/* ── Уведомления ── */
.toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 460px); }
.toast { background: var(--paper); color: var(--ink); padding: 12px 16px; border-radius: var(--r-m); font-weight: 600; box-shadow: 0 12px 30px rgba(0, 0, 0, .35); animation: toast-in .18s ease-out; }
.toast.bad { background: #ffdede; color: #6b0b0b; }
.toast.ok { background: #dcfbe7; color: #0b4a23; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.popover { position: absolute; right: 14px; top: 58px; width: min(92vw, 380px); max-height: 70vh; overflow: auto; background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--r-m); box-shadow: 0 20px 50px rgba(0, 0, 0, .45); padding: 8px; z-index: 30; }
.popover .item { padding: 10px; border-radius: var(--r-s); display: block; color: var(--paper); }
.popover .item.unread { background: rgba(255, 194, 75, .08); }
.popover .item small { color: var(--mute-2); display: block; }

/* ── Модальные окна ── */
.modal-back { position: fixed; inset: 0; background: rgba(5, 10, 26, .72); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--r-l); width: min(760px, 100%); max-height: 92vh; overflow: auto; padding: 22px; }
.modal.wide { width: min(1080px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.modal-head h2 { margin: 0; }
.x { background: none; border: 0; color: var(--mute); font-size: 1.6rem; cursor: pointer; line-height: 1; }

/* ── Счёт команд (общий элемент) ── */
.scorebar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; }
.scorebar .team { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.scorebar .team.right { text-align: right; align-items: flex-end; }
.scorebar .tname { font-weight: 700; color: var(--mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.scorebar .tpts { font-family: var(--display); font-weight: 800; font-size: 1.8rem; font-variant-numeric: tabular-nums; }
.scorebar .team.t1 .tpts { color: var(--team1); }
.scorebar .team.t2 .tpts { color: var(--team2); }
.scorebar .vs { color: var(--mute-2); font-family: var(--display); font-weight: 700; }

/* ── Лобби / вход ── */
.hero { display: grid; grid-template-columns: 1.15fr .85fr; gap: clamp(20px, 4vw, 56px); align-items: center; min-height: calc(100vh - 70px); }
.hero h1 { font-size: clamp(2rem, 5vw, 3.6rem); font-weight: 800; line-height: 1.05; }
.hero .lead { font-size: 1.12rem; color: var(--mute); max-width: 520px; }
.ring-demo { width: min(260px, 60vw); aspect-ratio: 1; margin: 18px 0; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; min-height: auto; } }

/* ── Календарь ── */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .dow { text-align: center; font-size: .78rem; color: var(--mute-2); font-weight: 700; padding: 4px 0; }
.cal .day { min-height: 64px; border-radius: var(--r-m); background: var(--ink); border: 1px solid var(--line-soft); padding: 6px 8px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; text-align: left; color: var(--paper); font: inherit; }
.cal .day.other { opacity: .35; }
.cal .day.today { border-color: var(--gold); }
.cal .day.sel { background: var(--ink-3); border-color: var(--paper); }
.cal .day .d { font-weight: 800; font-size: .92rem; }
.cal .dots { display: flex; gap: 3px; flex-wrap: wrap; }
.cal .dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }
.cal .dots i.mine { background: var(--team1); }
@media (max-width: 560px) { .cal .day { min-height: 46px; padding: 4px; } .cal .day .d { font-size: .8rem; } }

.event { display: grid; grid-template-columns: 74px 1fr auto; gap: 14px; align-items: center; padding: 14px; border-radius: var(--r-m); background: var(--ink); border: 1px solid var(--line-soft); }
.event + .event { margin-top: 10px; }
.event .time { font-family: var(--display); font-weight: 700; font-size: 1.15rem; }
@media (max-width: 560px) { .event { grid-template-columns: 1fr; } }

/* ── Рекламный блок ── */
.ad { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; padding: 16px 20px; border-radius: var(--r-l); background: linear-gradient(100deg, rgba(255, 194, 75, .12), rgba(255, 194, 75, .03)); border: 1px dashed rgba(255, 194, 75, .45); color: var(--paper); }
.ad img { width: 140px; height: 90px; object-fit: cover; border-radius: var(--r-m); }
.ad .ad-label { font-size: .72rem; color: var(--mute-2); font-weight: 700; }
.ad h3 { margin: 2px 0 4px; }
.ad p { margin: 0; color: var(--mute); }
a.ad:hover { text-decoration: none; border-color: var(--gold); }
