/*
  Штаб Yarn and Wolves. Две темы: «ночь» (по умолчанию) — ночной лагерь из главного
  меню игры: тёмно-синее небо, звёзды, светлячки и тёплый свет костра; «утро» — тот же
  лес при свете дня. Карточки — матовое стекло поверх живого фона (canvas #sky).

  Цвета рядов на графиках (--s1…--s5) проверены валидатором dataviz для обеих тем:
  различимы при всех типах дальтонизма и дают ≥ 3:1 к поверхности. Не подбирать на глаз.
  Порядок закреплён: s1 янтарь, s2 небо, s3 мята, s4 фиалка, s5 малина.
*/

:root,
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0a0918;
    --surface: rgba(30, 27, 60, .52);
    --surface-strong: rgba(32, 29, 64, .82);
    --surface-solid: #1a1830;
    --surface-sunken: rgba(6, 5, 20, .42);
    --surface-hover: rgba(255, 255, 255, .045);
    --border: rgba(255, 255, 255, .085);
    --border-strong: rgba(255, 255, 255, .17);
    --highlight: rgba(255, 255, 255, .07);

    --text: #f4f0ff;
    --text-muted: #b9b3d8;
    --text-faint: #8680a8;

    --fire: #ffb547;
    --fire-2: #ff7a45;
    --fire-soft: rgba(255, 170, 70, .14);
    --on-fire: #2a1306;
    --yarn: #ff5c8a;
    --yarn-soft: rgba(255, 92, 138, .14);
    --mint: #3ddc97;
    --mint-soft: rgba(61, 220, 151, .14);
    --carrot: #ff9a3d;
    --carrot-soft: rgba(255, 154, 61, .14);
    --wool: #a993ff;
    --wool-soft: rgba(169, 147, 255, .15);
    --sky: #6cb4ff;
    --sky-soft: rgba(108, 180, 255, .14);
    --gold: #ffd36b;
    --danger: #ff6b7a;
    --danger-soft: rgba(255, 107, 122, .14);
    --warning: #ffc857;

    --s1: #cc7f14;
    --s2: #3b87d8;
    --s3: #1f9e74;
    --s4: #8b72e6;
    --s5: #d4497a;
    --grid: rgba(255, 255, 255, .07);

    --shadow: 0 14px 40px -18px rgba(0, 0, 0, .7);
    --shadow-lg: 0 40px 100px -30px rgba(0, 0, 0, .85);
    --spot: rgba(255, 190, 110, .55);
    --spot-wash: rgba(255, 180, 90, .07);
    --page:
        radial-gradient(1100px 700px at 88% 112%, rgba(255, 128, 40, .17), transparent 62%),
        radial-gradient(900px 620px at 6% -12%, rgba(78, 108, 255, .2), transparent 60%),
        radial-gradient(800px 600px at 50% 40%, rgba(140, 60, 200, .07), transparent 70%),
        linear-gradient(180deg, #0c0b20 0%, #0a0918 55%, #110a16 100%);
    --aurora-1: rgba(84, 98, 255, .22);
    --aurora-2: rgba(255, 120, 60, .16);
    --aurora-3: rgba(225, 70, 140, .13);
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f6efe4;
    --surface: rgba(255, 252, 246, .68);
    --surface-strong: rgba(255, 253, 249, .92);
    --surface-solid: #fffaf2;
    --surface-sunken: rgba(120, 85, 40, .06);
    --surface-hover: rgba(90, 60, 20, .045);
    --border: rgba(80, 52, 20, .1);
    --border-strong: rgba(80, 52, 20, .2);
    --highlight: rgba(255, 255, 255, .8);

    --text: #2a2036;
    --text-muted: #685d74;
    --text-faint: #978ca2;

    --fire: #f59e2b;
    --fire-2: #ef6a33;
    --fire-soft: rgba(245, 158, 43, .14);
    --on-fire: #2a1306;
    --yarn: #dc3f74;
    --yarn-soft: rgba(220, 63, 116, .1);
    --mint: #12a36a;
    --mint-soft: rgba(18, 163, 106, .11);
    --carrot: #e07a22;
    --carrot-soft: rgba(224, 122, 34, .12);
    --wool: #7a5fd6;
    --wool-soft: rgba(122, 95, 214, .11);
    --sky: #2f7fd6;
    --sky-soft: rgba(47, 127, 214, .1);
    --gold: #c9900f;
    --danger: #d43f4d;
    --danger-soft: rgba(212, 63, 77, .1);
    --warning: #c98a1e;

    --s1: #c47410;
    --s2: #2f7fd6;
    --s3: #14966a;
    --s4: #7a5fd6;
    --s5: #d44a78;
    --grid: rgba(80, 52, 20, .09);

    --shadow: 0 14px 34px -18px rgba(110, 70, 30, .35);
    --shadow-lg: 0 40px 90px -30px rgba(110, 70, 30, .45);
    --spot: rgba(240, 140, 50, .5);
    --spot-wash: rgba(255, 170, 80, .08);
    --page:
        radial-gradient(1000px 640px at 92% -8%, rgba(255, 196, 120, .5), transparent 62%),
        radial-gradient(900px 640px at 0% 110%, rgba(140, 210, 160, .4), transparent 60%),
        radial-gradient(700px 500px at 45% 45%, rgba(255, 220, 230, .35), transparent 70%),
        linear-gradient(180deg, #fbf4ea 0%, #f6efe4 60%, #f1eadc 100%);
    --aurora-1: rgba(255, 190, 110, .32);
    --aurora-2: rgba(130, 200, 150, .26);
    --aurora-3: rgba(255, 150, 180, .2);
}

:root {
    --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --display: "Unbounded", "Manrope", system-ui, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius: 18px;
    --radius-sm: 12px;
    --sidebar-width: 268px;
    --ease-out: cubic-bezier(.16, 1, .3, 1);
    --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
    --blur: blur(20px) saturate(150%);
    --fire-gradient: linear-gradient(135deg, var(--fire) 0%, var(--fire-2) 100%);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
    background: var(--page), var(--bg);
    background-attachment: fixed;
    color: var(--text);
    font: 500 14px/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

[hidden] { display: none !important; }

h1, h2, h3 { margin: 0; line-height: 1.15; }

button, input, textarea, select { font: inherit; color: inherit; }

a { color: var(--fire); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: color-mix(in srgb, var(--fire) 40%, transparent); }

:focus-visible { outline: 2px solid var(--fire); outline-offset: 2px; border-radius: 6px; }

.display { font-family: var(--display); font-weight: 700; letter-spacing: -.01em; }
.eyebrow { margin: 0; font-size: 11.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--fire); }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.num { font-variant-numeric: tabular-nums; }

svg.icon { width: 1em; height: 1em; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[data-icon] { display: inline-flex; align-items: center; justify-content: center; }

/* ------------------------------------------------------------------ живой фон */

.sky {
    position: fixed; inset: 0;
    width: 100%; height: 100%;
    z-index: -1;
    pointer-events: none;
}
.aurora { position: fixed; inset: 0; z-index: -2; overflow: hidden; pointer-events: none; }
.aurora i {
    position: absolute;
    width: 60vmax; height: 60vmax;
    border-radius: 50%;
    animation: drift 34s ease-in-out infinite alternate;
}
.aurora i:nth-child(1) { left: -18vmax; top: -22vmax; background: radial-gradient(circle, var(--aurora-1), transparent 62%); }
.aurora i:nth-child(2) { right: -20vmax; bottom: -26vmax; background: radial-gradient(circle, var(--aurora-2), transparent 62%); animation-duration: 41s; animation-delay: -9s; }
.aurora i:nth-child(3) { left: 30vw; top: 20vh; width: 44vmax; height: 44vmax; background: radial-gradient(circle, var(--aurora-3), transparent 64%); animation-duration: 47s; animation-delay: -21s; }
@keyframes drift {
    0% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(6vw, 4vh, 0) scale(1.12); }
    100% { transform: translate3d(-4vw, 7vh, 0) scale(.94); }
}

/* ------------------------------------------------------------------ стекло и подсветка */

.glass {
    background: var(--surface);
    -webkit-backdrop-filter: var(--blur);
    backdrop-filter: var(--blur);
    border: 1px solid var(--border);
    box-shadow: inset 0 1px 0 var(--highlight), var(--shadow);
}

/* Подсветка под курсором: рамка разгорается там, где мышь (координаты ставит app.js). */
.spot { position: relative; isolation: isolate; }
.spot::before,
.spot::after {
    content: "";
    position: absolute; inset: 0;
    border-radius: inherit;
    pointer-events: none;
    opacity: 0;
    transition: opacity .35s;
}
.spot::before {
    padding: 1px;
    background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 50%), var(--spot), transparent 42%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    z-index: 2;
}
.spot::after {
    background: radial-gradient(520px circle at var(--mx, 50%) var(--my, 50%), var(--spot-wash), transparent 45%);
    z-index: -1;
}
.spot:hover::before, .spot:hover::after { opacity: 1; }

/* ------------------------------------------------------------------ кнопки и поля */

.button {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 40px; padding: 0 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-hover);
    cursor: pointer;
    font-weight: 700;
    white-space: nowrap;
    transition: transform .2s var(--ease-spring), background .2s, border-color .2s, box-shadow .25s, opacity .2s, color .2s;
    overflow: hidden;
}
.button:hover:not(:disabled) { border-color: var(--border-strong); background: color-mix(in srgb, var(--text) 8%, transparent); }
.button:active:not(:disabled) { transform: scale(.97); }
.button:disabled { opacity: .5; cursor: default; }
.button.wide { width: 100%; }
.button.big { height: 50px; font-size: 15px; border-radius: 14px; }
.button.small { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 10px; gap: 6px; }
.button svg.icon { font-size: 16px; }
.button.small svg.icon { font-size: 14px; }

.button.primary {
    background: var(--fire-gradient);
    color: var(--on-fire);
    border-color: transparent;
    box-shadow: 0 8px 26px -8px color-mix(in srgb, var(--fire-2) 70%, transparent), inset 0 1px 0 rgba(255, 255, 255, .35);
}
.button.primary:hover:not(:disabled) {
    background: var(--fire-gradient);
    border-color: transparent;
    box-shadow: 0 12px 34px -8px color-mix(in srgb, var(--fire-2) 85%, transparent), inset 0 1px 0 rgba(255, 255, 255, .45);
    transform: translateY(-1px);
}
.button.ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.button.ghost:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); border-color: var(--border); }
.button.danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.button.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 22%, transparent); border-color: var(--danger); }
.button.carrot { background: var(--carrot-soft); color: var(--carrot); border-color: color-mix(in srgb, var(--carrot) 25%, transparent); }
.button.carrot:hover:not(:disabled) { background: color-mix(in srgb, var(--carrot) 22%, transparent); border-color: var(--carrot); }
.button.wool { background: var(--wool-soft); color: var(--wool); border-color: color-mix(in srgb, var(--wool) 25%, transparent); }
.button.wool:hover:not(:disabled) { background: color-mix(in srgb, var(--wool) 22%, transparent); border-color: var(--wool); }
.button.mint { background: var(--mint-soft); color: var(--mint); border-color: color-mix(in srgb, var(--mint) 25%, transparent); }
.button img { width: 18px; height: 18px; object-fit: contain; }

/* Блик, пробегающий по главной кнопке входа. */
.shimmer::after {
    content: "";
    position: absolute; top: 0; bottom: 0; left: -60%;
    width: 40%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .55), transparent);
    transform: skewX(-18deg);
    animation: shimmer 3.6s ease-in-out infinite;
}
@keyframes shimmer { 0%, 55% { left: -60%; } 100% { left: 130%; } }

.icon-button {
    display: inline-grid; place-items: center;
    width: 40px; height: 40px;
    border: 1px solid var(--border); border-radius: 12px;
    background: var(--surface);
    -webkit-backdrop-filter: var(--blur);
    backdrop-filter: var(--blur);
    cursor: pointer; font-size: 18px;
    color: var(--text-muted);
    transition: background .2s, color .2s, transform .2s var(--ease-spring), border-color .2s;
}
.icon-button:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-1px); }
.icon-button:active { transform: scale(.94); }

.field { display: grid; gap: 7px; min-width: 0; }
.field > span:first-child { font-size: 12px; font-weight: 700; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.field > span:first-child img { width: 18px; height: 18px; object-fit: contain; }

input[type="text"], input[type="password"], input[type="number"], input[type="search"], textarea, select {
    width: 100%;
    height: 42px;
    padding: 0 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-sunken);
    outline: none;
    font-weight: 600;
    transition: border-color .2s, box-shadow .2s, background .2s;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); font-weight: 500; }
textarea { height: auto; padding: 12px 13px; resize: vertical; }
input:focus, textarea:focus, select:focus {
    border-color: color-mix(in srgb, var(--fire) 70%, transparent);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--fire) 16%, transparent);
    background: color-mix(in srgb, var(--surface-sunken) 60%, var(--surface-solid));
}
input[type="number"] { -moz-appearance: textfield; font-variant-numeric: tabular-nums; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
select { cursor: pointer; padding-right: 30px; }
select option { background: var(--surface-solid); color: var(--text); }

/* Галочка-переключатель. */
.switch { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch i {
    position: relative;
    width: 42px; height: 24px; flex: none;
    border-radius: 999px;
    background: var(--surface-sunken);
    border: 1px solid var(--border-strong);
    transition: background .25s, border-color .25s;
}
.switch i::after {
    content: "";
    position: absolute; top: 2px; left: 2px;
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--text-faint);
    transition: transform .35s var(--ease-spring), background .25s;
}
.switch input:checked + i { background: var(--fire-gradient); border-color: transparent; }
.switch input:checked + i::after { transform: translateX(18px); background: #fff; }
.switch input:disabled + i { opacity: .55; }
.switch input:focus-visible + i { outline: 2px solid var(--fire); outline-offset: 2px; }

/* Число со степпером −/+. */
.stepper { position: relative; display: flex; align-items: stretch; }
.stepper input { text-align: center; padding: 0 40px; }
.stepper button {
    position: absolute; top: 5px; bottom: 5px;
    width: 32px;
    border: 0; border-radius: 9px;
    background: var(--surface-hover);
    color: var(--text-muted);
    cursor: pointer; font-size: 15px;
    display: grid; place-items: center;
    transition: background .2s, color .2s;
}
.stepper button:hover { background: var(--fire-soft); color: var(--fire); }
.stepper button:first-of-type { left: 5px; }
.stepper button:last-of-type { right: 5px; }

.env-badge {
    display: inline-flex; align-items: center;
    padding: 2px 9px;
    border-radius: 999px;
    background: var(--carrot-soft);
    color: var(--carrot);
    border: 1px solid color-mix(in srgb, var(--carrot) 30%, transparent);
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    vertical-align: middle;
    line-height: 1.5;
}
/* Бой — красным, чтобы правку игрока на живом сервере не спутать со стендом. */
.env-badge.prod {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 30%, transparent);
}

kbd {
    display: inline-flex; align-items: center;
    height: 22px; padding: 0 7px;
    border-radius: 7px;
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    background: var(--surface-hover);
    font: 700 11px/1 var(--font);
    color: var(--text-muted);
}

/* ------------------------------------------------------------------ вход */

.login {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px 20px;
}
.login-stage {
    display: grid;
    grid-template-columns: minmax(0, 400px) minmax(0, 420px);
    align-items: center;
    gap: 56px;
    perspective: 1400px;
    animation: rise .9s var(--ease-out) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(26px) scale(.98); } }

.portal {
    position: relative;
    aspect-ratio: 940 / 1300;
    border-radius: 200px 200px 34px 34px;
    overflow: hidden;
    box-shadow:
        0 0 0 1px rgba(255, 210, 150, .25),
        0 0 0 10px rgba(255, 255, 255, .03),
        0 50px 120px -30px rgba(255, 120, 40, .45),
        var(--shadow-lg);
    transform-style: preserve-3d;
    transition: transform .25s ease-out;
    will-change: transform;
}
.portal-art {
    position: absolute; inset: -4%;
    background: url("assets/camp.webp") center 78% / cover no-repeat;
    transform: translate3d(calc(var(--tx, 0) * -14px), calc(var(--ty, 0) * -14px), 0) scale(1.04);
    transition: transform .25s ease-out;
}
.portal-shine {
    position: absolute; inset: 0;
    background:
        radial-gradient(circle at calc(50% + var(--tx, 0) * 40%) calc(30% + var(--ty, 0) * 40%), rgba(255, 255, 255, .16), transparent 45%),
        linear-gradient(180deg, transparent 55%, rgba(10, 8, 24, .65) 100%);
    pointer-events: none;
}
.portal-embers, .hero-embers { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.ember {
    position: absolute;
    width: var(--s, 4px); height: var(--s, 4px);
    border-radius: 50%;
    background: radial-gradient(circle, #fff6c8 0%, #ffb547 40%, rgba(255, 110, 40, 0) 72%);
    box-shadow: 0 0 10px 2px rgba(255, 150, 60, .65);
    animation: ember var(--d, 3.5s) linear infinite;
    animation-delay: var(--delay, 0s);
    opacity: 0;
}
@keyframes ember {
    0% { opacity: 0; transform: translate(0, 0) scale(1); }
    12% { opacity: 1; }
    100% { opacity: 0; transform: translate(var(--dx, 10px), var(--rise, -180px)) scale(.3); }
}
.portal-caption {
    position: absolute; left: 50%; bottom: 22px;
    transform: translateX(-50%);
    display: inline-flex; align-items: center; gap: 9px;
    padding: 8px 16px;
    border-radius: 999px;
    background: rgba(12, 10, 28, .55);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, .12);
    color: #f7efe2;
    font-size: 12.5px; font-weight: 700;
    white-space: nowrap;
}
.portal-dot { width: 8px; height: 8px; border-radius: 50%; background: #ffb547; box-shadow: 0 0 12px 3px rgba(255, 160, 60, .8); animation: flicker 2.4s infinite; }
@keyframes flicker { 0%, 100% { opacity: 1; } 45% { opacity: .55; } 50% { opacity: .9; } 70% { opacity: .65; } }

.login-card {
    position: relative;
    display: grid;
    gap: 16px;
    padding: 38px 34px 26px;
    border-radius: var(--radius-xl);
    background: var(--surface-strong);
    box-shadow: inset 0 1px 0 var(--highlight), var(--shadow-lg);
}
.login-logo { width: 64px; height: 64px; animation: bob 5s ease-in-out infinite; filter: drop-shadow(0 10px 24px rgba(236, 79, 131, .5)); }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-6px) rotate(6deg); } }
.login-title { font-size: 38px; font-weight: 800; line-height: 1.05; }
.login-title span {
    background: var(--fire-gradient);
    -webkit-background-clip: text; background-clip: text;
    color: transparent;
}
.login-subtitle { margin: -6px 0 6px; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.password-wrap { position: relative; display: block; }
.password-wrap input { height: 50px; padding-right: 48px; font-size: 16px; border-radius: 14px; }
.password-toggle {
    position: absolute; right: 6px; top: 50%;
    transform: translateY(-50%);
    width: 38px; height: 38px;
    border: 0; border-radius: 10px;
    background: transparent;
    color: var(--text-faint);
    cursor: pointer; font-size: 18px;
    display: grid; place-items: center;
}
.password-toggle:hover { color: var(--text); background: var(--surface-hover); }
.login-error {
    margin: 0; padding: 11px 14px;
    border-radius: var(--radius-sm);
    background: var(--danger-soft); color: var(--danger);
    border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
    font-weight: 700;
}
.login-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 4px; font-size: 12px; }
.shake { animation: shake .5s cubic-bezier(.36, .07, .19, .97); }
@keyframes shake {
    10%, 90% { transform: translateX(-2px); }
    20%, 80% { transform: translateX(4px); }
    30%, 50%, 70% { transform: translateX(-8px); }
    40%, 60% { transform: translateX(8px); }
}
.login.leaving .login-stage { animation: leave .7s var(--ease-out) forwards; }
@keyframes leave { to { opacity: 0; transform: scale(1.06); filter: blur(8px); } }

/* ------------------------------------------------------------------ каркас */

.app {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    min-height: 100vh;
}
.app.entering .sidebar { animation: slide-in .8s var(--ease-out) both; }
.app.entering .topbar { animation: fade-down .8s .1s var(--ease-out) both; }
@keyframes slide-in { from { opacity: 0; transform: translateX(-30px); } }
@keyframes fade-down { from { opacity: 0; transform: translateY(-14px); } }

.sidebar {
    position: sticky;
    top: 14px;
    height: calc(100vh - 28px);
    margin: 14px 0 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 22px 16px 16px;
    border-radius: var(--radius-xl);
    overflow: hidden;
    z-index: 5;
}
/* Вязаная фактура — еле заметные «косички» под стеклом боковой панели. */
.sidebar::before {
    content: "";
    position: absolute; inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='26' viewBox='0 0 22 26'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.05' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M2 2c3 6 6 9 9 11M20 2c-3 6-6 9-9 11M2 15c3 6 6 9 9 11M20 15c-3 6-6 9-9 11'/%3E%3C/g%3E%3C/svg%3E");
    -webkit-mask: linear-gradient(180deg, #000, transparent 75%);
    mask: linear-gradient(180deg, #000, transparent 75%);
    pointer-events: none;
}
:root[data-theme="light"] .sidebar::before { filter: invert(1); opacity: .7; }

.brand { position: relative; display: flex; align-items: center; gap: 12px; padding: 2px 6px; }
.brand-mark { width: 44px; height: 44px; flex: none; filter: drop-shadow(0 6px 14px rgba(236, 79, 131, .45)); transition: transform .6s var(--ease-spring); }
.brand:hover .brand-mark { transform: rotate(-20deg) scale(1.08); }
.brand-text { display: grid; gap: 3px; min-width: 0; }
.brand-text .display { font-size: 16px; font-weight: 800; white-space: nowrap; }
.brand-text b {
    background: var(--fire-gradient);
    -webkit-background-clip: text; background-clip: text;
    color: transparent;
}
.brand-text small { color: var(--text-faint); font-weight: 700; font-size: 11.5px; display: flex; align-items: center; gap: 6px; }

.nav { position: relative; display: grid; gap: 4px; }
.nav-indicator {
    position: absolute; left: 0; right: 0; top: 0;
    height: 46px;
    border-radius: 14px;
    background: linear-gradient(100deg, color-mix(in srgb, var(--fire) 24%, transparent), color-mix(in srgb, var(--fire-2) 8%, transparent));
    border: 1px solid color-mix(in srgb, var(--fire) 30%, transparent);
    box-shadow: 0 8px 26px -10px color-mix(in srgb, var(--fire-2) 70%, transparent), inset 0 1px 0 rgba(255, 255, 255, .12);
    transition: transform .55s var(--ease-spring), opacity .3s;
    opacity: 0;
}
.nav-indicator::before {
    content: "";
    position: absolute; left: -1px; top: 11px; bottom: 11px;
    width: 3px; border-radius: 3px;
    background: var(--fire);
    box-shadow: 0 0 12px 2px var(--fire);
}
.nav-item {
    position: relative; z-index: 1;
    display: flex; align-items: center; gap: 13px;
    height: 46px; padding: 0 14px;
    border: 0; border-radius: 14px;
    background: transparent;
    text-align: left; cursor: pointer;
    font-weight: 700; font-size: 14.5px;
    color: var(--text-muted);
    transition: color .25s;
}
.nav-item:hover { color: var(--text); }
.nav-item.active { color: var(--text); }
.nav-icon { font-size: 19px; transition: transform .4s var(--ease-spring), color .25s; }
.nav-item:hover .nav-icon { transform: scale(1.12) rotate(-6deg); }
.nav-item.active .nav-icon { color: var(--fire); }

.live-card {
    position: relative;
    margin-top: auto;
    padding: 16px;
    border-radius: 18px;
    background: linear-gradient(160deg, var(--mint-soft), transparent 70%), var(--surface-sunken);
    border: 1px solid color-mix(in srgb, var(--mint) 22%, transparent);
    overflow: hidden;
}
.live-head { display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--mint); }
.live-count { margin-top: 8px; display: flex; align-items: baseline; gap: 8px; }
.live-count b { font-size: 34px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.live-count span { color: var(--text-muted); font-weight: 700; }

.radar { position: relative; width: 10px; height: 10px; flex: none; }
.radar::before, .radar i {
    content: "";
    position: absolute; inset: 0;
    border-radius: 50%;
    background: var(--mint);
}
.radar::before { box-shadow: 0 0 10px 1px var(--mint); }
.radar i { animation: radar 2s var(--ease-out) infinite; }
@keyframes radar { 0% { transform: scale(1); opacity: .7; } 100% { transform: scale(3.4); opacity: 0; } }

.faces { display: flex; align-items: center; margin-top: 12px; min-height: 30px; }
.faces .avatar { margin-left: -8px; box-shadow: 0 0 0 2px var(--surface-solid); }
.faces .avatar:first-child { margin-left: 0; }
.faces .more { margin-left: 8px; font-size: 12px; font-weight: 800; color: var(--text-muted); }

.sidebar-footer { display: grid; gap: 4px; }
.sidebar-footer .button { justify-content: flex-start; }

.content { min-width: 0; padding: 26px 34px 60px; max-width: 1680px; width: 100%; margin: 0 auto; }

.topbar {
    position: relative;
    display: flex; align-items: flex-end; justify-content: space-between; gap: 20px;
    margin-bottom: 26px;
}
.topbar h1 { font-size: 34px; font-weight: 800; letter-spacing: -.02em; margin-top: 6px; }
.topbar-subtitle { margin: 6px 0 0; color: var(--text-muted); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.updated-at { position: absolute; right: 0; top: -12px; font-size: 11.5px; color: var(--text-faint); font-weight: 600; }
.mobile-only { display: none; }

.search-pill {
    display: inline-flex; align-items: center; gap: 10px;
    height: 44px; min-width: 300px; padding: 0 8px 0 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    -webkit-backdrop-filter: var(--blur);
    backdrop-filter: var(--blur);
    color: var(--text-faint);
    cursor: pointer;
    font-weight: 600;
    transition: border-color .2s, box-shadow .25s, color .2s;
}
.search-pill:hover { border-color: color-mix(in srgb, var(--fire) 45%, transparent); color: var(--text-muted); box-shadow: 0 0 0 4px color-mix(in srgb, var(--fire) 10%, transparent); }
.search-pill > [data-icon] { font-size: 17px; }
.search-pill-text { flex: 1; text-align: left; }

.refresh {
    position: relative;
    width: 44px; height: 44px;
    border: 1px solid var(--border); border-radius: 50%;
    background: var(--surface);
    -webkit-backdrop-filter: var(--blur);
    backdrop-filter: var(--blur);
    display: grid; place-items: center;
    cursor: pointer; font-size: 17px;
    color: var(--text-muted);
    transition: color .2s, transform .2s var(--ease-spring);
}
.refresh:hover { color: var(--fire); }
.refresh:disabled > [data-icon] { animation: spin .8s linear infinite; }
.refresh-ring { position: absolute; inset: -1px; width: calc(100% + 2px); height: calc(100% + 2px); transform: rotate(-90deg); }
.refresh-ring circle { fill: none; stroke-width: 2; stroke: transparent; }
.refresh-ring .refresh-progress {
    stroke: var(--fire);
    stroke-linecap: round;
    stroke-dasharray: 119.4;
    stroke-dashoffset: 119.4;
    filter: drop-shadow(0 0 4px var(--fire));
}
.refresh-ring.running .refresh-progress { animation: countdown var(--refresh-ms, 15s) linear forwards; }
@keyframes countdown { from { stroke-dashoffset: 119.4; } to { stroke-dashoffset: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* minmax(0, 1fr): иначе колонка сетки растягивается по ширине таблицы игроков,
   и вся страница уезжает вбок вместо прокрутки внутри таблицы. */
.view { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }

/* Появление карточек лесенкой — только при открытии раздела, не при автообновлении. */
.view.fresh .reveal { animation: reveal .8s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes reveal { from { opacity: 0; transform: translateY(22px) scale(.985); filter: blur(4px); } }

/* ------------------------------------------------------------------ карточки */

.card {
    border-radius: var(--radius-lg);
    padding: 22px;
    min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.card-head h2 { font-size: 16px; font-weight: 800; letter-spacing: -.01em; display: flex; align-items: center; gap: 9px; }
.card-head h2 svg.icon { color: var(--fire); font-size: 18px; }
.card-head .hint { font-size: 12px; color: var(--text-faint); font-weight: 600; }
.card-tools { display: flex; align-items: center; gap: 8px; }

.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 20px; }
.span-12 { grid-column: span 12; }
.span-8 { grid-column: span 8; }
.span-6 { grid-column: span 6; }
.span-4 { grid-column: span 4; }

/* ------------------------------------------------------------------ обзор: шапка с костром */

.hero {
    position: relative;
    min-height: 318px;
    padding: 32px 34px;
    border-radius: var(--radius-xl);
    overflow: hidden;
    display: flex; flex-direction: column; justify-content: space-between; gap: 22px;
}
.hero-art {
    position: absolute; top: 0; right: 0; bottom: 0;
    aspect-ratio: 940 / 780;
    max-width: 72%;
    background: url("assets/camp-hero.webp") center / cover no-repeat;
    -webkit-mask: linear-gradient(90deg, transparent 0%, #000 42%);
    mask: linear-gradient(90deg, transparent 0%, #000 42%);
    pointer-events: none;
}
.hero-art::after {
    content: "";
    position: absolute; inset: 0;
    background: radial-gradient(circle at 51% 66%, rgba(255, 170, 70, .28), transparent 34%);
    mix-blend-mode: screen;
    animation: flicker 3s infinite;
}
:root[data-theme="light"] .hero-art { opacity: .95; }
.hero-scrim {
    position: absolute; inset: 0;
    z-index: 1;
    background: linear-gradient(90deg, color-mix(in srgb, var(--surface-solid) 82%, transparent) 0%, color-mix(in srgb, var(--surface-solid) 55%, transparent) 34%, transparent 62%);
    pointer-events: none;
}
.hero-content { position: relative; z-index: 2; max-width: min(480px, 54%); }
.hero-figure { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-top: 14px; }
.hero-number {
    font-size: 84px; font-weight: 800; letter-spacing: -.045em; line-height: .9;
    background: linear-gradient(180deg, var(--text) 30%, color-mix(in srgb, var(--fire) 80%, var(--text)));
    -webkit-background-clip: text; background-clip: text;
    color: transparent;
    filter: drop-shadow(0 10px 30px color-mix(in srgb, var(--fire) 30%, transparent));
}
.hero-label { display: grid; gap: 6px; }
.hero-label b { font-size: 18px; font-weight: 800; display: flex; align-items: center; gap: 10px; }
.hero-label span { color: var(--text-muted); font-weight: 600; text-shadow: 0 1px 12px var(--surface-solid); }
.hero-chips { position: relative; z-index: 2; display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    font-weight: 700; font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
}
.chip b { color: var(--text); font-size: 14px; }
.hero .chip { background: var(--surface-strong); border-color: var(--border-strong); }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--fire)); box-shadow: 0 0 10px var(--c, var(--fire)); }

/* ------------------------------------------------------------------ живая лента */

.feed { display: grid; gap: 4px; }
.feed-row {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
    padding: 8px 10px;
    margin: 0 -10px;
    border-radius: 14px;
    cursor: pointer;
    transition: background .2s, transform .25s var(--ease-spring);
}
.feed-row:hover { background: var(--surface-hover); transform: translateX(3px); }
.feed-name { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-sub { font-size: 12px; color: var(--text-faint); font-weight: 600; }
.feed-when { font-size: 12px; font-weight: 700; color: var(--text-muted); text-align: right; white-space: nowrap; }
.feed-when.online { color: var(--mint); }

/* ------------------------------------------------------------------ аватарки */

.avatar {
    --size: 36px;
    position: relative;
    flex: none;
    width: var(--size); height: var(--size);
    border-radius: 50%;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--wool), var(--yarn));
    color: #fff;
    font-weight: 800; font-size: calc(var(--size) * .4);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--ring, var(--border-strong)) 70%, transparent);
}
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.avatar.online::after {
    content: "";
    position: absolute; right: -1px; bottom: -1px;
    width: clamp(9px, calc(var(--size) * .26), 16px); height: clamp(9px, calc(var(--size) * .26), 16px);
    border-radius: 50%;
    background: var(--mint);
    box-shadow: 0 0 0 2px var(--surface-solid), 0 0 8px var(--mint);
}
.avatar.xs { --size: 28px; }
.avatar.sm { --size: 32px; }
.avatar.lg { --size: 56px; }

/* ------------------------------------------------------------------ KPI */

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi {
    position: relative;
    padding: 18px 18px 16px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: transform .35s var(--ease-spring);
    min-height: 162px;
    display: flex; flex-direction: column;
}
.kpi:hover { transform: translateY(-3px); }
.kpi-top { display: flex; align-items: center; gap: 11px; }
.kpi-icon {
    width: 40px; height: 40px; flex: none;
    border-radius: 13px;
    display: grid; place-items: center;
    background: color-mix(in srgb, var(--c, var(--fire)) 15%, transparent);
    border: 1px solid color-mix(in srgb, var(--c, var(--fire)) 25%, transparent);
    color: var(--c, var(--fire));
    font-size: 19px;
}
.kpi-icon img { width: 30px; height: 30px; object-fit: contain; filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .3)); transition: transform .5s var(--ease-spring); }
.kpi:hover .kpi-icon img { transform: scale(1.18) rotate(-8deg); }
.kpi-label { font-size: 12.5px; font-weight: 700; color: var(--text-muted); line-height: 1.25; }
.kpi-value { margin-top: 14px; font-size: 34px; font-weight: 800; letter-spacing: -.035em; line-height: 1; }
.kpi-sub { margin-top: 6px; font-size: 12px; color: var(--text-faint); font-weight: 600; }
.kpi-trend { margin-top: auto; padding-top: 10px; position: relative; height: 44px; }
.kpi-trend svg { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 34px; overflow: visible; }
.kpi-trend .spark-dot {
    position: absolute; right: -4px;
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--c);
    box-shadow: 0 0 0 2px var(--surface-solid), 0 0 10px var(--c);
    transform: translateY(-50%);
}
.meter { margin-top: auto; padding-top: 14px; }
.meter-track { height: 8px; border-radius: 999px; background: color-mix(in srgb, var(--c, var(--fire)) 16%, transparent); overflow: hidden; }
.meter-fill {
    height: 100%; border-radius: 999px;
    background: linear-gradient(90deg, color-mix(in srgb, var(--c, var(--fire)) 70%, transparent), var(--c, var(--fire)));
    box-shadow: 0 0 14px color-mix(in srgb, var(--c, var(--fire)) 60%, transparent);
    transform-origin: left;
    animation: meter 1.4s .2s var(--ease-out) both;
}
.view:not(.fresh) .meter-fill { animation: none; }
@keyframes meter { from { transform: scaleX(0); } }
.meter-caption { display: flex; justify-content: space-between; margin-top: 7px; font-size: 11.5px; color: var(--text-faint); font-weight: 700; }

/* ------------------------------------------------------------------ графики */

.chart-host { position: relative; width: 100%; min-height: 220px; }
.chart { display: block; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis-label { fill: var(--text-faint); font-size: 11px; font-weight: 600; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .value-label { fill: var(--text); font-size: 11.5px; font-weight: 800; font-family: var(--font); }
.chart .line { fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart .line.glow { filter: drop-shadow(0 0 6px var(--glow)); }
.chart.animate .line { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw 1.6s var(--ease-out) forwards; }
.chart.animate .area { animation: fade-in 1.2s .4s ease both; }
.chart.animate .end-dot { animation: pop .5s 1.3s var(--ease-spring) both; }
.chart .end-halo { animation: halo 2.2s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop { from { transform: scale(0); } }
@keyframes halo { 0% { transform: scale(1); opacity: .55; } 100% { transform: scale(3); opacity: 0; } }
.chart .crosshair { stroke: var(--text-faint); stroke-width: 1; opacity: 0; transition: opacity .15s; shape-rendering: crispEdges; }
.chart .hover-dot { opacity: 0; transition: opacity .15s; }
.chart.hovering .crosshair, .chart.hovering .hover-dot { opacity: 1; }
.chart .hit { fill: transparent; cursor: crosshair; outline: none; }
.chart .bar { transition: filter .2s, opacity .2s; }
.chart .bar-col:hover .bar, .chart .bar-col:focus .bar { filter: brightness(1.25) drop-shadow(0 0 8px var(--glow)); }
.chart .bar-col { outline: none; cursor: default; }
.chart.animate .bar { transform-box: fill-box; transform-origin: bottom; animation: grow 1s var(--ease-out) both; animation-delay: calc(var(--i) * 28ms); }
@keyframes grow { from { transform: scaleY(0); } }

.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: -6px 0 14px; }
.legend-item { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700; color: var(--text-muted); }
.legend-item b { color: var(--text); font-weight: 800; }
.key-line { width: 16px; height: 3px; border-radius: 3px; background: var(--c); box-shadow: 0 0 8px var(--c); }
.key-rect { width: 11px; height: 11px; border-radius: 3px; background: var(--c); }

.chart-tip {
    position: fixed; z-index: 80;
    min-width: 150px;
    padding: 11px 13px;
    border-radius: 14px;
    background: var(--surface-strong);
    -webkit-backdrop-filter: var(--blur);
    backdrop-filter: var(--blur);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-lg);
    pointer-events: none;
    font-size: 12.5px;
    transform: translate(-50%, calc(-100% - 14px));
    transition: opacity .12s;
}
.chart-tip-title { font-size: 11.5px; font-weight: 700; color: var(--text-faint); margin-bottom: 6px; }
.chart-tip-row { display: flex; align-items: center; gap: 9px; }
.chart-tip-row + .chart-tip-row { margin-top: 4px; }
.chart-tip-row b { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 34px; }
.chart-tip-row span { color: var(--text-muted); font-weight: 600; }

.donut-wrap { display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 22px; }
.donut { position: relative; width: 190px; height: 190px; }
.donut svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.donut .seg { fill: none; stroke-width: 20; transition: stroke-width .3s var(--ease-spring), filter .3s; cursor: default; outline: none; }
.donut .seg:hover, .donut .seg:focus { stroke-width: 26; filter: drop-shadow(0 0 10px var(--glow)); }
.donut.animate .seg { animation: donut 1.4s var(--ease-out) both; animation-delay: calc(var(--i) * 120ms); }
@keyframes donut { from { stroke-dasharray: 0 999; } }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut-center b { font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.donut-center span { font-size: 12px; color: var(--text-faint); font-weight: 700; margin-top: 4px; }
.donut-legend { display: grid; gap: 10px; width: 100%; }
.donut-legend-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto auto; align-items: center; gap: 10px; font-weight: 700; }
.donut-legend-row .pct { color: var(--text-faint); font-size: 12px; min-width: 38px; text-align: right; font-variant-numeric: tabular-nums; }
.donut-legend-row .cnt { font-variant-numeric: tabular-nums; }

.mini-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini-table th, .mini-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.mini-table td.right, .mini-table th.right { text-align: right; font-variant-numeric: tabular-nums; }
.mini-table th { color: var(--text-faint); font-size: 11.5px; font-weight: 700; }
.chart-table-wrap { max-height: 260px; overflow: auto; }

.wins-card { display: grid; gap: 16px; }
.wins-big { display: flex; align-items: baseline; gap: 10px; }
.wins-big b { font-size: 56px; font-weight: 800; letter-spacing: -.04em; line-height: 1; }
.wins-big span { color: var(--text-muted); font-weight: 700; }
.split-bar { display: flex; gap: 2px; height: 14px; border-radius: 999px; overflow: hidden; }
.split-bar i { display: block; height: 100%; transform-origin: left; animation: meter 1.4s var(--ease-out) both; }
.view:not(.fresh) .split-bar i { animation: none; }
.split-legend { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; font-weight: 700; color: var(--text-muted); }
.split-legend b { color: var(--text); font-size: 15px; }
.stat-lines { display: grid; gap: 10px; padding-top: 6px; border-top: 1px solid var(--border); }
.stat-line { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 700; color: var(--text-muted); }
.stat-line b { color: var(--text); font-size: 15px; }
.stat-line span { display: inline-flex; align-items: center; gap: 8px; }
.stat-line img { width: 22px; height: 22px; object-fit: contain; }

.empty {
    display: grid; justify-items: center; gap: 10px;
    padding: 34px 16px;
    text-align: center;
    color: var(--text-faint);
    font-weight: 600;
}
.empty img { width: 84px; height: 84px; object-fit: contain; opacity: .9; animation: bob 5s ease-in-out infinite; }

/* ------------------------------------------------------------------ панель инструментов */

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.toolbar .spacer { flex: 1; }
.search-box { position: relative; flex: 1 1 320px; max-width: 480px; }
.search-box > svg.icon { position: absolute; z-index: 1; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-faint); font-size: 17px; pointer-events: none; }
.search-box input { height: 46px; padding-left: 42px; border-radius: 14px; background: var(--surface); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
.count-chip { font-weight: 700; color: var(--text-muted); }
.count-chip b { color: var(--text); }

.segmented {
    position: relative;
    display: inline-flex;
    padding: 4px;
    border-radius: 14px;
    background: var(--surface);
    -webkit-backdrop-filter: var(--blur);
    backdrop-filter: var(--blur);
    border: 1px solid var(--border);
}
.segmented-thumb {
    position: absolute; top: 4px; bottom: 4px; left: 0;
    border-radius: 10px;
    background: var(--fire-gradient);
    box-shadow: 0 6px 18px -6px color-mix(in srgb, var(--fire-2) 80%, transparent);
    transition: transform .45s var(--ease-spring), width .45s var(--ease-spring);
}
.segmented button {
    position: relative; z-index: 1;
    display: inline-flex; align-items: center; gap: 7px;
    height: 36px; padding: 0 15px;
    border: 0; border-radius: 10px;
    background: transparent;
    font-weight: 800; font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    transition: color .3s;
}
.segmented button.active { color: var(--on-fire); }
.segmented:not(.ready) .segmented-thumb { opacity: 0; }
.segmented:not(.ready) button.active { background: var(--fire-gradient); }
.segmented button svg.icon { font-size: 15px; }

/* ------------------------------------------------------------------ таблица */

.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-lg);
}
table.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th, .table td { padding: 12px 14px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--border); }
.table th {
    position: sticky; top: 0; z-index: 1;
    background: color-mix(in srgb, var(--surface-solid) 80%, transparent);
    -webkit-backdrop-filter: var(--blur);
    backdrop-filter: var(--blur);
    font-size: 11.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
    color: var(--text-faint);
    user-select: none;
}
.table th.sortable { cursor: pointer; transition: color .2s; }
.table th.sortable:hover { color: var(--text); }
.table th.sorted { color: var(--fire); }
.table th.sorted::after { content: " ↓"; }
.table th.sorted.asc::after { content: " ↑"; }
.table td.right, .table th.right { text-align: right; }
.table td.num { font-variant-numeric: tabular-nums; font-weight: 700; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .2s; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--surface-hover); }
.table tbody tr.clickable:hover .player-name { color: var(--fire); }
.view.fresh .table tbody tr { animation: row-in .55s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 18ms); }
@keyframes row-in { from { opacity: 0; transform: translateY(8px); } }

.player-cell { display: flex; align-items: center; gap: 12px; }
.player-name { font-weight: 800; transition: color .2s; }
.player-id { font-size: 11.5px; color: var(--text-faint); font-weight: 600; max-width: 300px; overflow: hidden; text-overflow: ellipsis; }

.pill {
    display: inline-flex; align-items: center; gap: 6px;
    height: 26px; padding: 0 10px;
    border-radius: 999px;
    font-size: 12px; font-weight: 800;
    background: color-mix(in srgb, var(--c, var(--text-faint)) 14%, transparent);
    color: var(--c, var(--text-muted));
    border: 1px solid color-mix(in srgb, var(--c, var(--text-faint)) 24%, transparent);
    white-space: nowrap;
}
.pill img { width: 16px; height: 16px; object-fit: contain; }
.pill.fire { --c: var(--fire); }
.pill.mint { --c: var(--mint); }
.pill.wool { --c: var(--wool); }
.pill.sky { --c: var(--sky); }
.pill.carrot { --c: var(--carrot); }
.pill.danger { --c: var(--danger); }
.pill.yarn { --c: var(--yarn); }

.with-icon { display: inline-flex; align-items: center; gap: 7px; }
.with-icon img { width: 20px; height: 20px; object-fit: contain; }
.vip-mark { height: 22px; width: auto; filter: drop-shadow(0 2px 6px rgba(255, 180, 60, .45)); }
.boosters { display: inline-flex; gap: 10px; }
.boosters span { display: inline-flex; align-items: center; gap: 4px; font-weight: 800; font-variant-numeric: tabular-nums; }
.boosters img { width: 22px; height: 22px; object-fit: contain; }
.wl { display: grid; gap: 5px; justify-items: end; }
.wl-bar { width: 70px; height: 4px; border-radius: 4px; background: color-mix(in srgb, var(--danger) 35%, transparent); overflow: hidden; }
.wl-bar i { display: block; height: 100%; background: var(--mint); }

.pager { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 6px; color: var(--text-muted); font-weight: 700; }
.pager-pages { display: flex; gap: 4px; }
.pager-pages button {
    min-width: 36px; height: 36px; padding: 0 8px;
    border: 1px solid transparent; border-radius: 10px;
    background: transparent;
    font-weight: 800; color: var(--text-muted); cursor: pointer;
    transition: background .2s, color .2s;
}
.pager-pages button:hover { background: var(--surface-hover); color: var(--text); }
.pager-pages button.active { background: var(--fire-gradient); color: var(--on-fire); }
.pager-pages .gap { min-width: 20px; display: grid; place-items: center; color: var(--text-faint); }

/* ------------------------------------------------------------------ игроки карточками */

.player-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.player-card {
    position: relative;
    padding: 20px 18px 16px;
    border-radius: var(--radius-lg);
    cursor: pointer;
    display: grid; justify-items: center; gap: 10px;
    text-align: center;
    overflow: hidden;
    transition: transform .4s var(--ease-spring);
}
.player-card:hover { transform: translateY(-5px); }
.player-card .avatar { --size: 76px; }
.player-card .avatar img { transition: transform .5s var(--ease-spring); }
.player-card:hover .avatar img { transform: scale(1.08) rotate(-3deg); }
.player-card::marker { content: none; }
.player-card-glow {
    position: absolute; left: 50%; top: -60px;
    width: 220px; height: 160px;
    transform: translateX(-50%);
    background: radial-gradient(closest-side, color-mix(in srgb, var(--ring, var(--fire)) 40%, transparent), transparent);
    pointer-events: none;
    opacity: .7;
}
.player-card-name { font-weight: 800; font-size: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-card-meta { font-size: 12px; color: var(--text-faint); font-weight: 600; }
.player-card-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; gap: 6px; margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--border); }
.player-card-stats div { display: grid; gap: 2px; }
.player-card-stats b { font-size: 15px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.player-card-stats b img { width: 16px; height: 16px; object-fit: contain; }
.player-card-stats span { font-size: 11px; color: var(--text-faint); font-weight: 700; }
.player-card .vip-corner { position: absolute; top: 12px; right: 12px; height: 22px; }
.view.fresh .player-card { animation: reveal .6s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 25ms); }

/* ------------------------------------------------------------------ рейтинг */

.countdown { display: inline-flex; align-items: center; gap: 6px; }
.countdown-unit { display: grid; justify-items: center; min-width: 50px; padding: 8px 8px 6px; border-radius: 12px; background: var(--surface-sunken); border: 1px solid var(--border); }
.countdown-unit b { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.countdown-unit span { font-size: 10px; font-weight: 800; color: var(--text-faint); letter-spacing: .06em; text-transform: uppercase; margin-top: 4px; }
.countdown-sep { font-weight: 800; color: var(--text-faint); }

.podium-stage {
    position: relative;
    padding: 34px 20px 0;
    border-radius: var(--radius-xl);
    overflow: hidden;
}
.podium-stage::before {
    content: "";
    position: absolute; left: 50%; top: -120px;
    width: 640px; height: 420px;
    transform: translateX(-50%);
    background: radial-gradient(closest-side, color-mix(in srgb, var(--gold) 28%, transparent), transparent);
    pointer-events: none;
}
.podium { position: relative; display: grid; grid-template-columns: repeat(3, minmax(0, 220px)); justify-content: center; align-items: end; gap: 18px; }
.podium-place { display: grid; justify-items: center; gap: 10px; cursor: pointer; text-align: center; min-width: 0; }
.podium-place .avatar { --size: 96px; box-shadow: 0 0 0 4px var(--medal), 0 0 34px -2px var(--medal); transition: transform .5s var(--ease-spring); }
.podium-place:hover .avatar { transform: translateY(-6px) scale(1.04); }
.podium-place.first .avatar { --size: 124px; }
.podium-crown {
    position: absolute; left: 50%; top: -34px;
    width: 52px; height: 40px;
    transform: translateX(-50%) rotate(-8deg);
    filter: drop-shadow(0 4px 12px rgba(255, 190, 60, .7));
    animation: crown 3.2s ease-in-out infinite;
}
@keyframes crown { 0%, 100% { transform: translateX(-50%) rotate(-8deg) translateY(0); } 50% { transform: translateX(-50%) rotate(4deg) translateY(-5px); } }
.podium-avatar { position: relative; }
.podium-name { font-weight: 800; font-size: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-score { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: 18px; }
.podium-score img { width: 20px; height: 26px; object-fit: contain; }
.podium-block {
    width: 100%;
    display: grid; place-items: center;
    border-radius: 18px 18px 0 0;
    background: linear-gradient(180deg, color-mix(in srgb, var(--medal) 48%, transparent), color-mix(in srgb, var(--medal) 8%, transparent));
    border: 1px solid color-mix(in srgb, var(--medal) 55%, transparent);
    border-bottom: 0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 -10px 40px -16px var(--medal);
    font-family: var(--display); font-weight: 800; font-size: 44px;
    color: color-mix(in srgb, var(--medal) 60%, #fff);
    text-shadow: 0 4px 18px var(--medal);
}
.view.fresh .podium-block { animation: podium 1s var(--ease-spring) both; transform-origin: bottom; }
.view.fresh .podium-place.first .podium-block { animation-delay: .25s; }
.view.fresh .podium-place.third .podium-block { animation-delay: .1s; }
@keyframes podium { from { transform: scaleY(0); } }
.podium-place.first { --medal: #ffc93c; }
.podium-place.second { --medal: #c3cfe2; }
.podium-place.third { --medal: #e0925a; }
.podium-place.first .podium-block { height: 150px; }
.podium-place.second .podium-block { height: 112px; }
.podium-place.third .podium-block { height: 86px; }
.sparkle {
    position: absolute;
    width: var(--s, 22px);
    pointer-events: none;
    animation: twinkle var(--d, 2.4s) ease-in-out infinite;
    animation-delay: var(--delay, 0s);
    filter: drop-shadow(0 0 8px rgba(255, 220, 120, .8));
}
@keyframes twinkle { 0%, 100% { opacity: 0; transform: scale(.3) rotate(0deg); } 50% { opacity: 1; transform: scale(1) rotate(45deg); } }

.board-list { display: grid; gap: 8px; }
.board-row {
    display: grid; grid-template-columns: 54px auto minmax(0, 1fr) minmax(120px, 30%) auto; align-items: center; gap: 14px;
    padding: 10px 16px;
    border-radius: 16px;
    cursor: pointer;
    transition: transform .3s var(--ease-spring), background .2s;
}
.board-row:hover { transform: translateX(4px); background: color-mix(in srgb, var(--surface-strong) 70%, transparent); }
.board-rank { font-family: var(--display); font-weight: 800; font-size: 17px; color: var(--text-faint); text-align: center; }
.board-bar { height: 8px; border-radius: 999px; background: color-mix(in srgb, var(--s1) 14%, transparent); overflow: hidden; }
.board-bar i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, color-mix(in srgb, var(--s1) 60%, transparent), var(--s1)); transform-origin: left; }
.view.fresh .board-bar i { animation: meter 1.2s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 30ms + .3s); }
.board-score { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 92px; justify-content: flex-end; }
.board-score img { width: 16px; height: 21px; object-fit: contain; }
.view.fresh .board-row { animation: row-in .6s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 30ms + .2s); }

/* ------------------------------------------------------------------ журнал */

.timeline { position: relative; display: grid; gap: 26px; }
.day-group { display: grid; gap: 12px; }
.day-label {
    position: sticky; top: 12px; z-index: 2;
    justify-self: start;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
    color: var(--fire);
    background: var(--surface-strong);
    -webkit-backdrop-filter: var(--blur);
    backdrop-filter: var(--blur);
    border: 1px solid color-mix(in srgb, var(--fire) 30%, transparent);
}
.events { position: relative; display: grid; gap: 10px; padding-left: 94px; }
/* Нитка через весь день — пунктир «стежками». */
.events::before {
    content: "";
    position: absolute; left: 67px; top: 8px; bottom: 8px;
    width: 2px;
    background: repeating-linear-gradient(180deg, var(--yarn) 0 8px, transparent 8px 13px);
    opacity: .55;
    border-radius: 2px;
}
.event { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 16px; padding: 14px 18px; border-radius: 18px; align-items: start; }
.event-time { position: absolute; left: -94px; top: 20px; width: 42px; text-align: right; font-size: 12px; font-weight: 800; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.event-node {
    position: absolute; left: -44px; top: 12px;
    width: 34px; height: 34px;
    border-radius: 12px;
    display: grid; place-items: center;
    background: color-mix(in srgb, var(--c) 18%, var(--surface-solid));
    border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
    color: var(--c);
    font-size: 16px;
    box-shadow: 0 0 18px -4px var(--c);
}
.event-node img { width: 22px; height: 22px; object-fit: contain; }
.event-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; font-weight: 800; }
.event-summary { color: var(--text-muted); font-weight: 600; overflow-wrap: anywhere; }
.event-meta { grid-column: 1 / -1; font-size: 11.5px; color: var(--text-faint); }
.player-link {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 2px 10px 2px 3px;
    border-radius: 999px;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    color: var(--text);
    font-weight: 800; font-size: 12.5px;
    cursor: pointer;
    transition: border-color .2s, color .2s;
}
.player-link:hover { border-color: var(--fire); color: var(--fire); text-decoration: none; }
.player-link .avatar { --size: 20px; font-size: 9px; box-shadow: none; }
.view.fresh .event { animation: row-in .6s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 35ms); }

/* ------------------------------------------------------------------ карточка игрока */

.drawer-backdrop {
    position: fixed; inset: 0;
    background: rgba(6, 4, 16, .5);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    z-index: 30;
    animation: fade-in .3s ease;
}
:root[data-theme="light"] .drawer-backdrop { background: rgba(60, 40, 20, .2); }
.drawer {
    position: fixed; top: 12px; right: 12px; bottom: 12px;
    width: min(780px, calc(100% - 24px));
    display: flex; flex-direction: column;
    background: var(--surface-strong);
    -webkit-backdrop-filter: blur(30px) saturate(160%);
    backdrop-filter: blur(30px) saturate(160%);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    z-index: 31;
    overflow: hidden;
    animation: drawer-in .6s var(--ease-out);
}
@keyframes drawer-in { from { transform: translateX(60px); opacity: 0; } }
.drawer-close { position: absolute; top: 16px; right: 16px; z-index: 5; }
.drawer-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; }

.p-hero {
    position: relative;
    padding: 30px 30px 22px;
    display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 22px;
    overflow: hidden;
}
.p-hero-bg {
    position: absolute; inset: -40px;
    background-image: var(--avatar-url);
    background-size: cover; background-position: center;
    filter: blur(50px) saturate(1.6);
    opacity: .45;
    pointer-events: none;
}
.p-hero-bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 30%, var(--surface-strong) 95%); }
.p-avatar { position: relative; width: 112px; height: 112px; }
.p-avatar .avatar { --size: 112px; position: relative; z-index: 1; box-shadow: 0 16px 40px -10px rgba(0, 0, 0, .6); font-size: 44px; }
.p-avatar-ring {
    position: absolute; inset: -6px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, var(--ring, var(--fire)), transparent 30%, var(--ring, var(--fire)) 55%, transparent 80%, var(--ring, var(--fire)));
    animation: spin 6s linear infinite;
    -webkit-mask: radial-gradient(closest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
    mask: radial-gradient(closest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
    filter: drop-shadow(0 0 8px var(--ring, var(--fire)));
}
.p-info { position: relative; min-width: 0; display: grid; gap: 8px; padding-right: 40px; }
.p-name { font-family: var(--display); font-weight: 800; font-size: 28px; line-height: 1.1; overflow-wrap: anywhere; }
.p-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.tabs {
    position: sticky; top: 0; z-index: 4;
    display: flex; gap: 2px;
    padding: 8px 22px 0;
    background: color-mix(in srgb, var(--surface-strong) 85%, transparent);
    -webkit-backdrop-filter: var(--blur);
    backdrop-filter: var(--blur);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    scrollbar-width: none;
}
.tab {
    position: relative;
    display: inline-flex; align-items: center; gap: 7px;
    height: 44px; padding: 0 14px;
    border: 0; background: transparent;
    font-weight: 800; font-size: 13.5px;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: color .2s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); }
.tab.active::after {
    content: "";
    position: absolute; left: 12px; right: 12px; bottom: -1px;
    height: 3px; border-radius: 3px 3px 0 0;
    background: var(--fire-gradient);
    box-shadow: 0 0 12px var(--fire);
    animation: tab-in .4s var(--ease-spring);
}
.tab.danger-tab.active::after { background: var(--danger); box-shadow: 0 0 12px var(--danger); }
.tab.danger-tab.active { color: var(--danger); }
@keyframes tab-in { from { transform: scaleX(0); } }
.tab svg.icon { font-size: 15px; }
.tab-panel { display: grid; gap: 16px; padding: 22px 26px 34px; align-content: start; animation: panel-in .45s var(--ease-out); }
@keyframes panel-in { from { opacity: 0; transform: translateY(10px); } }

.panel { padding: 20px; border-radius: var(--radius); background: var(--surface-sunken); border: 1px solid var(--border); }
.panel .card-head { margin-bottom: 14px; }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tile {
    position: relative;
    padding: 14px 14px 13px;
    border-radius: 16px;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: transform .3s var(--ease-spring), border-color .2s;
}
.tile:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.tile-label { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; color: var(--text-muted); }
.tile-label img { width: 20px; height: 20px; object-fit: contain; }
.tile-label svg.icon { color: var(--c, var(--fire)); font-size: 15px; }
.tile-value { margin-top: 8px; font-size: 24px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.tile-sub { margin-top: 4px; font-size: 11.5px; color: var(--text-faint); font-weight: 600; }
.streak { display: flex; gap: 5px; margin-top: 10px; }
.streak i { flex: 1; height: 8px; border-radius: 4px; background: var(--surface-hover); border: 1px solid var(--border); }
.streak i.on { background: var(--fire-gradient); border-color: transparent; box-shadow: 0 0 10px -2px var(--fire); }

.res-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.res {
    display: grid; justify-items: center; gap: 4px;
    padding: 12px 8px 10px;
    border-radius: 14px;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    text-align: center;
    transition: transform .35s var(--ease-spring);
}
.res:hover { transform: translateY(-3px); }
.res img { width: 38px; height: 38px; object-fit: contain; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .3)); transition: transform .5s var(--ease-spring); }
.res:hover img { transform: scale(1.15) rotate(-6deg); }
.res b { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.res span { font-size: 11px; color: var(--text-faint); font-weight: 700; }

.props { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 9px 14px; margin: 0; }
.props dt { color: var(--text-faint); font-weight: 700; font-size: 13px; }
.props dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-weight: 700; }

.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; }
.form-actions .grow { flex: 1; }
.inline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inline > input { flex: 1 1 180px; width: auto; }

.quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.json-view, .json-editor {
    margin: 0;
    max-height: 460px;
    overflow: auto;
    padding: 16px;
    border-radius: 14px;
    background: rgba(5, 4, 16, .55);
    border: 1px solid var(--border);
    font: 12.5px/1.6 var(--mono);
    white-space: pre;
    tab-size: 2;
}
:root[data-theme="light"] .json-view, :root[data-theme="light"] .json-editor { background: rgba(255, 255, 255, .7); }
.json-editor { width: 100%; min-height: 360px; resize: vertical; color: var(--text); }
.json-view .k { color: #9ec5ff; }
.json-view .s { color: #ffc37a; }
.json-view .n { color: #7ce3b4; }
.json-view .b { color: #ff8fb1; }
.json-view .z { color: var(--text-faint); }
:root[data-theme="light"] .json-view .k { color: #2459a8; }
:root[data-theme="light"] .json-view .s { color: #a35a06; }
:root[data-theme="light"] .json-view .n { color: #0d7f53; }
:root[data-theme="light"] .json-view .b { color: #b72d62; }

.notice {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 14px 16px;
    border-radius: 16px;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
}
.notice svg.icon { font-size: 18px; flex: none; margin-top: 1px; }
.notice.warn { background: var(--carrot-soft); color: var(--carrot); border-color: color-mix(in srgb, var(--carrot) 30%, transparent); }

.danger-zone {
    padding: 22px;
    border-radius: var(--radius);
    background: linear-gradient(160deg, var(--danger-soft), transparent 70%), var(--surface-sunken);
    border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
    display: grid; gap: 14px;
}
.danger-zone h3 { color: var(--danger); font-size: 17px; display: flex; align-items: center; gap: 9px; }

/* Кнопка «держать, чтобы удалить»: заливка растёт, пока кнопку держат. */
.hold {
    position: relative;
    height: 50px;
    border: 1px solid color-mix(in srgb, var(--danger) 50%, transparent);
    border-radius: 14px;
    background: var(--danger-soft);
    color: var(--danger);
    font-weight: 800; font-size: 14px;
    cursor: pointer;
    overflow: hidden;
    user-select: none;
    touch-action: none;
}
.hold:disabled { opacity: .45; cursor: not-allowed; }
.hold-fill { position: absolute; inset: 0; background: linear-gradient(90deg, #ff4d63, #ff7a45); transform-origin: left; transform: scaleX(var(--p, 0)); }
.hold:not(.holding) .hold-fill { transition: transform .35s var(--ease-out); }
.hold-label { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 8px; }
.hold.holding .hold-label { color: #fff; }

/* ------------------------------------------------------------------ окна: команды и подтверждения */

.palette, .dialog {
    position: fixed; inset: 0;
    z-index: 60;
    display: grid;
    align-items: start;
    justify-items: center;
    padding: 12vh 16px 16px;
    background: rgba(6, 4, 16, .45);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    animation: fade-in .2s ease;
}
:root[data-theme="light"] .palette, :root[data-theme="light"] .dialog { background: rgba(60, 40, 20, .18); }
.dialog { align-items: center; padding-top: 16px; z-index: 70; }
.palette-box, .dialog-box {
    width: min(640px, 100%);
    border-radius: var(--radius-lg);
    background: var(--surface-strong);
    -webkit-backdrop-filter: blur(30px) saturate(160%);
    backdrop-filter: blur(30px) saturate(160%);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255, 255, 255, .03);
    overflow: hidden;
    animation: pop-in .35s var(--ease-spring);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-10px) scale(.97); } }
.palette-input { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--border); }
.palette-input > svg.icon { font-size: 20px; color: var(--fire); }
.palette-input input { height: 62px; border: 0; background: transparent; padding: 0; font-size: 17px; box-shadow: none; }
.palette-input input:focus { box-shadow: none; background: transparent; }
.palette-list { max-height: 420px; overflow-y: auto; padding: 8px; }
.palette-group { padding: 10px 12px 6px; font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--text-faint); }
.palette-item {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border: 0; border-radius: 12px;
    background: transparent;
    text-align: left;
    cursor: pointer;
}
.palette-item.active { background: linear-gradient(100deg, color-mix(in srgb, var(--fire) 20%, transparent), color-mix(in srgb, var(--fire) 4%, transparent)); }
.palette-item-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-hover); color: var(--text-muted); font-size: 17px; }
.palette-item.active .palette-item-icon { color: var(--fire); }
.palette-item-title { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item-sub { font-size: 12px; color: var(--text-faint); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-hint { color: var(--text-faint); font-size: 12px; font-weight: 700; }
.palette-foot { display: flex; gap: 16px; padding: 10px 18px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-faint); font-weight: 600; }
.palette-foot span { display: inline-flex; align-items: center; gap: 6px; }
.palette-empty { padding: 26px; text-align: center; color: var(--text-faint); font-weight: 600; }

.dialog-box { width: min(460px, 100%); padding: 26px; display: grid; gap: 14px; }
.dialog-icon { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; font-size: 26px; background: var(--fire-soft); color: var(--fire); }
.dialog-icon.danger { background: var(--danger-soft); color: var(--danger); }
.dialog-box h3 { font-size: 20px; font-weight: 800; }
.dialog-box p { margin: 0; color: var(--text-muted); font-weight: 600; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ------------------------------------------------------------------ тосты и эффекты */

.toasts { position: fixed; right: 22px; bottom: 22px; z-index: 90; display: grid; gap: 10px; justify-items: end; pointer-events: none; }
.toast {
    position: relative;
    display: flex; align-items: center; gap: 12px;
    min-width: 260px; max-width: min(440px, calc(100vw - 44px));
    padding: 13px 16px 15px;
    border-radius: 16px;
    background: var(--surface-strong);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    backdrop-filter: blur(24px) saturate(160%);
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow-lg);
    font-weight: 700;
    overflow: hidden;
    pointer-events: auto;
    animation: toast-in .5s var(--ease-spring);
}
.toast.out { animation: toast-out .35s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(40px) scale(.95); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(40px) scale(.95); } }
.toast-icon { width: 30px; height: 30px; flex: none; border-radius: 10px; display: grid; place-items: center; background: var(--mint-soft); color: var(--mint); font-size: 16px; }
.toast.error .toast-icon { background: var(--danger-soft); color: var(--danger); }
.toast-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--mint); transform-origin: left; animation: toast-bar var(--t, 2.6s) linear forwards; }
.toast.error .toast-bar { background: var(--danger); }
@keyframes toast-bar { to { transform: scaleX(0); } }

.fx { position: fixed; inset: 0; pointer-events: none; z-index: 95; overflow: hidden; }
.fx img { position: absolute; width: 30px; height: auto; will-change: transform, opacity; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .35)); }

.skeleton {
    border-radius: var(--radius-lg);
    background: linear-gradient(100deg, var(--surface) 30%, color-mix(in srgb, var(--surface) 60%, var(--text) 6%) 50%, var(--surface) 70%);
    background-size: 200% 100%;
    animation: skeleton 1.4s ease infinite;
    min-height: 120px;
}
@keyframes skeleton { from { background-position: 100% 0; } to { background-position: -100% 0; } }

.drawer-loading { display: grid; place-items: center; gap: 14px; padding: 120px 20px; color: var(--text-faint); font-weight: 700; }
.drawer-loading svg { width: 64px; height: 64px; animation: spin 1.4s linear infinite; }

/* ------------------------------------------------------------------ узкие экраны */

@media (max-width: 1360px) {
    .span-8, .span-4 { grid-column: span 12; }
    .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .grid > .half-lg { grid-column: span 6; }
}

@media (max-width: 1100px) {
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .search-pill { min-width: 0; }
    .search-pill-text { display: none; }
    .grid > .half-lg { grid-column: span 12; }
}

@media (max-width: 860px) {
    .login-stage { grid-template-columns: minmax(0, 420px); gap: 0; }
    .portal { position: fixed; inset: 0; border-radius: 0; aspect-ratio: auto; z-index: -1; box-shadow: none; opacity: .5; }
    .portal-caption { display: none; }
    .tiles, .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .board-row { grid-template-columns: 40px auto minmax(0, 1fr) auto; }
    .board-bar { display: none; }
}

@media (max-width: 760px) {
    .app { grid-template-columns: minmax(0, 1fr); padding-bottom: 86px; }
    .sidebar {
        position: fixed; left: 10px; right: 10px; bottom: 10px; top: auto;
        height: auto; margin: 0;
        flex-direction: row;
        padding: 6px;
        border-radius: 22px;
        z-index: 25;
    }
    .sidebar::before, .brand, .live-card, .sidebar-footer { display: none; }
    .nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; gap: 0; }
    .nav-item { flex-direction: column; justify-content: center; gap: 2px; height: 58px; padding: 0; font-size: 11px; }
    .nav-icon { font-size: 21px; }
    .nav-indicator { height: 58px; }
    .nav-indicator::before { left: 30%; right: 30%; top: auto; bottom: -1px; width: auto; height: 3px; }
    .mobile-only { display: inline-grid; }
    .content { padding: 18px 16px 30px; }
    .topbar { flex-direction: column; align-items: stretch; gap: 14px; margin-bottom: 18px; }
    .topbar h1 { font-size: 28px; }
    .topbar-actions { justify-content: flex-end; }
    .search-pill { flex: 1; }
    .search-pill-text { display: inline; }
    .search-pill kbd { display: none; }
    .updated-at { display: none; }
    .hero { padding: 24px 22px; min-height: 360px; justify-content: flex-start; }
    .hero-art { max-width: 100%; left: 0; aspect-ratio: auto; opacity: .45; -webkit-mask: linear-gradient(180deg, transparent, #000 60%); mask: linear-gradient(180deg, transparent, #000 60%); }
    .hero-content { max-width: 100%; }
    .hero-number { font-size: 64px; }
    .kpis { gap: 12px; }
    .kpi { min-height: 150px; padding: 15px; }
    .kpi-value { font-size: 27px; }
    .card { padding: 18px; }
    .drawer { inset: 0; width: 100%; border-radius: 0; border: 0; }
    .p-hero { grid-template-columns: 1fr; justify-items: center; text-align: center; padding-top: 40px; }
    .p-info { padding-right: 0; justify-items: center; }
    .p-chips { justify-content: center; }
    .tab-panel { padding: 18px 16px 30px; }
    .props { grid-template-columns: 1fr; gap: 2px; }
    .props dd { margin-bottom: 10px; }
    .podium { gap: 8px; }
    .podium-place .avatar { --size: 64px; }
    .podium-place.first .avatar { --size: 84px; }
    .podium-block { font-size: 30px; }
    .podium-place.first .podium-block { height: 110px; }
    .podium-place.second .podium-block { height: 82px; }
    .podium-place.third .podium-block { height: 62px; }
    .events { padding-left: 52px; }
    .events::before { left: 25px; }
    .event-time { display: none; }
    .event { grid-template-columns: 1fr; }
    .toasts { left: 16px; right: 16px; bottom: 96px; justify-items: stretch; }
    .toast { max-width: none; }
}

@media (max-width: 480px) {
    .kpis { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .tiles { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .login-card { padding: 30px 22px 22px; }
    .login-title { font-size: 31px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        animation-delay: 0s !important;
        transition-duration: .001ms !important;
    }
    .chart.animate .line { stroke-dasharray: none; stroke-dashoffset: 0; }
}

@media (forced-colors: active) {
    .glass, .card, .kpi { border: 1px solid CanvasText; }
}
