:root {
    --bg: #07111f;
    --line: rgba(255, 255, 255, 0.08);
    --text: #ffffff;
    --accent: #ff8c00;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    position: relative;
    isolation: isolate;
    margin: 0;
    font-family: Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
    overflow-y: auto;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        linear-gradient(180deg, rgba(7, 17, 31, 0.82), rgba(7, 17, 31, 0.9)),
        url('/assets/statics/images/DivisionBackground.jpeg');
    background-repeat: no-repeat, no-repeat;
    background-size: cover, cover;
    background-position: center, center;
}

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

.division-page {
    max-width: 1400px;
    margin: 0 auto;
    padding: 118px 30px 40px;
}

.division-back-wrapper {
    display: flex;
    justify-content: center;
    margin-top: 14px;
    margin-bottom: 18px;
}

.division-back-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 280px;
    padding: 12px 20px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03));
    overflow: hidden;
    color: var(--text);
    font-weight: 700;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, filter 0.2s ease;
}

.division-back-btn::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0) 55%),
        linear-gradient(110deg, rgba(255, 255, 255, 0) 42%, rgba(255, 255, 255, 0.45) 50%, rgba(255, 255, 255, 0) 58%);
    background-size: 0% 0%, 0% 100%;
    background-position: center, -140% 0;
    background-repeat: no-repeat;
    transition: background-size 0.32s ease, background-position 0.32s ease;
    pointer-events: none;
}

.division-back-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.28);
    border-color: rgba(255, 255, 255, 0.35);
    filter: brightness(1.04);
}

.division-back-btn:hover::after {
    background-size: 130% 130%, 180% 100%;
    background-position: center, 60% 0;
}

.bracket-section {
    display: none;
}

.bracket-section.is-visible {
    display: block;
}

.bracket-stage {
    border: 1px solid var(--line);
    border-radius: 20px;
    background:
        radial-gradient(circle at top left, rgba(255, 140, 0, 0.1), transparent 38%),
        radial-gradient(circle at bottom right, rgba(114, 137, 218, 0.12), transparent 42%),
        rgba(10, 20, 34, 0.9);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 20px 46px rgba(0, 0, 0, 0.35);
    padding: 16px;
    overflow: visible;
}

.bracket-stage .bracket-section {
    width: 100%;
    height: auto;
    overflow-x: auto;
    overflow-y: visible;
    scrollbar-width: none;
}

.bracket-stage .bracket-section::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.bracket-preview {
    width: max-content;
    min-width: 100%;
    min-height: 0;
    overflow: visible;
    padding: 22px;
    border-radius: 24px;
    border: 1px solid rgba(103, 151, 201, 0.38);
    box-shadow:
        inset 0 0 0 1px rgba(160, 204, 247, 0.15),
        inset 0 0 44px rgba(80, 163, 255, 0.13),
        0 26px 55px rgba(0, 0, 0, 0.44);
    background:
        radial-gradient(circle at 10% 0%, rgba(255, 202, 107, 0.2), transparent 28%),
        radial-gradient(circle at 90% 8%, rgba(108, 186, 255, 0.18), transparent 35%),
        linear-gradient(160deg, #141e2c, #0e1625 58%, #122039);
}

.single-bracket-board {
    display: grid;
    gap: 14px;
    min-width: max-content;
    min-height: max-content;
}

.single-bracket-board__headers,
.single-bracket-board__rounds {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 220px;
    gap: 42px;
    min-width: max-content;
}

.single-bracket-board__headers {
    align-items: stretch;
    padding-bottom: 6px;
}

.single-bracket-board__rounds {
    align-items: start;
}

.round-column {
    position: relative;
    display: grid;
    gap: 12px;
}

.round-column-title {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border: 1px solid rgba(181, 209, 240, 0.54);
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(117, 135, 158, 0.95), rgba(39, 50, 68, 0.95));
    color: #e7f3ff;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.9);
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 800;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.34);
}

.match-grid {
    display: grid;
    row-gap: var(--round-gap);
    padding-top: var(--round-offset);
}

.round-column:not(:first-child) .match-card .match-card__index::after {
    content: "";
    position: absolute;
    top: 50%;
    left: -8px;
    width: 6px;
    height: 2px;
    background: #89bcff;
    box-shadow: 0 0 10px rgba(137, 188, 255, 0.6);
}

.round-column:not(:last-child) .match-card::after {
    content: "";
    position: absolute;
    top: 50%;
    right: -18px;
    width: 10px;
    height: 2px;
    background: #89bcff;
    box-shadow: 0 0 10px rgba(137, 188, 255, 0.6);
}

.round-column:not(:last-child) .match-card.is-upper::before,
.round-column:not(:last-child) .match-card.is-lower::before {
    content: "";
    position: absolute;
    right: -18px;
    width: 2px;
    background: #89bcff;
    box-shadow: 0 0 12px rgba(137, 188, 255, 0.65);
}

.round-column:not(:last-child) .match-card.is-upper::before {
    top: 50%;
    height: calc(var(--round-gap) + var(--match-card-height));
}

.round-column:not(:last-child) .match-card.is-lower::before {
    bottom: 50%;
    height: calc(var(--round-gap) + var(--match-card-height));
}

.match-card {
    position: relative;
    display: grid;
    grid-template-columns: 16px 1fr;
    align-items: center;
    gap: 6px;
    min-height: var(--match-card-height);
    border: 0;
    border-radius: 0;
    padding: 0;
    background: transparent;
    color: #ffffff;
    text-align: left;
    cursor: pointer;
}

.match-card:hover .match-card__name,
.match-card:hover .match-card__score {
    box-shadow: 0 0 0 1px rgba(128, 190, 255, 0.35), 0 0 10px rgba(128, 190, 255, 0.2);
}

.match-card.is-disabled {
    opacity: 0.7;
    cursor: default;
}

.match-card.is-disabled:hover .match-card__name,
.match-card.is-disabled:hover .match-card__score {
    box-shadow: none;
}

.match-card__index {
    align-self: center;
    font-size: 14px;
    color: rgba(225, 236, 249, 0.65);
    font-weight: 700;
    position: relative;
}

.match-card__body {
    display: grid;
    gap: 3px;
}

.match-card__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 30px;
    min-height: 22px;
}

.match-card__name,
.match-card__score {
    display: flex;
    align-items: center;
    min-height: 22px;
}

.match-card__name {
    padding: 0 8px;
    background: linear-gradient(180deg, #253a53, #1a2c43);
    color: #eef7ff;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    gap: 6px;
}

.match-card__name.is-filled {
    background: linear-gradient(180deg, #2e4662, #1d334d);
}

.match-card__logo {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    object-fit: contain;
    flex: 0 0 auto;
}

.match-card__label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.match-card__score {
    justify-content: center;
    background: linear-gradient(180deg, #3a4654, #2a3442);
    color: #dde8f7;
    font-size: 12px;
}

.match-card__score.is-active {
    background: linear-gradient(180deg, #415168, #313f55);
    color: #e7f0fb;
}

.match-card__score.is-win {
    background: linear-gradient(180deg, #3ebf69, #2f8e4f);
    color: #03190b;
}

.match-card__score.is-loss {
    background: linear-gradient(180deg, #dd5f5f, #b84343);
    color: #220707;
}

.match-card__score.is-draw {
    background: linear-gradient(180deg, #73859f, #55667f);
    color: #eaf1fb;
}

.match-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .75);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.match-modal.open {
    display: flex;
}

.match-modal-content {
    width: min(1180px, 96vw);
    max-width: 96vw;
    max-height: min(86vh, 800px);
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: none;
    background: linear-gradient(180deg, rgba(24, 36, 54, 0.98), rgba(14, 24, 39, 0.98));
    border: 1px solid rgba(157, 196, 235, 0.28);
    border-radius: 16px;
    padding: 28px;
    position: relative;
    box-shadow: 0 26px 52px rgba(0, 0, 0, 0.42);
}

.match-modal-content::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.close-modal {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    border: none;
    background: none;
    color: white;
    cursor: pointer;
}

.match-modal-content h2 {
    margin: 0;
    font-size: clamp(28px, 2.8vw, 44px);
    line-height: 1.1;
}

.match-modal-header {
    display: grid;
    gap: 8px;
    margin: 10px 0 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(157, 196, 235, 0.22);
}

.match-meta-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    color: #b8cee5;
}

.match-meta-left {
    display: grid;
    gap: 4px;
}

.match-modal-select--format {
    min-width: 110px;
    max-width: 140px;
}

.match-meta-label {
    color: #8ea9c6;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.match-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.match-status-badge.is-pending {
    background: rgba(115, 133, 159, 0.22);
}

.match-status-badge.is-live {
    background: rgba(62, 191, 105, 0.26);
}

.match-status-badge.is-done {
    background: rgba(255, 177, 77, 0.24);
}

.match-versus {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 16px;
    align-items: center;
    margin-bottom: 18px;
}

.match-team-card {
    display: grid;
    justify-items: center;
    gap: 10px;
    text-align: center;
    border: 1px solid rgba(163, 202, 241, 0.18);
    border-radius: 14px;
    padding: 12px;
    background: rgba(7, 17, 31, 0.42);
}

.match-team-card img {
    width: 78px;
    height: 78px;
    object-fit: contain;
    border-radius: 12px;
    border: 1px solid rgba(163, 202, 241, 0.24);
}

.match-team-card strong {
    font-size: clamp(18px, 1.7vw, 24px);
    line-height: 1.25;
    max-width: 100%;
    text-align: center;
}

.match-versus-score {
    font-size: clamp(26px, 2.2vw, 38px);
    font-weight: 800;
    color: #ffd37f;
}

.match-modal-edit-tools {
    margin: 8px 0 14px;
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.match-modal-edit-tools__hint {
    color: #9fb8d2;
    font-size: 13px;
    font-weight: 600;
}

.match-modal-edit-tools label {
    display: grid;
    gap: 6px;
    color: #bdd3e8;
    font-size: 13px;
    font-weight: 700;
}

.match-modal-save-btn {
    appearance: none;
    border: 1px solid rgba(255, 169, 60, 0.75);
    background: linear-gradient(180deg, #ffae42, #f39210);
    color: #231100;
    font-weight: 800;
    border-radius: 10px;
    height: 38px;
    padding: 0 16px;
    cursor: pointer;
}

.match-modal-save-btn:hover {
    filter: brightness(1.05);
}

.match-slots {
    display: grid;
    gap: 10px;
    margin-top: 10px;
}

.match-slot-row {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(180px, 220px) minmax(220px, 1fr) minmax(150px, 190px);
    gap: 12px;
    align-items: stretch;
    padding: 0;
    background: transparent;
}

.match-slot-row.match-slot-row--header {
    background: transparent;
    color: #9eb8d4;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    padding: 0 2px;
}

.match-slot-col-head {
    padding: 0 8px 2px;
}

.match-slot-cell {
    min-height: 76px;
    display: grid;
    align-content: start;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid rgba(157, 196, 235, 0.2);
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(23, 39, 61, 0.96), rgba(13, 24, 41, 0.96));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.match-slot-cell__label {
    color: #87a5c3;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.match-slot-cell--score,
.match-slot-cell--status {
    justify-items: center;
}

.match-slot-player {
    overflow: hidden;
    font-weight: 600;
    min-height: 34px;
    display: flex;
    align-items: center;
}

.match-slot-score {
    text-align: center;
    font-weight: 700;
    color: #ffd37f;
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.match-slot-score--editable {
    display: grid;
    grid-template-columns: 56px auto 56px;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.match-slot-sep {
    color: #ffd37f;
    font-weight: 800;
}

.match-slot-status {
    text-align: center;
    font-size: 12px;
    color: #c7dbef;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.match-modal-input,
.match-modal-select {
    width: 100%;
    height: 38px;
    border-radius: 8px;
    border: 1px solid rgba(147, 185, 222, 0.35);
    background: rgba(7, 17, 31, 0.78);
    color: #eff8ff;
    font-size: 14px;
    padding: 0 10px;
}

.match-modal-input::placeholder {
    color: rgba(199, 219, 239, 0.55);
}

.match-modal-input:focus,
.match-modal-select:focus {
    outline: none;
    border-color: rgba(255, 176, 82, 0.85);
    box-shadow: 0 0 0 2px rgba(255, 176, 82, 0.24);
}

.match-modal-input:disabled,
.match-modal-select:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    border-color: rgba(147, 185, 222, 0.18);
    color: rgba(239, 248, 255, 0.55);
}

.match-modal-input--team {
    text-align: center;
    font-weight: 700;
}

.match-modal-select--team {
    text-align: center;
    font-weight: 700;
}

.match-modal-input--score {
    text-align: center;
    font-weight: 700;
    padding: 0;
}

.modal-versus {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-team {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 200px;
}

.modal-team img {
    width: 120px;
    height: 120px;
    object-fit: contain;
}

.modal-team h3 {
    margin-top: 15px;
    color: white;
    text-align: center;
}

.modal-vs {
    font-size: 45px;
    color: white;
    font-weight: bold;
}

@media (max-width: 900px) {
    .division-page {
        padding: 106px 16px 24px;
    }

    .division-back-btn {
        min-width: 100%;
    }

    .division-back-wrapper {
        margin-top: 10px;
    }

    .bracket-stage {
        padding: 10px;
    }

    .bracket-preview {
        padding: 14px;
    }

    .single-bracket-board {
        grid-auto-flow: row;
        grid-auto-columns: unset;
        min-width: 0;
    }

    .single-bracket-board__headers,
    .single-bracket-board__rounds {
        gap: 20px;
    }

    .round-column:not(:last-child) .match-card::after,
    .round-column:not(:last-child) .match-card::before {
        display: none;
    }

    .match-slot-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .match-slot-score--editable {
        grid-template-columns: 1fr auto 1fr;
    }

    .match-slot-row.match-slot-row--header {
        display: none;
    }

    .match-meta-head,
    .match-versus {
        grid-template-columns: 1fr;
        justify-items: start;
    }

    .match-modal-content {
        width: min(96vw, 900px);
        max-width: 96vw;
        max-height: 90vh;
        padding: 18px;
    }

    .match-team-card {
        width: 100%;
        justify-items: start;
        text-align: left;
    }

    .match-slot-score,
    .match-slot-status {
        text-align: left;
    }

    .match-modal-edit-tools {
        align-items: stretch;
    }

    .match-modal-save-btn {
        width: 100%;
    }
}
