.players-layout {
    display: block;
}

.profile-section {
    padding-top: 0.62rem;
    margin-top: 0.38rem;
}

.profile-section + .section {
    margin-top: 0.72rem;
}

.profile-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.55rem;
    margin-bottom: 0.4rem;
}

.profile-logout-btn {
    width: 2.45rem;
    min-width: 2.45rem;
    min-height: 2.45rem;
    padding: 0;
    border-radius: 999px;
    display: inline-grid;
    place-items: center;
    border-color: rgba(200, 74, 82, 0.26);
    background: linear-gradient(180deg, #fff7f7, #fdebed);
    color: #a43b45;
    box-shadow: 0 10px 22px rgba(17, 27, 41, 0.1);
}

.profile-logout-btn svg {
    width: 1.16rem;
    height: 1.16rem;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.95;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.profile-logout-btn:hover {
    background: linear-gradient(180deg, #ffffff, #f9e0e4);
    border-color: rgba(200, 74, 82, 0.42);
}

.profile-logout-btn-inline {
    align-self: start;
    justify-self: end;
}

.profile-snapshot {
    display: grid;
    gap: 0.52rem;
    max-width: 1140px;
    margin-inline: auto;
}

.readonly-chip {
    border-color: color-mix(in srgb, var(--green-500) 48%, var(--border));
    background: color-mix(in srgb, var(--green-100) 72%, var(--white));
    color: var(--green-700);
}

.profile-image-square {
    width: 108px;
    height: 108px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: color-mix(in srgb, var(--surface-strong) 84%, transparent);
}

.profile-image-square img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.profile-actions-inline {
    display: flex;
    justify-content: flex-end;
}

.profile-actions-inline .btn {
    min-width: 152px;
}

.profile-footer-actions {
    margin-top: 0.14rem;
}

.profile-top {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.62rem;
    align-items: start;
}

.profile-image-square-lg {
    width: 112px;
    height: 112px;
}

.profile-hero {
    display: grid;
    gap: 0.46rem;
    align-content: start;
    min-width: 0;
    width: 100%;
}

.profile-summary {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--white) 92%, var(--surface-strong));
    padding: 0.56rem 0.62rem;
    display: grid;
    gap: 0.18rem;
    min-width: 0;
}

.profile-summary-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.62rem;
}

.profile-summary-title {
    display: grid;
    gap: 0.12rem;
    min-width: 0;
}

.profile-summary-name {
    margin: 0;
    font-size: 1.12rem;
    line-height: 1.2;
    color: var(--ink-900);
}

.profile-summary-location {
    margin: 0;
    font-size: 0.8rem;
    line-height: 1.35;
    color: var(--ink-600);
}

.profile-role-chip {
    white-space: nowrap;
}

.profile-summary-identity {
    margin: 0.08rem 0 0;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.4;
    color: var(--ink-600);
}

.profile-summary-contact {
    display: flex;
    flex-wrap: wrap;
    gap: 0.42rem 0.66rem;
}

.profile-summary-contact-item {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--ink-700);
    background: color-mix(in srgb, var(--surface-strong) 88%, transparent);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 0.16rem 0.48rem;
}

.snapshot-grid {
    display: grid;
    gap: 0.46rem;
}

.snapshot-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--surface-strong) 82%, transparent);
    padding: 0.42rem 0.56rem;
    min-height: 62px;
}

.snapshot-item .label {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--ink-500);
}

.snapshot-item .value {
    margin-top: 0.12rem;
    font-weight: 700;
    font-size: 0.9rem;
    line-height: 1.26;
    color: var(--ink-900);
    word-break: break-word;
}

.snapshot-item.full {
    grid-column: 1 / -1;
}

.profile-form-actions {
    justify-content: flex-end;
}

.page-profile .profile-cover-surface {
    background:
        radial-gradient(circle at top right, rgba(21, 163, 155, 0.08), transparent 28%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(247, 250, 252, 0.94));
}

.page-profile .profile-hub-surface {
    background:
        radial-gradient(circle at top left, rgba(214, 36, 47, 0.05), transparent 22%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(249, 252, 253, 0.94));
}

#update-profile-modal .player-modal {
    width: min(980px, calc(100vw - 1rem));
    max-height: min(94vh, 760px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 0.6rem;
}

.profile-edit-modal-topbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

#update-profile-modal #profile-form {
    margin-top: 0;
    overflow: auto;
    align-content: start;
    gap: 0.58rem;
    padding-right: 0.2rem;
    scrollbar-gutter: stable both-edges;
}

#update-profile-modal .field {
    gap: 0.22rem;
}

#update-profile-modal input,
#update-profile-modal select,
#update-profile-modal textarea {
    padding: 0.58rem 0.68rem;
}

#update-profile-modal textarea {
    min-height: 80px;
}

#update-profile-modal .profile-form-actions {
    position: sticky;
    bottom: 0;
    z-index: 1;
    background: var(--white);
    border-top: 1px solid var(--border);
    padding-top: 0.48rem;
    margin-top: 0.1rem;
    justify-content: flex-end;
}

.profile-image-editor {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.profile-image-square-interactive {
    cursor: pointer;
}

.profile-image-square-interactive:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--green-500) 44%, var(--border));
    outline-offset: 2px;
}

.profile-image-input-wrap {
    display: grid;
    gap: 0.32rem;
    position: relative;
}

.profile-image-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.profile-image-controls {
    margin: 0;
    gap: 0.45rem;
}

.profile-image-action-btn {
    border-radius: var(--radius-sm);
    flex: 1 1 10rem;
    justify-content: center;
    text-align: center;
}

.player-cards {
    display: grid;
    gap: 0.7rem;
}

.player-search-pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.search-filter-actions {
    align-items: flex-end;
    justify-content: flex-start;
    gap: 0.5rem;
}

.player-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.8rem;
    background: color-mix(in srgb, var(--white) 91%, transparent);
    display: grid;
    gap: 0.45rem;
}

.player-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.player-avatar {
    width: 2.8rem;
    height: 2.8rem;
    border-radius: 50%;
    border: 2px solid color-mix(in srgb, var(--green-500) 32%, transparent);
    overflow: hidden;
    background: color-mix(in srgb, var(--surface-strong) 80%, transparent);
}

.player-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.stat-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.stat-tab {
    border: 1px solid var(--border);
    background: color-mix(in srgb, var(--white) 90%, transparent);
    border-radius: var(--radius-pill);
    padding: 0.5rem 0.85rem;
    font-weight: 700;
    cursor: pointer;
}

.stat-tab.active {
    border-color: color-mix(in srgb, var(--green-500) 44%, var(--border));
    background: color-mix(in srgb, var(--green-500) 16%, transparent);
    color: var(--ink-900);
}

.stat-panel {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--white) 92%, transparent);
    padding: 0.72rem;
}

.career-metrics {
    display: grid;
    gap: 0.48rem;
}

.career-metric {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--surface-strong) 84%, transparent);
    padding: 0.52rem 0.6rem;
}

.career-metric .label {
    font-size: 0.64rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--ink-500);
}

.career-metric .value {
    margin-top: 0.12rem;
    font-weight: 700;
}

.recent-match-grid {
    display: grid;
    gap: 0.62rem;
}

.recent-match-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--white) 92%, transparent);
    padding: 0.72rem;
    display: grid;
    gap: 0.38rem;
}

.recent-match-row {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    align-items: center;
}

.recent-match-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

@media (min-width: 768px) {
    .profile-top {
        grid-template-columns: 112px 1fr;
    }

    #update-profile-modal #profile-form.form-grid.two {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .snapshot-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .player-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .career-metrics {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

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

@media (min-width: 992px) {
    .profile-summary {
        min-height: 100%;
    }

    .profile-actions-inline .btn {
        min-width: 142px;
    }

    .snapshot-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .snapshot-item.full {
        grid-column: span 2;
    }

    .career-metrics {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    #update-profile-modal .player-modal {
        width: min(1040px, calc(100vw - 2rem));
    }

    #update-profile-modal #profile-form.form-grid.two {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .page-profile .profile-section {
        padding-top: 0.38rem;
        margin-top: 0.24rem;
    }

    .page-profile .profile-toolbar {
        margin-bottom: 0.28rem;
    }

    .page-profile .profile-summary {
        padding: 0.46rem 0.5rem;
        gap: 0.14rem;
    }

    .page-profile .profile-summary-head {
        gap: 0.4rem;
    }

    .page-profile .profile-summary-name {
        font-size: 0.98rem;
    }

    .page-profile .profile-summary-location,
    .page-profile .profile-summary-identity {
        font-size: 0.72rem;
    }

    .page-profile .profile-summary-contact {
        gap: 0.28rem;
    }

    .page-profile .profile-summary-contact-item {
        font-size: 0.7rem;
        padding: 0.14rem 0.42rem;
    }

    .page-profile .snapshot-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.38rem;
    }

    .page-profile .snapshot-item {
        min-height: 54px;
        padding: 0.36rem 0.46rem;
    }

    .page-profile .snapshot-item.full {
        grid-column: 1 / -1;
    }

    .page-profile .snapshot-item .label {
        font-size: 0.56rem;
    }

    .page-profile .snapshot-item .value {
        font-size: 0.82rem;
        line-height: 1.2;
    }

    .page-profile .profile-footer-actions {
        gap: 0.36rem;
    }

    .page-profile .profile-footer-actions .btn {
        min-width: 0;
        min-height: 40px;
    }

    .profile-image-square {
        width: 84px;
        height: 84px;
    }

    .profile-image-square-lg {
        width: 92px;
        height: 92px;
    }

    .profile-top {
        grid-template-columns: 92px 1fr;
        gap: 0.48rem;
    }

    .profile-logout-btn {
        width: 2.2rem;
        min-width: 2.2rem;
        min-height: 2.2rem;
    }

    .profile-summary-name {
        font-size: 1.06rem;
    }

    .snapshot-item .value {
        font-size: 0.97rem;
    }

    .player-search-pagination {
        justify-content: space-between;
    }

    #update-profile-modal .player-modal {
        width: min(100%, calc(100vw - 0.7rem));
        max-height: 96vh;
        padding: 0.74rem;
        gap: 0.5rem;
    }

    #update-profile-modal #profile-form {
        grid-template-columns: 1fr;
        gap: 0.48rem;
        padding-right: 0;
        scrollbar-gutter: auto;
    }

    #update-profile-modal .field {
        gap: 0.18rem;
    }

    #update-profile-modal input,
    #update-profile-modal select,
    #update-profile-modal textarea {
        min-height: 40px;
        padding: 0.44rem 0.56rem;
        font-size: 0.84rem;
    }

    #update-profile-modal textarea {
        min-height: 62px;
    }

    #update-profile-modal .profile-form-actions {
        position: static;
        z-index: auto;
        grid-column: 1 / -1;
        border-top: 0;
        background: transparent;
        padding-top: 0.18rem;
        margin-top: 0.08rem;
    }

    .profile-image-editor {
        gap: 0.55rem;
        align-items: center;
    }

    .profile-image-controls {
        gap: 0.32rem;
    }

    .profile-form-actions {
        gap: 0.4rem;
    }

    .profile-form-actions .btn {
        flex: 0 0 auto;
        width: 100%;
        justify-content: center;
    }

    .stat-tabs {
        gap: 0.35rem;
    }

    .stat-tab {
        flex: 1 1 auto;
        text-align: center;
    }
}

/* CricHeroes-style profile refresh */
.profile-cover-surface {
    background: linear-gradient(180deg, #ffffff, #f8fafb);
    border-color: var(--ui-border);
    color: var(--ui-text);
}

.profile-cover-surface .profile-toolbar {
    justify-content: flex-end;
}

.profile-snapshot-hero {
    background: #ffffff;
    border-color: var(--ui-border);
    box-shadow: 0 4px 14px rgba(24, 34, 45, 0.06);
}

.profile-snapshot-hero .profile-image-square {
    border-color: var(--ui-border);
    background: #f7f9fb;
}

.profile-snapshot-hero .profile-summary {
    border-color: var(--ui-border);
    background: #fbfcfd;
}

.profile-snapshot-hero .profile-summary-name,
.profile-snapshot-hero .value,
.profile-snapshot-hero .label,
.profile-snapshot-hero p,
.profile-snapshot-hero .profile-summary-contact-item {
    color: var(--ui-text);
}

.profile-snapshot-hero .profile-summary-contact-item,
.profile-snapshot-hero .snapshot-item {
    border-color: var(--ui-border);
    background: #f7f9fb;
}

.profile-snapshot-hero .snapshot-item .label {
    color: var(--ui-muted);
}

.profile-snapshot-hero .btn-outline {
    border-color: var(--ui-border);
    color: var(--ui-text);
    background: #ffffff;
}

.profile-snapshot-hero .btn-outline:hover {
    background: #f4f7fa;
}

.profile-footer-actions {
    display: flex;
    gap: 0.45rem;
    justify-content: flex-end;
}

.profile-hub-surface {
    padding-top: 0.8rem;
}

.profile-primary-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
}

.profile-primary-tab {
    border: 1px solid var(--ui-border);
    background: #f8fafb;
    color: var(--ui-muted);
    border-radius: 999px;
    padding: 0.45rem 0.52rem;
    font-weight: 700;
    cursor: pointer;
}

.profile-primary-tab.active {
    border-color: color-mix(in srgb, var(--teal-500) 45%, var(--ui-border));
    background: var(--ui-surface);
    color: var(--ui-text);
    box-shadow: inset 0 -2px 0 var(--teal-500);
}

.profile-primary-panel {
    margin-top: 0.2rem;
}

.profile-primary-panel.hidden {
    display: none;
}

.stat-tab {
    border-radius: 999px;
    padding: 0.46rem 0.76rem;
    font-size: 0.84rem;
}

.stat-tab.active {
    border-color: color-mix(in srgb, var(--teal-500) 45%, var(--border));
    background: color-mix(in srgb, var(--teal-100) 82%, #fff);
    color: #125e66;
}

.stat-panel {
    border-radius: 0.85rem;
}

.career-metric {
    border-radius: 0.8rem;
}

.recent-match-card {
    border-radius: 0.85rem;
}

.recent-match-row strong {
    font-size: 0.95rem;
}

.player-card {
    border-radius: 0.85rem;
}

.player-head h3 {
    font-size: 1rem;
}

@media (max-width: 768px) {
    .profile-cover-surface {
        padding: 0.75rem;
    }

    .profile-snapshot-hero {
        padding: 0.72rem;
    }

    .profile-primary-tabs {
        gap: 0.36rem;
    }

    .profile-primary-tab {
        font-size: 0.82rem;
        padding: 0.4rem 0.44rem;
    }

    .profile-footer-actions {
        justify-content: stretch;
    }

    .profile-footer-actions .btn {
        flex: 1;
        min-width: 0;
    }
}

/* Mobile-first CricHeroes style stats */
#career-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.42rem;
}

#career-tabs .stat-tab {
    padding: 0.44rem 0.3rem;
    font-size: 0.8rem;
    text-align: center;
    border-radius: 999px;
}

#career-tabs .stat-tab.active {
    border-color: color-mix(in srgb, var(--teal-500) 48%, var(--ui-border));
    background: color-mix(in srgb, var(--teal-100) 85%, var(--ui-surface));
    color: #0f666e;
    box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--teal-500) 70%, var(--ui-surface));
}

.stats-sheet {
    display: grid;
    gap: 0.72rem;
}

.stats-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.55rem;
}

.stats-top-row h3 {
    margin: 0;
    font-size: 1.05rem;
    color: var(--ui-text);
}

.stats-compare-btn {
    padding: 0.42rem 0.8rem;
    border-radius: 999px;
    font-size: 0.8rem;
    background: var(--teal-600);
}

.stats-group {
    display: grid;
    gap: 0.48rem;
}

.stats-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
}

.stats-group-head h4 {
    margin: 0;
    font-size: 1.02rem;
    color: var(--ui-text);
}

.stats-ball-indicator {
    border: 1px solid color-mix(in srgb, var(--teal-500) 45%, var(--ui-border));
    background: color-mix(in srgb, var(--teal-100) 80%, var(--ui-surface));
    color: #0f666e;
    border-radius: 999px;
    padding: 0.2rem 0.45rem;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.stats-tile-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
}

.stats-tile {
    border: 1px solid var(--ui-border);
    background: #f4f6f8;
    border-radius: 0.7rem;
    padding: 0.55rem 0.32rem;
    min-height: 76px;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 0.18rem;
    text-align: center;
}

.stats-tile-value {
    font-size: 2rem;
    line-height: 1;
    font-weight: 800;
    color: var(--ui-text);
    letter-spacing: -0.02em;
}

.stats-tile-label {
    font-size: 0.76rem;
    color: var(--ui-muted);
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.stats-note {
    font-size: 0.78rem;
    color: var(--ui-muted);
}

#career-panel-fielding .empty-state,
#career-panel-captain .empty-state {
    border-style: solid;
    background: #f8fafb;
}

@media (max-width: 540px) {
    #career-tabs {
        gap: 0.34rem;
    }

    #career-tabs .stat-tab {
        font-size: 0.76rem;
        padding: 0.4rem 0.22rem;
    }

    .stats-tile {
        min-height: 72px;
        padding: 0.5rem 0.22rem;
    }

    .stats-tile-value {
        font-size: 1.72rem;
    }

    .stats-tile-label {
        font-size: 0.72rem;
    }

    .stats-compare-btn {
        padding: 0.38rem 0.64rem;
        font-size: 0.75rem;
    }
}

@media (min-width: 768px) {
    #career-tabs {
        grid-template-columns: repeat(4, minmax(120px, max-content));
        justify-content: start;
    }

    .stats-tile-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}
