/* =========================================================
   RESET
========================================================= */

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    overflow: hidden;
    background: #080a0d;
    color: #f5f7fa;
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}


/* =========================================================
   DASHBOARD
========================================================= */

.dashboard {
    width: 100%;
    height: 100vh;
    height: 100dvh;

    display: flex;

    background: #080a0d;
}


/* =========================================================
   SIDEBAR
========================================================= */

.sidebar {
    width: 270px;
    min-width: 270px;
    height: 100%;

    background: #101318;

    border-right: 1px solid #252a31;

    overflow-y: auto;
    overflow-x: hidden;

    transition:
        width 0.2s ease,
        min-width 0.2s ease,
        transform 0.2s ease,
        opacity 0.2s ease;
}

.sidebar.hidden {
    width: 0;
    min-width: 0;

    opacity: 0;
    overflow: hidden;
}


.sidebar-inner {
    width: 270px;
    min-height: 100%;

    padding: 18px;

    display: flex;
    flex-direction: column;
}


/* =========================================================
   BRAND
========================================================= */

.brand {
    margin-bottom: 24px;
}

.brand-title {
    font-size: 17px;
    font-weight: 700;
    line-height: 1.2;
}

.brand-subtitle {
    margin-top: 4px;

    color: #858d98;

    font-size: 11px;
}


/* =========================================================
   SIDEBAR SECTIONS
========================================================= */

.sidebar-section {
    margin-bottom: 22px;
}

.sidebar-section-title {
    margin-bottom: 9px;

    color: #7f8792;

    font-size: 10px;
    font-weight: 700;

    letter-spacing: 0.08em;
    text-transform: uppercase;
}


/* =========================================================
   LAYOUT SELECTOR
========================================================= */

.layout-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);

    gap: 5px;
}

.layout-button {
    height: 34px;

    border: 1px solid #2b3139;
    border-radius: 7px;

    background: #171b21;
    color: #aeb5be;

    font-size: 12px;
    font-weight: 600;

    cursor: pointer;

    transition:
        background 0.15s ease,
        color 0.15s ease,
        border-color 0.15s ease;
}

.layout-button:hover {
    border-color: #444b55;
    color: #ffffff;
}

.layout-button.active {
    background: #252b33;
    border-color: #565e69;
    color: #ffffff;
}


/* =========================================================
   SIDEBAR MATCH CONTROLS
========================================================= */

.sidebar-match {
    margin-bottom: 10px;

    padding: 10px;

    background: #15191f;

    border: 1px solid #252b33;
    border-radius: 8px;
}

.sidebar-match-header {
    display: flex;
    align-items: center;

    gap: 7px;

    margin-bottom: 7px;
}

.sidebar-match-number {
    color: #ffffff;

    font-size: 10px;
    font-weight: 700;
}

.sidebar-match-label {
    color: #858d98;

    font-size: 10px;
}

.sidebar-match-controls {
    display: flex;

    gap: 5px;
}

.sidebar-event-input {
    min-width: 0;
    flex: 1;

    height: 31px;

    padding: 0 8px;

    border: 1px solid #303640;
    border-radius: 6px;

    outline: none;

    background: #0d1014;
    color: #ffffff;

    font-size: 11px;
}

.sidebar-event-input:focus {
    border-color: #606975;
}

.sidebar-go-button {
    width: 40px;
    height: 31px;

    padding: 0;

    border: 0;
    border-radius: 6px;

    background: #e9edf2;
    color: #101318;

    font-size: 10px;
    font-weight: 800;

    cursor: pointer;

    transition:
        opacity 0.15s ease,
        transform 0.15s ease;
}

.sidebar-go-button:hover {
    opacity: 0.9;
}

.sidebar-go-button:active {
    transform: scale(0.96);
}


/* =========================================================
   SIDEBAR FOOTER
========================================================= */

.sidebar-footer {
    margin-top: auto;
    padding-top: 18px;
}

.sidebar-hide-button {
    width: 100%;
    height: 34px;

    border: 1px solid #2b3139;
    border-radius: 7px;

    background: transparent;
    color: #858d98;

    font-size: 11px;

    cursor: pointer;
}

.sidebar-hide-button:hover {
    color: #ffffff;
    border-color: #444b55;
}


/* =========================================================
   SHOW SIDEBAR BUTTON
========================================================= */

.show-sidebar-button {
    position: fixed;

    left: 12px;
    top: 12px;

    z-index: 1000;

    width: 34px;
    height: 34px;

    display: none;
    align-items: center;
    justify-content: center;

    border: 1px solid #303640;
    border-radius: 7px;

    background: rgba(16, 19, 24, 0.94);
    color: #ffffff;

    cursor: pointer;

    font-size: 15px;
}

.show-sidebar-button.visible {
    display: flex;
}


/* =========================================================
   MAIN CONTENT
========================================================= */

.content {
    flex: 1;
    min-width: 0;
    min-height: 0;

    height: 100%;

    padding: 8px;

    overflow: hidden;
}


/* =========================================================
   MATCH GRID
========================================================= */

.match-grid {
    width: 100%;
    height: 100%;

    display: grid;

    gap: 8px;

    min-width: 0;
    min-height: 0;
}


/* 2 × 2 */

.match-grid.layout-2x2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
}


/* 1 × 2 */

.match-grid.layout-1x2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: minmax(0, 1fr);
}


/* 1 × 1 */

.match-grid.layout-1x1 {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
}


/* Hide unused matches */

.match-grid.layout-1x1 .match:nth-child(n + 2),
.match-grid.layout-1x2 .match:nth-child(n + 3) {
    display: none;
}


/* =========================================================
   MATCH CONTAINER
========================================================= */

.match {
    position: relative;

    width: 100%;
    height: 100%;

    min-width: 0;
    min-height: 0;

    display: flex;
    flex-direction: column;

    overflow: hidden;

    background: #0c0f13;

    border: 1px solid #222831;
    border-radius: 8px;

    container-type: size;
}


/* =========================================================
   SUMMARY
========================================================= */

.summary {
    flex: 0 0 auto;

    min-height: 56px;

    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        auto
        minmax(0, 1fr);

    align-items: center;

    gap: 10px;

    padding: 8px 12px;

    background: #11151a;

    border-bottom: 1px solid #242a31;
}


.team {
    min-width: 0;

    display: flex;
    align-items: center;

    gap: 7px;
}

.home-team {
    justify-content: flex-start;
}

.away-team {
    justify-content: flex-end;
}


.team-logo {
    width: 25px;
    height: 25px;

    flex: 0 0 25px;

    object-fit: contain;
}


.team-name {
    min-width: 0;

    color: #f1f3f5;

    font-size: 12px;
    font-weight: 650;

    line-height: 1.1;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


.score-area {
    min-width: 68px;

    display: flex;
    flex-direction: column;

    align-items: center;
    justify-content: center;

    text-align: center;
}


.score {
    display: flex;
    align-items: center;

    font-size: 20px;
    font-weight: 800;

    line-height: 1;
}

.score-separator {
    margin: 0 4px;

    color: #747c87;
}


.status {
    margin-top: 4px;

    color: #b4bbc4;

    font-size: 9px;
    font-weight: 600;

    white-space: nowrap;
}


.competition {
    max-width: 130px;

    margin-top: 2px;

    color: #69717d;

    font-size: 8px;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* =========================================================
   STATS
========================================================= */

.stats {
    flex: 0 0 auto;

    height: 27px;

    display: grid;

    grid-template-columns: repeat(3, minmax(0, 1fr));

    align-items: center;

    border-bottom: 1px solid #1d2228;

    background: #0e1115;
}


.stat {
    min-width: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    gap: 5px;

    padding: 0 5px;

    border-right: 1px solid #1d2228;
}

.stat:last-child {
    border-right: 0;
}


.stat-label {
    color: #69717c;

    font-size: 8px;

    white-space: nowrap;
}


.stat-values {
    display: flex;
    align-items: center;

    color: #cdd2d8;

    font-size: 9px;
    font-weight: 700;
}

.stat-divider {
    margin: 0 3px;

    color: #505762;
}


/* =========================================================
   MOMENTUM
========================================================= */

.momentum-container {
    position: relative;

    flex: 0 0 auto;

    height: 14px;

    padding: 3px 8px 3px;
}

.momentum-label {
    position: absolute;

    left: 8px;
    top: 1px;

    z-index: 2;

    color: rgba(255, 255, 255, 0.48);

    font-size: 6px;
    font-weight: 700;

    pointer-events: none;
}

.momentum-bar {
    width: 100%;
    height: 8px;

    display: flex;

    overflow: hidden;

    border-radius: 99px;

    background: #1c2128;
}

.momentum-fill {
    height: 100%;

    transition: width 0.5s ease;
}

.momentum-home {
    width: 50%;
}

.momentum-away {
    width: 50%;
}


/* =========================================================
   TRACKER
========================================================= */

.tracker-wrapper {
    position: relative;

    flex: 1 1 0;

    width: 100%;

    min-width: 0;
    min-height: 0;

    height: auto;

    overflow: hidden;

    background: #0a0d10;
}


.tracker {
    display: block;

    width: 100%;
    height: 100%;

    min-width: 0;
    min-height: 0;

    border: 0;

    overflow: hidden;

    background: #0a0d10;
}


/* =========================================================
   INCIDENT OVERLAY
========================================================= */

.incident-ticker {
    position: absolute;

    inset: 0;

    z-index: 20;

    width: 100%;
    height: 100%;

    overflow: hidden;

    pointer-events: none;
}


.incident-list {
    position: absolute;

    inset: 0;

    width: 100%;
    height: 100%;

    display: grid;

    grid-template-columns: 1fr 1fr;

    align-items: stretch;

    pointer-events: none;
}


/* =========================================================
   INCIDENT COLUMNS
========================================================= */

.incident-column-home,
.incident-column-away {
    min-width: 0;
    min-height: 0;

    display: flex;
    flex-direction: column;

    justify-content: flex-start;

    gap: 3px;

    padding: 8px;

    overflow: hidden;

    pointer-events: none;
}

.incident-column-home {
    align-items: flex-start;
}

.incident-column-away {
    align-items: flex-end;
}


/* =========================================================
   INCIDENT ITEM
========================================================= */

.incident-item {
    max-width: min(190px, 44%);

    display: flex;
    align-items: center;

    gap: 4px;

    padding: 3px 6px;

    border-radius: 5px;

    background: rgba(9, 12, 16, 0.76);

    color: #f0f2f5;

    font-size: 8px;
    font-weight: 650;

    line-height: 1.15;

    backdrop-filter: blur(3px);

    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.2);

    animation: incident-in 0.2s ease-out;
}


.incident-icon {
    flex: 0 0 auto;

    font-size: 10px;
    line-height: 1;
}


.incident-time {
    flex: 0 0 auto;

    color: #929aa5;

    font-size: 7px;
}


.incident-player {
    min-width: 0;

    overflow: hidden;

    white-space: nowrap;
    text-overflow: ellipsis;
}


/* =========================================================
   INCIDENT TYPES
========================================================= */

.incident-item.goal {
    background: rgba(10, 14, 12, 0.82);
}

.incident-item.card {
    background: rgba(9, 12, 15, 0.76);
}

.incident-item.substitution {
    background: rgba(9, 12, 16, 0.74);
}


/* =========================================================
   UPDATE INDICATOR
========================================================= */

.update-indicator {
    position: absolute;

    right: 6px;
    bottom: 5px;

    z-index: 30;

    padding: 2px 5px;

    border-radius: 4px;

    background: rgba(5, 7, 9, 0.7);

    color: #6f7782;

    font-size: 7px;

    pointer-events: none;
}


/* =========================================================
   GOAL ALERT
========================================================= */

.goal-alert {
    position: absolute;

    left: 50%;
    top: 50%;

    z-index: 50;

    transform: translate(-50%, -50%) scale(0.85);

    padding: 8px 14px;

    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 7px;

    background: rgba(8, 10, 13, 0.94);

    color: #ffffff;

    font-size: 18px;
    font-weight: 900;

    letter-spacing: 0.05em;

    opacity: 0;
    visibility: hidden;

    pointer-events: none;
}

.goal-alert.show {
    visibility: visible;

    animation: goal-alert 2.2s ease-out;
}


/* =========================================================
   ANIMATIONS
========================================================= */

@keyframes incident-in {

    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }

}


@keyframes goal-alert {

    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }

    15% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    75% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1.05);
    }

}


/* =========================================================
   FULLSCREEN
========================================================= */

.match.fullscreen {
    position: fixed;

    inset: 0;

    z-index: 9999;

    width: 100vw;
    width: 100dvw;

    height: 100vh;
    height: 100dvh;

    border-radius: 0;

    background: #080a0d;
}


/* =========================================================
   RESPONSIVE CONTAINER SIZING
========================================================= */

/*
   Each match is a size container.

   1x1:
   Large match area -> larger UI.

   1x2:
   Medium UI.

   2x2:
   Compact UI.
*/


@container (min-width: 700px) and (min-height: 600px) {

    .summary {
        min-height: 88px;
        padding: 14px 24px;
        gap: 20px;
    }

    .team-logo {
        width: 48px;
        height: 48px;

        flex-basis: 48px;
    }

    .team-name {
        font-size: clamp(15px, 2.2cqw, 25px);
    }

    .score-area {
        min-width: 130px;
    }

    .score {
        font-size: clamp(30px, 4.5cqw, 54px);
    }

    .score-separator {
        margin: 0 8px;
    }

    .status {
        margin-top: 7px;
        font-size: clamp(10px, 1.1cqw, 14px);
    }

    .competition {
        margin-top: 4px;
        max-width: 220px;
        font-size: clamp(9px, 0.9cqw, 12px);
    }

    .stats {
        height: 36px;
    }

    .stat {
        gap: 8px;
    }

    .stat-label {
        font-size: clamp(9px, 0.9cqw, 13px);
    }

    .stat-values {
        font-size: clamp(10px, 1cqw, 14px);
    }

    .momentum-container {
        height: 20px;
        padding: 5px 14px 4px;
    }

    .momentum-bar {
        height: 11px;
    }

    .momentum-label {
        left: 14px;
        top: 2px;
        font-size: 7px;
    }

    .incident-column-home,
    .incident-column-away {
        gap: 5px;
        padding: 14px;
    }

    .incident-item {
        padding: 5px 9px;
        font-size: clamp(9px, 0.9cqw, 13px);
    }

    .incident-icon {
        font-size: clamp(11px, 1.1cqw, 16px);
    }

    .incident-time {
        font-size: clamp(8px, 0.7cqw, 11px);
    }

}


/* =========================================================
   LARGE 1 × 1 MODE
========================================================= */

@container (min-width: 1000px) and (min-height: 700px) {

    .summary {
        min-height: 115px;

        padding: 18px 34px;

        gap: 30px;
    }

    .team {
        gap: 12px;
    }

    .team-logo {
        width: 64px;
        height: 64px;

        flex-basis: 64px;
    }

    .team-name {
        font-size: clamp(20px, 2cqw, 34px);
    }

    .score-area {
        min-width: 180px;
    }

    .score {
        font-size: clamp(42px, 5cqw, 70px);
    }

    .score-separator {
        margin: 0 12px;
    }

    .status {
        margin-top: 9px;
        font-size: clamp(12px, 1.1cqw, 16px);
    }

    .competition {
        max-width: 300px;
        margin-top: 5px;
        font-size: clamp(10px, 0.85cqw, 14px);
    }

    .stats {
        height: 46px;
    }

    .stat {
        gap: 10px;
    }

    .stat-label {
        font-size: clamp(10px, 0.9cqw, 14px);
    }

    .stat-values {
        font-size: clamp(11px, 1cqw, 16px);
    }

    .momentum-container {
        height: 25px;

        padding:
            6px
            20px
            5px;
    }

    .momentum-bar {
        height: 14px;
    }

    .momentum-label {
        left: 20px;
        top: 3px;

        font-size: 8px;
    }

    .incident-column-home,
    .incident-column-away {
        gap: 7px;
        padding: 20px;
    }

    .incident-item {
        max-width: 300px;

        padding: 7px 11px;

        font-size: clamp(10px, 0.9cqw, 15px);
    }

    .incident-icon {
        font-size: clamp(13px, 1.1cqw, 18px);
    }

    .incident-time {
        font-size: clamp(8px, 0.7cqw, 12px);
    }

    .update-indicator {
        right: 10px;
        bottom: 8px;

        font-size: 9px;
    }

}


/* =========================================================
   MEDIUM CONTAINERS
========================================================= */

@container (max-width: 500px) {

    .summary {
        min-height: 48px;

        padding: 6px 8px;

        gap: 6px;
    }

    .team {
        gap: 5px;
    }

    .team-logo {
        width: 20px;
        height: 20px;

        flex-basis: 20px;
    }

    .team-name {
        font-size: 10px;
    }

    .score-area {
        min-width: 54px;
    }

    .score {
        font-size: 16px;
    }

    .status {
        margin-top: 3px;
        font-size: 7px;
    }

    .competition {
        max-width: 90px;
        font-size: 6px;
    }

    .stats {
        height: 23px;
    }

    .stat {
        gap: 3px;
        padding: 0 3px;
    }

    .stat-label {
        font-size: 6px;
    }

    .stat-values {
        font-size: 7px;
    }

    .momentum-container {
        height: 11px;
        padding: 2px 5px;
    }

    .momentum-bar {
        height: 6px;
    }

    .momentum-label {
        left: 5px;
        top: 0;

        font-size: 5px;
    }

    .incident-column-home,
    .incident-column-away {
        gap: 2px;
        padding: 5px;
    }

    .incident-item {
        max-width: 48%;

        padding: 2px 4px;

        font-size: 6px;
    }

    .incident-icon {
        font-size: 8px;
    }

    .incident-time {
        font-size: 5px;
    }

}


/* =========================================================
   VERY SMALL CONTAINERS
========================================================= */

@container (max-width: 330px) {

    .summary {
        grid-template-columns:
            minmax(0, 1fr)
            auto
            minmax(0, 1fr);

        gap: 3px;

        padding: 5px;
    }

    .team-logo {
        width: 17px;
        height: 17px;

        flex-basis: 17px;
    }

    .team-name {
        font-size: 8px;
    }

    .score-area {
        min-width: 43px;
    }

    .score {
        font-size: 13px;
    }

    .status {
        font-size: 6px;
    }

    .competition {
        display: none;
    }

    .stats {
        height: 20px;
    }

    .stat {
        gap: 2px;
        padding: 0 2px;
    }

    .stat-label {
        display: none;
    }

    .stat-values {
        font-size: 6px;
    }

    .momentum-container {
        display: none;
    }

    .incident-item {
        max-width: 70%;

        padding: 2px 3px;

        font-size: 5px;
    }

}


/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 700px) {

    .sidebar {
        position: fixed;

        left: 0;
        top: 0;
        bottom: 0;

        z-index: 2000;

        box-shadow:
            8px 0 30px rgba(0, 0, 0, 0.35);
    }

    .sidebar.hidden {
        transform: translateX(-100%);

        width: 270px;
        min-width: 270px;

        opacity: 1;
    }

    .content {
        padding: 5px;
    }

    .match-grid.layout-2x2 {
        gap: 5px;
    }

    .match-grid.layout-1x2 {
        gap: 5px;
    }

}


/* =========================================================
   TOUCH / SMALL HEIGHT
========================================================= */

@media (max-height: 500px) {

    .sidebar-inner {
        padding: 12px;
    }

    .brand {
        margin-bottom: 14px;
    }

    .sidebar-section {
        margin-bottom: 14px;
    }

    .sidebar-match {
        margin-bottom: 6px;
        padding: 7px;
    }

}