.player-stat-controls{display:flex;align-items:flex-end;flex-wrap:wrap;gap:14px;margin:20px 0;padding:16px;border:1px solid #28506c;border-radius:6px;background:#0a2032}
.player-stat-controls label{display:flex;flex-direction:column;gap:8px;margin:0;color:#9ac8e5;font-size:.8rem}
.player-stat-controls select,.player-stat-controls button{box-sizing:border-box;height:2.75rem;min-height:2.75rem;margin:0}
.player-stat-controls select{min-width:180px;border:1px solid #34566f;border-radius:5px;padding:8px 12px;background:#07182b;color:#eef7ff;font:inherit}
.player-stat-controls>span{margin:auto 0 auto auto;font-size:.78rem;color:#9ab5c9}

/* Accent colours identify the type of statistic. Performance colours are supplied separately. */
.stat-theme--attack{--stat-accent:#f3ab85}
.stat-theme--build{--stat-accent:#6ed8df}
.stat-theme--defend{--stat-accent:#b8b2f4}
.stat-theme--time{--stat-accent:#83c6f2}
.stat-theme--honour{--stat-accent:#efc671}
.stat-theme--form{--stat-accent:#80d4c4}
.stat-theme--discipline{--stat-accent:#b7c7d9}
.stat-theme--yellow{--stat-accent:#ffda53}
.stat-theme--red{--stat-accent:#ff8d8f}

/* Keep each preset on one desktop row. Allow cards to wrap on smaller screens. */
.player-stats-summary,.player-position-metrics{
    --card-columns:4;
    --card-gap:12px;
    display:flex;
    flex-flow:row wrap;
    justify-content:center;
    gap:var(--card-gap);
}
@media(min-width:721px) and (max-width:959px){
    .player-position-metrics:has(>.player-position-metric:nth-child(6):last-child){
        --card-columns:3;
    }
}
@media(min-width:960px){
    .player-stats-summary,.player-position-metrics{
        display:grid;
        grid-template-columns:none;
        grid-auto-flow:column;
        grid-auto-columns:minmax(0,1fr);
        gap:8px;
    }
}
.player-stat-tile,.player-position-metric{
    box-sizing:border-box;
    flex:0 0 calc((100% + var(--card-gap)) / var(--card-columns) - var(--card-gap));
    display:grid;
    grid-template-rows:auto 1fr;
    place-items:center;
    text-align:center;
    min-width:0;
    min-height:9rem;
    padding:1rem .5rem 0;
    border:1px solid #28506c;
    border-top:2px solid var(--stat-accent,#76bcdd);
    border-radius:5px;
    background:linear-gradient(135deg,#102e49,#0a2032);
}
.player-stat-tile>.player-stat-label,.player-position-metric>.player-stat-label,.player-stat-detail>.player-stat-label{
    display:flex;
    align-items:center;
    gap:.36rem;
    min-width:0;
    color:#c4d8e7;
    font-size:.75rem;
    font-weight:650;
    line-height:1.25;
    text-transform:none;
    overflow-wrap:anywhere;
}
.player-stats-page .player-stat-icon{
    display:inline-block;
    flex:none;
    width:.94rem;
    height:.94rem;
    color:var(--stat-accent,#82bee4);
    line-height:1;
}
.player-stat-tile>.player-stat-label,.player-position-metric>.player-stat-label{
    flex-direction:column;
    gap:.4rem;
    width:100%;
    font-size:.86rem;
    text-align:center;
}
.player-stat-tile .player-stat-label .player-stat-icon,.player-position-metric .player-stat-label .player-stat-icon{
    width:1.5rem;
    height:1.5rem;
}
@media(min-width:960px){
    /* Reserve room for two-line titles so the values share a baseline. */
    .player-stat-tile>.player-stat-label,.player-position-metric>.player-stat-label{min-height:4.05rem}
}
.player-stat-tile>strong,.player-stats-page .player-position-metric .player-stat-value .player-stat-number{
    margin:0;
    color:#f2f8ff;
    font-size:clamp(1.2rem,1.8vw,1.5rem);
    font-weight:800;
    line-height:1.15;
    font-variant-numeric:tabular-nums;
}
.player-stats-page .player-stat-value{
    display:flex;
    align-items:center;
    justify-content:space-between;
    flex-wrap:wrap;
    gap:12px;
    min-width:0;
    font-variant-numeric:tabular-nums;
    line-height:1.35;
    text-transform:none;
    letter-spacing:normal;
}
.player-stats-page .player-stat-totals{display:flex;flex-direction:column;gap:7px;min-width:0}
.player-stats-page .player-stat-primary{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 7px}
.player-stats-page .player-stat-value .player-stat-number{display:inline;margin:0;color:#f2f8ff;font-size:1.08rem;font-weight:800;line-height:1.2;white-space:nowrap}
.player-stats-page .player-stat-caption{color:#aac1d3;font-size:.7rem;font-weight:400;line-height:1.4}
.player-stats-page .player-stat-secondary{display:block;color:#a5bed1;font-size:.78rem;line-height:1.4}
.player-stats-page .player-stat-denominator{font-weight:600;white-space:nowrap}
:is(.player-stats-page,.navigation-report) .player-stat-rate{
    display:inline-flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    flex-shrink:0;
    gap:4px;
    min-width:82px;
    padding:9px 10px;
    border:1px solid #28616a;
    border-radius:7px;
    background:#0c323e;
    text-align:center;
}
:is(.player-stats-page,.navigation-report) .player-stat-value .player-stat-rate-number{display:block;margin:0;color:#7ce8da;font-size:1.05rem;font-weight:800;line-height:1.2;white-space:nowrap}
:is(.player-stats-page,.navigation-report) .player-stat-rate-caption{color:#a3d7d5;font-size:.65rem;font-weight:400;line-height:1.3;white-space:normal}
:is(.player-stats-page,.navigation-report) .player-stat-rate.is-unavailable{border-color:#304b60;background:#102638}
:is(.player-stats-page,.navigation-report) .player-stat-rate.is-unavailable .player-stat-rate-number,
:is(.player-stats-page,.navigation-report) .player-stat-rate.is-unavailable .player-stat-rate-caption{color:#9bb3c5}
.player-stats-page .player-stat-unavailable{display:flex;flex-direction:column;gap:5px}
.player-stats-page .player-stat-unavailable .player-stat-number{color:#9bb3c5}
.player-stats-page .player-position-metric>.player-stat-value{
    justify-content:center;
    text-align:center;
}
.player-position-metric .player-stat-primary{justify-content:center;column-gap:5px}
.player-position-metric .player-stat-unavailable{align-items:center}

/* Match the existing last-five ratings and use a softer tint on the surrounding card. */
.player-stat-tile--recent-form{
    --form-fill:#526c80;
    --form-tint:#203d54;
    --stat-accent:#acc6db;
    --card-glow:239 198 113;
    border:2px solid #efc671;
    box-shadow:0 0 8px rgb(239 198 113 / .16);
    background:linear-gradient(135deg,var(--form-tint),#0a2032);
}
.player-stat-tile--recent-form.good,.player-stat-tile--recent-form.elite{
    --form-fill:#219655;
    --form-tint:#163e38;
    --stat-accent:#82e8a4;
}
.player-stat-tile--recent-form.poor{
    --form-fill:#bb3d4b;
    --form-tint:#462836;
    --stat-accent:#ffa7aa;
}
.player-stat-tile--recent-form>strong{
    align-self:center;
    min-width:3.1em;
    padding:2px 7px;
    border-radius:4px;
    background:var(--form-fill);
    color:#fff;
}
.player-stat-tile--recent-form.is-unrated{
    --stat-accent:#93a8b7;
    --form-fill:#395366;
    --form-tint:#193144;
}
.player-stat-tile--recent-form.is-unrated>strong{
    color:#b5cad8;
    background:transparent;
}

.player-stat-details{margin-top:16px}
.player-stat-details>summary{cursor:pointer;color:#dcecf7;font-weight:700}
.player-stat-details[open]>summary{margin-bottom:16px}
.player-stat-details .player-stats-list{
    grid-template-columns:minmax(0,1fr);
    grid-auto-rows:1fr;
}
.player-stat-details .player-stats-list>.player-stat-detail-row{
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:1px;
    padding:0;
    background:transparent;
}
.player-stat-detail-row:nth-child(even){--player-row-base:#0e273c}
.player-stat-grade-help .stat-tooltip{right:0;left:auto;width:15rem;text-align:left}
.player-stat-detail-body:hover .player-stat-grade-help .stat-tooltip{display:block}
.player-stats-page .player-stat-detail-row>.player-stat-detail{
    display:grid;
    grid-template-columns:minmax(0,1fr) auto;
    align-items:center;
    gap:5px 12px;
    padding:9px 12px;
    min-width:0;
    background:var(--player-row-highlight,var(--player-row-base,#0b2033));
}
.player-stat-detail>.player-stat-label{font-size:.82rem;line-height:1.35}
.player-stat-detail-body{display:flex;flex-direction:column;align-items:flex-end;gap:3px;text-align:right}
.player-stat-detail .player-stat-totals{align-items:flex-end}
.player-stat-detail .player-stat-grade{
    color:var(--stat-tone,#b3c9d9);
    font-size:.69rem;
    font-weight:650;
    line-height:1.2;
    white-space:nowrap;
}
.player-stats-page .player-stat-detail .player-stat-number{color:var(--stat-tone,#edf6fd)}

/* Compact table cells use separate lines instead of one long value string. */
.player-stats-page .table-wrapper{max-width:100%;overflow-x:auto}
.player-stats-page :is(.player-history-table,.player-competition-table,.player-form-table) td{padding:12px 10px;vertical-align:middle}
.player-stats-page :is(.player-history-table,.player-competition-table,.player-form-table) tbody tr>:is(td,.stat-row-label){
    background-color:var(--player-row-highlight,var(--player-row-base,#07182b));
}
.player-form-table tbody tr:nth-child(even){--player-row-base:#0a1d31}
.player-history-table td:first-child,.player-competition-table td:first-child,.player-form-table td:first-child{position:sticky;left:0;background:#07182b;z-index:1}
.player-stats-page .player-stat-cell .player-stat-value{display:inline-flex;flex-direction:column;align-items:center;justify-content:center;flex-wrap:nowrap;gap:7px;min-width:66px}
.player-stats-page .player-stat-cell .player-stat-totals{align-items:center;gap:3px}
.player-stats-page .player-stat-cell .player-stat-primary{justify-content:center;gap:5px}
.player-stats-page .player-stat-cell .player-stat-number{font-size:.94rem}
.player-stats-page .player-stat-cell .player-stat-caption{font-size:.7rem}
:is(.player-stats-page,.navigation-report) .player-stat-cell .player-stat-rate{flex-direction:row;gap:6px;min-width:0;padding:4px 7px;border-radius:5px}
:is(.player-stats-page,.navigation-report) .player-stat-cell .player-stat-rate-number{font-size:.78rem}
:is(.player-stats-page,.navigation-report) .player-stat-cell .player-stat-rate-caption{font-size:.68rem;white-space:nowrap}
:is(.player-stats-page,.navigation-report) .player-stat-cell .player-stat-value--percent .player-stat-rate{flex-direction:column;padding:7px 9px}
:is(.player-stats-page,.navigation-report) .player-stat-cell .player-stat-value--percent .player-stat-rate-number{font-size:.94rem}
.player-stats-page .player-stat-cell .player-stat-value--count .player-stat-totals .player-stat-caption,
.player-stats-page .player-stat-cell .player-stat-value--decimal .player-stat-totals .player-stat-caption{display:none}
.player-stats-page .player-stat-cell .player-stat-unavailable{align-items:center}
.player-stats-page select:focus-visible,.player-stat-details summary:focus-visible{outline:2px solid #ffda32;outline-offset:3px}

/* Match the first column, totals and awards to the groups in the header. */
.player-stats-page :is(.player-history-table,.player-competition-table) thead th{
    background:#10283c;
    color:#b3d1e7;
    font-size:.66rem;
    line-height:1.3;
    padding:9px 7px;
}
.player-stats-page :is(.player-history-table,.player-competition-table) :is(td,.stat-row-label){
    padding:8px 7px;
    color:#c3d5e4;
    font-variant-numeric:tabular-nums;
    line-height:1.35;
}
:is(.player-history-table,.player-competition-table) tbody tr{--player-row-base:#0a1c2e}
:is(.player-history-table,.player-competition-table) tbody tr:nth-child(even){--player-row-base:#10283b}
.player-stats-page :is(.player-history-table,.player-competition-table) .stat-row-label{
    position:sticky;
    left:0;
    z-index:1;
    color:#e1edf7;
    font-size:.82rem;
    font-weight:700;
    text-align:left;
    text-transform:none;
}
.player-stats-page :is(.player-history-table,.player-competition-table) .stat-group-start{border-left:1px solid #345065}
.player-stats-page :is(.player-history-table,.player-competition-table) thead th:nth-last-child(-n+2){color:#ecc982}
.player-stats-page :is(.player-history-table,.player-competition-table) .stat-award-cell{color:#f3d387}
.player-competition-table .stat-award-cell a{color:inherit;text-underline-offset:3px}
.player-competition-table .stat-award-cell a:hover{text-decoration:underline}
.stat-competition-label{display:inline-flex;align-items:center;gap:6px}
.stat-competition-label .form-competition-icon{color:#a9cee7;font-size:1rem;line-height:1}
.player-stats-page :is(.player-history-table,.player-competition-table) .player-stat-value{min-width:0;gap:4px}
:is(.player-stats-page,.navigation-report) :is(.player-history-table,.player-competition-table) .player-stat-rate{padding:2px 5px}

/* Recent form keeps each result and role in a single, stacked column. */
.player-form-table td{color:#dceaf4}
.player-stats-page .player-form-table :is(th,td){padding:8px 6px}
.player-stats-page .player-form-table th{white-space:normal}
.player-stats-page .player-form-table .player-stat-value{min-width:0}
.player-form-table .form-fixture-link{
    display:inline-flex;
    align-items:center;
    gap:.4rem;
    min-width:min(7rem,26vw);
    max-width:11rem;
    text-align:left;
    white-space:normal;
    line-height:1.3;
}
.form-fixture-link>span:last-child{overflow-wrap:anywhere}
.form-fixture-link .form-competition-icon{flex:none;color:#a9cee7;font-size:1rem;line-height:1}
.player-form-table .form-cell-stack{display:inline-flex;flex-direction:column;align-items:center;gap:4px}
.form-cell-stack small{color:#aac1d3;font-size:.7rem}
.form-cell-stack .form-score{color:#dceaf4;font-weight:600;font-variant-numeric:tabular-nums}
.form-cell-stack .form-position-badge{
    display:inline-block;
    min-width:2em;
    padding:3px 5px;
    border:1px solid #396789;
    border-radius:4px;
    background:#173651;
    color:#cceaff;
    font-size:.75rem;
    font-weight:800;
    text-align:center;
}
.player-form-table .form-potm-star{color:#ffd24a;font-size:1.15rem;line-height:1}
.player-form-table .form-week{position:relative;cursor:help;text-underline-offset:3px}
.form-week:focus-visible::after{
    content:attr(title);
    position:absolute;
    z-index:3;
    top:50%;
    left:50%;
    transform:translate(-50%,-50%);
    padding:5px 8px;
    border:1px solid #ffda32;
    border-radius:4px;
    background:#07182b;
    color:#eef7ff;
    white-space:nowrap;
    pointer-events:none;
}

/* Highlight a complete data row, including its sticky first cell. */
.player-stats-page{--player-row-light:#193b52}
.player-stats-page :is(.player-stat-detail-row,tbody tr):focus-within{--player-row-highlight:var(--player-row-light)}
.player-stats-page .player-award:focus-visible{
    box-shadow:0 0 0 1px rgb(239 198 113 / .55),0 2px 12px rgb(239 198 113 / .24);
}
@media (hover:hover) and (pointer:fine){
    .player-stats-page :is(.player-stat-detail-row,tbody tr):hover{--player-row-highlight:var(--player-row-light)}
    .player-stats-page :is(.player-stat-tile,.player-position-metric,.standing-card,.form-rating):hover{
        box-shadow:0 0 0 1px rgb(var(--card-glow,126 198 239) / .48),0 2px 12px rgb(var(--card-glow,126 198 239) / .23);
    }
    .player-stat-details>summary:hover{color:#b8e5ff}
}
@media (hover:hover) and (pointer:fine) and (prefers-reduced-motion:no-preference){
    .player-stats-page :is(.player-stat-tile,.player-position-metric,.standing-card,.form-rating){
        transition:transform 140ms ease-out,box-shadow 140ms ease-out;
    }
    .player-stats-page :is(.player-stat-tile,.player-position-metric,.standing-card,.form-rating):hover{
        transform:scale(1.012);
    }
}

@media(max-width:720px){
    .player-stats-summary,.player-position-metrics{--card-columns:2;--card-gap:10px}
    .player-stat-tile,.player-position-metric{min-height:8rem}
    .player-stat-controls>span{flex-basis:100%;margin:0}
    .player-stat-controls label{flex:1;min-width:0}
    .player-stat-controls select{width:100%;min-width:0}
    .player-stats-page .player-stat-detail-row>.player-stat-detail{
        position:relative;
        grid-template-columns:minmax(0,1fr);
        align-content:center;
        justify-items:start;
        gap:4px;
        padding:8px;
    }
    .player-stat-detail-body,.player-stat-detail .player-stat-totals{align-items:flex-start;text-align:left}
    .player-stat-detail .player-stat-grade-help{position:static}
    .player-stat-detail .stat-tooltip{box-sizing:border-box;max-width:190%}
    .player-stat-detail:nth-child(odd) .stat-tooltip{left:0;right:auto}
}
@media(max-width:480px){
    .player-stat-controls label{flex:1 1 100%}
    .player-stat-controls button{width:100%}
    .player-stats-page .player-stat-value{gap:10px}
    :is(.player-stats-page,.navigation-report) .player-stat-rate{min-width:76px;padding:8px}
}

/* Crossing percentages share the existing rate cell. */
.player-crossing-rates{display:flex;flex-direction:column;gap:8px;width:100%;min-width:0}
.player-crossing-rate{display:flex;align-items:baseline;justify-content:space-between;gap:12px}
.player-crossing-rate strong{white-space:nowrap}
.player-crossing-rates .player-stat-grade-help{align-self:flex-end}
.player-crossing-rates small{font-size:.75rem}

.player-crossing-rates .player-crossing-rate{display:flex;align-items:center;justify-content:space-between;gap:12px}.player-stat-grade.is-small-sample{font-size:.58rem!important;color:#8197a8!important;opacity:.85;background:none;border:0;padding:1px 0}.player-crossing-rate .player-stat-label{display:flex;align-items:center;gap:7px}
