/* Match card */
.tmt-match {
    --match-status: #cbd5e1;
    --match-status-bg: #f8fafc;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
    margin: 10px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-left: 4px solid var(--match-status);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgb(15 23 42 / 6%);
    color: #1e293b;
    font-size: 14px;
    transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.tmt-match:hover {
    border-color: #cbd5e1;
    border-left-color: var(--match-status);
    box-shadow: 0 12px 30px rgb(15 23 42 / 10%);
}

.tmt-match.status-1 {
    --match-status: #f59e0b;
    --match-status-bg: #fffbeb;
}

.tmt-match.status-2 {
    --match-status: #0ea5e9;
    --match-status-bg: #f0f9ff;
}

.tmt-match.status-3 {
    --match-status: #22c55e;
    --match-status-bg: #f0fdf4;
}

/* Header */
.tmt-match .match-title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 8px 10px;
    background: var(--match-status-bg);
    border-bottom: 1px solid #e2e8f0;
    cursor: pointer;
}

.tmt-match .match-title > b {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    line-height: 20px;
}

.tmt-match .match-title > b:hover {
    color: var(--main-color);
}

.tmt-match .match-title > .fa-up-down-left-right {
    flex: 0 0 auto;
    color: #94a3b8;
    cursor: grab;
}

.tmt-match .match-title > .fa-up-down-left-right:active {
    cursor: grabbing;
}

.tmt-match .match-time {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    font-size: 12px;
}

.tmt-match .match-time > i {
    color: var(--match-status);
}

/* Teams */
.tmt-match .match-body {
    padding: 5px 8px;
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.tmt-match .team-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.tmt-match .team-container .team-item {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    min-width: 0;
    min-height: 58px;
    margin: 0;
    padding: 6px 8px;
    background: #fff;
    border: 1px solid transparent;
    border-radius: 8px;
    line-height: 20px;
    transition: background .2s ease, border-color .2s ease;
}

.tmt-match .team-container .team-item + .team-item {
    border-top-color: #f1f5f9;
}

.tmt-match .team-container .team-item:hover {
    background: #f8fafc;
    border-color: #e2e8f0;
}

.tmt-match .team-container .team-item.winner {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.tmt-match .team-container .team-item.retire {
    opacity: .55;
    filter: grayscale(.35);
}

.tmt-match .team-container .team-item > .oneline {
    width: 100%;
    margin-bottom: 2px;
    color: #64748b;
    font-size: 12px;
    line-height: 17px;
}

.team-score-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 7px;
    width: 100%;
    min-width: 0;
}

.tmt-match .acc-items {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
}

.tmt-match .acc-item {
    flex: 1 1 0;
    min-width: 0;
}

.tmt-match .acc-item .user-name {
    max-height: 36px;
    overflow: hidden;
    font-size: 13px;
    line-height: 18px;
}

.tmt-match .acc-item.unchecked {
    opacity: .55;
}

/* Serving and scores */
.tmt-match .serving {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 12px;
}

.tmt-match .serving i {
    margin: 0;
    color: var(--main-highlight-color, #2563eb);
    font-size: 10px;
}

.team-item .scores {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
}

.team-item .scores span {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}

.team-item .scores span.highlight {
    background: var(--main-highlight-color, #2563eb);
    border-color: var(--main-highlight-color, #2563eb);
    color: #fff;
}

.tmt-match .match-body > .start-time {
    box-sizing: border-box;
    display: flex;
    flex: 0 0 82px;
    align-items: center;
    justify-content: center;
    padding: 8px 6px;
    background: #fffbeb;
    border: 1px dashed #fcd34d;
    border-radius: 8px;
    color: #92400e;
    font-size: 11px;
    font-weight: 600;
    line-height: 17px;
    text-align: center;
    white-space: normal;
    flex-direction: column;
}

.tmt-match .start-time small,
.tmt-match .start-time b {
    display: block;
}

.tmt-match .start-time small {
    margin-bottom: 2px;
    color: #94a3b8;
    font-size: 10px;
    font-weight: 500;
}

.tmt-match .start-time b {
    color: #475569;
    font-size: 11px;
    line-height: 16px;
}


@media (max-width: 640px) {
    .tmt-match .match-body {
        gap: 5px;
        padding: 5px 6px;
    }

    .tmt-match .match-body > .start-time {
        flex-basis: 68px;
        padding: 6px 4px;
        font-size: 10px;
        line-height: 15px;
    }
}

/* Footer */
.tmt-match .match-footer {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 38px;
    margin: 0;
    padding: 6px 10px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.tmt-match .match-footer .match-round,
.tmt-match .match-footer > b {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    color: #475569;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tmt-match .match-footer button,
.tmt-match .match-footer select,
.tmt-match .sub-match-actions button {
    box-sizing: border-box;
    min-height: 30px;
    margin: 0;
    padding: 4px 9px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    background: #fff;
    color: #334155;
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.tmt-match .match-footer button:hover,
.tmt-match .sub-match-actions button:hover {
    border-color: #94a3b8;
    background: #f1f5f9;
}

.tmt-match .match-footer select {
    max-width: 135px;
}

.tmt-match .streaming {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: #ef4444;
    border-radius: 7px;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
}

.tmt-match .streaming i {
    margin: 0;
    color: inherit;
}

/* Team-match actions */
.tmt-match .sub-match-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    background: #fff;
    border-top: 1px dashed #cbd5e1;
}

.tmt-match .sub-match-show {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #475569;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    user-select: none;
}

.tmt-match .sub-match-show:hover {
    color: var(--main-highlight-color, #2563eb);
}

/* Sub-match list */
.tmt-match > .sub-matches {
    position: relative;
    margin: 0 8px 8px;
    padding: 8px;
    background: #f8fafc;
    border: 1px solid #dbe3ec;
    border-radius: 10px;
}

.tmt-match > .sub-matches::before {
    position: absolute;
    top: 13px;
    bottom: 13px;
    left: 13px;
    width: 2px;
    background: #cbd5e1;
    border-radius: 2px;
    content: "";
}

.tmt-match > .sub-matches > .sub-match-item {
    margin: 0 0 7px 12px;
    border-left-width: 3px;
    border-radius: 9px;
    box-shadow: 0 3px 10px rgb(15 23 42 / 5%);
}

.tmt-match > .sub-matches > .sub-match-item:last-child {
    margin-bottom: 0;
}

.tmt-match > .sub-matches > .sub-match-item::before {
    position: absolute;
    top: 19px;
    left: -10px;
    width: 8px;
    height: 2px;
    background: #cbd5e1;
    content: "";
}

.sub-match-item .match-title {
    padding: 6px 8px;
}

.sub-match-item .match-title > b {
    padding: 2px 6px;
    font-size: 12px;
}

.sub-match-item .match-body {
    padding: 4px 6px;
}

.sub-match-item .team-container {
    gap: 2px;
}

.sub-match-item .team-container .team-item {
    min-height: 50px;
    padding: 4px 6px;
}

.sub-match-item .team-container .team-item > .oneline {
    margin-bottom: 0;
    font-size: 11px;
}

.sub-match-item .acc-item img {
    flex-basis: 26px;
    width: 26px;
    height: 26px;
}

.sub-match-item .acc-item .user-name {
    max-height: 32px;
    font-size: 12px;
    line-height: 16px;
}

.sub-match-item .scores span {
    width: 25px;
    height: 25px;
    border-radius: 6px;
    font-size: 12px;
}

.sub-match-item .match-footer {
    justify-content: flex-end;
    min-height: 34px;
    padding: 4px 8px;
}

.sub-match-item .match-footer select {
    max-width: 150px;
}

/* Existing arrow */
.tmt-match .sub-match-show .arrow {
    transition: transform .2s ease;
}

.tmt-match .sub-match-show .arrow.down {
    transform: rotate(180deg);
}

/* General icons */
.tmt-match i.fa-solid {
    margin-right: 2px;
}

/* Narrow cards / mobile */
@media (max-width: 640px) {
    .tmt-match {
        margin: 8px 5px;
        border-radius: 10px;
    }

    .tmt-match .team-score-wrap {
        gap: 4px;
    }

    .tmt-match .acc-items {
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
    }

    .tmt-match .acc-item img {
        flex-basis: 26px;
        width: 26px;
        height: 26px;
    }

    .tmt-match .scores {
        gap: 2px;
    }

    .tmt-match .scores span {
        width: 25px;
        height: 25px;
    }

    .tmt-match .match-footer,
    .tmt-match .sub-match-actions {
        flex-wrap: wrap;
    }

    .tmt-match .match-footer .match-round {
        flex-basis: 100%;
    }

    .tmt-match > .sub-matches {
        margin-right: 5px;
        margin-left: 5px;
        padding: 6px;
    }
}