.profile-history-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    width: 100%;
}

.profile-history-box {
    height: calc(100vh - var(--header-height, 70px) - 90px);
    width: calc(100vh - var(--header-height, 70px) - 90px);
    max-height: 740px;
    max-width: 740px;
    aspect-ratio: 1 / 1;
    flex-shrink: 1;
    box-sizing: border-box;
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
}

.profile-history-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    background: var(--bg-base);
    border-radius: 12px;
    border: 1px dashed var(--border-light);
}

.profile-chart-container { width: 100%; margin-bottom: 15px; display: flex; flex-direction: column; }
.chart-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.chart-title { color: var(--text-dim); font-size: 0.85rem; text-transform: uppercase; font-weight: bold; }
.chart-current-elo { color: var(--primary); font-size: 1.2rem; font-weight: 800; font-family: monospace; }
.elo-sparkline { overflow: visible; margin-top: 5px; }

.profile-chart-empty { height: 100px; display: flex; align-items: center; justify-content: center; color: var(--text-dim); font-style: italic; border: 1px dashed var(--border-light); border-radius: 8px; }

.profile-history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 5px;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
}

@keyframes infinite-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.profile-history-list::-webkit-scrollbar { width: 6px; }
.profile-history-list::-webkit-scrollbar-track { background: transparent; }
.profile-history-list::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

.ghr-date-header {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.80rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: bold;
    margin: 15px 0 8px 0;
    position: sticky;
    top: -5px;
    background: var(--bg-panel);
    padding: 5px 0;
    z-index: 5;
}

.ghr-date-header:first-child { margin-top: 0; }

.game-history-row {
    content-visibility: auto;
    contain-intrinsic-size: 0 62px;
    display: grid;
    grid-template-columns: 14px 50px 1fr 95px 1fr 65px 14px;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 12px 15px;
    gap: 15px;
    transition: background 0.2s, transform 0.1s;
    cursor: pointer;
    margin-bottom: 5px;
}

@media (hover: hover) {
    .game-history-row:hover { background: var(--border-lighter); border-color: var(--border-color); }
}
.game-history-row:active { transform: scale(0.99); }

.ghr-dot { width: 14px; height: 14px; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.5); flex-shrink: 0; }
.dot-white { background: var(--text-pure); border: 2px solid var(--text-main); }
.dot-black { background: var(--bg-base); border: 2px solid var(--border-color); }

.ghr-cadence { display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-dim); font-size: 0.8rem; font-weight: 700; font-family: monospace; }
.ghr-cadence svg { width: 18px; height: 18px; margin-bottom: 4px; }

.ghr-player { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ghr-white { text-align: right; align-items: flex-end; }
.ghr-black { text-align: left; align-items: flex-start; }

.ghr-name { color: var(--text-pure); font-size: 0.95rem; font-weight: bold; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ghr-tag { color: var(--text-dim); font-size: 0.8em; font-weight: normal; margin-left: 4px; }

.ghr-elo-line { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; }
.ghr-elo-box { color: var(--text-dim); background: var(--border-lighter); padding: 2px 6px; border-radius: 4px; font-size: 0.8rem; font-family: monospace; font-weight: bold; }

.elo-change { font-weight: bold; font-family: monospace; font-size: 0.9rem; }
.elo-change.pos { color: var(--success); }
.elo-change.neg { color: var(--danger); }
.elo-change.neutral { color: var(--text-dim); }

.ghr-score-box { display: flex; align-items: center; justify-content: center; font-size: 1.25rem; font-weight: 900; background: var(--bg-base); padding: 6px 0; border-radius: 6px; border: 1px solid var(--border-lighter); width: 100%; box-sizing: border-box; }

.ghr-type { font-size: 0.75rem; font-weight: 800; text-transform: uppercase; text-align: center; letter-spacing: 0.5px; }
.ghr-type.rated { color: var(--warning); }
.ghr-type.casual { color: var(--text-dim); }

.game-history-row.puzzle-row { cursor: default; }
@media (hover: hover) { .game-history-row.puzzle-row:hover { transform: none; background: var(--bg-input); border-color: var(--border-light); } }

@media (max-width: 1100px) {
    .profile-history-box {
        height: auto;
        width: 100%;
        padding: 1rem;
        aspect-ratio: auto;
    }

    .game-history-row {
        grid-template-columns: 10px 40px 1fr 1fr;
        padding: 10px;
        gap: 10px;
    }

    .game-history-row > :nth-child(6),
    .game-history-row > :nth-child(7) {
        display: none;
    }

    .ghr-score-box {
        grid-column: 1 / -1;
        margin-top: 5px;
        padding: 4px 0;
        font-size: 1.1rem;
    }
}