﻿:root {
    --color-bg: #f5f3ee;
    --color-surface: #ffffff;
    --color-primary: #1a56db;
    --color-primary-hover: #1648c0;
    --color-text: #111827;
    --color-text-muted: #6b7280;
    --color-border: #d1d5db;
    --color-error: #dc2626;
    --color-success: #16a34a;
    --color-diary-line: #b8d4f0;
    --color-diary-bg: #fffef0;
    --font-heading: 'Bebas Neue', 'Impact', sans-serif;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: system-ui, -apple-system, sans-serif;
    background-color: #eff4fa;
    background-image:
        repeating-linear-gradient(0deg,
            transparent, transparent 39px,
            var(--color-diary-line) 39px, var(--color-diary-line) 40px),
        repeating-linear-gradient(90deg,
            transparent, transparent 39px,
            var(--color-diary-line) 39px, var(--color-diary-line) 40px);
    color: var(--color-text);
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.container { max-width: 960px; margin: 0 auto; padding: 0 16px; }

/* ---- Header ---- */
.header {
    background: var(--color-surface);
    border-bottom: 2px solid var(--color-diary-line);
    padding: 10px 0;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 0 rgba(17, 24, 39, 0.04), 0 2px 10px rgba(17, 24, 39, 0.05);
}

.header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.logo {
    text-decoration: none;
    font-family: var(--font-heading);
    font-size: 1.8rem;
    letter-spacing: 0.04em;
    color: var(--color-text);
    line-height: 1.05;
    display: inline-flex;
    align-items: center;
    gap: 12px;
}
.logo__icon,
.logo svg.logo-flag { flex-shrink: 0; }
.logo svg.logo-flag { transform: rotate(-8deg); }
.logo__text {
    display: inline-flex;
    flex-direction: column;
    line-height: 1.05;
}
.logo__main {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    letter-spacing: 0.04em;
    line-height: 1.05;
    color: var(--color-text);
    display: block;
}
.logo__text span,
.logo__sub {
    display: block;
    font-family: system-ui, sans-serif;
    font-size: 0.6rem;
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}

.nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nav__profile {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: inherit;
    padding: 4px 12px 4px 4px;
    border-radius: 999px;
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s;
}
.nav__profile:hover { background: var(--color-bg); }
.nav__avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    flex-shrink: 0;
    overflow: hidden;
}
.nav__avatar img { width: 100%; height: 100%; object-fit: cover; }
.nav__profile-text { display: inline-flex; flex-direction: column; line-height: 1.15; }
.nav__user { font-weight: 600; }
.nav__points { color: var(--color-text-muted); font-size: 0.72rem; }
.nav__form { display: inline; }
.nav__logout { border-color: transparent; }
.nav__logout:hover { border-color: var(--color-border); }

@media (max-width: 560px) {
    .logo { font-size: 1.4rem; }
    .nav__profile-text { display: none; }
    .nav { gap: 6px; }
}

/* ---- Footer ---- */
.footer {
    flex-shrink: 0;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: 16px 0;
    margin-top: 40px;
}
.footer__inner { text-align: center; color: var(--color-text-muted); font-size: 0.8rem; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 7px 14px; border: none; border-radius: var(--radius);
    font-size: 0.875rem; font-weight: 600; cursor: pointer;
    text-decoration: none; transition: background 0.15s;
    white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--primary { background: var(--color-primary); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--color-primary-hover); }
.btn--secondary { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); }
.btn--secondary:hover { background: var(--color-bg); }
.btn--ghost { background: transparent; color: var(--color-text-muted); border: 1px solid var(--color-border); }
.btn--ghost:hover { background: rgba(0,0,0,0.05); color: var(--color-text); }
.btn--success { background: #27a26a; color: #fff; }
.btn--success:hover:not(:disabled) { background: #1f8555; }
.btn--full { width: 100%; }
.btn--lg { padding: 11px 24px; font-size: 1rem; }
.btn--sm { padding: 4px 10px; font-size: 0.8rem; }

/* ---- Main ---- */
.main { flex: 1 0 auto; padding: 32px 0; }

/* ---- Hero ---- */
.hero { text-align: center; margin-bottom: 40px; }
.hero__title {
    font-family: var(--font-heading);
    font-size: clamp(4rem, 12vw, 8rem);
    letter-spacing: 0.04em;
    line-height: 0.9;
    color: var(--color-text);
    margin-bottom: 8px;
}
.hero__tagline {
    font-family: var(--font-heading);
    font-size: clamp(1rem, 3vw, 1.6rem);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 12px;
}
.hero p {
    color: var(--color-text-muted);
    max-width: 480px;
    margin: 0 auto 20px;
    font-size: 1rem;
}
.hero--logged {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
}
.hero__actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }

/* ---- Page Title (РІРЅСѓС‚СЂРµРЅРЅРёРµ СЃС‚СЂР°РЅРёС†С‹) ---- */
.page-title { text-align: center; margin-bottom: 32px; }
.page-title__main {
    font-family: var(--font-heading);
    font-size: clamp(2rem, 6vw, 4rem);
    letter-spacing: 0.04em;
    line-height: 0.9;
    color: var(--color-text);
}
.page-title__sub {
    font-family: var(--font-heading);
    font-size: clamp(0.9rem, 2vw, 1.2rem);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-top: 6px;
}

/* ---- Auth ---- */
.auth-grid { display: flex; flex-direction: row; justify-content: center; gap: 24px; }
.auth-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
    width: 320px;
    flex-shrink: 0;
}
.auth-card h3 { margin-bottom: 18px; font-size: 1.15rem; }
@media (max-width: 600px) {
    .auth-card { width: 100%; max-width: 400px; }
}

/* ---- Forms ---- */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 0.85rem; }
.form-group input {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--color-border); border-radius: var(--radius);
    font-size: 1rem; font-family: inherit; background: #f9fafb;
    transition: border-color 0.15s;
}
.form-group input:focus { outline: none; border-color: var(--color-primary); background: #fff; }
.form-hint { display: block; margin-top: 3px; font-size: 0.72rem; color: var(--color-text-muted); }
.form-error {
    background: #fef2f2; border: 1px solid #fecaca; color: var(--color-error);
    padding: 9px 12px; border-radius: var(--radius); margin-bottom: 12px; font-size: 0.85rem;
}

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

/* ================================
   Р”РќР•Р’РќРРљ вЂ” СЃС‚РёР»Рё РЅР°СЃС‚СЂРѕРµРє
   ================================ */
.setup-diary {
    background: var(--color-diary-bg);
    border: 2px solid var(--color-diary-line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    max-width: 700px;
    margin: 0 auto 28px;
    overflow: hidden;
}

.diary-row {
    display: grid;
    grid-template-columns: 120px 1fr;
    border-bottom: 1px solid var(--color-diary-line);
}
.diary-row:last-child { border-bottom: none; }

.diary-cell--label {
    background: #f0f7ff;
    padding: 14px 16px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    border-right: 1px solid var(--color-diary-line);
    display: flex;
    align-items: center;
}

.diary-cell--value {
    padding: 10px 16px;
    display: flex;
    align-items: center;
}

.setup-options { display: flex; gap: 8px; flex-wrap: wrap; }
.setup-options--row { display: flex; gap: 8px; }

.setup-opt {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 12px; border: 1px solid var(--color-border);
    border-radius: var(--radius); cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    font-size: 0.875rem;
}
.setup-opt:hover { border-color: var(--color-primary); background: rgba(26,86,219,0.04); }
.setup-opt input { accent-color: var(--color-primary); width: 16px; height: 16px; flex-shrink: 0; }
.setup-opt__label { display: flex; flex-direction: column; gap: 1px; }
.setup-opt__label strong { font-size: 0.9rem; }
.setup-opt__label small { font-size: 0.72rem; color: var(--color-text-muted); font-weight: 400; }
.setup-opt input:checked + .setup-opt__label { color: var(--color-primary); }
.setup-opt input:checked ~ * { color: var(--color-primary); }

.setup-actions { text-align: center; margin-bottom: 32px; }

/* ---- Notebook ---- */
.notebook {
    background: var(--color-diary-bg);
    border: 2px solid var(--color-diary-line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    max-width: 700px;
    margin: 0 auto;
    overflow: hidden;
}
.notebook-empty {
    padding: 48px 24px; text-align: center; color: var(--color-text-muted);
}
.notebook-empty p { margin-bottom: 18px; font-size: 1.05rem; }

.race-entry {
    border-bottom: 1px solid var(--color-diary-line);
    padding: 14px 20px;
}
.race-entry:last-child { border-bottom: none; }
.race-entry__header {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px;
}
.race-entry__date { font-weight: 600; font-size: 0.8rem; }
.race-entry__badge {
    font-size: 0.7rem; color: var(--color-text-muted);
    background: #e8f0ff; padding: 2px 7px; border-radius: 10px;
}
.race-entry__body {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.race-entry__result { font-size: 0.85rem; color: var(--color-text-muted); }

/* ---- Match placeholder ---- */
.match-placeholder {
    max-width: 480px; margin: 0 auto; text-align: center;
    background: var(--color-surface); border-radius: var(--radius);
    padding: 40px 28px; box-shadow: var(--shadow-md); border: 1px solid var(--color-border);
}
.match-placeholder__icon { font-size: 3.5rem; margin-bottom: 12px; }
.match-placeholder h2 { font-size: 1.4rem; margin-bottom: 10px; }
.match-placeholder p { color: var(--color-text-muted); margin-bottom: 18px; line-height: 1.7; }
.match-info {
    padding: 10px; background: #f0f4ff; border-radius: var(--radius);
    margin-bottom: 22px; font-size: 0.875rem; text-align: left;
}

/* ---- Public lobbies ---- */
.public-lobbies { max-width: 700px; margin: 0 auto; }
.lobby-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 16px; background: var(--color-surface);
    border: 1px solid var(--color-border); border-radius: var(--radius); margin-bottom: 8px;
}
.text-muted { color: var(--color-text-muted); }

/* ================================
   РљРђР‘РРќР•Рў вЂ” РіР»Р°РІРЅР°СЏ Р°РІС‚РѕСЂРёР·РѕРІР°РЅРЅРѕРіРѕ
   ================================ */
.dashboard-head {
    display: flex;
    justify-content: center;
    margin-bottom: 32px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}
@media (max-width: 760px) {
    .dashboard-grid { grid-template-columns: 1fr; }
}
.dashboard-col { display: flex; flex-direction: column; gap: 24px; }

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}
.dashboard-card__title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--color-border);
}
.dashboard-card__more { margin-top: 14px; text-align: center; }

/* РџСЂРѕС„РёР»СЊ */
.profile { display: flex; gap: 16px; align-items: center; }
.profile__avatar {
    width: 64px; height: 64px; flex-shrink: 0;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-heading);
    font-size: 2rem;
    overflow: hidden;
}
.profile__avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile__name { font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; }
.profile__meta { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.profile__points { color: var(--color-primary); font-weight: 700; }
.profile__rank { color: var(--color-text-muted); font-size: 0.85rem; }
.profile__joined { font-size: 0.8rem; color: var(--color-text-muted); }

/* Р РµР№С‚РёРЅРі */
.rating-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.rating-table th {
    text-align: left; font-size: 0.72rem; text-transform: uppercase;
    color: var(--color-text-muted); padding: 6px 8px; border-bottom: 1px solid var(--color-border);
}
.rating-table th:first-child { width: 36px; }
.rating-table th:last-child { text-align: right; }
.rating-table td { padding: 7px 8px; border-bottom: 1px solid #f0f0f0; }
.rating-table td:first-child { color: var(--color-text-muted); }
.rating-table__pts { text-align: right; font-weight: 700; color: var(--color-text-muted); }
.rating-table tr.rating-row--me { background: #eef4ff; font-weight: 600; }
.rating-table tr.rating-row--me td:first-child { color: var(--color-primary); }

/* Шлемы топ-3 рейтинга (index.php) */
.r-medal { display: inline-block; vertical-align: middle; margin-right: 6px; }
.r-medal svg { display: block; width: 15px; height: 15px; }
.r-medal--gold { color: #d9a51f; }
.r-medal--silver { color: #b7bfc9; }
.r-medal--bronze { color: #b87333; }

/* ================================
   РњРђРўР§ вЂ” Canvas-РїРѕР»Рµ
   ================================ */
.match-page { max-width: none; width: 100%; }

/* РџРѕР»Рµ РЅР° РІРµСЃСЊ СЌРєСЂР°РЅ: main С‚СЏРЅРµС‚СЃСЏ, РІРЅСѓС‚СЂРё flex-РєРѕР»РѕРЅРєР°, canvas Р·Р°РЅРёРјР°РµС‚ РІСЃС‘ */
.match-main {
    display: flex;
    flex-direction: column;
    padding-top: 8px;
    padding-bottom: 8px;
}

.match-page {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.match-layout {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 1fr;
    gap: 0;
    min-height: 0;
}

/* Р Р°СЃС‚СЏРіРёРІР°РµРј РјР°С‚С‡ РЅР° РІСЃСЋ РІС‹СЃРѕС‚Сѓ: shell вЂ” flex-РєРѕР»РѕРЅРєР°, layout С‚СЏРЅРµС‚СЃСЏ */
.match-shell {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.match-board-wrap {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    box-shadow: var(--shadow-md);
    padding: 8px;
}

.canvas-frame {
    flex: 1;
    position: relative;
    width: 100%;
    min-height: 0;
}

#paper-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: #fbfaf5;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: default;
    touch-action: manipulation;
}

@media (max-width: 860px) {
    .match-main { height: auto; }
    .canvas-frame { min-height: 60vh; }
    #paper-canvas { position: relative; height: 60vh; }
    .race-info { max-width: min(240px, 55%); font-size: 0.72rem; }
}

/* ---- РњРѕРґР°Р»СЊРЅРѕРµ РѕРєРЅРѕ СЂРµР·СѓР»СЊС‚Р°С‚РѕРІ ---- */
.results-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.results-modal[hidden] { display: none; }
.results-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, 0.55);
    backdrop-filter: blur(2px);
}
.results-modal__card {
    position: relative;
    width: min(460px, 100%);
    background: var(--color-surface);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 24px;
    text-align: center;
    animation: results-pop 0.2s ease-out;
}
@keyframes results-pop {
    from { transform: scale(0.92); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.results-modal__title {
    font-family: var(--font-heading);
    font-size: 1.7rem;
    letter-spacing: 0.04em;
    margin-bottom: 18px;
}

.podium {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 12px;
    margin-bottom: 16px;
}
.podium__place {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px 8px;
    border-radius: var(--radius) var(--radius) 0 0;
    color: #fff;
}
.podium__place--you { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.podium__place--1 { height: 128px; background: #d9a520; }
.podium__place--2 { height: 96px; background: #8a97a6; }
.podium__place--3 { height: 72px; background: #b07a3e; }
.podium__medal { font-size: 1.6rem; line-height: 1; }
.podium__name { font-weight: 700; font-size: 0.9rem; line-height: 1.2; }
.podium__place-label { font-size: 0.7rem; opacity: 0.9; }

.results-modal__others {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    margin-bottom: 20px;
    min-height: 1.2em;
}

.results-modal__actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* Кнопки масштаба карты — правый нижний угол канваса */
.match-zoom {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 6;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.match-zoom__btn {
    width: 30px;
    height: 30px;
    border: 1px solid rgba(17, 24, 39, 0.2);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(3px);
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1;
    color: var(--color-text);
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.match-zoom__btn:hover:not(:disabled) { background: #fff; border-color: var(--color-primary); }
.match-zoom__btn:disabled { opacity: 0.4; cursor: default; }

/* ---- Инфопанель гонки (оверлей на канвасе) ---- */
.race-info {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 5;
    max-width: min(300px, 60%);
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(17, 24, 39, 0.16);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(3px);
    pointer-events: none;
    font-size: 0.78rem;
    line-height: 1.35;
}
.race-info__head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
}
.race-info__title {
    font-weight: 700;
    letter-spacing: 0.03em;
    white-space: nowrap;
}
.race-info__status {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    padding: 1px 8px;
    border-radius: 999px;
    background: rgba(17, 24, 39, 0.06);
    white-space: nowrap;
}
.race-info__status--running { color: #1b7f3b; background: rgba(27, 127, 59, 0.12); }
.race-info__status--picking { color: #0d5f66; background: rgba(13, 95, 102, 0.12); }
.race-info__status--finished { color: #aa2f2f; background: rgba(170, 47, 47, 0.1); }
.race-info__timer {
    margin-left: auto;
    font-size: 0.7rem;
    color: var(--color-text-muted);
    white-space: nowrap;
}
.race-info__timer strong {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    line-height: 1;
    color: #3a4a5a;
}
.race-info__timer--low { color: #aa2f2f; }
.race-info__timer--low strong { color: #aa2f2f; }
.race-info__msg { color: #3a4a5a; margin-bottom: 4px; }
.race-info__msg:empty { display: none; margin: 0; }
.race-info__players {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.race-info__player {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
    white-space: nowrap;
}
.race-info__dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
    align-self: center;
    border: 1px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 0 1px rgba(17, 24, 39, 0.25);
}
.race-info__name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
}
.race-info__player--you .race-info__name { text-decoration: underline; text-decoration-color: rgba(17,24,39,0.35); }
.race-info__turn {
    color: #1b7f3b;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    flex-shrink: 0;
}
.race-info__pstate {
    margin-left: auto;
    color: var(--color-text-muted);
    font-size: 0.72rem;
}
.race-info__player--you .race-info__pstate { font-weight: 600; color: var(--color-text); }

/* Кнопка выхода из гонки — в правом верхнем углу поля */
.match-leave {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 6;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(3px);
}

/* ================================
   Р”Р РЈР—Р¬РЇ вЂ” РєР°СЂС‚РѕС‡РєР° РЅР° РіР»Р°РІРЅРѕР№
   ================================ */
.friends-search {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.friends-search__input {
    flex: 1;
    min-width: 0;
    padding: 7px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.875rem;
}
.friends-search__input:focus { outline: 1px solid var(--color-primary); }

.friend-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 6px;
    font-size: 0.9rem;
    background: var(--color-surface);
}
.friend-row--request { background: #f2f7ff; border-color: #c9dcff; }
.friend-row__nick { font-weight: 600; }
.friends-list { margin-top: 6px; }
.friends-list__label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin: 10px 0 6px;
}
.friends-ok { color: #27a26a; font-size: 0.85rem; margin-bottom: 8px; }
.friends-search__msg { font-size: 0.85rem; }

/* ---- Р’РєР»Р°РґРєРё РІ РєР°СЂС‚РѕС‡РєРµ В«РћС‚РєСЂС‹С‚С‹Рµ Р»РѕР±Р±РёВ» ---- */
.lobby-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}
.lobby-tab {
    padding: 5px 14px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
}
.lobby-tab:hover { background: rgba(0,0,0,0.04); }
.lobby-tab--active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

/* ================================
   РџР РђР’РР›Рђ
   ================================ */
/* KABINET v2: polosa profilya, skroll, filtry */
.cab-profile { display: flex; align-items: center; gap: 16px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 20px; margin-bottom: 24px; }
.cab-profile__avatar { width: 54px; height: 54px; flex-shrink: 0; border-radius: 50%; background: var(--color-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-family: var(--font-heading); font-size: 1.6rem; overflow: hidden; }
.cab-profile__avatar img { width: 100%; height: 100%; object-fit: cover; }
.cab-profile__info { flex: 1; min-width: 0; }
.cab-profile__name { font-size: 1.25rem; font-weight: 700; margin-bottom: 6px; }
.cab-profile__meta { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 560px) {
    .cab-profile { flex-wrap: wrap; }
    .cab-profile__cta { width: 100%; }
}

.cab-profile__avatar-box { position: relative; flex-shrink: 0; }
.cab-profile__avatar { cursor: pointer; }
.cab-profile__avatar--img { overflow: hidden; }
.cab-profile__avatar--img img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.cab-profile__avatar-box::before {
    content: '✎';
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 0.7rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.cab-profile__avatar-del {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--color-error);
    color: #fff;
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cab-profile__avatar-del:hover { background: #b91c1c; }
.cab-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; background: var(--color-bg); border: 1px solid var(--color-border); font-size: 0.75rem; color: var(--color-text-muted); white-space: nowrap; }
.cab-chip--accent { background: #e8f0ff; color: var(--color-primary); font-weight: 700; }
.cab-grid { display: grid; grid-template-columns: 7fr 5fr; gap: 24px; align-items: start; }
@media (max-width: 860px) { .cab-grid { grid-template-columns: 1fr; } }
.cab-col { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.cab-card { display: flex; flex-direction: column; }
.cab-card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}
.cab-card-head .dashboard-card__title {
    margin-bottom: 6px;
    flex-shrink: 0;
}
.cab-card-head + .lobby-tabs { margin-bottom: 10px; }
.cab-count {
    font-size: 0.72rem;
    color: var(--color-text-muted);
    white-space: nowrap;
}
.cab-head-tools {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}
.cab-head-tools .cab-search { width: 150px; }
.cab-head-tools .cab-select { width: auto; }
.cab-scroll { overflow-y: auto; min-height: 120px; max-height: 460px; padding-right: 4px; scrollbar-width: thin; scrollbar-color: #c4cdd9 transparent; }
.cab-scroll--sm { max-height: 240px; }
.cab-scroll::-webkit-scrollbar { width: 6px; }
.cab-scroll::-webkit-scrollbar-track { background: transparent; }
.cab-scroll::-webkit-scrollbar-thumb { background: #c4cdd9; border-radius: 3px; }
.cab-scroll::-webkit-scrollbar-thumb:hover { background: #a8b4c4; }
.cab-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); margin-bottom: 6px; font-size: 0.88rem; }
.cab-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0 12px; }
.cab-search { flex: 1; min-width: 120px; padding: 6px 10px; border: 1px solid var(--color-border); border-radius: var(--radius); font-size: 0.82rem; }
.cab-search:focus { outline: 1px solid var(--color-primary); }
.cab-select { padding: 6px 8px; border: 1px solid var(--color-border); border-radius: var(--radius); font-size: 0.82rem; background: var(--color-surface); color: var(--color-text); }
@media (max-width: 560px) {
    .cab-card-head { margin-bottom: 10px; }
    .cab-head-tools { width: 100%; margin-left: 0; }
    .cab-head-tools .cab-search { flex: 1; width: auto; min-width: 0; }
}
.cab-pin { margin-top: 12px; padding: 8px 12px; background: #eef4ff; border: 1px solid #c9dcff; border-radius: var(--radius); font-size: 0.82rem; text-align: center; }
.cab-recent-date { font-weight: 600; font-size: 0.78rem; color: var(--color-text-muted); white-space: nowrap; }
.cab-badge { font-size: 0.68rem; color: var(--color-text-muted); background: #e8f0ff; padding: 2px 7px; border-radius: 10px; white-space: nowrap; }
.cab-recent-result { flex: 1; text-align: right; font-size: 0.85rem; color: var(--color-text-muted); }
.rules-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 0.9rem;
    line-height: 1.55;
}
.rules-list li {
    position: relative;
    padding-left: 18px;
}
.rules-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.5em;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-diary-line);
}

/* ================================
   ЛОГО-ДЕМО (logo_test.php)
   ================================ */
.logo-demo { margin-top: 10px; }
.logo-demo-item {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}
.logo-demo-text { display: inline-flex; flex-direction: column; text-align: left; }
.logo-demo-text .logo__main {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    letter-spacing: 0.04em;
    line-height: 1.05;
    color: var(--color-text);
}
.logo-demo-text .logo__sub {
    font-family: system-ui, sans-serif;
    font-size: 0.6rem;
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}
.logo-flag {
    flex-shrink: 0;
    transform: rotate(-8deg);
}
.logo-demo-item svg.logo-tape { display: block; margin-bottom: 2px; }

/* ================================
   СОЗДАНИЕ ГОНКИ (lobby.php) — карточки-секции
   ================================ */
.mk-cards { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.mk-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
}
.mk-card__title {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border);
}
.mk-card__hint { font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 0.75rem; }
.mk-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 620px) { .mk-modes { grid-template-columns: 1fr; } }
.mk-mode {
    position: relative;
    display: block;
    cursor: pointer;
}
.mk-mode input { position: absolute; opacity: 0; pointer-events: none; }
.mk-mode__box {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 14px 16px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    height: 100%;
}
.mk-mode__box:hover { border-color: #9db8ea; }
.mk-mode__name { font-weight: 700; font-size: 1rem; display: flex; align-items: center; gap: 6px; }
.mk-mode__desc { font-size: 0.75rem; color: var(--color-text-muted); }
.mk-mode input:checked + .mk-mode__box {
    border-color: var(--color-primary);
    background: #f0f5ff;
    box-shadow: 0 0 0 3px rgba(26,86,219,0.12);
}
.mk-mode input:checked + .mk-mode__box .mk-mode__name { color: var(--color-primary); }
.mk-mode__check {
    display: none;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    font-size: 0.7rem;
    align-items: center;
    justify-content: center;
    margin-left: auto;
}
.mk-mode input:checked + .mk-mode__box .mk-mode__check { display: inline-flex; }
.mk-seg { display: flex; gap: 6px; flex-wrap: wrap; }
.mk-seg__opt { position: relative; cursor: pointer; }
.mk-seg__opt input { position: absolute; opacity: 0; pointer-events: none; }
.mk-seg__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.15s;
    min-width: 44px;
}
.mk-seg__btn small { font-weight: 400; color: var(--color-text-muted); font-size: 0.72rem; }
.mk-seg__opt:hover .mk-seg__btn { border-color: var(--color-primary); }
.mk-seg__opt input:checked + .mk-seg__btn {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}
.mk-seg__opt input:checked + .mk-seg__btn small { color: rgba(255,255,255,0.8); }
.mk-start-row { display: flex; gap: 10px; align-items: center; justify-content: center; margin: 20px auto 0; }

/* ================================
   КОМНАТА ОЖИДАНИЯ ЛОББИ (lobby.php?lobby=N) — слоты за столом
   ================================ */
.room { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.room-head {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 20px; text-align: center;
}
.room-count {
    font-family: var(--font-heading); font-size: 2.6rem; line-height: 1;
    color: var(--color-text);
}
.room-count small { font-size: 1.2rem; color: var(--color-text-muted); }
.room-count-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--color-text-muted); margin-top: 4px; }
.room-bar { height: 8px; border-radius: 4px; background: var(--color-bg); border: 1px solid var(--color-border); margin-top: 14px; overflow: hidden; }
.room-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #4a7bea, var(--color-primary)); border-radius: 4px; transition: width 0.4s; }
.room-meta { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }
.room-meta .chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 12px; border-radius: 999px;
    background: var(--color-bg); border: 1px solid var(--color-border);
    font-size: 0.78rem; font-weight: 600;
}
.room-host { font-size: 0.85rem; color: var(--color-text-muted); margin-top: 12px; }
.room-table { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 560px) { .room-table { grid-template-columns: repeat(2, 1fr); } }
.room-seat {
    position: relative;
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 16px 8px 12px; text-align: center; min-height: 118px;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.room-seat .ava {
    width: 46px; height: 46px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 1.2rem;
}
.room-seat .name { font-weight: 700; font-size: 0.85rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-seat .name .you { color: var(--color-primary); font-size: 0.72rem; font-weight: 700; }
.room-seat .tag {
    font-size: 0.66rem; padding: 2px 8px; border-radius: 10px;
    background: #e8f0ff; color: var(--color-primary); font-weight: 700;
}
.room-seat--empty {
    border-style: dashed; box-shadow: none; background: transparent;
    justify-content: center; color: var(--color-text-muted); font-size: 0.72rem;
}
.room-seat--empty .plus {
    width: 46px; height: 46px; border-radius: 50%;
    border: 2px dashed var(--color-border);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; color: var(--color-text-muted);
}
.room-invite {
    display: flex; gap: 8px;
    background: var(--color-surface); border: 1px dashed var(--color-border);
    border-radius: var(--radius); padding: 10px 12px;
}
.room-invite .lbl { font-size: 0.78rem; color: var(--color-text-muted); display: flex; align-items: center; white-space: nowrap; }
.room-invite input {
    flex: 1; min-width: 0; border: none; background: transparent;
    font-size: 0.8rem; color: var(--color-text-muted);
}
.room-invite input:focus { outline: none; }
.room-actions { display: flex; gap: 10px; justify-content: center; }

/* ================================
   ФОНОВЫЕ УКРАШЕНИЯ ГЛАВНОЙ (bg-deco.js)
   ================================ */
.bg-deco {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    min-height: 100vh;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}
.bg-deco svg { position: absolute; display: block; }
.bg-deco .move path { stroke-dasharray: 14 10; animation: bg-dash 1.4s linear infinite; }
@keyframes bg-dash { to { stroke-dashoffset: -24; } }
@media (prefers-reduced-motion: reduce) {
    .bg-deco .move path { animation: none; }
}
.bg-deco-layered { position: relative; }

/* ================================
   ОБРАТНАЯ СВЯЗЬ (feedback.js)
   ================================ */
.fb-fab {
    position: fixed;
    left: 18px;
    bottom: 18px;
    z-index: 40;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: var(--color-primary);
    color: #fff;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: background 0.15s, transform 0.15s;
}
.fb-fab:hover { background: var(--color-primary-hover); transform: translateY(-2px); }
.fb-fab:active { transform: translateY(0); }

.fb-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.fb-modal[hidden] { display: none; }
.fb-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, 0.45);
}
.fb-modal__card {
    position: relative;
    width: min(92vw, 440px);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: fb-pop 0.16s ease-out;
}
@keyframes fb-pop {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}
.fb-modal__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.fb-modal__title {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    letter-spacing: 0.03em;
}
.fb-modal__x {
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: var(--radius);
}
.fb-modal__x:hover { background: var(--color-bg); color: var(--color-text); }
.fb-modal__hint { font-size: 0.82rem; color: var(--color-text-muted); }
.fb-modal__text {
    width: 100%;
    min-height: 120px;
    resize: vertical;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 10px 12px;
    font: inherit;
    font-size: 0.9rem;
    background: var(--color-bg);
    color: var(--color-text);
}
.fb-modal__text:focus { outline: 2px solid rgba(26, 86, 219, 0.35); background: var(--color-surface); }
.fb-modal__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.fb-voice {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-surface);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.fb-voice[hidden] { display: none; }
.fb-voice:hover { border-color: var(--color-primary); color: var(--color-primary); }
.fb-voice--on {
    background: var(--color-error);
    border-color: var(--color-error);
    color: #fff;
    animation: fb-pulse 1.1s infinite;
}
@keyframes fb-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5); }
    50%      { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}
.fb-modal__count { font-size: 0.72rem; color: var(--color-text-muted); }
.fb-modal__status {
    font-size: 0.82rem;
    padding: 8px 10px;
    border-radius: var(--radius);
    background: var(--color-bg);
}
.fb-modal__status[hidden] { display: none; }
.fb-modal__status--ok { background: #e7f6ee; color: #15803d; }
.fb-modal__status--error { background: #fdecec; color: var(--color-error); }
.fb-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
@media (max-width: 560px) {
    .fb-fab { left: 14px; bottom: 14px; width: 48px; height: 48px; }
}

/* ---- Replay (просмотр истории гонки) ---- */
.replay { display: flex; flex-direction: column; gap: 16px; }

.replay-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.replay-head__title {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    letter-spacing: 0.04em;
    line-height: 1;
}
.replay-head__meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }

.replay-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; align-items: start; }
@media (max-width: 860px) { .replay-layout { grid-template-columns: 1fr; } }

.replay-board {
    position: relative;
    height: min(78vh, 820px);
    background: #fbfaf5;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}
#replay-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
@media (max-width: 860px) { .replay-board { height: 62vh; } }

.replay-side {
    display: flex; flex-direction: column; gap: 12px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 14px;
    position: sticky; top: 78px;
}
@media (max-width: 860px) { .replay-side { position: static; } }

.replay-controls { display: flex; align-items: center; justify-content: center; gap: 8px; }
.replay-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    transition: all 0.15s;
}
.replay-btn:hover:not(:disabled) { border-color: var(--color-primary); color: var(--color-primary); background: #f3f7ff; }
.replay-btn:disabled { opacity: 0.4; cursor: default; }
.replay-btn--play { width: 46px; height: 46px; background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.replay-btn--play:hover:not(:disabled) { background: var(--color-primary-hover); color: #fff; }

.replay-range { width: 100%; accent-color: var(--color-primary); cursor: pointer; }
.replay-status { font-size: 0.85rem; min-height: 1.3em; text-align: center; }
.replay-counter { font-size: 0.75rem; text-align: center; color: var(--color-text-muted); }

.replay-players { list-style: none; display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.replay-player { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--radius); font-size: 0.85rem; }
.replay-player:nth-child(odd) { background: var(--color-bg); }
.replay-player__dot { width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto; }
.replay-player__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.replay-player__place { font-weight: 700; color: var(--color-text-muted); white-space: nowrap; }

/* ---- История: фильтры и пагинация ---- */
.hist-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px 14px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 16px;
    margin: 0 auto 16px;
    max-width: 700px;
}
.hist-field { display: flex; flex-direction: column; gap: 4px; }
.hist-field label {
    font-size: 0.72rem; font-weight: 600; color: var(--color-text-muted);
    text-transform: uppercase; letter-spacing: 0.04em;
}
.hist-field input,
.hist-field select {
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font: inherit;
    font-size: 0.85rem;
    background: var(--color-bg);
    color: var(--color-text);
}
.hist-field input:focus,
.hist-field select:focus { outline: none; border-color: var(--color-primary); background: #fff; }
.hist-field input[type="number"] { width: 110px; }
.hist-field input[type="text"] { width: 160px; }
.hist-field .hist-select--empty { color: var(--color-text-muted); }
.hist-filters__actions { display: flex; gap: 8px; margin-left: auto; }

.page-back { margin-bottom: 12px; }

.hist-summary {
    max-width: 700px;
    margin: 0 auto 10px;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
    margin: 20px auto 0;
    max-width: 700px;
}
.pager__nums { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pager__btn {
    padding: 6px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.8rem;
    text-decoration: none;
    transition: all 0.15s;
}
.pager__btn:hover { border-color: var(--color-primary); color: var(--color-primary); }
.pager__btn--off { opacity: 0.4; cursor: default; }
.pager__num {
    min-width: 32px;
    padding: 6px 8px;
    text-align: center;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.8rem;
    text-decoration: none;
    transition: all 0.15s;
}
.pager__num:hover { border-color: var(--color-primary); color: var(--color-primary); }
.pager__num--active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.pager__dots { color: var(--color-text-muted); padding: 0 2px; }

@media (max-width: 560px) {
    .hist-field input[type="text"] { width: 130px; }
    .hist-filters__actions { margin-left: 0; width: 100%; }
}

/* ---- Правила: лендинг ---- */
.rl { --rl-gap: 40px; }

.rl-hero {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: 36px;
    align-items: center;
    padding: 30px 0 40px;
}
.rl-kicker {
    font-family: var(--font-heading);
    font-size: 1rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--color-primary);
}
.rl-title {
    font-family: var(--font-heading);
    font-size: 3.4rem;
    line-height: 0.95;
    letter-spacing: 0.03em;
    margin: 6px 0 14px;
}
.rl-lead {
    font-size: 1.05rem;
    color: var(--color-text-muted);
    line-height: 1.6;
    max-width: 46ch;
}
.rl-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }
.rl-cta--center { justify-content: center; }
.rl-hero__art {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    box-shadow: var(--shadow-md);
    padding: 12px;
    transform: rotate(-1.2deg);
}

.rl-sections { max-width: 960px; }
.rl-sec {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--rl-gap);
    align-items: center;
    margin: 54px 0;
}
.rl-sec:first-child { margin-top: 10px; }
.rl-sec--rev .rl-media { order: 2; }
.rl-media {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    box-shadow: var(--shadow-md);
    padding: 12px;
}
.rl-cap { font-size: 0.75rem; color: var(--color-text-muted); text-align: center; margin-top: 8px; }
.rl-body h2 {
    font-family: var(--font-heading);
    font-size: 2.1rem;
    letter-spacing: 0.03em;
    margin-bottom: 14px;
    line-height: 1;
}
.rl-body p { color: var(--color-text-muted); margin-bottom: 14px; line-height: 1.6; }
.rl-duo { display: grid; gap: 14px; }
.rl-duo figure { margin: 0; }
.rl-duo figcaption { font-size: 0.78rem; color: var(--color-text-muted); text-align: center; margin-top: 6px; }

.rl-modes { margin: 60px auto; }
.rl-modes h2 {
    font-family: var(--font-heading);
    font-size: 2.1rem;
    text-align: center;
    letter-spacing: 0.03em;
    margin-bottom: 22px;
}
.rl-mode-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.rl-mode {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 20px;
}
.rl-mode__ico { font-size: 1.9rem; line-height: 1; margin-bottom: 10px; }
.rl-mode h3 { font-size: 1.05rem; margin-bottom: 6px; }
.rl-mode p { font-size: 0.88rem; color: var(--color-text-muted); line-height: 1.55; }

.rl-final {
    background: linear-gradient(135deg, #1a56db, #2f6fed);
    color: #fff;
    border-radius: 16px;
    padding: 34px 26px;
    text-align: center;
    margin: 20px auto 10px;
}
.rl-final h2 { font-family: var(--font-heading); font-size: 2.2rem; letter-spacing: 0.03em; margin-bottom: 10px; }
.rl-final p { opacity: 0.9; margin-bottom: 20px; }
.rl-final .btn--ghost { color: #fff; border-color: rgba(255, 255, 255, 0.5); }
.rl-final .btn--ghost:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }

@media (max-width: 760px) {
    .rl-hero { grid-template-columns: 1fr; gap: 22px; padding-top: 12px; }
    .rl-title { font-size: 2.6rem; }
    .rl-hero__art { transform: none; }
    .rl-sec { grid-template-columns: 1fr; gap: 20px; margin: 36px 0; }
    .rl-sec--rev .rl-media { order: 0; }
    .rl-mode-grid { grid-template-columns: 1fr; }
}

/* ---- Публичная главная (лендинг) ---- */
.lp-hero {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    gap: 36px;
    align-items: center;
    padding: 24px 0 8px;
}
.lp-kicker {
    font-family: var(--font-heading);
    font-size: 1rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--color-primary);
}
.lp-title {
    font-family: var(--font-heading);
    font-size: clamp(2.8rem, 7vw, 4.6rem);
    line-height: 0.92;
    letter-spacing: 0.03em;
    margin: 8px 0 16px;
}
.lp-lead {
    font-size: 1.05rem;
    color: var(--color-text-muted);
    line-height: 1.6;
    max-width: 48ch;
}
.lp-facts {
    list-style: none;
    margin: 20px 0 0;
    display: grid;
    gap: 8px;
}
.lp-facts li {
    position: relative;
    padding-left: 26px;
    font-size: 0.95rem;
    line-height: 1.45;
}
.lp-facts li::before {
    content: '✓';
    position: absolute;
    left: 0;
    top: 0;
    color: var(--color-success);
    font-weight: 700;
}
.lp-cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }

.lp-auth { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.lp-auth .auth-card { width: 100%; max-width: 400px; }

.auth-switch {
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.lp-sec {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: center;
    margin: 56px 0;
}
.lp-media {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    box-shadow: var(--shadow-md);
    padding: 12px;
}
.lp-cap { font-size: 0.75rem; color: var(--color-text-muted); text-align: center; margin-top: 8px; }
.lp-body h2 {
    font-family: var(--font-heading);
    font-size: 2.1rem;
    letter-spacing: 0.03em;
    line-height: 1;
    margin-bottom: 14px;
}
.lp-body p { color: var(--color-text-muted); line-height: 1.6; margin-bottom: 14px; }

.lp-features { margin: 60px auto; }
.lp-h2 {
    font-family: var(--font-heading);
    font-size: 2.1rem;
    text-align: center;
    letter-spacing: 0.03em;
    margin-bottom: 22px;
}
.lp-feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.lp-feature {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 20px;
}
.lp-feature__ico { font-size: 1.9rem; line-height: 1; margin-bottom: 10px; }
.lp-feature h3 { font-size: 1.05rem; margin-bottom: 6px; }
.lp-feature p { font-size: 0.88rem; color: var(--color-text-muted); line-height: 1.55; }

.lp-steps { max-width: 700px; margin: 0 auto; }
.lp-steps .rules-list { margin-bottom: 18px; counter-reset: lp-step; }
.lp-steps .rules-list li { counter-increment: lp-step; padding-left: 32px; }
.lp-steps .rules-list li::before {
    content: counter(lp-step);
    top: -1px;
    left: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lp-steps__more {
    display: inline-block;
    font-weight: 600;
    color: var(--color-primary);
    text-decoration: none;
}
.lp-steps__more:hover { text-decoration: underline; }

@media (max-width: 760px) {
    .lp-hero { grid-template-columns: 1fr; gap: 22px; padding-top: 12px; }
    .lp-title { font-size: 2.6rem; }
    .lp-sec { grid-template-columns: 1fr; gap: 20px; margin: 36px 0; }
    .lp-feature-grid { grid-template-columns: 1fr; }
}