*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --bg: #05060a;
    --bg-elevated: rgba(20, 22, 30, 0.9);
    --accent: #48b0ff;
    --accent-soft: rgba(72, 176, 255, 0.25);
    --accent-strong: #5ee6ff;
    --border-subtle: rgba(255, 255, 255, 0.08);
    --text-main: #f5f5f7;
    --text-muted: #8b8c92;
    --danger: #ff4b6a;
    --radius-lg: 24px;
    --radius-xl: 32px;
    --shadow-soft: 0 18px 65px rgba(0, 0, 0, 0.85);

    --gold: #facc15;
}

body.body-dark {
    margin: 0;
    min-height: 100vh;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-main);
    background: radial-gradient(circle at top, #151827 0, #05060a 55%);
}

.background-glow {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 10% 0, rgba(72, 176, 255, 0.2), transparent 55%),
        radial-gradient(circle at 90% 10%, rgba(122, 84, 255, 0.18), transparent 60%);
    opacity: 0.9;
    z-index: -1;
}

.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 32px;
    margin: 16px auto;
    max-width: 1120px;
    border-radius: 999px;
    position: sticky;
    top: 8px;
    z-index: 10;
}

.glass {
    background: radial-gradient(circle at top left, rgba(255, 255, 255, 0.12), rgba(17, 19, 28, 0.96));
    backdrop-filter: blur(26px);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-soft);
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 0.08em;
    font-size: 14px;
    text-transform: uppercase;
}

.brand-dot {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: conic-gradient(from 160deg, #48b0ff, #5ee6ff, #7b5cff);
    box-shadow: 0 0 18px rgba(88, 190, 255, 0.8);
}

.brand-name {
    font-weight: 600;
}

.nav-links {
    display: flex;
    gap: 18px;
    font-size: 14px;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 6px 0;
    position: relative;
}

.nav-links a::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -4px;
    width: 0;
    height: 2px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), var(--accent-strong));
    transition: width 0.2s ease-out;
}

.nav-links a:hover::after {
    width: 100%;
}

.nav-right {
    display: flex;
    gap: 10px;
    align-items: center;
}

.page-container {
    max-width: 1120px;
    margin: 0 auto 80px;
    padding: 0 16px 40px;
}

/* --- Hero --- */

.hero {
    margin-top: 40px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

/* верхний ряд с двумя блоками */
.hero-top-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

/* текстовый блок, под ними, по центру */
.hero-text {
    max-width: 680px;
}

.hero-text-centered {
    margin: 0 auto;
    text-align: center;
}

.hero-text h1 {
    font-size: clamp(32px, 4vw, 40px);
    line-height: 1.05;
    margin-bottom: 14px;
}

.accent {
    background: linear-gradient(120deg, var(--accent-strong), #ffffff);
    -webkit-background-clip: text;
    color: transparent;
}

.subtitle {
    color: var(--text-muted);
    font-size: 15px;
    max-width: 460px;
    margin-left: auto;
    margin-right: auto;
}

.hero-actions {
    display: flex;
    gap: 12px;
    margin-top: 22px;
}

.hero-actions-centered {
    justify-content: center;
}

/* золотистый акцент для карточек */
.card-gold {
    border-color: rgba(250, 204, 21, 0.38);
    box-shadow: 0 18px 60px rgba(250, 204, 21, 0.22);
    background: radial-gradient(
        circle at top left,
        rgba(250, 204, 21, 0.16),
        rgba(17, 19, 28, 0.96)
    );
}

/* --- Buttons / chips --- */

.primary-btn,
.ghost-btn,
.chip {
    border-radius: 999px;
    font-size: 14px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}

.primary-btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--accent), #7b5cff);
    color: #05060a;
    font-weight: 600;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
}

.primary-btn.huge {
    padding-inline: 28px;
    font-size: 15px;
}

.primary-btn.full {
    width: 100%;
}

.primary-btn:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

.ghost-btn {
    padding: 9px 18px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
}

.chip {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-main);
    font-size: 13px;
}

/* --- Cards / lists --- */

.hero-panel {
    border-radius: var(--radius-xl);
    padding: 20px 20px 18px;
}

.hero-panel h2 {
    font-size: 16px;
    margin-top: 0;
    margin-bottom: 8px;
}

.mt {
    margin-top: 18px;
}

.list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.list.small .list-item {
    padding-block: 6px;
}

.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: 16px;
    background: radial-gradient(circle at top left, rgba(255, 255, 255, 0.06), rgba(10, 12, 18, 0.9));
    border: 1px solid rgba(255, 255, 255, 0.06);
    margin-bottom: 6px;
}

.list-title {
    font-size: 14px;
    font-weight: 500;
}

.list-meta {
    font-size: 12px;
    color: var(--text-muted);
}

/* кликабельные лобби */

.list-item-clickable {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.16s ease-out, box-shadow 0.16s ease-out, background 0.16s ease-out;
    cursor: pointer;
}

.list-item-clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.7);
    background: radial-gradient(circle at top left,
        rgba(255, 255, 255, 0.12),
        rgba(10, 12, 18, 0.96));
}

/* --- Messages / panels --- */

.messages {
    margin-top: 16px;
    margin-bottom: 12px;
}

.message {
    padding: 10px 14px;
    border-radius: 999px;
    font-size: 13px;
    border: 1px solid var(--border-subtle);
    background: rgba(20, 22, 30, 0.85);
}

.message.success {
    border-color: rgba(72, 176, 255, 0.5);
}

.message.error {
    border-color: rgba(255, 75, 106, 0.5);
}

.panel {
    margin-top: 32px;
    padding: 22px 22px 18px;
    border-radius: var(--radius-xl);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.panel-header h1 {
    margin: 0;
    font-size: 22px;
}

.panel-actions {
    display: flex;
    gap: 10px;
}

/* --- Profile --- */

.profile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-top: 12px;
}

.label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.value {
    font-size: 16px;
}

.value.highlight {
    font-size: 18px;
    font-weight: 600;
}

/* --- Table --- */

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 16px;
}

.table th,
.table td {
    padding: 10px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    text-align: left;
}

.table th {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 12px;
}

.table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* --- рейтинг: шапка и топ-3 карточки --- */

.rating-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 18px;
}

.rating-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.rating-filter {
    font-size: 12px;
    padding-inline: 12px;
}

.rating-filter-active {
    background: linear-gradient(135deg, var(--accent), #7b5cff);
    border-color: transparent;
    color: #05060a;
}

/* карточки 1–3 места */

.rating-top-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.rating-top-card {
    border-radius: 20px;
    padding: 14px 16px 12px;
    background: radial-gradient(circle at top left,
        rgba(255, 255, 255, 0.06),
        rgba(10, 12, 18, 0.96));
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rating-top-place {
    font-size: 13px;
    color: var(--text-muted);
}

.rating-top-name {
    font-weight: 600;
    font-size: 16px;
}

.rating-top-role {
    font-size: 12px;
    color: var(--text-muted);
}

.rating-top-rating {
    margin-top: 4px;
    font-size: 22px;
    font-weight: 700;
}

.rating-top-rating-suffix {
    font-size: 13px;
    font-weight: 500;
    opacity: 0.9;
}

.rating-top-meta {
    margin-top: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    font-size: 11px;
    color: var(--text-muted);
}

/* 1 место — жёлто-белый градиент */
.rating-top-card-1 {
    background: radial-gradient(circle at top left,
        rgba(250, 204, 21, 0.32),
        rgba(10, 12, 18, 0.96));
    border-color: rgba(250, 204, 21, 0.7);
    box-shadow: 0 0 28px rgba(250, 204, 21, 0.5);
}

/* 2 место — красно-белый градиент */
.rating-top-card-2 {
    background: radial-gradient(circle at top left,
        rgba(248, 113, 113, 0.32),
        rgba(10, 12, 18, 0.96));
    border-color: rgba(248, 113, 113, 0.7);
    box-shadow: 0 0 28px rgba(248, 113, 113, 0.5);
}

/* 3 место — фиолетово-белый градиент */
.rating-top-card-3 {
    background: radial-gradient(circle at top left,
        rgba(168, 85, 247, 0.32),
        rgba(10, 12, 18, 0.96));
    border-color: rgba(168, 85, 247, 0.7);
    box-shadow: 0 0 28px rgba(168, 85, 247, 0.5);
}

/* сама таблица рейтинга */

.rating-table {
    margin-top: 8px;
}

/* старая подсветка лидеров по строкам (сейчас не используется, но не мешает) */

.table tr.rating-row td {
    transition: background 0.16s ease-out, box-shadow 0.16s ease-out;
}

.table tr.rating-leader-1 td {
    background: linear-gradient(90deg,
        rgba(250, 204, 21, 0.32),
        rgba(255, 255, 255, 0.06));
    border-bottom-color: rgba(250, 204, 21, 0.5);
    box-shadow: 0 0 22px rgba(250, 204, 21, 0.45);
}

.table tr.rating-leader-2 td {
    background: linear-gradient(90deg,
        rgba(248, 113, 113, 0.32),
        rgba(255, 255, 255, 0.06));
    border-bottom-color: rgba(248, 113, 113, 0.5);
    box-shadow: 0 0 22px rgba(248, 113, 113, 0.45);
}

.table tr.rating-leader-3 td {
    background: linear-gradient(90deg,
        rgba(168, 85, 247, 0.32),
        rgba(255, 255, 255, 0.06));
    border-bottom-color: rgba(168, 85, 247, 0.5);
    box-shadow: 0 0 22px rgba(168, 85, 247, 0.45);
}

.muted {
    color: var(--text-muted);
    text-align: center;
}

/* --- Auth --- */

.auth-card {
    max-width: 420px;
    margin: 48px auto 0;
    padding: 22px 22px 20px;
    border-radius: var(--radius-xl);
}

.auth-card h1 {
    margin-top: 0;
    margin-bottom: 18px;
    font-size: 22px;
}

.form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.field label {
    font-size: 13px;
    color: var(--text-muted);
}

.field input,
.field select {
    background: rgba(5, 7, 14, 0.9);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.09);
    padding: 8px 10px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 14px;
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(88, 190, 255, 0.3);
}

.error {
    font-size: 12px;
    color: var(--danger);
}

.help-text {
    font-size: 11px;
    color: var(--text-muted);
}

.muted a {
    color: var(--accent-strong);
}

/* --- Лобби --- */

.lobby-layout {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    gap: 20px;
    margin-top: 12px;
}

.teams {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

/* подсветка владельца и топ-2 по рейтингу — фон/обводка, не текст */

.player-row.owner {
    border-color: rgba(74, 222, 128, 0.9);
    box-shadow: 0 0 18px rgba(34, 197, 94, 0.45);
    background: radial-gradient(circle at top left,
        rgba(34, 197, 94, 0.20),
        rgba(10, 12, 18, 0.95));
}

.player-row.top {
    border-color: rgba(248, 113, 113, 0.9);
    box-shadow: 0 0 18px rgba(248, 113, 113, 0.45);
    background: radial-gradient(circle at top left,
        rgba(248, 113, 113, 0.18),
        rgba(10, 12, 18, 0.95));
}

/* Старт заблокирован */

.primary-btn.btn-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.primary-btn.btn-disabled:hover {
    transform: none;
    filter: none;
}

/* --- Модалка старт/завершение --- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: none;              /* включаем через JS: display:flex */
    align-items: center;
    justify-content: center;
    z-index: 40;
}

.modal {
    max-width: 420px;
    width: 92%;
    padding: 22px 20px 18px;
    border-radius: var(--radius-xl);
    background: radial-gradient(circle at top left, rgba(255, 255, 255, 0.12), rgba(10, 12, 18, 0.96));
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-soft);
}

.modal h2 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    justify-content: flex-end;
}

/* --- адаптив --- */

@media (max-width: 840px) {
    .top-nav {
        padding-inline: 16px;
        border-radius: 20px;
    }
    .hero {
        margin-top: 24px;
    }
    .hero-top-row {
        grid-template-columns: minmax(0, 1fr);
    }
    .panel-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .panel-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }
    .lobby-layout {
        grid-template-columns: minmax(0, 1fr);
    }
    .teams {
        grid-template-columns: minmax(0, 1fr);
    }

    .rating-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .rating-top-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 640px) {
    .top-nav {
        flex-wrap: wrap;
        gap: 8px;
    }
    .nav-links {
        display: none;
    }
}
