/* ── Layout ──────────────────────────────────────────────────── */
.profile-hero {
    position: relative;
    background: linear-gradient(155deg, var(--bg-primary) 0%, var(--bg-tertiary) 130%);
    border-radius: var(--radius-xl);
    overflow: hidden;
    margin-bottom: var(--space-xl);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 1px 0 rgba(0, 0, 0, .05), 0 5px 0 rgba(0, 0, 0, .06), 0 14px 26px -10px rgba(0, 0, 0, .18);
    opacity: 0;
    transform: translateY(-12px);
    animation: heroFadeIn .5s ease forwards;
}

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

.hero-bg-pattern {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 80% 50%, rgba(249, 115, 22, .06) 0%, transparent 60%),
        radial-gradient(circle at 20% 80%, rgba(99, 102, 241, .04) 0%, transparent 50%);
    pointer-events: none;
}

.hero-inner {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-2xl);
    padding: var(--space-2xl);
}

.hero-avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.hero-avatar {
    width: 110px;
    height: 110px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 3px solid var(--bg-primary);
    box-shadow: 0 3px 0 rgba(0, 0, 0, .1), 0 6px 16px rgba(0, 0, 0, .18), 0 0 0 3px var(--color-primary);
    display: block;
    transition: transform .2s ease;
}

.hero-avatar:hover {
    transform: scale(1.03);
}

.avatar-change-btn {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 28px;
    height: 28px;
    background: linear-gradient(160deg, var(--color-primary-light) 0%, var(--color-primary) 55%, var(--color-primary-dark) 100%);
    color: #fff;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 2px 0 var(--bevel-primary-edge), 0 3px 8px var(--bevel-primary-glow);
    transition: transform .15s cubic-bezier(.34, 1.56, .64, 1), box-shadow .15s ease;
}

.avatar-change-btn:hover {
    transform: translateY(-2px) scale(1.08);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 4px 0 var(--bevel-primary-edge), 0 6px 12px var(--bevel-primary-glow);
}

.upload-loader {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, .8);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
}

.loader-dots {
    display: flex;
    gap: 5px;
}

.loader-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-primary);
    animation: ldot .8s infinite ease-in-out both;
}

.loader-dots span:nth-child(2) {
    animation-delay: .16s;
}

.loader-dots span:nth-child(3) {
    animation-delay: .32s;
}

@keyframes ldot {

    0%,
    80%,
    100% {
        transform: scale(0)
    }

    40% {
        transform: scale(1)
    }
}

.hero-info {
    flex: 1;
    min-width: 0;
}

.hero-name {
    font-size: var(--text-3xl);
    font-weight: var(--font-extrabold);
    color: var(--text-primary);
    margin: 0 0 6px;
    line-height: 1.1;
}

.hero-since {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin: 0 0 var(--space-md);
}

.hero-rating-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 6px var(--space-lg);
    background: linear-gradient(160deg, var(--color-primary-light) 0%, var(--color-primary) 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 3px 0 var(--bevel-primary-edge), 0 4px 10px var(--bevel-primary-glow);
    border-radius: var(--radius-full);
}

.pill-label {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: .06em;
    color: rgba(255, 255, 255, .9);
    font-weight: var(--font-semibold);
}

.pill-value {
    font-size: var(--text-2xl);
    font-weight: var(--font-extrabold);
    color: #fff;
    text-shadow: 0 1px 1px rgba(0, 0, 0, .15);
    line-height: 1;
}

/* Rating-pill + actieknop naast elkaar; omslaan i.p.v. overflowen op smal */
.hero-actions-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-md);
}

/* ── Body grid ───────────────────────────────────────────────── */
.profile-body {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: var(--space-xl);
    align-items: start;
}

.profile-left,
.profile-right {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.profile-left {
    position: sticky;
    top: calc(var(--topbar-height, 60px) + var(--space-lg));
}

/* ── Cards ───────────────────────────────────────────────────── */
.pcard {
    background: linear-gradient(155deg, var(--bg-primary) 0%, var(--bg-tertiary) 130%);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 1px 0 rgba(0, 0, 0, .05), 0 4px 0 rgba(0, 0, 0, .05), 0 10px 18px -8px rgba(0, 0, 0, .16);
    opacity: 0;
    transform: translateY(16px);
    transition: opacity .45s ease, transform .45s ease, box-shadow .2s ease;
}

.pcard.visible {
    opacity: 1;
    transform: translateY(0);
}

.pcard:hover {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 1px 0 rgba(0, 0, 0, .05), 0 6px 0 rgba(0, 0, 0, .07), 0 16px 26px -10px rgba(0, 0, 0, .2);
}

.pcard-head {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-xl);
    border-bottom: 1px solid var(--color-gray-100);
    background: rgba(0, 0, 0, .015);
}

.pcard-icon {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 2px 0 rgba(0, 0, 0, .12), 0 2px 6px rgba(0, 0, 0, .15);
}

.icon-orange {
    background: linear-gradient(160deg, var(--color-primary-light) 0%, var(--color-primary) 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 2px 0 var(--bevel-primary-edge), 0 2px 6px var(--bevel-primary-glow);
}

.icon-purple {
    background: linear-gradient(160deg, #c4b5fd 0%, #7c3aed 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 2px 0 #4c1d95, 0 2px 6px rgba(124, 58, 237, .4);
}

.icon-blue {
    background: linear-gradient(160deg, #93c5fd 0%, #2563eb 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 2px 0 #1e3a8a, 0 2px 6px rgba(37, 99, 235, .4);
}

.icon-teal {
    background: linear-gradient(160deg, #5eead4 0%, #0d9488 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 2px 0 #115e59, 0 2px 6px rgba(13, 148, 136, .4);
}

.pcard-title {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin: 0;
    flex: 1;
}

.pcard-body {
    padding: var(--space-xl);
}

.pcard-body--no-pad {
    padding: 0;
}

.pcard-action {
    margin-top: var(--space-lg);
}

/* ── Circle stats ────────────────────────────────────────────── */
.circle-stats-row {
    display: flex;
    justify-content: space-around;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.circle-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
}

.cstat-ring-wrap {
    position: relative;
    width: 80px;
    height: 80px;
}

.circle-stat--large .cstat-ring-wrap {
    width: 120px;
    height: 120px;
}

.cstat-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
    display: block;
}

.cstat-track {
    fill: none;
    stroke: var(--color-gray-100);
    stroke-width: 7;
}

.cstat-fill {
    fill: none;
    stroke-width: 7;
    stroke-linecap: round;
    /* dasharray/offset set by JS */
}

.cstat-win {
    stroke: var(--color-success, #22c55e);
}

.cstat-draw {
    stroke: var(--color-warning, #f59e0b);
}

.cstat-loss {
    stroke: var(--color-error, #ef4444);
}

.cstat-purple {
    stroke: #7c3aed;
}

.cstat-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    line-height: 1;
}

.cstat-num {
    font-size: 1.1rem;
    font-weight: var(--font-bold);
}

.cstat-sub {
    font-size: .6rem;
    color: var(--text-secondary);
}

.cstat-label {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-secondary);
    font-weight: var(--font-medium);
}

.win-col {
    color: var(--color-success, #22c55e);
}

.draw-col {
    color: var(--color-warning, #f59e0b);
}

.loss-col {
    color: var(--color-error, #ef4444);
}

.purple-col {
    color: #7c3aed;
}

.circle-stat--large .cstat-track {
    stroke-width: 8;
}

.circle-stat--large .cstat-fill {
    stroke-width: 8;
}

.total-games-badge {
    text-align: center;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, .06);
}

.total-games-badge strong {
    color: var(--text-primary);
    font-weight: var(--font-bold);
}

/* ── Puzzle stats ────────────────────────────────────────────── */
.puzzle-rating-hero {
    text-align: center;
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid var(--color-gray-100);
    margin-bottom: var(--space-lg);
}

.puzzle-rating-num {
    font-size: var(--text-5xl);
    font-weight: var(--font-extrabold);
    color: #7c3aed;
    line-height: 1;
    margin-bottom: 4px;
}

.puzzle-rating-label {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-secondary);
}

.puzzle-circle-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: var(--space-lg);
}

.puzzle-meta-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--color-gray-100);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: var(--space-lg);
}

.pmeta-item {
    background: var(--bg-primary);
    text-align: center;
    padding: var(--space-sm) var(--space-xs);
}

.pmeta-val {
    display: block;
    font-size: var(--text-xl);
    font-weight: var(--font-bold);
    color: var(--text-primary);
    line-height: 1.2;
}

.pmeta-key {
    display: block;
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-secondary);
}

.streak-section {
    margin-bottom: var(--space-md);
}

.streak-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.streak-bar-label strong {
    color: #7c3aed;
    font-weight: var(--font-semibold);
}

.streak-track {
    height: 6px;
    background: var(--bg-tertiary);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, .12);
    border-radius: 99px;
    overflow: hidden;
}

.streak-fill {
    height: 100%;
    width: var(--streak-w, 0%);
    background: linear-gradient(90deg, #a78bfa, #7c3aed);
    box-shadow: 0 0 6px rgba(124, 58, 237, .5);
    border-radius: 99px;
    transition: width 1s cubic-bezier(.4, 0, .2, 1);
}

.btn-puzzle {
    background: linear-gradient(160deg, #c4b5fd 0%, #7c3aed 100%);
    color: #fff;
    border: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 3px 0 #4c1d95, 0 4px 10px rgba(124, 58, 237, .4);
    transition: transform .15s ease, box-shadow .15s ease;
}

.btn-puzzle:hover {
    color: #fff;
    transform: translateY(-2px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 5px 0 #4c1d95, 0 6px 14px rgba(124, 58, 237, .45);
}

.btn-puzzle:active {
    transform: translateY(2px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 1px 0 #4c1d95;
}

/* ── About textarea ──────────────────────────────────────────── */
.about-textarea {
    width: 100%;
    min-height: 120px;
    padding: var(--space-md);
    border: 1.5px solid var(--color-gray-200);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    resize: vertical;
    font-family: var(--font-sans);
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: border-color .15s ease, box-shadow .15s ease;
    box-sizing: border-box;
}

.about-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, .1);
}

.char-counter {
    text-align: right;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    margin-top: var(--space-xs);
}

.char-counter.warning {
    color: var(--color-warning);
}

.char-counter.error {
    color: var(--color-error);
}

/* ── Chart ───────────────────────────────────────────────────── */
.chart-container {
    position: relative;
    height: 240px;
}

.rating-trend-badge {
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    padding: 3px 10px;
    border-radius: var(--radius-full);
    margin-left: auto;
    color: #fff;
    text-shadow: 0 1px 1px rgba(0, 0, 0, .15);
}

.trend-up {
    background: linear-gradient(160deg, #4ade80 0%, #16a34a 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 2px 0 var(--bevel-green-edge), 0 2px 6px var(--bevel-green-glow);
}

.trend-down {
    background: linear-gradient(160deg, #fca5a5 0%, #ef4444 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 2px 0 var(--bevel-red-edge), 0 2px 6px var(--bevel-red-glow);
}

/* ── Game timeline ───────────────────────────────────────────── */
.game-timeline {
    padding: var(--space-md) var(--space-xl);
}

.tl-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    cursor: pointer;
    position: relative;
    padding: var(--space-md) var(--space-md);
    border-radius: var(--radius-lg);
    transition: background .15s ease;
}

.tl-item:hover {
    background: var(--bg-secondary);
}

.tl-item:hover .tl-arrow {
    opacity: 1;
    transform: translateX(0);
}

.tl-dot {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
    position: relative;
    z-index: 1;
}

.dot-win {
    background: linear-gradient(160deg, #4ade80 0%, #16a34a 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 2px 0 var(--bevel-green-edge), 0 2px 5px var(--bevel-green-glow);
    color: #fff;
}

.dot-loss {
    background: linear-gradient(160deg, #fca5a5 0%, #ef4444 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 2px 0 var(--bevel-red-edge), 0 2px 5px var(--bevel-red-glow);
    color: #fff;
}

.dot-draw {
    background: linear-gradient(160deg, #fcd34d 0%, #d97706 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 2px 0 var(--bevel-amber-edge), 0 2px 5px var(--bevel-amber-glow);
    color: #fff;
}

.tl-line {
    position: absolute;
    left: calc(var(--space-md) + 13px);
    top: calc(var(--space-md) + 28px + 2px);
    width: 2px;
    bottom: 0;
    background: var(--color-gray-100);
    z-index: 0;
}

.tl-content {
    flex: 1;
    min-width: 0;
}

.tl-main-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
}

.tl-result-label {
    font-weight: var(--font-semibold);
    font-size: var(--text-sm);
}

.tl-win-text {
    color: var(--color-success, #22c55e);
}

.tl-loss-text {
    color: var(--color-error, #ef4444);
}

.tl-draw-text {
    color: var(--color-warning, #f59e0b);
}

.tl-rating-change {
    font-weight: var(--font-bold);
    font-size: var(--text-base);
}

.tl-sub-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    font-size: var(--text-xs);
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.tl-opponent {
    font-weight: var(--font-medium);
    color: var(--text-primary);
}

.tl-new-rating {
    color: var(--color-primary);
    font-weight: var(--font-semibold);
}

.tl-arrow {
    color: var(--text-secondary);
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity .15s ease, transform .15s ease;
    flex-shrink: 0;
    margin-top: 2px;
}

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 2.5rem;
    margin-bottom: var(--space-md);
    line-height: 1;
}

/* ── Alert ───────────────────────────────────────────────────── */
.prof-alert {
    margin-bottom: var(--space-lg);
    animation: slideDown .3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px)
    }

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

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .profile-body {
        grid-template-columns: 1fr;
    }

    .profile-left {
        position: static;
    }

    .circle-stats-row {
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .hero-inner {
        flex-direction: column;
        text-align: center;
        gap: var(--space-lg);
    }

    .hero-since {
        justify-content: center;
    }

    .hero-actions-row {
        justify-content: center;
    }

    .profile-tabs {
        justify-content: center;
    }

    .pcard-body {
        padding: var(--space-lg);
    }

    .game-timeline {
        padding: var(--space-sm) var(--space-md);
    }

    .puzzle-meta-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (prefers-reduced-motion: reduce) {

    .pcard,
    .profile-hero {
        animation: none;
        transition: none;
    }

    .cstat-fill {
        transition: none;
    }

    .streak-fill {
        transition: none;
    }
}