/* Game Analysis component family. All classes are prefixed `pga-`. */

.pga {
    --pga-ink: #1c2417;
    --pga-muted: #75806c;
    --pga-line: rgba(17, 17, 17, 0.08);
    --pga-card-bg: var(--panda-white, #ffffff);
    --pga-board-size: clamp(29rem, min(75vw, calc(100dvh - 4.85rem)), 58rem);
    --pga-board-shell-width: calc(var(--pga-board-size) + 2.7rem);
    --pga-rail-width: clamp(16rem, 18vw, 19.25rem);
    --pga-bamboo: var(--panda-bamboo, #7da443);
    --pga-bamboo-deep: #2f5524;
    --pga-bamboo-soft: #eef4e3;
    --pga-brilliant: #18aee8;
    --pga-best: #2f8f45;
    --pga-excellent: #4f9e3d;
    --pga-good: #78a64b;
    --pga-inaccuracy: #d6a11d;
    --pga-mistake: #d86f24;
    --pga-blunder: #c9362d;
    --pga-book: #8a5a2b;
    --pga-forced: #6f8f3a;
    --pga-only-move: #4d8f5c;
    --pga-sacrifice: #18aee8;

    color: var(--pga-ink);
}

.pga__layout {
    display: grid;
    grid-template-columns: minmax(0, var(--pga-board-shell-width)) minmax(17rem, var(--pga-rail-width));
    gap: 0.68rem;
    align-items: start;
    justify-content: center;
}

/* ---------- Board column ---------- */

.pga__board-column {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    gap: 0.52rem;
    min-width: 0;
}

.pga__board-card {
    position: relative;
    display: grid;
    gap: 0.22rem;
    width: 100%;
    max-width: var(--pga-board-shell-width);
    padding: 0.38rem 0.52rem 0.2rem;
    border: 0;
    border-radius: 16px;
    background: var(--pga-card-bg);
    box-shadow: 0 1px 2px rgba(28, 36, 23, 0.05), 0 14px 40px rgba(28, 36, 23, 0.09);
    min-width: 0;
}

.pga__board-header {
    display: flex;
    align-items: center;
    gap: 0.42rem;
    min-width: 0;
}

.pga__side-column {
    display: grid;
    align-content: start;
    gap: 0.62rem;
    min-width: 0;
}

.pga__board-header .pga__player {
    flex: 1 1 auto;
}

.pga__player {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 1.4rem;
    padding: 0;
}

.pga__player--bottom {
    min-height: 1.05rem;
}

.pga__player--bottom .pga__player-dot {
    width: 0.86rem;
    height: 0.86rem;
    border-radius: 4px;
}

.pga__player-dot {
    display: inline-flex;
    width: 1rem;
    height: 1rem;
    flex: 0 0 auto;
    border-radius: 7px;
    box-shadow: inset 0 0 0 1.5px rgba(17, 17, 17, 0.45), 0 2px 5px rgba(17, 17, 17, 0.14);
}

.pga__player-dot--white {
    background: linear-gradient(150deg, #ffffff, #e8e8df);
}

.pga__player-dot--black {
    background: linear-gradient(150deg, #3a4036, #181c15);
}

.pga__player-name {
    font-size: 0.8rem;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pga__player-rating {
    padding: 0.03rem 0.34rem;
    border-radius: var(--panda-radius-pill, 999px);
    background: rgba(17, 17, 17, 0.06);
    color: var(--pga-muted);
    font-size: 0.72rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.pga__player-score {
    margin-left: auto;
    min-width: 1.9rem;
    padding: 0.08rem 0.46rem;
    border-radius: 8px;
    background: var(--panda-black, #111111);
    color: var(--panda-white, #ffffff);
    font-size: 0.76rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.pga__board-frame {
    display: grid;
    grid-template-columns: 1.48rem minmax(0, var(--pga-board-size));
    justify-content: center;
    gap: 0.34rem;
    width: fit-content;
    max-width: 100%;
    margin-inline: auto;
    min-width: 0;
}

.pga__board-frame--no-evalbar .pga__evalbar {
    display: none;
}

.pga__board-frame--no-evalbar {
    grid-template-columns: minmax(0, var(--pga-board-size));
}

.pga__board-stack {
    position: relative;
    width: 100%;
    max-width: var(--pga-board-size);
    min-width: 0;
    aspect-ratio: 1;
}

.pga__board {
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(28, 36, 23, 0.2), 0 0 0 1px rgba(28, 36, 23, 0.08);
}

.pga__board .cm-chessboard,
.pga__board .cm-chessboard svg {
    width: 100%;
    height: 100%;
    border-radius: inherit;
}

.pga__badge-layer {
    position: absolute;
    inset: 0;
    z-index: 6;
    pointer-events: none;
}

.pga__board-badge {
    position: absolute;
    border-radius: 50%;
    box-shadow: 0 7px 12px rgba(0, 0, 0, 0.28);
    transform: translateZ(0);
    animation: pga-badge-pop 260ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pga-badge-pop {
    from {
        opacity: 0;
        transform: scale(0.4);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Last-move square tints keyed by classification tone. */
.cm-chessboard .markers .marker.pga-marker {
    fill: var(--panda-bamboo, #7da443);
    opacity: 0.34;
}

.cm-chessboard .markers .marker.pga-marker--praise {
    fill: var(--pga-best);
    opacity: 0.4;
}

.cm-chessboard .markers .marker.pga-marker--best {
    fill: var(--pga-best);
    opacity: 0.4;
}

.cm-chessboard .markers .marker.pga-marker--excellent {
    fill: var(--pga-excellent);
    opacity: 0.4;
}

.cm-chessboard .markers .marker.pga-marker--good {
    fill: var(--pga-good);
    opacity: 0.4;
}

.cm-chessboard .markers .marker.pga-marker--brilliant,
.cm-chessboard .markers .marker.pga-marker--checkmate,
.cm-chessboard .markers .marker.pga-marker--sacrifice {
    fill: var(--pga-brilliant);
    opacity: 0.38;
}

.cm-chessboard .markers .marker.pga-marker--inaccuracy {
    fill: #e3b341;
    opacity: 0.46;
}

.cm-chessboard .markers .marker.pga-marker--mistake {
    fill: #e07b2f;
    opacity: 0.46;
}

.cm-chessboard .markers .marker.pga-marker--blunder {
    fill: var(--pga-blunder);
    opacity: 0.46;
}

.cm-chessboard .markers .marker.pga-marker--book {
    fill: var(--pga-book);
    opacity: 0.44;
}

.cm-chessboard .markers .marker.pga-marker--forced {
    fill: var(--pga-forced);
    opacity: 0.4;
}

.cm-chessboard .markers .marker.pga-marker--only_move {
    fill: var(--pga-only-move);
    opacity: 0.46;
}

.cm-chessboard .markers .marker.pga-marker--neutral {
    fill: #6f7d63;
    opacity: 0.32;
}

/* ---------- Evaluation bar (bamboo) ---------- */

.pga__evalbar {
    display: grid;
    grid-template-rows: 1fr auto;
    gap: 0.35rem;
    width: 1.48rem;
}

.pga__evalbar-track {
    position: relative;
    overflow: hidden;
    border: 2px solid rgba(57, 91, 30, 0.86);
    border-radius: 10px;
    background: rgba(221, 225, 208, 0.9);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.3),
        inset 0 10px 16px rgba(255, 255, 255, 0.18),
        inset 0 -10px 16px rgba(17, 45, 16, 0.28),
        0 8px 16px rgba(48, 72, 33, 0.2);
}

.pga__evalbar-fill {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 50%;
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0.02) 28%, rgba(11, 43, 14, 0.18) 72%, rgba(255, 255, 255, 0.18)),
        url("../../eval-bar/bamboo-generated-strip.png");
    background-blend-mode: soft-light, normal;
    background-position: center, center bottom;
    background-size: 100% 100%, 100% auto;
    transition: height 560ms cubic-bezier(0.22, 1, 0.36, 1);
    will-change: height;
}

.pga__evalbar-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 1.2rem;
    color: #2f4a1d;
    font-size: 0.7rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    text-shadow:
        0 1px 0 rgba(255, 255, 255, 0.92),
        0 0 5px rgba(255, 255, 255, 0.76);
}

/* ---------- Toolbar ---------- */

.pga__toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
    justify-items: center;
    gap: 0.28rem;
    width: 100%;
    margin: 0 auto;
    padding: 0.38rem 0.5rem;
    border-radius: 14px;
    background: var(--pga-card-bg);
    box-shadow: 0 1px 2px rgba(28, 36, 23, 0.05), 0 10px 30px rgba(28, 36, 23, 0.07);
}

.pga__nav-group {
    display: inline-flex;
    align-items: center;
    gap: 0.18rem;
    padding: 0.22rem;
    border: 0;
    border-radius: 999px;
    background: #f1f4ea;
}

.pga__nav-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    min-height: 2rem;
    padding: 0.16rem 0.36rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #434b3c;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.16s ease, color 0.16s ease, transform 0.12s ease, box-shadow 0.16s ease;
}

.pga__nav-button:hover:not(:disabled) {
    background: #ffffff;
    color: var(--pga-bamboo-deep);
    box-shadow: 0 2px 8px rgba(28, 36, 23, 0.12);
}

.pga__nav-button:active:not(:disabled) {
    transform: scale(0.92);
}

.pga__nav-button:disabled {
    opacity: 0.28;
    cursor: default;
}

.pga__nav-button--primary {
    min-width: 2.14rem;
    min-height: 2.14rem;
    margin: 0 0.12rem;
    background: var(--panda-black, #111111);
    color: var(--panda-white, #ffffff);
    box-shadow: 0 5px 14px rgba(17, 17, 17, 0.25);
}

.pga__nav-button--primary:hover:not(:disabled) {
    background: var(--pga-bamboo-deep);
    color: var(--panda-white, #ffffff);
    box-shadow: 0 5px 14px rgba(47, 85, 36, 0.3);
}

.pga__nav-button.is-active {
    background: #ffffff;
    color: var(--pga-bamboo-deep);
    box-shadow: 0 2px 8px rgba(28, 36, 23, 0.12);
}

.pga__board-settings-action {
    width: 1.52rem;
    min-width: 1.52rem;
    height: 1.52rem;
    min-height: 1.52rem;
    flex: 0 0 auto;
    padding: 0;
    background: #f1f4ea;
    color: #596151;
    font-size: 0.72rem;
}

.pga__board-settings-action:hover:not(:disabled),
.pga__board-settings-action.is-active {
    background: var(--pga-bamboo-soft);
    color: var(--pga-bamboo-deep);
    box-shadow: inset 0 0 0 1px rgba(47, 85, 36, 0.18);
}

.pga__nav-button--primary.is-active {
    background: var(--pga-bamboo-deep);
    color: var(--panda-white, #ffffff);
    box-shadow: 0 5px 14px rgba(47, 85, 36, 0.3);
}

.pga__nav-button:focus-visible {
    outline: 2px solid rgba(59, 124, 39, 0.72);
    outline-offset: 2px;
}

.pga__ply-counter {
    display: grid;
    justify-self: center;
    min-height: 1.1rem;
    min-width: 0;
    max-width: 100%;
    place-items: center;
    color: #3d4631;
    font-variant-numeric: tabular-nums;
}

.pga__ply-counter-label,
.pga__ply-counter-count {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pga__ply-counter-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.86rem;
    font-weight: 800;
    line-height: 1.15;
    color: #20241d;
}

.pga__ply-counter-count {
    color: #9aa48e;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    line-height: 1.1;
}

.pga__ply-counter-separator,
.pga__hint {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

/* ---------- Settings panel ---------- */

.pga__settings {
    position: fixed;
    top: 5.6rem;
    right: max(1rem, calc((100vw - 96rem) / 2 + 1rem));
    z-index: 1605;
    display: grid;
    gap: 0.7rem;
    width: min(30rem, calc(100% - 1.4rem));
    max-height: calc(100dvh - 7rem);
    margin: 0;
    padding: 0.78rem;
    overflow-y: auto;
    border: 1px solid var(--pga-line);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 24px 56px rgba(17, 17, 17, 0.18);
}

.pga__settings[hidden] {
    display: none !important;
}

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

.pga__settings-field {
    display: grid;
    gap: 0.28rem;
    color: #4d5748;
    font-size: 0.74rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0;
}

.pga__settings-select {
    min-height: 2.15rem;
    padding: 0.25rem 0.5rem;
    border: 1.5px solid var(--panda-grey, #e9ecef);
    border-radius: 6px;
    background: var(--pga-card-bg);
    color: var(--pga-ink);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
}

.pga__settings-select:focus {
    border-color: var(--pga-bamboo);
    outline: none;
    box-shadow: 0 0 0 3px rgba(125, 164, 67, 0.18);
}

.pga__settings-toggles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem 0.65rem;
}

.pga__settings-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: #4d5748;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
}

.pga__settings-toggle input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--pga-bamboo);
}

/* ---------- Cards ---------- */

.pga__card {
    width: 100%;
    padding: 0.85rem 0.95rem;
    border: 0;
    border-radius: 14px;
    background: var(--pga-card-bg);
    box-shadow: 0 1px 2px rgba(28, 36, 23, 0.05), 0 10px 30px rgba(28, 36, 23, 0.07);
    min-width: 0;
}

.pga__card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.55rem;
    margin-bottom: 0.45rem;
}

.pga__card-title {
    color: #98a18d;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.pga__side-column {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.58rem;
    align-self: start;
    min-width: 0;
}

@media (min-width: 981px) {
    .pga__side-column {
        position: sticky;
        top: 0.85rem;
        max-height: calc(100vh - 1.7rem);
        overflow-y: auto;
        padding-right: 0.15rem;
        overscroll-behavior: contain;
    }
}

/* ---------- Insights ---------- */

.pga__card--insights {
    order: -2;
    display: grid;
    gap: 0.64rem;
    padding: 0.78rem;
    background:
        linear-gradient(135deg, rgba(125, 164, 67, 0.12), rgba(255, 255, 255, 0) 42%),
        var(--pga-card-bg);
}

.pga__card--insights .pga__card-head {
    margin-bottom: 0;
}

.pga__card--insights[data-tone="white"] {
    background:
        linear-gradient(135deg, rgba(246, 247, 241, 0.95), rgba(255, 255, 255, 0) 52%),
        var(--pga-card-bg);
}

.pga__card--insights[data-tone="black"] {
    background:
        linear-gradient(135deg, rgba(32, 36, 29, 0.09), rgba(255, 255, 255, 0) 54%),
        var(--pga-card-bg);
}

.pga__insights-meta {
    color: var(--pga-bamboo-deep);
    font-size: 0.72rem;
    font-weight: 850;
    font-variant-numeric: tabular-nums;
}

.pga__insight-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 2.7rem;
    gap: 0.65rem;
    align-items: center;
    min-width: 0;
}

.pga__insight-eval {
    display: grid;
    gap: 0.08rem;
    min-width: 0;
}

.pga__insight-score {
    display: inline-flex;
    align-items: center;
    width: max-content;
    max-width: 100%;
    min-height: 1.54rem;
    padding: 0.08rem 0.42rem;
    border-radius: 6px;
    background: #20241d;
    color: #f7f8f2;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.86rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.pga__insight-eval strong {
    overflow: hidden;
    color: #20241d;
    font-size: 1.05rem;
    font-weight: 900;
    line-height: 1.12;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pga__insight-eval span:last-child {
    overflow: hidden;
    color: var(--pga-muted);
    font-size: 0.76rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pga__insight-badge {
    width: 2.65rem;
    height: 2.65rem;
    justify-self: end;
    border-radius: 50%;
    object-fit: contain;
    filter: drop-shadow(0 5px 10px rgba(17, 17, 17, 0.22));
}

.pga__insight-badge--empty {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--panda-black, #111111);
    color: var(--panda-white, #ffffff);
    filter: none;
}

.pga__insight-rows {
    display: grid;
}

.pga__insight-row {
    display: grid;
    grid-template-columns: 4.7rem minmax(0, 1fr);
    gap: 0.55rem;
    align-items: center;
    min-height: 2.1rem;
    padding: 0.3rem 0.1rem;
    border: 0;
    background: transparent;
}

.pga__insight-row + .pga__insight-row {
    border-top: 1px solid rgba(28, 36, 23, 0.07);
}

.pga__insight-row span {
    color: #98a18d;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.pga__insight-row strong {
    min-width: 0;
    overflow: hidden;
    color: #2c3426;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pga__moment-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.pga__moment-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.42rem;
    min-width: 0;
    min-height: 2rem;
    padding: 0.28rem 0.7rem 0.28rem 0.55rem;
    border: 0;
    border-radius: 999px;
    background: #f4f6ef;
    color: #20241d;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}

.pga__moment-chip::before {
    content: "";
    width: 0.52rem;
    height: 0.52rem;
    flex: 0 0 auto;
    border-radius: 50%;
    background: rgba(84, 95, 74, 0.5);
}

.pga__moment-chip:hover {
    background: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(28, 36, 23, 0.14);
}

.pga__moment-chip:focus-visible {
    outline: 2px solid rgba(59, 124, 39, 0.72);
    outline-offset: 2px;
}

.pga__moment-chip--brilliant::before {
    background: var(--pga-brilliant);
}

.pga__moment-chip--praise::before {
    background: var(--pga-best);
}

.pga__moment-chip--best::before {
    background: var(--pga-best);
}

.pga__moment-chip--excellent::before {
    background: var(--pga-excellent);
}

.pga__moment-chip--good::before {
    background: var(--pga-good);
}

.pga__moment-chip--book::before {
    background: var(--pga-book);
}

.pga__moment-chip--forced::before {
    background: var(--pga-forced);
}

.pga__moment-chip--only_move::before {
    background: var(--pga-only-move);
}

.pga__moment-chip--inaccuracy::before {
    background: var(--pga-inaccuracy);
}

.pga__moment-chip--mistake::before {
    background: #ca8124;
}

.pga__moment-chip--blunder::before {
    background: var(--pga-blunder);
}

.pga__moment-chip--checkmate::before,
.pga__moment-chip--sacrifice::before {
    background: var(--pga-brilliant);
}

.pga__moment-move,
.pga__moment-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pga__moment-move {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    font-weight: 800;
}

.pga__moment-label {
    color: #9aa48e;
    font-size: 0.7rem;
    font-weight: 600;
}

.pga__insight-kpis {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
    padding-top: 0.55rem;
    border-top: 1px solid rgba(28, 36, 23, 0.07);
}

.pga__insight-kpis--two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pga__insight-kpi {
    display: grid;
    gap: 0.08rem;
    min-width: 0;
    padding: 0.3rem 0.46rem;
    border: 0;
    background: transparent;
    text-align: center;
}

.pga__insight-kpi + .pga__insight-kpi {
    border-left: 1px solid rgba(28, 36, 23, 0.09);
}

.pga__insight-kpi span {
    overflow: hidden;
    color: #98a18d;
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1.1;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.pga__insight-kpi small {
    display: none;
}

.pga__insight-kpi strong {
    color: #20241d;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.35rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

/* ---------- Rail ---------- */

.pga__rail {
    display: grid;
    gap: 0.78rem;
    padding: 0.85rem 0.95rem 0.95rem;
}

.pga__rail-section {
    display: grid;
    gap: 0.55rem;
    min-width: 0;
}

.pga__rail-section + .pga__rail-section {
    padding-top: 0.78rem;
    border-top: 1px solid rgba(28, 36, 23, 0.09);
}

.pga__rail-verdict {
    min-height: 4.1rem;
    padding: 0.6rem 0.75rem;
    border-radius: 12px;
    background: #f4f6ef;
    transition: background 0.25s ease;
}

.pga__rail-verdict[data-tone="praise"] {
    background: linear-gradient(135deg, rgba(125, 164, 67, 0.16), rgba(125, 164, 67, 0.05));
}

.pga__rail-verdict[data-tone="best"] {
    background: linear-gradient(135deg, rgba(47, 143, 69, 0.16), rgba(47, 143, 69, 0.05));
}

.pga__rail-verdict[data-tone="excellent"] {
    background: linear-gradient(135deg, rgba(79, 158, 61, 0.16), rgba(79, 158, 61, 0.05));
}

.pga__rail-verdict[data-tone="good"] {
    background: linear-gradient(135deg, rgba(120, 166, 75, 0.16), rgba(120, 166, 75, 0.05));
}

.pga__rail-verdict[data-tone="brilliant"],
.pga__rail-verdict[data-tone="checkmate"],
.pga__rail-verdict[data-tone="sacrifice"] {
    background: linear-gradient(135deg, rgba(8, 127, 155, 0.14), rgba(8, 127, 155, 0.04));
}

.pga__rail-verdict[data-tone="inaccuracy"] {
    background: linear-gradient(135deg, rgba(217, 158, 27, 0.18), rgba(217, 158, 27, 0.05));
}

.pga__rail-verdict[data-tone="mistake"] {
    background: linear-gradient(135deg, rgba(182, 95, 0, 0.16), rgba(182, 95, 0, 0.05));
}

.pga__rail-verdict[data-tone="blunder"],
.pga__rail-verdict[data-tone="error"] {
    background: linear-gradient(135deg, rgba(198, 45, 45, 0.14), rgba(198, 45, 45, 0.04));
}

.pga__rail-verdict[data-tone="book"] {
    background: linear-gradient(135deg, rgba(138, 90, 43, 0.16), rgba(138, 90, 43, 0.05));
}

.pga__rail-verdict[data-tone="forced"] {
    background: linear-gradient(135deg, rgba(111, 143, 58, 0.16), rgba(111, 143, 58, 0.05));
}

.pga__rail-verdict[data-tone="only_move"] {
    background: linear-gradient(135deg, rgba(77, 143, 92, 0.16), rgba(77, 143, 92, 0.05));
}

.pga__tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    padding: 0;
    border: 0;
    border-bottom: 1px solid rgba(28, 36, 23, 0.09);
    background: transparent;
}

.pga__tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.34rem;
    min-height: 2.3rem;
    padding: 0.3rem 0.2rem 0.55rem;
    border: 0;
    background: transparent;
    color: #8d9683;
    font-size: 0.79rem;
    font-weight: 700;
    cursor: pointer;
    transition: color 0.16s ease;
}

.pga__tab i {
    font-size: 0.85rem;
}

.pga__tab span {
    display: none;
}

.pga__tab::after {
    content: "";
    position: absolute;
    right: 18%;
    bottom: -1px;
    left: 18%;
    height: 2.5px;
    border-radius: 999px;
    background: transparent;
    transition: background 0.16s ease;
}

.pga__tab:hover {
    color: var(--pga-bamboo-deep);
}

.pga__tab.is-active {
    color: var(--pga-bamboo-deep);
    font-weight: 800;
}

.pga__tab.is-active::after {
    background: var(--pga-bamboo-deep);
}

.pga__tab:focus-visible {
    outline: 2px solid rgba(59, 124, 39, 0.72);
    outline-offset: 1px;
    border-radius: 6px;
}

.pga__panel {
    display: grid;
    gap: 0.55rem;
    min-height: 12rem;
}

.pga__panel[hidden] {
    display: none;
}

.pga__panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.6rem;
}

.pga__panel-title {
    color: #5c6356;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.pga__verdict {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.pga__verdict strong {
    display: block;
    font-size: 0.98rem;
    font-weight: 800;
    line-height: 1.25;
}

.pga__verdict p {
    margin: 0.12rem 0 0;
    color: #7c8671;
    font-size: 0.8rem;
    line-height: 1.35;
}

.pga__verdict-badge {
    width: 2.55rem;
    height: 2.55rem;
    flex: 0 0 auto;
    filter: drop-shadow(0 4px 8px rgba(17, 17, 17, 0.2));
}

.pga__verdict--brilliant strong {
    color: var(--pga-brilliant);
}

.pga__verdict--praise strong {
    color: var(--pga-bamboo-deep);
}

.pga__verdict--inaccuracy strong {
    color: #8a6312;
}

.pga__verdict--mistake strong {
    color: var(--pga-mistake);
}

.pga__verdict--blunder strong {
    color: var(--pga-blunder);
}

.pga__verdict--empty i,
.pga__verdict--error i {
    font-size: 1.9rem;
    color: var(--pga-muted);
}

.pga__verdict--error i {
    color: var(--pga-blunder);
}

.pga__verdict-spinner {
    width: 2.2rem;
    height: 2.2rem;
    flex: 0 0 auto;
    border-radius: 50%;
    border: 4px solid var(--panda-grey, #e9ecef);
    border-top-color: var(--pga-bamboo);
    animation: pga-spin 0.9s linear infinite;
}

@keyframes pga-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---------- Engine lines ---------- */

.pga__engine-meta {
    color: var(--pga-muted);
    font-size: 0.74rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.pga__engine-lines {
    display: grid;
}

.pga__rail-section--graph {
    gap: 0.42rem;
}

.pga__rail-section--moves {
    min-height: 0;
}

.pga__engine-line {
    display: grid;
    grid-template-columns: 1rem 2.9rem 1fr;
    gap: 0.5rem;
    align-items: center;
    min-height: 2.25rem;
    padding: 0.3rem 0.25rem;
    border-radius: 8px;
    background: transparent;
    transition: background 0.15s ease;
}

.pga__engine-line + .pga__engine-line {
    border-top: 1px solid rgba(28, 36, 23, 0.07);
}

.pga__engine-line:hover {
    background: #f6f8f1;
}

.pga__engine-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    background: transparent;
    color: #aab3a0;
    font-size: 0.72rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.pga__engine-score {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 1.38rem;
    padding: 0 0.32rem;
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.74rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.pga__engine-score--white {
    background: #f6f7f1;
    color: #20241d;
    box-shadow: inset 0 0 0 1.5px rgba(17, 17, 17, 0.3);
}

.pga__engine-score--black {
    background: #20241d;
    color: #f6f7f1;
}

.pga__engine-moves {
    min-width: 0;
    overflow: hidden;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.76rem;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pga__engine-empty {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--pga-muted);
    font-size: 0.82rem;
}

.pga__engine-line--loading {
    position: relative;
    overflow: hidden;
    background: rgba(17, 17, 17, 0.04);
}

.pga__engine-line--loading::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent);
    animation: pga-shimmer 1.2s ease-in-out infinite;
}

@keyframes pga-shimmer {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(100%);
    }
}

@media (prefers-reduced-motion: reduce) {
    .pga__engine-line--loading::after,
    .pga__board-badge,
    .pga__verdict-spinner {
        animation: none;
    }
}

/* ---------- Moves card ---------- */

.pga__analysis-progress {
    color: var(--pga-muted);
    font-size: 0.7rem;
    font-weight: 800;
}

.pga__analysis-progress[data-tone="busy"] {
    color: #6d4b00;
}

.pga__analysis-progress[data-tone="done"] {
    color: var(--pga-bamboo-deep);
}

.pga__analysis-progress[data-tone="warn"] {
    color: var(--pga-mistake);
}

.pga__move-list .panda-move-history {
    max-height: clamp(12rem, 34vh, 22rem);
}

.pga__move-list .panda-move-history__table {
    min-width: 0;
}

.pga__move-list .panda-move-history__head {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--pga-card-bg);
}

/* Without time meta the second grid column is unused; give the SAN the full
 * width so long labels like exd8=Q+ never truncate. */
.pga__move-list .panda-move-history__move-cell,
.pga__move-list .panda-move-history__move-button {
    grid-template-columns: minmax(0, 1fr);
}

.pga__move-list .panda-move-history__classification-badge {
    width: 1.1em;
    height: 1.1em;
}

/* ---------- Evaluation graph ---------- */

.pga__graph-hint {
    color: var(--pga-muted);
    font-size: 0.72rem;
    font-weight: 700;
}

.pga__graph-svg {
    display: block;
    width: 100%;
    height: clamp(4.8rem, 10vh, 6.4rem);
    cursor: pointer;
    border-radius: 6px;
    background: linear-gradient(180deg, #fdfdfa 0%, #f4f6ee 100%);
}

.pga__graph-zero {
    stroke: rgba(28, 36, 23, 0.28);
    stroke-width: 1;
    stroke-dasharray: 4 4;
}

.pga__graph-line {
    stroke: var(--pga-bamboo-deep);
    stroke-width: 2;
    stroke-linejoin: round;
}

.pga__graph-area {
    fill: rgba(125, 164, 67, 0.28);
    stroke: none;
}

.pga__graph-cursor {
    stroke: rgba(28, 36, 23, 0.55);
    stroke-width: 1.5;
}

.pga__graph-point {
    cursor: pointer;
    stroke: var(--panda-white, #ffffff);
    stroke-width: 2;
    filter: drop-shadow(0 2px 4px rgba(17, 17, 17, 0.28));
    transition: r 0.14s ease, stroke-width 0.14s ease;
}

.pga__graph-point--brilliant {
    fill: var(--pga-brilliant);
}

.pga__graph-point--mistake {
    fill: var(--pga-mistake);
}

.pga__graph-point--blunder {
    fill: var(--pga-blunder);
}

.pga__graph-point:hover,
.pga__graph-point:focus {
    stroke: var(--panda-black, #111111);
    stroke-width: 3;
    outline: none;
}

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {
    .pga {
        --pga-board-size: clamp(26rem, min(70vw, calc(100dvh - 5.05rem)), 50rem);
        --pga-rail-width: clamp(13.75rem, 19vw, 15.25rem);
    }

    .pga__layout {
        grid-template-columns: minmax(0, var(--pga-board-shell-width)) minmax(14rem, var(--pga-rail-width));
        gap: 0.48rem;
    }
}

@media (max-width: 980px) {
    body.is-game-analysis-view .main-content {
        padding-right: 0.65rem;
        padding-left: 0.65rem;
    }

    .pga {
        --pga-board-size: min(calc(100vw - 1.5rem), calc(100dvh - 8.8rem), 44rem);
    }

    /* Single column keeps the board first, then the priority analysis rail. */
    .pga__layout {
        grid-template-columns: minmax(0, 1fr);
        justify-items: center;
        gap: 0.6rem;
    }

    .pga__board-column,
    .pga__side-column {
        display: contents;
    }

    .pga__board-frame {
        width: 100%;
        grid-template-columns: 1.18rem minmax(0, var(--pga-board-size));
        gap: 0.24rem;
    }

    .pga__evalbar {
        width: 1.18rem;
    }

    .pga__board-card,
    .pga__rail {
        width: 100%;
        max-width: var(--pga-board-shell-width);
    }

    .pga__rail {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        max-width: calc(var(--pga-board-size) - 1rem);
        gap: 0.52rem;
        padding: 0.62rem 0.75rem 0.72rem;
    }

    .pga__rail-section--lines {
        grid-column: 1;
    }

    .pga__rail-section--graph {
        grid-column: 2;
        padding-top: 0;
        border-top: 0;
    }

    .pga__rail-section--moves {
        grid-column: 1 / -1;
    }

    .pga__rail-section {
        gap: 0.4rem;
    }

    .pga__rail-section + .pga__rail-section {
        padding-top: 0.52rem;
    }

    .pga__rail .pga__rail-section--graph {
        padding-top: 0;
        border-top: 0;
    }

    .pga__engine-line {
        grid-template-columns: 0.85rem 2.55rem minmax(0, 1fr);
        gap: 0.34rem;
        min-height: 1.9rem;
        padding: 0.2rem 0.14rem;
    }

    .pga__graph-svg {
        height: clamp(3.4rem, 7vh, 4.75rem);
    }

    .pga__tab span {
        display: inline;
    }

    .pga__board-card {
        order: 0;
    }

    .pga__rail {
        order: 1;
    }

    .pga__toolbar {
        order: 2;
        width: 100%;
        max-width: var(--pga-board-shell-width);
    }

    .pga__hint {
        display: none;
    }

    .pga__panel {
        min-height: 8rem;
    }

    .pga__rail-section {
        min-height: 0;
    }

    .pga__move-list .panda-move-history {
        max-height: 16rem;
    }
}

@media (max-width: 991.98px) {
    .pga__settings {
        top: auto;
        right: 0.95rem;
        bottom: calc(6.15rem + env(safe-area-inset-bottom, 0px));
        left: 0.95rem;
        width: auto;
        max-height: min(27rem, calc(100dvh - 8.5rem));
        padding: 0.85rem;
        border-radius: 8px 8px 0 0;
        box-shadow: 0 -18px 46px rgba(20, 22, 18, 0.22);
    }
}

/* ---------- Game setup card (app + dev page chrome) ---------- */

#view-analysis > * {
    width: min(100%, 104rem);
    margin-inline: auto;
}

body.is-game-analysis-view #view-analysis > * {
    width: min(100%, 100rem);
}

body.is-game-analysis-view #view-analysis > .view-header {
    align-items: center;
    margin-bottom: 0.45rem !important;
}

body.is-game-analysis-view #view-analysis > .view-header > div:first-child {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    min-width: 0;
    flex-wrap: wrap;
}

body.is-game-analysis-view #view-analysis .view-header h1 {
    line-height: 1;
}

body.is-game-analysis-view #view-analysis .ga-subpage-tabs {
    display: inline-flex;
    margin-top: 0;
}

.ga-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.48rem;
    flex-wrap: wrap;
}

.ga-subpage-tabs {
    display: inline-flex;
    align-items: center;
    gap: 0.24rem;
    margin-top: 0.65rem;
    padding: 0.24rem;
    border: 1px solid rgba(17, 17, 17, 0.1);
    border-radius: var(--panda-radius-pill, 999px);
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 8px 18px rgba(28, 36, 23, 0.06);
}

.ga-subpage-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.36rem;
    min-height: 2rem;
    padding: 0.36rem 0.78rem;
    border: 0;
    border-radius: var(--panda-radius-pill, 999px);
    background: transparent;
    color: #4d5748;
    font-size: 0.82rem;
    font-weight: 850;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
}

.ga-subpage-tab:hover {
    color: var(--panda-bamboo, #7da443);
}

.ga-subpage-tab:focus-visible {
    outline: 2px solid rgba(59, 124, 39, 0.72);
    outline-offset: 2px;
}

.ga-subpage-tab.is-active {
    background: var(--panda-black, #111111);
    color: var(--panda-white, #ffffff);
}

.ga-board-settings-button {
    min-height: 2.1rem;
    padding: 0.35rem 0.8rem;
    text-transform: none;
    letter-spacing: 0;
}

.ga-setup-card {
    margin-bottom: 1.1rem;
    padding: 1rem 1.1rem;
    border-radius: var(--panda-surface-radius, var(--panda-radius-lg, 1rem));
    background:
        linear-gradient(135deg, rgba(125, 164, 67, 0.08), rgba(255, 255, 255, 0) 52%),
        var(--panda-white, #ffffff);
}

.ga-setup-card.is-collapsed {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.55rem;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.ga-setup-card.is-collapsed .ga-setup-toggle {
    width: auto;
    justify-content: center;
    min-height: 2.15rem;
    padding: 0.36rem 0.76rem;
    border: 1px solid rgba(17, 17, 17, 0.1);
    border-radius: var(--panda-radius-pill, 999px);
    background: rgba(255, 255, 255, 0.86);
    box-shadow: 0 8px 18px rgba(28, 36, 23, 0.06);
}

.ga-setup-card textarea {
    min-height: 7rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.86rem;
    line-height: 1.5;
}

.ga-setup-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
    margin-top: 0.75rem;
}

.ga-depth-label {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin-left: auto;
    color: #4d5748;
    font-size: 0.78rem;
    font-weight: 800;
}

.ga-depth-label input {
    width: 5rem;
}

.ga-demo-label {
    display: inline-flex;
    align-items: center;
    gap: 0.38rem;
    min-height: 2.25rem;
    padding: 0.25rem 0.65rem;
    border: 1px solid rgba(17, 17, 17, 0.1);
    border-radius: var(--panda-radius-pill, 999px);
    background: rgba(255, 255, 255, 0.78);
    color: #4d5748;
    font-size: 0.78rem;
    font-weight: 800;
    cursor: pointer;
}

.ga-demo-label input {
    accent-color: var(--panda-bamboo, #7da443);
}

.ga-setup-error {
    margin-top: 0.5rem;
}

.ga-setup-error:empty {
    display: none;
}

.ga-setup-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: #4d5748;
    font-size: 0.82rem;
    font-weight: 800;
    cursor: pointer;
}

.ga-setup-toggle:hover {
    color: var(--panda-bamboo, #7da443);
}

.ga-setup-toggle:focus-visible,
.ga-demo-label:focus-within {
    outline: 2px solid rgba(59, 124, 39, 0.72);
    outline-offset: 2px;
}

.ga-view-status {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2.1rem;
    padding: 0.35rem 0.2rem;
    border: 0;
    background: transparent;
    color: #6c7563;
    font-size: 0.82rem;
    font-weight: 650;
}

.ga-view-status::before {
    content: "";
    width: 0.52rem;
    height: 0.52rem;
    flex: 0 0 auto;
    border-radius: 50%;
    background: #6fa84a;
    box-shadow: 0 0 0 3px rgba(111, 168, 74, 0.18);
}

.ga-view-status[data-tone="loading"] {
    color: #79683a;
}

.ga-view-status[data-tone="loading"]::before {
    background: #d9a521;
    box-shadow: 0 0 0 3px rgba(217, 165, 33, 0.2);
    animation: pga-status-pulse 1.4s ease-in-out infinite;
}

.ga-view-status[data-tone="error"] {
    color: #8f1f2d;
}

.ga-view-status[data-tone="error"]::before {
    background: #c62d2d;
    box-shadow: 0 0 0 3px rgba(198, 45, 45, 0.16);
}

@keyframes pga-status-pulse {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.45;
    }
}

.ga-summary-empty {
    display: grid;
    gap: 0.9rem;
    place-items: center;
    min-height: min(28rem, 55vh);
    padding: 2.5rem 1.25rem;
    border: 1px dashed rgba(17, 17, 17, 0.16);
    border-radius: var(--panda-radius-xl, 1.5rem);
    background:
        linear-gradient(135deg, rgba(125, 164, 67, 0.12), transparent 60%),
        var(--panda-white, #ffffff);
    text-align: center;
}

.ga-summary-empty__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border-radius: 14px;
    background: var(--panda-black, #111111);
    color: var(--panda-white, #ffffff);
    font-size: 1.35rem;
}

.ga-summary-empty h2 {
    margin: 0;
    font-size: clamp(1.35rem, 2vw, 1.9rem);
    font-weight: 900;
}

.ga-summary-empty p {
    max-width: 32rem;
    margin: 0;
    color: var(--pga-muted);
    font-weight: 650;
}

.ga-summary-loading {
    align-items: center;
}

.ga-summary-loading .panda-loader {
    margin-bottom: 0.35rem;
}

.ga-summary-loading__progress {
    color: #4f6d2f;
    font-weight: 800;
}

@media (max-width: 575.98px) {
    body.is-game-analysis-view {
        padding-bottom: calc(5.15rem + env(safe-area-inset-bottom, 0px));
    }

    body.is-game-analysis-view .main-content {
        padding-right: 0.35rem;
        padding-left: 0.35rem;
    }

    body.is-game-analysis-view .sidebar {
        right: 0.55rem;
        bottom: calc(0.45rem + env(safe-area-inset-bottom, 0px));
        left: 0.55rem;
        border-radius: 1rem;
    }

    body.is-game-analysis-view .sidebar .nav-list {
        gap: 0.16rem;
        padding: 0.28rem;
    }

    body.is-game-analysis-view .sidebar .nav-link,
    body.is-game-analysis-view .sidebar .nav-item--training-child .nav-link {
        grid-template-rows: 1.1rem 0.72rem;
        gap: 0.08rem;
        min-height: 3.18rem;
        padding: 0.28rem 0.2rem;
        border-radius: 0.8rem;
    }

    body.is-game-analysis-view .sidebar .nav-link i,
    body.is-game-analysis-view .sidebar .nav-item--training-child .nav-link i {
        font-size: 1.05rem;
    }

    body.is-game-analysis-view .sidebar .nav-link span::after {
        font-size: 0.56rem;
    }

    body.is-game-analysis-view .sidebar .nav-item.active:not(.nav-item--training-parent)::before {
        bottom: 0.28rem;
    }

    body.is-game-analysis-view .sidebar .nav-item.active .nav-link {
        transform: translateY(-0.08rem);
    }

    .pga {
        --pga-board-size: min(calc(100vw - 0.55rem), calc(100dvh - 8.8rem), 34rem);
        --pga-board-shell-width: 100%;
        padding-bottom: 0.65rem;
    }

    body.is-game-analysis-view #view-analysis > .view-header {
        margin-bottom: 0.55rem !important;
    }

    #view-analysis .view-header h1 {
        margin-bottom: 0;
        font-size: 1.35rem;
        line-height: 1.1;
    }

    body.is-game-analysis-view #view-analysis > .view-header > div:first-child {
        display: block;
        width: 100%;
    }

    .view-header-row {
        gap: 0.48rem;
    }

    .ga-subpage-tabs {
        display: flex;
        width: 100%;
        margin-top: 0.45rem;
    }

    .ga-subpage-tab {
        flex: 1 1 0;
        min-width: 0;
        min-height: 1.86rem;
        padding: 0.28rem 0.42rem;
    }

    .pga__board-card {
        gap: 0.22rem;
        padding: 0.16rem 0.16rem 0.12rem;
    }

    .pga__rail {
        max-width: min(calc(100vw - 2rem), calc(var(--pga-board-size) - 0.75rem));
        gap: 0.46rem;
        padding: 0.56rem 0.64rem 0.64rem;
    }

    .pga__rail-section {
        gap: 0.34rem;
    }

    .pga__rail-section + .pga__rail-section {
        padding-top: 0.46rem;
    }

    .pga__engine-line {
        grid-template-columns: 0.76rem 2.45rem minmax(0, 1fr);
        gap: 0.28rem;
        min-height: 1.58rem;
        padding: 0.16rem 0.12rem;
    }

    .pga__graph-svg {
        height: 2.65rem;
    }

    .pga__card,
    .ga-setup-card {
        padding-inline: 0.65rem;
    }

    .pga__player {
        gap: 0.34rem;
        min-height: 1.34rem;
    }

    .pga__player-dot {
        width: 0.98rem;
        height: 0.98rem;
        border-radius: 5px;
    }

    .pga__player-name {
        font-size: 0.76rem;
    }

    .pga__player-rating {
        padding: 0.01rem 0.26rem;
        font-size: 0.64rem;
    }

    .pga__player-score {
        min-width: 1.45rem;
        padding: 0.04rem 0.32rem;
        font-size: 0.68rem;
    }

    .pga__board-frame {
        grid-template-columns: 0.52rem minmax(0, 1fr);
        gap: 0.1rem;
    }

    .pga__board-frame--no-evalbar {
        grid-template-columns: minmax(0, 1fr);
    }

    .pga__evalbar {
        width: 0.52rem;
    }

    .pga__evalbar-label {
        font-size: 0.54rem;
    }

    .pga__board {
        border-radius: 8px;
    }

    .pga__toolbar {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        justify-items: center;
        gap: 0.26rem;
        width: 100%;
    }

    .pga__ply-counter {
        width: 100%;
        max-width: none;
        min-height: 1.55rem;
        grid-column: 1;
        order: 2;
    }

    .pga__nav-group {
        justify-content: center;
        gap: 0.12rem;
        padding: 0.14rem;
    }

    .pga__nav-group:first-child {
        width: 100%;
        grid-column: 1 / -1;
        order: 1;
    }

    .pga__nav-group--secondary {
        width: max-content;
        max-width: 100%;
        grid-column: 1;
        order: 3;
    }

    .pga__nav-button {
        min-width: 2.42rem;
        min-height: 2.42rem;
        padding: 0;
    }

    .pga__nav-button--primary {
        min-width: 2.42rem;
        min-height: 2.42rem;
    }

    .pga__board-settings-action {
        width: 1.58rem;
        min-width: 1.58rem;
        height: 1.58rem;
        min-height: 1.58rem;
        font-size: 0.7rem;
    }

    .pga__settings {
        right: 0.7rem;
        bottom: calc(5.9rem + env(safe-area-inset-bottom, 0px));
        left: 0.7rem;
        padding: 0.78rem;
    }

    .pga__settings-grid,
    .pga__settings-toggles {
        grid-template-columns: 1fr;
    }

    .pga__insight-row {
        grid-template-columns: 4.45rem minmax(0, 1fr);
    }

    .pga__insight-kpi {
        padding-inline: 0.34rem;
    }

    .ga-header-actions {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr);
        align-items: center;
        gap: 0.26rem;
        width: 100%;
    }

    .ga-board-settings-button {
        width: auto;
        min-width: 3rem;
        min-height: 2.35rem;
        padding-inline: 0.72rem;
    }

    .ga-view-status,
    .ga-setup-row .panda-btn,
    .ga-depth-label,
    .ga-demo-label {
        width: 100%;
    }

    .ga-view-status {
        justify-content: center;
        min-width: 0;
        min-height: 1.8rem;
        padding-block: 0.18rem;
        font-size: 0.74rem;
    }

    .ga-depth-label {
        justify-content: space-between;
        margin-left: 0;
    }

    .ga-depth-label input {
        width: 6rem;
    }
}

@media (max-width: 991.98px) and (max-height: 430px) and (orientation: landscape) {
    body.is-game-analysis-view {
        padding-bottom: 0;
    }

    body.is-game-analysis-view .main-content {
        padding: 0;
    }

    body.is-game-analysis-view .sidebar {
        display: none;
    }

    .pga {
        --pga-landscape-rail-width: clamp(10rem, 22vw, 12rem);
        --pga-board-size: min(100dvh, calc(100vw - var(--pga-landscape-rail-width) - 2rem), 34rem);
        --pga-board-shell-width: calc(var(--pga-board-size) + 1.1rem);
        padding-bottom: 0;
    }

    body.is-game-analysis-view #view-analysis > .view-header {
        display: none !important;
    }

    .pga__layout {
        grid-template-columns: minmax(0, var(--pga-board-shell-width)) minmax(9.5rem, var(--pga-landscape-rail-width));
        justify-content: center;
        justify-items: stretch;
        gap: 0.45rem;
    }

    .pga__board-column {
        display: grid;
        justify-items: center;
        gap: 0;
    }

    .pga__side-column {
        display: block;
        max-width: var(--pga-landscape-rail-width);
        min-width: 0;
    }

    .pga__board-card {
        width: 100%;
        max-width: var(--pga-board-shell-width);
        gap: 0;
        padding: 0;
    }

    .pga__board-header {
        position: absolute;
        top: 0.22rem;
        right: 0.22rem;
        left: auto;
        z-index: 20;
        pointer-events: none;
    }

    .pga__board-header .pga__player,
    .pga__player--bottom,
    .pga__toolbar {
        display: none;
    }

    .pga__rail {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        width: 100%;
        max-width: var(--pga-landscape-rail-width);
        max-height: calc(100dvh - 0.65rem);
        padding: 0.52rem;
        overflow-y: auto;
    }

    .pga__rail-section--lines,
    .pga__rail-section--graph,
    .pga__rail-section--moves {
        grid-column: 1;
    }

    .pga__rail .pga__rail-section--graph {
        padding-top: 0.46rem;
        border-top: 1px solid rgba(28, 36, 23, 0.09);
    }

    .pga__rail-verdict {
        min-height: 0;
        padding: 0.45rem 0.5rem;
    }

    .pga__tab {
        min-height: 2rem;
        padding-block: 0.24rem 0.46rem;
    }

    .pga__tab span {
        display: none;
    }

    .pga__panel {
        min-height: 0;
    }

    .pga__rail {
        gap: 0.46rem;
    }

    .pga__rail-section {
        gap: 0.35rem;
    }

    .pga__rail-section + .pga__rail-section {
        padding-top: 0.46rem;
    }

    .pga__graph-svg {
        height: 3.25rem;
    }

    .pga__move-list .panda-move-history {
        max-height: min(8rem, calc(100dvh - 15.5rem));
    }

    .pga__insight-row {
        grid-template-columns: minmax(3.8rem, 0.58fr) minmax(0, 1fr);
        gap: 0.35rem;
    }

    .pga__board-settings-action {
        display: none;
    }

    .pga__board-frame {
        grid-template-columns: 0.9rem minmax(0, var(--pga-board-size));
        gap: 0.2rem;
    }

    .pga__evalbar {
        width: 0.9rem;
    }
}

@media (max-width: 560px) and (max-height: 430px) and (orientation: landscape) {
    .pga {
        --pga-landscape-rail-width: clamp(8.5rem, 28vw, 10rem);
        --pga-board-size: min(100dvh, calc(100vw - var(--pga-landscape-rail-width) - 0.8rem), 34rem);
        --pga-board-shell-width: calc(var(--pga-board-size) + 1.1rem);
    }

    .pga__layout {
        grid-template-columns: minmax(0, var(--pga-board-shell-width)) minmax(8.25rem, var(--pga-landscape-rail-width));
        gap: 0.22rem;
    }

    .pga__side-column {
        display: block;
        max-width: var(--pga-landscape-rail-width);
        min-width: 0;
    }

    .pga__board-header {
        left: calc((100vw - var(--pga-board-shell-width)) / 2 + var(--pga-board-shell-width) - 1.7rem);
        right: auto;
    }

    .pga__board-settings-action {
        display: none;
    }
}

/* Programmatic focus lands on the view title for screen readers; the
 * default focus ring reads as a rendering glitch for everyone else. */
#view-analysis .view-header h1:focus {
    outline: none;
}

/* ---------- Settings panel: quick actions + analysis depth ---------- */

.pga__settings-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.7rem;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid var(--pga-line);
}

.pga__settings-action {
    display: inline-flex;
    align-items: center;
    gap: 0.42rem;
    min-height: 2.1rem;
    padding: 0.3rem 0.75rem;
    border: 1.5px solid var(--panda-grey, #e9ecef);
    border-radius: var(--panda-radius-pill, 999px);
    background: var(--pga-card-bg);
    color: var(--pga-ink);
    font-size: 0.82rem;
    font-weight: 800;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.pga__settings-action:hover {
    border-color: var(--pga-bamboo);
    background: var(--pga-bamboo-soft);
    color: var(--pga-bamboo-deep);
}

.pga__settings-field--depth {
    padding-top: 0.65rem;
    border-top: 1px solid var(--pga-line);
}

.pga__settings-field--depth input {
    width: 5.2rem;
}

/* ---------- Load game button + sheet ---------- */

.ga-load-game-button {
    min-height: 2.1rem;
    padding: 0.35rem 0.9rem;
    text-transform: none;
    letter-spacing: 0;
}

@media (max-width: 575.98px) {
    .ga-load-game-button {
        min-height: 1.95rem;
        padding: 0.28rem 0.62rem;
        font-size: 0.76rem;
    }
}

.ga-sheet {
    position: fixed;
    inset: 0;
    z-index: 1700;
}

.ga-sheet[hidden] {
    display: none !important;
}

.ga-sheet__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 22, 14, 0.45);
    backdrop-filter: blur(2px);
}

.ga-sheet__panel {
    position: absolute;
    top: 50%;
    left: 50%;
    display: grid;
    gap: 0.75rem;
    width: min(36rem, calc(100vw - 2rem));
    max-height: calc(100dvh - 3rem);
    padding: 1.15rem 1.25rem 1.25rem;
    overflow-y: auto;
    border-radius: 14px;
    background: var(--panda-white, #ffffff);
    box-shadow: 0 32px 80px rgba(17, 17, 17, 0.3);
    transform: translate(-50%, -50%);
}

.ga-sheet__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.ga-sheet__header h2 {
    margin: 0;
    font-size: 1.12rem;
    font-weight: 800;
}

.ga-sheet__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    border: 0;
    border-radius: 50%;
    background: rgba(17, 17, 17, 0.05);
    color: #3d4631;
    cursor: pointer;
    transition: background 0.15s ease;
}

.ga-sheet__close:hover {
    background: rgba(17, 17, 17, 0.12);
}

.ga-sheet__pgn {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
    resize: vertical;
}

.ga-sheet__parameters {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
    padding: 0.7rem 0.78rem;
    border: 1px solid rgba(17, 17, 17, 0.08);
    border-radius: 8px;
    background: #f7f9f3;
}

.ga-sheet__parameters-title {
    color: #20241d;
    font-size: 0.82rem;
    font-weight: 850;
}

.ga-sheet__parameters .ga-depth-label {
    margin-left: 0;
}

.ga-sheet__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

body.ga-sheet-open {
    overflow: hidden;
}

@media (max-width: 575.98px) {
    .ga-sheet__panel {
        top: auto;
        bottom: 0;
        left: 0;
        width: 100%;
        max-height: calc(100dvh - 4rem);
        padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
        border-radius: 16px 16px 0 0;
        transform: none;
    }

    .ga-sheet__actions .btn {
        flex: 1 1 100%;
    }

    .ga-sheet__parameters {
        align-items: stretch;
        flex-direction: column;
    }

    .ga-sheet__parameters .ga-depth-label {
        justify-content: space-between;
    }
}
