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

/* ================== BASE ================== */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #0f0f0f;
    color: #ffffff;
    line-height: 1.6;
}

body.no-scroll {
    overflow: hidden;
}

input {
    transition: 0.2s;
}

/* ================== CONTAINER ================== */
.container {
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 15px;
}

/* ================== HEADINGS ================== */
h1 {
    margin-bottom: 20px;
    color: #f5a623;
    text-align: center;
}

/* ================== LINKS ================== */
a {
    text-decoration: none;
    color: inherit;
}

/* ================== TOPBAR ================== */
.topbar {
    background: #1a1a1a;
    border-bottom: 2px solid #f5a623;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    position: sticky;
    top: 0;
    z-index: 1200;
}

.left {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* ================== BRAND ================== */
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Russo One', sans-serif;
    font-size: 20px;
    color: #f5a623;
    text-transform: uppercase;
}

.logo {
    height: 40px;
}

/* ================== DESKTOP USER ================== */
.right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-box {
    text-align: right;
}

.user-name {
    font-weight: bold;
    color: #f5a623;
}

.user-role {
    font-size: 12px;
    color: #b3b3b3;
}

/* ================== BUTTONS ================== */
.btn,
.logout-btn,
.event-link {
    background: linear-gradient(45deg, #f5a623, #ff7b00);
    color: #ffffff;
    border: none;
    padding: 10px 18px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    text-align: center;
    display: inline-block;
    font-family: inherit;
}

.btn:hover,
.logout-btn:hover,
.event-link:hover {
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(245, 166, 35, 0.7);
}

/* ================== BURGER ================== */
.burger {
    display: none;
    flex-direction: column;
    cursor: pointer;
    gap: 5px;
    z-index: 1300;
}

.burger span {
    width: 28px;
    height: 3px;
    background: #f5a623;
    border-radius: 2px;
    transition: 0.3s;
}

.burger.active span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.burger.active span:nth-child(2) {
    opacity: 0;
}

.burger.active span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

/* ================== MENU ================== */
.menu {
    display: flex;
    align-items: center;
    gap: 20px;
    z-index: 1100;
}

.menu a {
    color: #ffffff;
    transition: 0.3s;
}

.menu a:hover {
    color: #f5a623;
}

.mobile-user {
    display: none;
}

/* ================== EVENTS ================== */
.event-list-simple {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.event-item {
    background: #1a1a1a;
    border: 1px solid #333;
    border-left: 4px solid #f5a623;
    border-radius: 10px;
    padding: 15px;
    display: flex;
    gap: 20px;
    align-items: center;
    transition: 0.3s;
}

.event-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 0 15px rgba(245, 166, 35, 0.3);
}

.event-image img {
    width: 150px;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
}

.event-main {
    flex: 1;
}

.no-events {
    text-align: center;
    color: #aaa;
    padding: 20px;
}

/* ================== FORMS ================== */
textarea[name="players"] {
    width: 100%;
    min-height: 300px;
    resize: vertical;
}

.input-dark {
    width: 100%;
    background: #0f0f0f;
    color: #fff;
    border: 1px solid #333;
    padding: 14px 16px;
    font-size: 16px;
    border-radius: 10px;
}

.input-dark:focus {
    outline: 2px solid #f5a623;
}

#tournamentFormMessage {
    margin-top: 15px;
    font-weight: bold;
}

/* ================== TICKER ================== */
#ticker-bar {
    width: 100%;
    overflow: hidden;
    background: #111;
    color: #fff;
}

#ticker-content {
    white-space: nowrap;
    display: inline-block;
    padding: 6px 0;
    font-size: 14px;
}

/* ================== WINNER BAR ================== */
.winner-bar-wrap {
    margin: 20px 0 30px;
}

.winner-bar-title {
    font-size: 14px;
    opacity: 0.75;
    margin-bottom: 10px;
    text-align: center;
    letter-spacing: 0.5px;
}

.winner-bar {
    padding: 12px;
    background: transparent;
    border: 1px solid rgba(255, 215, 0, 0.22);
    border-radius: 12px;
    box-shadow: 0 0 18px rgba(255, 215, 0, 0.08);
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.winner-item {
    position: relative;
    overflow: hidden;
    padding: 10px 14px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 13px;
    color: #fff;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255,255,255,0.08);
    backdrop-filter: blur(6px);
}

.winner-item::before {
    content: "";
    position: absolute;
    top: -50%;
    left: -60%;
    width: 220%;
    height: 220%;
    background: linear-gradient(
        120deg,
        transparent,
        rgba(255,255,255,0.08),
        rgba(255,215,0,0.22),
        transparent
    );
    transform: rotate(25deg);
    animation: shine 3.2s linear infinite;
}

.w1 {
    border-color: rgba(255,215,0,0.65);
    box-shadow: 0 0 12px rgba(255,215,0,0.18);
}

.w2 {
    border-color: rgba(192,192,192,0.65);
    box-shadow: 0 0 12px rgba(192,192,192,0.12);
}

.w3 {
    border-color: rgba(205,127,50,0.65);
    box-shadow: 0 0 12px rgba(205,127,50,0.12);
}

.winner-bar-link {
    display: block;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.winner-bar-link:hover .winner-item {
    transform: scale(1.02);
    transition: 0.2s ease;
}

@keyframes shine {
    0% {
        transform: translateX(-100%) rotate(25deg);
    }

    100% {
        transform: translateX(100%) rotate(25deg);
    }
}

/* ================== ADMIN PANEL ================== */
.admin-page h2 {
    color: #f5a623;
    margin-bottom: 15px;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.admin-card {
    background: #1a1a1a;
    border: 1px solid #333;
    border-left: 4px solid #f5a623;
    border-radius: 10px;
    padding: 18px;
    transition: 0.3s;
}

.admin-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 0 15px rgba(245, 166, 35, 0.3);
}

.admin-card-title {
    display: block;
    color: #f5a623;
    font-weight: bold;
    margin-bottom: 8px;
}

.admin-card-text {
    display: block;
    font-size: 14px;
    color: #ccc;
}

.admin-section {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
}

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

.admin-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: #ddd;
    font-weight: 600;
}

.admin-form input,
.admin-form select,
.admin-form textarea {
    width: 100%;
    background: #0f0f0f;
    color: #fff;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 12px;
    font-size: 15px;
}

.admin-form textarea {
    min-height: 120px;
    resize: vertical;
}

.admin-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.admin-checkboxes {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.admin-checkboxes label {
    flex-direction: row;
    align-items: center;
}

.admin-success {
    background: rgba(0, 180, 90, 0.18);
    border: 1px solid rgba(0, 180, 90, 0.4);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    color: #8cffb0;
}

.admin-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.admin-item {
    background: #0f0f0f;
    border: 1px solid #333;
    border-left: 4px solid #f5a623;
    border-radius: 10px;
    padding: 15px;
    display: flex;
    gap: 20px;
    justify-content: space-between;
    align-items: flex-start;
}

.admin-item-main {
    flex: 1;
}

.admin-meta {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.admin-meta span {
    background: #1a1a1a;
    border: 1px solid #333;
    padding: 5px 9px;
    border-radius: 6px;
    font-size: 13px;
    color: #ccc;
}

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
    max-width: 420px;
}

.admin-actions form {
    margin: 0;
}

.admin-actions button.event-link:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.admin-badge {
    background: #6f42c1;
    color: #fff;
    padding: 10px 18px;
    border-radius: 6px;
    font-weight: bold;
}

/* ================== STATUSES ================== */
.status-open,
.status-active {
    color: #33d17a !important;
    font-weight: bold;
}

.status-closed {
    color: #ff5c5c !important;
    font-weight: bold;
}

.status-draft {
    color: #aaa !important;
    font-weight: bold;
}

.status-archived,
.status-completed {
    color: #b388ff !important;
    font-weight: bold;
}

.status-registration {
    color: #f5a623 !important;
    font-weight: bold;
}

/* ================== TOURNAMENT HOME TREE ================== */
.tournament-home-item {
    align-items: flex-start;
}

.tournament-empty-bracket {
    margin-top: 15px;
    padding: 12px;
    background: #0f0f0f;
    border: 1px dashed #444;
    border-radius: 10px;
    color: #aaa;
}

.home-bracket-tree {
    margin-top: 15px;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(230px, 270px);
    gap: 35px;
    overflow-x: auto;
    align-items: start;
    padding-bottom: 8px;
}

.tree-round {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.tree-round-title {
    color: #f5a623;
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 4px;
    text-align: center;
}

.tree-match {
    display: grid;
    grid-template-rows: auto auto auto;
    gap: 4px;
    position: relative;
}

.tree-player {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 7px;
    padding: 7px 9px;
    font-size: 14px;
}

.tree-connector {
    color: #f5a623;
    font-weight: bold;
    font-size: 13px;
    padding-left: 26px;
    white-space: nowrap;
    line-height: 1.3;
}

.tree-round-2 {
    padding-top: 42px;
}

.tree-round-3 {
    padding-top: 105px;
}

.tree-round-4 {
    padding-top: 230px;
}

.tree-round-5 {
    padding-top: 480px;
}

/* ================== FOOTER ================== */
.footer {
    background: #111;
    border-top: 2px solid #f5a623;
    color: #ccc;
    margin-top: 40px;
}

/* ================== RESPONSIVE ================== */
@media (max-width: 992px) {
    .admin-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .admin-item {
        flex-direction: column;
    }

    .admin-actions {
        max-width: none;
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 768px) {
    .container {
        margin: 20px auto;
        padding: 0 10px;
    }

    .burger {
        display: flex;
    }

    .right {
        display: none;
    }

    .menu {
        position: fixed;
        top: 0;
        right: -100%;
        width: 260px;
        height: 100%;
        background: #1a1a1a;
        flex-direction: column;
        align-items: flex-start;
        padding: 80px 20px;
        gap: 20px;
        transition: right 0.3s ease;
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.5);
    }

    .menu.active {
        right: 0;
    }

    .mobile-user {
        display: block;
        width: 100%;
        border-top: 1px solid #333;
        padding-top: 15px;
        margin-top: 10px;
    }

    .menu a {
        width: 100%;
        padding: 10px 0;
        border-bottom: 1px solid #2a2a2a;
    }

    .event-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .event-image img {
        width: 100%;
        height: auto;
    }

    .event-link,
    .tournament-home-item .event-link {
        width: 100%;
        margin-top: 10px;
    }

    .admin-grid {
        grid-template-columns: 1fr;
    }

    .admin-section {
        padding: 15px;
    }

    .admin-form-row {
        grid-template-columns: 1fr;
    }

    .admin-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .admin-actions .event-link,
    .admin-actions button.event-link {
        width: 100%;
    }

    .admin-meta {
        flex-direction: column;
    }

    .admin-meta span {
        width: 100%;
    }

    .home-bracket-tree {
        grid-auto-columns: minmax(210px, 240px);
        gap: 22px;
    }

    .tree-player {
        font-size: 13px;
    }

    .tree-connector {
        font-size: 12px;
    }

    .tree-round-2,
    .tree-round-3,
    .tree-round-4,
    .tree-round-5 {
        padding-top: 0;
    }

    /* ===== ДОПОЛНИТЕЛЬНЫЕ ПРАВИЛА ДЛЯ СЕТКИ (МОБИЛЬНЫЕ) ===== */
    .bracket-match {
        padding: 6px;
    }
    .bracket-player {
        font-size: 12px;
        padding: 5px 8px;
    }
    .bracket-meta {
        font-size: 9px;
    }
    .bracket-next-info {
        font-size: 8px;
    }
}

/* ================== ТУРНИРНАЯ СЕТКА (улучшенная) ================== */
.bracket-page {
    margin-top: 25px;
    display: flex;
    gap: 35px;
    align-items: stretch;
    overflow-x: auto;
    padding: 15px 5px 25px;
}

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

.bracket-round-title {
    color: #f5a623;
    text-align: center;
    font-size: 18px;
    margin-bottom: 18px;
}

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

.bracket-match {
    background: #1a1a1a;
    border: 1px solid #333;
    border-left: 4px solid #f5a623;
    border-radius: 10px;
    padding: 10px;
    transition: 0.2s;
}

/* Чередование фона для удобства чтения */
.bracket-match-odd {
    background: #1a1a1a;
}
.bracket-match-even {
    background: #151515;
}

.bracket-player {
    background: #0f0f0f;
    border: 1px solid #333;
    border-radius: 7px;
    padding: 8px 10px;
    font-size: 14px;
}

.bracket-meta {
    color: #f5a623;
    font-size: 12px;
    font-weight: bold;
    padding: 4px 2px;
    text-align: center;
}

.bracket-player-winner {
    border-color: #33d17a;
    color: #33d17a;
    font-weight: bold;
}

/* Подсказка, куда идёт победитель */
.bracket-next-info {
    font-size: 10px;
    color: #888;
    text-align: center;
    margin-top: 8px;
    border-top: 1px dashed #333;
    padding-top: 6px;
}

.tournament-next-match {
    margin-top: 12px;
    padding: 12px;
    background: #0f0f0f;
    border: 1px solid #333;
    border-radius: 10px;
}