/* ==========================================================================
   Xenotech Game Review Stylesheet
   Modern, high-fidelity styles replicating Chess.com Game Review aesthetics.
   ========================================================================== */

/* Modal Backdrops */
.gr-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(8, 9, 13, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: grFadeIn 0.25s ease-out;
}

@keyframes grFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Close Button */
.gr-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.6rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 0.5rem;
    transition: color 0.2s;
}
.gr-close-btn:hover {
    color: var(--white);
}

/* Modal Cards */
.gr-modal-card {
    background: var(--xt-surface, #161622);
    border: 1px solid var(--xt-line, rgba(255, 255, 255, 0.1));
    border-radius: 16px;
    padding: 2rem;
    width: 100%;
    max-width: 520px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

/* Progress Card */
.gr-progress-card {
    background: var(--xt-surface, #161622);
    border: 1px solid var(--xt-line, rgba(255, 255, 255, 0.1));
    border-radius: 20px;
    padding: 2.5rem;
    width: 100%;
    max-width: 440px;
    text-align: center;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7);
}

.gr-spinner {
    font-size: 2.8rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
    text-shadow: 0 0 25px rgba(240, 126, 19, 0.4);
}

.gr-progress-track {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.gr-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #ffd54f);
    border-radius: 6px;
    transition: width 0.15s ease-out;
}

/* Summary Modal */
.gr-summary-card {
    background: var(--xt-surface, #161622);
    border: 1px solid var(--xt-line, rgba(255, 255, 255, 0.12));
    border-radius: 20px;
    padding: 1.25rem 1.6rem;
    width: min(94vw, 980px);
    max-width: 980px;
    max-height: 94vh;
    overflow-y: auto;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.85), 0 0 40px rgba(240, 126, 19, 0.08);
    display: flex;
    flex-direction: column;
}

.gr-summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.85rem;
    padding-bottom: 0.7rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.gr-trophy-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(240, 126, 19, 0.15);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

/* 2-Column Desktop Grid Layout */
.gr-summary-body {
    display: grid;
    grid-template-columns: 1.12fr 1fr;
    gap: 1.25rem;
    align-items: stretch;
    margin-bottom: 0.85rem;
}

.gr-summary-col-left {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.gr-summary-col-right {
    display: flex;
    flex-direction: column;
}

/* Accuracy Head-to-Head */
.gr-accuracy-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0;
}

.gr-acc-box {
    flex: 1;
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 0.65rem 0.85rem;
    text-align: center;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.gr-acc-box:hover {
    border-color: rgba(255, 255, 255, 0.16);
}

.gr-acc-white {
    border-top: 3px solid #ffffff;
}

.gr-acc-black {
    border-top: 3px solid #5a5a70;
}

.gr-acc-title {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.gr-acc-score {
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--white);
    line-height: 1.1;
    letter-spacing: -0.5px;
}

.gr-acc-badge {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.gr-acc-vs {
    font-weight: 800;
    color: var(--text-muted);
    font-size: 0.8rem;
    letter-spacing: 1px;
    opacity: 0.6;
}

/* Advantage Graph */
.gr-chart-section {
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 0.75rem 0.95rem;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.gr-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}

.gr-chart-title {
    color: var(--white);
    font-weight: 600;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.gr-chart-hint {
    color: var(--text-muted);
    font-size: 0.72rem;
}

.gr-chart-box {
    width: 100%;
    height: 140px;
    position: relative;
    flex: 1;
}

.gr-svg-graph {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.gr-graph-dot:hover {
    r: 6.5;
    filter: drop-shadow(0 0 6px currentColor);
}

/* Move Breakdown Section */
.gr-breakdown-section {
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.gr-breakdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}

.gr-breakdown-title {
    color: var(--white);
    margin: 0;
    font-size: 0.84rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.gr-breakdown-hint {
    color: var(--text-muted);
    font-size: 0.72rem;
}

.gr-table-wrap {
    flex: 1;
    overflow-y: visible;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.24);
}

.gr-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.gr-table th {
    padding: 0.38rem 0.7rem;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.gr-table td {
    padding: 0.26rem 0.7rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.gr-table-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0.16rem 0.5rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.76rem;
    line-height: 1.2;
}

/* Footer Actions */
.gr-summary-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.gr-summary-tip {
    color: var(--text-muted);
    font-size: 0.78rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.gr-summary-btn-group {
    display: flex;
    gap: 0.75rem;
}

.gr-summary-btn-group .btn {
    padding: 0.5rem 1.15rem;
    font-size: 0.84rem;
    font-weight: 600;
    border-radius: 9px;
    white-space: nowrap;
}

/* Responsive: Tablets & Mobile fallback */
@media (max-width: 860px) {
    .gr-summary-card {
        max-width: 540px;
        width: 95vw;
        max-height: 92vh;
        padding: 1.2rem;
    }

    .gr-summary-body {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .gr-table-wrap {
        max-height: 220px;
        overflow-y: auto;
    }

    .gr-summary-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .gr-summary-tip {
        justify-content: center;
        text-align: center;
    }

    .gr-summary-btn-group {
        flex-direction: column-reverse;
        width: 100%;
    }

    .gr-summary-btn-group .btn {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
}

/* In-Board Walkthrough HUD */
.gr-hud-container {
    background: var(--xt-surface-raised, #1d1d2b);
    border: 1px solid var(--primary);
    border-radius: 12px;
    padding: 1rem;
    margin-top: 1rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    animation: grSlideUp 0.25s ease-out;
}

@keyframes grSlideUp {
    from { transform: translateY(10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.gr-hud-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}

.gr-badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.35rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    border: 1px solid transparent;
}

.gr-hud-body {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 8px;
    padding: 0.8rem;
    margin-bottom: 0.8rem;
}

.gr-hud-controls {
    display: flex;
    gap: 0.4rem;
    justify-content: space-between;
}

/* ==========================================================================
   Academy Scoresheet Table Styles
   ========================================================================== */
.scoresheet-container {
    width: 100%;
    height: clamp(170px, 26vh, 230px);
    background: rgba(0, 0, 0, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4);
}

.scoresheet-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
    font-family: inherit;
    font-size: 0.88rem;
    box-sizing: border-box;
}

.scoresheet-table thead {
    position: sticky;
    top: 0;
    z-index: 50 !important;
    background: #14141e !important;
    background-color: #14141e !important;
    opacity: 1 !important;
    isolation: isolate;
}

.scoresheet-table thead tr {
    position: sticky;
    top: 0;
    z-index: 50 !important;
    background: #14141e !important;
    background-color: #14141e !important;
    opacity: 1 !important;
}

.scoresheet-table thead th {
    position: sticky;
    top: 0;
    background: #14141e !important;
    background-color: #14141e !important;
    opacity: 1 !important;
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: none; /* Keep natural case for player names */
    letter-spacing: 0.2px;
    padding: 0.45rem 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
    z-index: 50 !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.7);
    box-sizing: border-box;
    vertical-align: middle;
}

/* Extra right padding on Black column header to prevent collision with vertical scrollbar */
.scoresheet-table thead th.scoresheet-th-black {
    padding-right: 1.25rem;
}

.scoresheet-th-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    min-width: 0;
    overflow: hidden;
}

.scoresheet-th-row {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    min-width: 0;
    overflow: hidden;
}

.scoresheet-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

.scoresheet-dot.white {
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    box-shadow: 0 0 3px rgba(255, 255, 255, 0.6);
}

.scoresheet-dot.black {
    background: #1e293b;
    border: 1.5px solid #e2e8f0;
    box-shadow: 0 0 3px rgba(255, 255, 255, 0.3);
}

.scoresheet-th-name {
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #f8fafc;
    font-weight: 700;
    font-size: 0.78rem;
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.2;
}

.scoresheet-th-sub {
    display: flex;
    align-items: center;
    padding-left: 15px; /* Indent under name past the dot */
}

.scoresheet-elo {
    font-size: 0.66rem;
    font-weight: 600;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.06);
    padding: 0 4px;
    border-radius: 3px;
    letter-spacing: 0.3px;
}

.scoresheet-row {
    border-bottom: 1px solid rgba(255, 255, 255, 0.035);
    transition: background 0.15s;
    position: relative;
    z-index: 1;
}

.scoresheet-table tbody td {
    position: relative;
    z-index: 1;
}

.scoresheet-row:nth-child(even) {
    background: rgba(255, 255, 255, 0.015);
}

.scoresheet-row:hover {
    background: rgba(255, 255, 255, 0.04);
}

.scoresheet-num {
    width: 36px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.45rem 0.3rem;
    text-align: center;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    box-sizing: border-box;
}

.scoresheet-cell {
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    width: calc(50% - 18px);
    transition: all 0.15s ease-in-out;
    user-select: none;
    vertical-align: middle;
    box-sizing: border-box;
}

.scoresheet-cell:hover {
    background: rgba(240, 126, 19, 0.15);
}

.scoresheet-cell.active-cell {
    background: rgba(240, 126, 19, 0.28) !important;
    border-left: 3px solid var(--primary);
}

.scoresheet-cell.active-cell .scoresheet-san {
    color: #fff !important;
    font-weight: 800;
}

.scoresheet-move-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.scoresheet-san {
    font-weight: 600;
    color: #e2e8f0;
    font-size: 0.9rem;
    letter-spacing: 0.2px;
}

/* Badge Tags inside Scoresheet */
.badge-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 800;
    border-radius: 4px;
    padding: 1px 5px;
    line-height: 1.2;
    min-width: 20px;
    height: 18px;
    box-sizing: border-box;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.badge-brilliant  { background: rgba(27, 174, 165, 0.25); color: #1baea5; border: 1px solid #1baea5; }
.badge-great      { background: rgba(92, 139, 176, 0.25); color: #5c8bb0; border: 1px solid #5c8bb0; }
.badge-best       { background: rgba(150, 188, 75, 0.25); color: #96bc4b; border: 1px solid #96bc4b; }
.badge-excellent  { background: rgba(150, 188, 75, 0.18); color: #96bc4b; }
.badge-good       { background: rgba(168, 181, 138, 0.18); color: #a8b58a; }
.badge-book       { background: rgba(213, 164, 125, 0.25); color: #d5a47d; border: 1px solid #d5a47d; }
.badge-inaccuracy { background: rgba(247, 198, 49, 0.25); color: #f7c631; border: 1px solid #f7c631; }
.badge-mistake    { background: rgba(230, 145, 44, 0.25); color: #e6912c; border: 1px solid #e6912c; }
.badge-missed_win { background: rgba(219, 83, 65, 0.25); color: #db5341; border: 1px solid #db5341; }
.badge-blunder    { background: rgba(202, 52, 49, 0.35); color: #ff5252; border: 1px solid #ff5252; font-weight: 900; }

/* Coach Advice Card directly underneath scoresheet */
.scoresheet-coach-card {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    margin-top: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: all 0.25s ease;
}

.scoresheet-coach-card.has-review {
    border-color: rgba(240, 126, 19, 0.35);
    background: rgba(240, 126, 19, 0.04);
}

/* Move Highlights & Compact Layout Utilities */
.square-55d63.xt-sq-last-move {
    background-color: rgba(245, 246, 130, 0.68) !important;
}
.square-55d63.black-3c85d.xt-sq-last-move {
    background-color: rgba(186, 202, 68, 0.76) !important;
}
.square-55d63.white-1e1d7.xt-sq-last-move {
    background-color: rgba(246, 246, 136, 0.76) !important;
}

/* Compact Tool Drawers in Analysis */
.xt-accordion-tool {
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 0.45rem 0.75rem;
    transition: background 0.2s, border-color 0.2s;
}
.xt-accordion-tool[open] {
    background: rgba(0, 0, 0, 0.35);
    border-color: rgba(240, 126, 19, 0.3);
}
.xt-accordion-summary {
    cursor: pointer;
    color: var(--white);
    font-size: 0.84rem;
    font-weight: 600;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}
.xt-accordion-summary::-webkit-details-marker {
    display: none;
}
.xt-accordion-summary:hover {
    color: var(--primary);
}
.xt-accordion-summary i.chevron {
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}
.xt-accordion-tool[open] .xt-accordion-summary i.chevron {
    transform: rotate(180deg);
}
.xt-accordion-content {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* ==========================================================================
   Player Info Banners (Top & Bottom of Chessboard)
   ========================================================================== */
.xt-player-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(22, 22, 34, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 0.28rem 0.65rem;
    font-size: 0.82rem;
    min-height: 28px;
    box-sizing: border-box;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    transition: background 0.2s ease, border-color 0.2s ease;
}

.xt-player-bar:hover {
    background: rgba(26, 26, 40, 0.95);
    border-color: rgba(255, 255, 255, 0.14);
}

.xt-player-identity {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
    overflow: hidden;
}

.xt-player-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    line-height: 1;
    flex-shrink: 0;
}

.xt-player-name {
    font-weight: 700;
    color: #f3f4f6;
    letter-spacing: 0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
}

.xt-player-rating {
    font-size: 0.74rem;
    font-weight: 600;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.07);
    padding: 1px 6px;
    border-radius: 4px;
    flex-shrink: 0;
}

.xt-player-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    font-weight: 700;
}

.xt-player-result {
    padding: 1px 7px;
    border-radius: 4px;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.xt-player-result.win {
    background: rgba(150, 188, 75, 0.22);
    color: #96bc4b;
    border: 1px solid rgba(150, 188, 75, 0.4);
}

.xt-player-result.draw {
    background: rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.xt-player-result.loss {
    background: rgba(202, 52, 49, 0.2);
    color: #f87171;
    border: 1px solid rgba(202, 52, 49, 0.35);
}
