.teamstat-wrapper{
    max-width:1240px;
    width:calc(100% - 24px);
    margin:20px auto 40px;
    color:#fff;
    font-family:'Jost',sans-serif;
    background:#2e2750;
    border-radius:12px;
    padding:16px;
    display:flex;
    flex-direction:column;
}

.teamstat-header{
    display:flex;
    justify-content:space-between;
    align-items:center;
    margin-bottom:14px;
    gap:20px;
}

.teamstat-title{
    font-size:28px;
    font-weight:800;
    margin:0;
    line-height:1.1;
}

.teamstat-header form{
    width:100%;
    max-width:283px;
}

.teamstat-header .socca-select-shell{
    width:100%;
}

.teamstat-tabs{
    display:flex;
    gap:0;
    margin:6px 0 16px;
    background:#4a4270;
    border-radius:6px;
    padding:4px;
    width:100%;
    overflow-x:auto;
    scrollbar-width:none;
    -ms-overflow-style:none;
}

.teamstat-tabs::-webkit-scrollbar{display:none;}

.stat-tab{
    flex:1 1 0;
    min-width:0;
    padding:7px 12px;
    text-align:center;
    border-radius:4px;
    cursor:pointer;
    font-size:14px;
    font-weight:500;
    color:#dce0f2;
    transition:0.2s;
    white-space:nowrap;
}

.stat-tab.active{
    background:#8b74f1;
    color:#ffffff;
    font-weight:600;
}

.teamstat-header .socca-select-shell{
    position:relative;
    width:100%;
    max-width:283px;
    min-height:46px;
    background:#231c3d;
    border:1px solid #6f58cf;
    border-radius:10px;
    box-shadow:0 0 0 1px rgba(139,116,241,0.15) inset;
    display:flex;
    align-items:center;
    overflow:hidden;
}

.teamstat-header .socca-select-shell .socca-select{
    background:transparent;
    color:#f5f7ff;
    font-weight:600;
    width:100%;
    height:46px;
    padding:0 38px 0 42px;
    border:0;
    outline:none;
    appearance:none;
    -webkit-appearance:none;
    -moz-appearance:none;
    cursor:pointer;
}

.teamstat-header .socca-select-shell .socca-select-icon{
    position:absolute;
    left:12px;
    top:50%;
    transform:translateY(-50%);
    color:#b9a8ff;
    pointer-events:none;
    z-index:2;
}

.teamstat-header .socca-select-shell::after{
    content:"";
    position:absolute;
    right:12px;
    top:50%;
    width:8px;
    height:8px;
    border-right:2px solid #b9a8ff;
    border-bottom:2px solid #b9a8ff;
    transform:translateY(-62%) rotate(45deg);
    pointer-events:none;
    z-index:2;
    border-right-color:#b9a8ff;
    border-bottom-color:#b9a8ff;
}

.teamstat-header .socca-select-shell .socca-select:hover,
.teamstat-header .socca-select-shell .socca-select:focus{
    background:rgba(139,116,241,0.12);
}

.teamstat-header .socca-select-shell .socca-select option{
    background:#231c3d;
    color:#f5f7ff;
}

.stat-content{
    background:transparent;
    border-radius:8px;
    padding:0;
    overflow-x:auto;
    -webkit-overflow-scrolling:touch;
}

.stat-content .stat-table{
    min-width:760px;
}

.stat-table{
    width:100%;
    border-collapse:separate;
    border-spacing:0 4px;
    background:transparent;
}

.stat-table thead tr{background:transparent;}

.stat-table th,
.stat-table td{
    padding:8px 16px;
    text-align:left;
    border:0;
}

.stat-table th{
    color:#bdb2da;
    font-weight:500;
    font-size:13px;
}

.icon-head{text-align:center!important;}

.th-icon{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    line-height:1;
    color:#bdb2da;
}

.th-icon svg{
    display:block;
    width:auto;
    height:20px;
}

.stat-table tbody tr{
    border-radius:5px;
}

.stat-table tbody tr:nth-child(even){
    background:#2b2149;
}

.stat-table tbody tr:nth-child(odd){
    background:#2e2750;
}

.stat-table tbody tr td:first-child{
    border-left:3px solid transparent;
    border-radius:5px 0 0 5px;
}

.stat-table tbody tr:first-child td:first-child{
    border-left-color:#39d68d;
}

.stat-table tbody tr:last-child td:first-child{
    border-left-color:#d7263d;
}

.stat-table tbody tr td:last-child{
    border-radius:0 5px 5px 0;
}

.rank-col{
    width:25px;
    text-align:center;
    color:#fff;
    font-size:18px;
    line-height:1;
    font-weight:800;
}

.team-col{
    display:flex;
    align-items:center;
    gap:12px;
    font-size:16px;
    font-weight:600;
    min-width:0;
}

.team-logo{
    width:40px;
    height:40px;
    border-radius:999px;
    object-fit:contain;
    flex-shrink:0;
}

.val-col{
    font-weight:700;
    color:#fff;
    font-size:16px;
    text-align:center;
}

.metric-pill{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    min-width:30px;
    padding:4px 12px;
    border-radius:3px;
    line-height:1.1;
    font-weight:700;
}

.metric-pill-green{
    background:#2fda83;
    color:#1f2638;
}

/* Green badge only for rank-1 row; all others use neutral pill */
.stat-table tbody tr:not(:first-child) .metric-pill-green {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.mobile-stat-card .stat-card:not(:first-child) .stat-card-value.green {
    background: transparent;
    color: #fff;
    padding: 0;
    border-radius: 0;
}

.highlight-red{color:#e8e9f8;}

.stat-table td:nth-child(3),
.stat-table td:nth-child(4),
.stat-table th:nth-child(3),
.stat-table th:nth-child(4){
    text-align:center;
}

.stat-table td:nth-child(3){
    font-size:16px;
    font-weight:500;
    width:32px;
}

.stat-table td:nth-child(4){
    width:32px;
}

/* Mobile Card View for Team Stats */
.mobile-stat-card {
    display: none;
}

.mobile-stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px 10px;
    color: #bcb4d8;
    font-size: 11px;
    font-weight: 600;
}

.mobile-stat-header-icons {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-stat-header-icon {
    display: inline-flex;
    align-items: center;
    color: #bcb4d8;
}

.mobile-stat-header-icon svg {
    display: block;
    height: 16px;
    width: auto;
}

@media (max-width:1024px){
    .teamstat-title{
        font-size:24px;
    }

    .stat-tab{
        min-width:0;
        font-size:13px;
    }

    .team-col{
        gap:10px;
        font-size:14px;
    }

    .team-logo{
        width:28px;
        height:28px;
    }

    .rank-col{
        font-size:16px;
        width:24px;
    }

    .stat-table th,
    .stat-table td{
        padding:8px 12px;
    }

    .th-icon svg{height:16px;}

    .stat-table td:nth-child(3),
    .stat-table td:nth-child(4){
        width:24px;
        font-size:13px;
    }
}

@media (max-width:768px){
    .teamstat-wrapper{
        width:calc(100% - 12px);
        margin:12px auto 30px;
        padding:10px;
        background:transparent;
        border-radius:0;
    }

    .teamstat-title{
        font-size:18px;
        line-height:24px;
    }

    .teamstat-header{
        flex-direction:column;
        align-items:flex-start;
        gap:10px;
    }

    .teamstat-header form{
        max-width:none;
        width:100%;
    }

    .teamstat-header .socca-select-shell{
        max-width:none;
    }

    .teamstat-tabs{
        margin:4px 0 12px;
        gap:0;
        height:auto;
        background:#1f1a38;
        border-radius:8px;
        padding:4px;
    }

    .stat-tab{
        font-size:12px;
        min-width:0;
        flex:1;
        padding:8px 6px;
    }

    .stat-content{
        padding:0;
        overflow-x:visible;
    }

    /* Hide table on mobile, show cards instead */
    .stat-content .stat-table{
        display: none;
    }

    .mobile-stat-card {
        display: block;
    }

    .mobile-stat-card .stat-card {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 10px 12px;
        background: #2e2750;
        border-radius: 6px;
        margin-bottom: 6px;
    }

    .mobile-stat-card .stat-card:nth-child(odd) {
        background: #302852;
    }

    .mobile-stat-card .stat-card:first-child {
        border-left: 3px solid #39d68d;
    }

    .mobile-stat-card .stat-card-left {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .mobile-stat-card .stat-card-rank {
        font-size: 14px;
        font-weight: 800;
        color: #fff;
        min-width: 20px;
    }

    .mobile-stat-card .stat-card-team {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .mobile-stat-card .stat-card-team img {
        width: 24px;
        height: 24px;
        border-radius: 50%;
        object-fit: contain;
    }

    .mobile-stat-card .stat-card-team span {
        font-size: 13px;
        font-weight: 600;
        color: #fff;
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-stat-card .stat-card-right {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .mobile-stat-card .stat-card-matches {
        font-size: 12px;
        color: #9f9f9f;
    }

    .mobile-stat-card .stat-card-value {
        font-size: 14px;
        font-weight: 700;
        color: #fff;
        min-width: 30px;
        text-align: center;
    }

    .mobile-stat-card .stat-card-value.green {
        background: #2fda83;
        color: #1f2638;
        padding: 2px 8px;
        border-radius: 3px;
    }

    .stat-table th{
        font-size:10px;
    }

    .team-col{
        font-size:12px;
    }

    .rank-col{
        font-size:12px;
    }

    .val-col,
    .stat-table td:nth-child(3),
    .stat-table td:nth-child(4){
        font-size:12px;
    }

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

    .metric-pill{
        padding:3px 8px;
    }
}

@media (max-width:425px) {
    .teamstat-wrapper {
        padding: 8px;
    }

    .teamstat-title {
        font-size: 16px;
    }

    .stat-tab {
        font-size: 11px;
        padding: 6px 4px;
    }

    .mobile-stat-card .stat-card {
        padding: 8px 10px;
    }

    .mobile-stat-card .stat-card-rank {
        font-size: 12px;
    }

    .mobile-stat-card .stat-card-team img {
        width: 20px;
        height: 20px;
    }

    .mobile-stat-card .stat-card-team span {
        font-size: 11px;
        max-width: 100px;
    }

    .mobile-stat-card .stat-card-matches {
        font-size: 10px;
    }

    .mobile-stat-card .stat-card-value {
        font-size: 12px;
    }
}
