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

:root {
    --bg: #0a0a0d;
    --bg-elevated: #16161c;
    --bg-card: #1c1c24;
    --border: #2a2a34;
    --accent: #e8283c;
    --accent-dim: #7a1620;
    --accent-glow: rgba(232, 40, 60, 0.45);
    --gold: #f2a93b;
    --text: #f2f2f5;
    --text-muted: #8b8b96;
    --success: #34d399;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    margin: 0;
}

a { color: inherit; text-decoration: none; }

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ============ ШАПКА ============ */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, var(--bg-elevated), transparent);
}

.logo {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 22px;
    letter-spacing: 0.05em;
}

.logo span { color: var(--accent); }

/* ============ ФОН С ГРАДИЕНТОМ И ПУЛЬСАЦИЕЙ ============ */
.hero {
    position: relative;
    padding: 80px 20px 60px;
    text-align: center;
    overflow: hidden;
}

.hero::before {
    content: "";
    position: absolute;
    top: -200px; left: 50%;
    width: 700px; height: 700px;
    transform: translateX(-50%);
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    animation: pulse-glow 6s ease-in-out infinite;
    pointer-events: none;
}

@keyframes pulse-glow {
    0%, 100% { opacity: 0.5; transform: translateX(-50%) scale(1); }
    50% { opacity: 0.9; transform: translateX(-50%) scale(1.1); }
}

.hero h1 {
    font-size: clamp(32px, 6vw, 56px);
    position: relative;
    z-index: 1;
}

.hero p {
    color: var(--text-muted);
    max-width: 480px;
    margin: 14px auto 0;
    position: relative;
    z-index: 1;
}

/* ============ КАРТОЧКИ ============ */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    padding: 20px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    cursor: pointer;
    transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
    opacity: 0;
    animation: fade-up 0.5s ease forwards;
}

.card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-dim);
    box-shadow: 0 8px 30px var(--accent-glow);
}

.card h3 { font-size: 19px; margin-bottom: 6px; }
.card p { color: var(--text-muted); font-size: 14px; margin: 0; }
.card p.card-prize { color: var(--gold); font-size: 12px; margin-top: 8px; font-weight: 600; }

@keyframes fade-up {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

.card:nth-child(1) { animation-delay: 0.02s; }
.card:nth-child(2) { animation-delay: 0.08s; }
.card:nth-child(3) { animation-delay: 0.14s; }
.card:nth-child(4) { animation-delay: 0.20s; }
.card:nth-child(5) { animation-delay: 0.26s; }
.card:nth-child(6) { animation-delay: 0.32s; }
.card:nth-child(7) { animation-delay: 0.38s; }

/* ============ СВОДКА ПРИЗОВЫХ ============ */
.prize-summary {
    display: flex;
    gap: 24px;
    justify-content: center;
    padding: 16px 20px 30px;
    flex-wrap: wrap;
}

.prize-stat {
    text-align: center;
}

.prize-stat .value {
    font-family: 'Rajdhani', sans-serif;
    font-size: 34px;
    font-weight: 700;
    color: var(--gold);
}

.prize-stat .label {
    color: var(--text-muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ============ ТАБЛИЦА РЕЙТИНГА ============ */
.table-wrap {
    padding: 10px 20px 60px;
    overflow-x: auto;
    max-width: 1100px;
    margin: 0 auto;
}

table.rating {
    width: 100%;
    border-collapse: collapse;
    min-width: 640px;
}

table.rating th {
    text-align: left;
    font-family: 'Rajdhani', sans-serif;
    font-size: 14px;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 10px 12px;
    border-bottom: 2px solid var(--border);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

table.rating th:hover { color: var(--text); }

table.rating td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

table.rating tbody tr {
    transition: background 0.15s ease;
    opacity: 0;
    animation: fade-in 0.4s ease forwards;
}

@keyframes fade-in { to { opacity: 1; } }

table.rating tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.03); }
table.rating tbody tr:hover { background: var(--bg-card); }

table.rating.points-table {
    min-width: 0;
    width: auto;
    margin: 0 auto;
}
table.rating.points-table th,
table.rating.points-table td {
    text-align: center;
    padding: 8px 10px;
    white-space: nowrap;
}
table.rating.points-table th:first-child,
table.rating.points-table td:first-child {
    text-align: left;
    padding-right: 6px;
}
table.rating.points-table th:last-child {
    line-height: 1.25;
}

table.rating.history-table {
    min-width: 0;
    width: 100%;
}
table.rating.history-table th:nth-child(2):not(:last-child),
table.rating.history-table td:nth-child(2):not(:last-child) {
    text-align: center;
    white-space: nowrap;
}
table.rating.history-table th:last-child,
table.rating.history-table td:last-child {
    text-align: right;
}
table.rating.history-table th:first-child,
table.rating.history-table td:first-child {
    word-break: break-word;
}

@media (max-width: 600px) {
    table.rating.history-table {
        table-layout: fixed;
    }
    table.rating.history-table td, table.rating.history-table th {
        word-break: break-word;
    }
    table.rating.history-table th:nth-child(2):not(:last-child),
    table.rating.history-table td:nth-child(2):not(:last-child) {
        width: 90px;
    }
    table.rating.history-table th:last-child,
    table.rating.history-table td:last-child {
        width: 128px;
    }
}

table.rating.podium-table {
    min-width: 0;
    width: 100%;
}
table.rating.podium-table th:first-child,
table.rating.podium-table td:first-child {
    text-align: center;
    font-size: 16px;
}
table.rating.podium-table th:last-child,
table.rating.podium-table td:last-child {
    text-align: right;
}

/* Узкие фиксированные колонки и перенос текста — только на маленьких экранах (телефоны) */
@media (max-width: 600px) {
    table.rating.podium-table {
        table-layout: fixed;
    }
    table.rating.podium-table td, table.rating.podium-table th {
        word-break: break-word;
    }
    table.rating.podium-table th:first-child,
    table.rating.podium-table td:first-child {
        width: 34px;
    }
    table.rating.podium-table th:nth-child(3),
    table.rating.podium-table td:nth-child(3) {
        width: 90px;
    }
    table.rating.podium-table th:last-child,
    table.rating.podium-table td:last-child {
        width: 120px;
    }
}

.rank-1 { color: var(--gold); font-weight: 700; }
.rank-2 { color: #c7c7d1; font-weight: 700; }
.rank-3 { color: #d9924a; font-weight: 700; }

.stats-subid {
    color: var(--text-muted);
    font-size: 11px;
    margin-top: 2px;
}

.stats-toggle {
    display: flex;
    gap: 8px;
    padding: 0 20px 14px;
    max-width: 1100px;
    margin: 0 auto;
}
.stats-toggle .toggle-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius);
    padding: 8px 16px;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.stats-toggle .toggle-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

table.rating.stats-table {
    min-width: 0;
    width: 100%;
    table-layout: fixed;
}
table.rating.stats-table th, table.rating.stats-table td {
    text-align: center;
    padding: 8px 4px;
    font-size: 13px;
}
table.rating.stats-table th:first-child, table.rating.stats-table td:first-child {
    text-align: left;
    width: auto;
    font-size: 14px;
}

.status-dodge { color: var(--gold); }
.status-banned { color: var(--accent); }

/* ============ ПОИСК ============ */
.search-box {
    display: flex;
    gap: 10px;
    padding: 20px 20px 0;
    max-width: 1100px;
    margin: 0 auto;
}

.search-box input {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 14px;
    color: var(--text);
    font-size: 14px;
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent);
}

.non-players-hint {
    max-width: 1100px;
    margin: 14px auto 0;
    padding: 0 20px;
}

.non-players-row {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--gold);
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-muted);
}

.non-players-row a {
    color: var(--text);
    font-weight: 600;
}

.non-players-row a:hover { color: var(--accent); }

.non-players-row .stats-subid {
    display: inline;
    margin: 0 4px;
}

/* ============ СЕТКА ТУРНИРА ============ */
.bracket {
    display: flex;
    gap: 40px;
    padding: 30px 20px;
    overflow-x: auto;
    position: relative;
}

.bracket-lines {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    overflow: visible;
}

.bracket-line {
    fill: none;
    stroke: var(--accent-dim);
    stroke-width: 2;
}

.bracket-round {
    display: flex;
    flex-direction: column;
    min-width: 220px;
}

.round-label {
    font-family: 'Rajdhani', sans-serif;
    text-transform: uppercase;
    font-size: 13px;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 14px;
}

.round-matches {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    gap: 20px;
    flex: 1;
}

.match-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    min-height: 108px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: border-color 0.2s ease;
}

.match-card:hover { border-color: var(--accent-dim); }

.match-result-form {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.match-entry {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 8px 10px;
    font-size: 14px;
    border-radius: 6px;
}

.match-entry.pick {
    all: unset;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    text-align: left;
    transition: background 0.15s ease;
}

.match-entry.pick:hover {
    background: rgba(232, 40, 60, 0.14);
}

.match-entry.pick:hover .nick { color: var(--accent); }

.match-entry.winner {
    color: var(--success);
    font-weight: 600;
    background: rgba(52, 211, 153, 0.08);
}

.match-entry.loser {
    opacity: 0.4;
}

.match-entry.prized {
    background: rgba(242, 169, 59, 0.18);
    box-shadow: inset 0 0 0 1px rgba(242, 169, 59, 0.5);
}

.match-entry.loser.prized {
    opacity: 1;
}

.match-entry .prize-badge {
    margin-top: 3px;
    font-size: 12px;
    font-weight: 700;
    color: var(--gold);
}

.match-entry.placeholder {
    color: var(--text-muted);
    font-size: 13px;
    padding: 8px 10px;
}

.match-entry .nick { font-weight: 600; }
.match-entry .ffid { color: var(--text-muted); font-size: 11px; }

.kills-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 2px 10px 8px;
}

.kills-inline label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.kills-inline input {
    width: 44px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    padding: 3px 5px;
    font-size: 12px;
}

.bracket-third-place {
    margin: 10px 20px 40px;
    padding-top: 20px;
    border-top: 1px dashed var(--border);
    max-width: 260px;
}

/* ============ КНОПКИ ============ */
.btn {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 10px 20px;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: filter 0.2s ease, transform 0.15s ease;
}

.btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
.btn.secondary { background: var(--bg-card); border: 1px solid var(--border); color: var(--text); }

/* ============ АНИМИРОВАННЫЕ СЧЁТЧИКИ ============ */
.counter { font-variant-numeric: tabular-nums; }

/* ============ ПРОФИЛЬ ИГРОКА ============ */
.profile-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 40px 20px;
}

.avatar-placeholder {
    width: 72px; height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-dim));
    display: flex; align-items: center; justify-content: center;
    font-family: 'Rajdhani', sans-serif;
    font-size: 26px; font-weight: 700;
}

.badge-dodge, .badge-banned {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 10px;
}

.badge-dodge { background: rgba(242, 169, 59, 0.15); color: var(--gold); }
.badge-banned { background: rgba(232, 40, 60, 0.15); color: var(--accent); }

/* ============ ФОРМЫ АДМИНКИ ============ */
.form-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 420px;
    margin: 60px auto;
}

.form-box.wide { max-width: none; margin: 20px 0 0; }

.form-box input, .form-box select, .form-box textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text);
    margin-bottom: 14px;
    font-family: inherit;
}

.form-box label {
    font-size: 13px;
    color: var(--text-muted);
    display: block;
    margin-bottom: 4px;
}

.hint {
    color: var(--text-muted);
    font-size: 12px;
    margin: -6px 0 10px;
}

.divider {
    display: flex;
    align-items: center;
    color: var(--text-muted);
    font-size: 12px;
    margin: 20px 0;
}

.divider::before, .divider::after {
    content: "";
    flex: 1;
    border-bottom: 1px solid var(--border);
}

.divider span { padding: 0 10px; white-space: nowrap; }

.notice-msg {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--gold);
    padding: 10px 14px;
    border-radius: 8px;
    margin: 16px 0;
    font-size: 14px;
}

.prize-place-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.prize-place-row input {
    margin-bottom: 0;
    flex: 1;
    min-width: 0;
}

.prize-place-label {
    min-width: 66px;
    flex-shrink: 0;
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
}

.placements-editor td input {
    width: 80px;
    margin-bottom: 0;
}

.placements-editor td:first-child {
    white-space: nowrap;
}

.collapsible-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    padding: 4px 0;
}

.collapsible-header .chevron {
    display: inline-block;
    font-size: 15px;
    color: var(--text-muted);
    transition: transform 0.25s ease;
    margin-left: 10px;
    flex-shrink: 0;
}

.collapsible-header:hover .chevron {
    color: var(--text);
}

.collapsible-header:not(.collapsed) .chevron {
    transform: rotate(180deg);
}

.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.error-msg { color: var(--accent); font-size: 13px; margin-bottom: 10px; }

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