@import 'switch.css';
#main-wrap {
    --main-max-width: auto;
    --ranks-top: 0px;
    --files-left: 0px;
    --pocketMargin: 0px;
    --panel-height: 240px;
}
.analysis-app {
    grid-area: main;
    display: grid;
}

/* DuckInput uses a0 as a temporary off-board holding square before
   the first duck placement. Clip the analysis board so that fake
   source square stays hidden while its legal destination dots remain visible. */
.analysis-app cg-board {
    overflow: hidden;
}

.sidebar-first {
    box-shadow: none;
}
@media (max-width: 799px) {
    #main-wrap {
        --main-max-width: 100%;
    }
    .analysis-app {
        grid-template-rows: auto;
        grid-template-areas: 'pocket-top' 'board' 'pocket-bot' 'move-controls' 'ceval' 'pv' 'misc-info' 'vari' 'tools' 'uboard' 'side';
    }
    under-left {
        display: none;
    }
}
@media (min-width: 800px) and (min-height: 500px) {
    .analysis-app {
        --board-scale: calc((var(--zoom) / 100));
    }
}

@media (min-width: 800px) {
    .analysis-app {
        grid-template-columns: minmax(230px, 20vw) 2vmin minmax(calc(70vmin * var(--board-scale)), calc(100vh * var(--board-scale) - calc(var(--site-header-height) + var(--site-header-margin)) - 3rem)) var(--gauge-gap) minmax(240px, 400px);
        grid-template-rows: min-content 1fr;
        grid-template-areas: 'side . board gauge pocket-top' 'side . board gauge tools' 'side . board gauge tools' 'side . board gauge pocket-bot' 'uleft . uboard . move-controls';
    }
    body[data-view='analysis'] .analysis-app:not(.bug) > under-left#spectators {
        margin-top: 2vmin;
    }
    /* move rank numbers to the left side of the board */
    .cg-wrap coords.side {
        right: auto;
    }
    .cg-wrap coords.side coord {
        transform: translate(var(--ranks-left), 39%);
    }
}

.anal-clock {
    position: absolute;
    right: 0;
    padding: 0 0.5em;
    margin-left: 12px;
    height: 20px;
    font-weight: bold;
    text-align: center;
    background: var(--bg-color2);
    box-shadow: var(--base-shadow);
    z-index: 1;
}
.anal-clock.active {
    background: var(--anal-clock);
}
.anal-clock.top {
    top: -20px;
}
.anal-clock.bottom {
    top: var(--cg-height, 100%);
}
.anal-clock tenths {
    font-size: 80%;
}

/* .round-app grid has 2vmin grid-gap, but .analysis-app doesn't.
   Because of this the cross table needs extra top padding */
div.ctable-container {
    padding-top: 3vmin;
}
#gauge {
    grid-area: gauge;
}
#gauge, #gaugePartner {
    display: block;
    background-color: var(--analysis-gauge-first, #fff);
    width: var(--gauge-gap);
    overflow: hidden;
    position: relative;
}
.flipped {
    transform: rotateX(180deg);
}
#gauge::after, #gaugePartner::after {
    content: '';
    display: block;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    box-shadow: 0 0 5px rgba(0,0,0,0.7) inset;
}
#gauge .fill, #gaugePartner .fill{
    background-color: var(--analysis-gauge-second, #888);
    transition: height 1s;
}
#gauge .tick, #gaugePartner .tick{
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    border-bottom: 2px ridge #eee;
    opacity: 0.4;
}
#gauge .tick.zero, #gaugePartner .tick.zero{
    opacity: 1;
    border-bottom: 7px solid rgba(214,79,0,0.4);
    margin-top: -3px;
}
@media (max-width: 799px) and (orientation: portrait) {
    #gauge, #gaugePartner {
        display: none;
    }
}

.movelist-block{
    grid-area: moves;
    flex: 2 1 0;
    overflow-y: auto;
    justify-content: initial;
}
#movelist {
    display: flex;
    height: auto;
    max-height: none;
}
@media (max-width: 799px) and (orientation: portrait) {
    .movelist-block {
        flex: initial;
        height: var(--movelist-max-height);
        max-height: var(--movelist-max-height);
    }
}
.analysis-tools, .analysis-settings {
  grid-area: tools;
  display: flex;
  flex-flow: column;
  box-shadow: var(--base-shadow);
}
div.analysis-settings {
  display: none;
  padding: 2vmin;
  background: var(--bg-color0);
  border-bottom: 3px solid var(--green-switch);
}

button#bars {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
}
button#bars.active {
  background: var(--green-switch) !important;
  color: var(--bg-color0);
}
/* Engine info */
.nnue {
    color: var(--good);
    font-weight: bold;
}
.engine-settings-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-color);
    padding: 2px 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
    font-size: 18px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}
.engine-settings-btn:hover {
    opacity: 1;
    transform: rotate(35deg);
}
div#ceval {
    grid-area: ceval;
    background-color: var(--bg-color2);
    box-shadow: var(--btn-shadow);
    border-bottom: 1px solid var(--border-color);
}
.engine {
    display: flex;
    align-items: center;
    padding: 6px 10px;
}
.engine-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
}
.engine-source-bar {
    display: flex;
    padding: 4px 8px 8px 8px;
    gap: 6px;
    background-color: var(--bg-color2);
    border-top: 1px dashed var(--border-color);
}
.engine-source-btn {
    flex: 1;
    font-size: 12px;
    padding: 5px 6px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: var(--bg-color0);
    color: var(--text-color);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.15s ease;
    text-align: center;
}
.engine-source-btn:hover {
    background: var(--bg-color1);
}
.engine-source-btn.active {
    background: #27ae60 !important;
    color: #ffffff !important;
    border-color: #27ae60 !important;
    font-weight: bold;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
div.info, div.infoBug {
    flex: 1 1 auto;
    align-self: center;
    line-height: 18px;
}
div.infoBug{
    text-align: center;
}
a.icon.icon-plus-square {
    opacity:0.9;
    color: var(--link-color-blue);
    background-color: var(--bg-body);
    font-size: 16px;
    margin-left: 4px;
}
div.pv {
    grid-area: pv;
    display: flex;
    flex: 0 1 auto;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-color0);
}
div.pvbox {
    position: relative;
}
div.pv:hover {
    background-color: var(--pv-hover);
}
.analysis-keyboard-help {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    background-color: rgba(0, 0, 0, 0.45);
    z-index: 1300;
}
.analysis-keyboard-help__content {
    width: min(720px, calc(100vw - 2rem));
    max-height: min(80vh, 640px);
    overflow: auto;
    background: var(--modal-bg);
    color: var(--text-color);
    border-radius: 12px;
    border: 1px solid var(--bg-color2);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
}
.analysis-keyboard-help__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}
.analysis-keyboard-help__header h2 {
    margin: 0;
    font-size: 1.3rem;
}
.analysis-keyboard-help__close {
    border: 0;
    background: transparent;
    color: var(--text-color);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}
.analysis-keyboard-help__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    padding: 1.25rem;
}
.analysis-keyboard-help__section h3 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
}
.analysis-keyboard-help__section table {
    width: 100%;
    border-collapse: collapse;
}
.analysis-keyboard-help__section td {
    padding: 0.45rem 0;
    vertical-align: top;
}
.analysis-keyboard-help__section td.keys-cell {
    width: 40%;
    padding-right: 1rem;
}
.analysis-keyboard-help__section .keys {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}
.analysis-keyboard-help__section kbd {
    display: inline-flex;
    align-items: center;
    min-height: 1.8rem;
    padding: 0 0.45rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-color1);
    box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.12);
    font: inherit;
    font-weight: 600;
}
.analysis-keyboard-help__section .sep {
    color: var(--text-dim-color);
    font-size: 0.9rem;
}
.analysis-keyboard-help__section .description-cell {
    color: var(--text-color);
}
pvline {
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    min-width: 0;
    max-width: var(--cg-width);
    height: 28px;
    line-height: 28px;
    font-size: 13px;
    padding-left: 6px;
}
pvline strong {
    padding-right: 6px;
}
.pv-move-number {
    color: var(--text-dim-color);
    margin-inline-end: 0.2em;
}
.pv-san-move {
    display: inline-block;
    margin-inline-end: 0.4em;
}
.pv-hover-board {
    position: absolute;
    left: 28px;
    z-index: 50;
    pointer-events: none;
}
.pv-hover-board .cg-wrap {
    width: 230px;
    box-shadow: var(--base-shadow);
    border: 1px solid var(--border-color);
}
@media (max-width: 799px) and (orientation: portrait) {
    .pv-hover-board {
        left: 0;
    }
    .pv-hover-board .cg-wrap {
        width: 200px;
    }
}
.pv:hover .pv-san-move:hover {
    color: var(--link-color-blue);
}
@media (max-width: 799px) and (orientation: portrait) {
    pvline {
        padding-left: 0;
    }
}
score {
    flex: 0 0 75px;
    font-weight: bold;
    font-size: 22px;
    align-self: center;
    padding-left: 8px;
}

/* loader */
#loader-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0.1%;
    z-index: 1000;
}
#loader {
    display: none;
    position: relative;
    top: 100px;
    left: 50%;
    width: 40px;
    height: 40px;
}

.spinner {
    stroke-dasharray: 400;
    fill:none;
    stroke-width:1.65;
    animation: dash 4s cubic-bezier(0.72, 0, 0.18, 1.01) infinite;
}

@keyframes dash{
    0% {stroke-dashoffset:400;stroke:gray;}
    40% {stroke-dashoffset: 0;stroke:green;}
    60% {stroke-dashoffset: 0;stroke:orange;}
    100% {stroke-dashoffset: -400;stroke:red;}
}

input[type="checkbox"] {
    vertical-align: middle;
}

/* analysis chart */
.chart-container {
    position: relative;
    justify-content: center;
    align-items: center;
}
#chart-analysis, #chart-movetime {
    display: none;
    width:100%;
    height:240px;
    background: linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,0) 20%, rgba(128,128,128,0.2) 50%, rgba(255,255,255,0) 80%, rgba(255,255,255,0) 100%);
}
.i-pgn .icon::before {
    padding-right: 4px;
}

/* Request analysis (analysis chart) */
div#request-analysis {
  display: flex;
  padding-top: 3vmin;
}
div#request-analysis, div#panel-1 {
    align-items: center;
    justify-content: center;
}
/* FEN & PGN */
div#panel-4 {
    font-size: 0.9em;
    flex-flow: column;
}
div.pgn-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}
div.pgnbuttons {
    display: flex;
}
button.analysis-add-to-study {
    border: 0;
    background: transparent;
    font: inherit;
    cursor: pointer;
}
div#pgntext {
    white-space: pre-wrap;
    font-family: monospace;
    user-select: all;
    -moz-user-select: all;
    -webkit-user-select: all;
}

/* PUZZLE */
.puzzle-info, .puzzle-user {
  background: var(--bg-color0);
  box-shadow: var(--base-shadow);
  margin-bottom: 16px;
  padding: 12px;
  font-size: 14px;
  border-radius: 3px;
}
div.config-toggle {
  display: flex;
  align-items: center;
}
.rated-toggle, .auto-next-toggle {
  display: flex;
  flex-flow: row nowrap;
  align-items: center;
}
.puzzle-user .rating {
  font-size: 3.5em;
}
.puzzle-user strong {
  justify-content: center;
  display: flex;
  flex-flow: row wrap;
  align-items: center;
}
.puzzle-user .rating.casual {
  font-size: .9em;
  margin-top: 1em;
}
.rp {
  font-size: 1.6rem;
  margin-left: 1ch;
}
.rp span::before {
  margin-right: .2em;
  opacity: 0.9;
}
.feedback {
    display: flex;
    flex-flow: column;
    flex: 1 0 9rem;
    background: var(--bg-meta);
    justify-content: center;
}
.feedback:not(.after) {
    padding: 2em;
}
.feedback .player {
    display: flex;
    align-items: center;
    justify-content: center;
}
.feedback .no-square {
    flex: 0 0 64px;
    height: 64px;
    margin-right: 10px;
    background-size: contain;
    background-repeat: no-repeat;
  }
.feedback .player .icon {
    width: 64px;
    height: 64px;
    font-size: 50px;
    line-height: 64px;
    text-align: center;
}
.feedback.fail .icon, san span.fail {
    color: var(--bad);
}
.feedback.good .icon {
    color: var(--good);
}
.instruction san {
    font-size: 1.5em;
}
.feedback .instruction strong {
    font-size: 1.5em;
}
.feedback .instruction > * {
    display: block;
}
.feedback .view-solution, .feedback .view-hint {
    margin-top: 1.5em;
    text-align: center;
    visibility: hidden;
    opacity: 0;
}
.feedback .view-solution.show, .feedback .view-hint.show {
    visibility: visible;
    opacity: 0.8;
    transition: opacity 1.5s;
}
.feedback.after {
    flex-flow: column;
    max-height: 50%;
}
.feedback .complete {
    display: flex;
    justify-content: center;
    font-size: 1.3em;
    white-space: nowrap;
    flex: 1 1 50%;
}
div.more {
    border-top: 1px solid var(--border-color);
    padding: 1em 2em;
    flex-flow: row wrap;
    text-align: center;
    justify-content: space-between;
}
.button.button-empty, .button.button-empty:hover {
    color: var(--link-hover);
}
.button.button-empty {
    text-transform: uppercase;
    transition: none;
    background: none;
    box-shadow: none;
    padding: 0.8em 1em;
}
.button.button-empty:not(.disabled):hover {
    box-shadow:0 2px 5px 0 rgba(0,0,0,0.225);
}
#btn-controls-top button {
  background: inherit;
}

.puzzle-meta .info2 span {
  padding-right: 1ch;
}
.puzzle_vote {
  display: flex;
  flex-flow: column;
  flex: 1 1 70%;
}
.puzzle_vote_help {
  display: block;
  margin: 0 1em;
}
.puzzle_vote_help p {
  display: inline;
}
.puzzle_vote_buttons {
  display: flex;
  flex-flow: row nowrap;
  opacity: .1;
  flex: 1 1 100%;
  align-items: stretch;
  text-align: center;
}
.puzzle_vote_buttons.enabled {
  opacity: 1;
  transition: opacity .5s;
}
.puzzle_vote .vote {
  display: flex;
  flex-flow: row wrap;
  align-items: center;
  justify-content: center;
  flex: 0 0 50%;
  cursor: pointer;
  color: #629924;
}
.feedback .icon.icon-thumbs-o-up {
  font-size: 4.5em;
}
.puzzle_vote .vote.vote-down {
  color: #c33;
}
.puzzle_vote .vote.vote-down::before {
  opacity: inherit;
  transform:rotate(0.5turn);
}
.puzzle_vote .vote:hover,
.puzzle_vote .vote.active {
  background:#629924;
  color:#fff
}
.puzzle_vote .vote.vote-down:hover,
.puzzle_vote .vote.vote-down.active {
  background:#c33
}

/* PGN comments flow with variations, and interrupt mainline move pairs. */
.analysis-app .tree-comment {
    display: inline;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    padding: 0 .25em;
    font-size: inherit;
    font-style: normal;
    line-height: 1.4;
    color: var(--font-color);
}
.analysis-app #movelist > interrupt > .tree-comment {
    display: block;
    padding: .25rem .5rem;
    background: var(--bg-color2);
}

/* Plain-language move explanations (xiangqi) */
.move-explain {
    padding: 0.6em 0.8em;
    border-top: 1px solid var(--border);
    font-size: 0.95em;
    line-height: 1.45;
}
.move-explain .explain-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5em;
    padding-bottom: 0.4em;
    border-bottom: 1px dashed rgba(128, 128, 128, 0.25);
}
.move-explain .explain-title {
    font-weight: 700;
}
.move-explain .explain-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.move-explain .explain-voice-btn {
    background: var(--bg-color-hover, rgba(128, 128, 128, 0.15));
    color: var(--font-color);
    border: 1px solid rgba(128, 128, 128, 0.3);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 0.82em;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    transition: all 0.15s ease-in-out;
}
.move-explain .explain-voice-btn:hover {
    background: rgba(128, 128, 128, 0.25);
}
.move-explain .explain-voice-btn.active {
    background: #2b78e4;
    color: #fff;
    border-color: #2b78e4;
}
.move-explain .explain-voice-btn.active:hover {
    background: #1c5ec2;
}
.move-explain .explain-reset-btn {
    background: #e04b4b;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 3px 9px;
    font-size: 0.85em;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background 0.15s ease-in-out;
}
.move-explain .explain-reset-btn:hover {
    background: #c53030;
}
.move-explain .explain-speak-btn {
    background: none;
    border: 1px solid rgba(128, 128, 128, 0.25);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    padding: 1px 6px;
    margin-left: 4px;
    color: var(--font-color);
    line-height: 1.2;
    transition: background 0.15s;
}
.move-explain .explain-speak-btn:hover {
    background: rgba(43, 120, 228, 0.15);
    border-color: #2b78e4;
}
.move-explain .explain-speak-all-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    margin: 6px 0 10px 0;
    transition: transform 0.12s, background 0.15s, box-shadow 0.15s;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}
.move-explain .explain-speak-all-btn:hover {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35);
}
.move-explain .explain-speak-all-btn:active {
    transform: translateY(0);
}
#move-controls button#reset-board:hover {
    color: #e04b4b;
}
.move-explain .explain-head {
    display: flex;
    gap: 0.5em;
    align-items: baseline;
}
.move-explain ul {
    margin: 0.2em 0 0.5em 1.1em;
    padding: 0;
}
.move-explain .explain-story {
    font-style: italic;
}
.explain-glyph.blunder,
.explain-glyph.allowed_mate {
    color: #df5353;
}
.explain-glyph.mistake,
.explain-glyph.missed_mate {
    color: #e69f00;
}
.explain-glyph.inaccuracy {
    color: #56b4e9;
}
.move-explain .explain-better {
    font-weight: 600;
}
.move-explain .explain-error {
    color: #c33;
}
.move-explain .explain-btn {
    margin-top: 0.4em;
}
.move-explain .explain-btn.btn-highlight {
    background: #2b78e4;
    color: #fff;
    font-weight: 600;
    padding: 7px 16px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    margin-top: 0.6em;
    font-size: 0.95em;
    transition: background 0.2s;
}
.move-explain .explain-btn.btn-highlight:hover {
    background: #1c5ec2;
}

.move-explain .explain-welcome {
    margin-top: 0.3em;
    background: rgba(43, 120, 228, 0.08);
    border-radius: 6px;
    padding: 8px 10px;
    border-left: 3px solid #2b78e4;
}
.move-explain .explain-welcome .explain-hint {
    font-weight: 600;
    margin-bottom: 0.3em;
    color: var(--font-color);
}
.move-explain .explain-guide {
    margin: 0.3em 0 0.2em 1.2em;
    padding: 0;
    font-size: 0.9em;
    line-height: 1.5;
}
.move-explain .explain-guide li {
    margin-bottom: 0.3em;
}

/* Coaching Cards for Xiangqi Master Pedagogy */
.move-explain .explain-card {
    margin-top: 0.5em;
    padding: 0.55em 0.75em;
    border-radius: 6px;
    font-size: 0.92em;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    gap: 0.25em;
}

.move-explain .explain-card .card-badge {
    align-self: flex-start;
    font-size: 0.78em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 1px 6px;
    border-radius: 4px;
}

.move-explain .explain-opening-card {
    background: rgba(234, 179, 8, 0.12);
    border-left: 3px solid #eab308;
}
.move-explain .explain-opening-card .card-badge {
    background: #eab308;
    color: #1e1e1e;
}
.move-explain .explain-opening-card .card-body {
    font-weight: 600;
    color: var(--font-color);
}

.move-explain .explain-intent-card {
    background: rgba(59, 130, 246, 0.1);
    border-left: 3px solid #3b82f6;
}
.move-explain .explain-intent-card .card-badge {
    background: #3b82f6;
    color: #fff;
}

.move-explain .explain-proverb-card {
    background: rgba(168, 85, 247, 0.1);
    border-left: 3px solid #a855f7;
    font-style: italic;
}
.move-explain .explain-proverb-card .card-badge {
    background: #a855f7;
    color: #fff;
    font-style: normal;
}
.move-explain .explain-proverb-card .proverb-text {
    color: #c084fc;
}
body:not(.dark) .move-explain .explain-proverb-card .proverb-text {
    color: #7e22ce;
}

.move-explain .explain-plan-card {
    background: rgba(16, 185, 129, 0.1);
    border-left: 3px solid #10b981;
}
.move-explain .explain-plan-card .card-badge {
    background: #10b981;
    color: #fff;
}

/* AI Play Bar in Analysis */
.ai-play-bar {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.6rem 0.8rem;
    margin: 0.4rem 0.5rem 0.5rem;
    background: rgba(0, 0, 0, 0.035);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 6px;
}

body.dark .ai-play-bar {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.1);
}

.ai-play-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-play-title {
    font-weight: 700;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--font-color);
}

.ai-play-toggle-btn {
    border: none;
    border-radius: 4px;
    padding: 0.25rem 0.65rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    background: #e0e0e0;
    color: #333;
    transition: all 0.15s ease;
}

body.dark .ai-play-toggle-btn {
    background: #333;
    color: #ddd;
}

.ai-play-toggle-btn.active {
    background: #d32f2f;
    color: #fff;
    box-shadow: 0 1px 4px rgba(211, 47, 47, 0.35);
}

.ai-play-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.ai-play-levels {
    display: inline-flex;
    gap: 2px;
    background: rgba(0, 0, 0, 0.05);
    padding: 2px;
    border-radius: 4px;
}

body.dark .ai-play-levels {
    background: rgba(255, 255, 255, 0.07);
}

.ai-level-btn {
    border: none;
    background: transparent;
    color: var(--font-color);
    padding: 0.2rem 0.5rem;
    font-size: 0.78rem;
    font-weight: 500;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ai-level-btn.active {
    background: var(--link-color-blue, #2d70b6);
    color: #fff;
    font-weight: 600;
}

.ai-level-btn[data-level="easy"].active {
    background: #388e3c;
}
.ai-level-btn[data-level="medium"].active {
    background: #1976d2;
}
.ai-level-btn[data-level="hard"].active {
    background: #d32f2f;
}

.ai-play-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ai-flip-btn {
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: transparent;
    color: var(--font-color);
    padding: 0.2rem 0.45rem;
    font-size: 0.78rem;
    border-radius: 3px;
    cursor: pointer;
}

body.dark .ai-flip-btn {
    border-color: rgba(255, 255, 255, 0.15);
}

.ai-play-status {
    font-size: 0.8rem;
    font-weight: 600;
    color: color-mix(in srgb, var(--font-color) 65%, transparent);
}

.ai-play-status.thinking {
    color: #e65100;
    animation: ai-pulse 1s infinite alternate;
}

.ai-play-status.human-turn {
    color: #2e7d32;
}

.ai-play-status.ai-turn {
    color: #d32f2f;
}

@keyframes ai-pulse {
    from { opacity: 0.6; }
    to { opacity: 1; }
}

/* Feature Tabs in Analysis Panel */
.analysis-feature-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 0.8rem;
    padding: 3px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 6px;
}
body.dark .analysis-feature-tabs {
    background: rgba(255, 255, 255, 0.06);
}
.feat-tab {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 10px;
    border: none;
    background: transparent;
    color: var(--font-color);
    font-size: 0.82rem;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.feat-tab:hover {
    background: rgba(128, 128, 128, 0.15);
}
.feat-tab.active {
    background: var(--link-color-blue, #2d70b6);
    color: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

/* Opening Explorer */
.opening-explorer {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.opening-explorer__header {
    background: rgba(128, 128, 128, 0.08);
    border: 1px solid rgba(128, 128, 128, 0.2);
    border-radius: 6px;
    padding: 0.75rem;
}
.opening-explorer__title-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 0.25rem;
}
.opening-icon {
    font-size: 1.2rem;
}
.opening-name {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #b71c1c;
}
body.dark .opening-name {
    color: #ef5350;
}
.opening-subname {
    display: inline-block;
    font-size: 0.8rem;
    color: color-mix(in srgb, var(--font-color) 70%, transparent);
    font-style: italic;
    margin-bottom: 0.4rem;
}
.opening-proverb {
    margin: 0 0 0.35rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #8d4f00;
    font-style: italic;
}
body.dark .opening-proverb {
    color: #ffb74d;
}
.opening-strategy {
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.4;
    color: var(--font-color);
}
.opening-table-wrap {
    overflow-x: auto;
    border: 1px solid rgba(128, 128, 128, 0.2);
    border-radius: 6px;
}
.opening-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.opening-table th {
    background: rgba(128, 128, 128, 0.12);
    padding: 6px 8px;
    text-align: left;
    font-weight: 600;
    border-bottom: 1px solid rgba(128, 128, 128, 0.2);
}
.opening-row {
    cursor: pointer;
    transition: background 0.15s ease;
    border-bottom: 1px solid rgba(128, 128, 128, 0.1);
}
.opening-row:hover {
    background: rgba(45, 112, 182, 0.15);
}
.opening-table td {
    padding: 6px 8px;
    vertical-align: middle;
}
.opening-san {
    color: #b71c1c;
    font-weight: 700;
    white-space: nowrap;
}
body.dark .opening-san {
    color: #ef5350;
}
.opening-varname {
    font-weight: 500;
}
.opening-games {
    color: color-mix(in srgb, var(--font-color) 65%, transparent);
    font-size: 0.78rem;
    white-space: nowrap;
}
.opening-rate-bar {
    display: flex;
    width: 90px;
    height: 14px;
    border-radius: 3px;
    overflow: hidden;
    background: #555;
}
.rate-w {
    background: #fff;
    height: 100%;
}
.rate-d {
    background: #888;
    height: 100%;
}
.rate-b {
    background: #222;
    height: 100%;
}
.eval-pill {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(128, 128, 128, 0.18);
    font-weight: 600;
    font-size: 0.78rem;
}
.opening-hint {
    margin: 0;
    font-size: 0.8rem;
    color: color-mix(in srgb, var(--font-color) 70%, transparent);
    font-style: italic;
}

/* Game Review */
.game-review {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.game-review__hero {
    text-align: center;
    padding: 1.5rem 1rem;
    background: linear-gradient(135deg, rgba(45, 112, 182, 0.12) 0%, rgba(183, 28, 28, 0.12) 100%);
    border: 1px solid rgba(128, 128, 128, 0.25);
    border-radius: 8px;
}
.game-review__icon-big {
    font-size: 2.2rem;
    margin-bottom: 0.5rem;
}
.game-review__title {
    margin: 0 0 0.4rem;
    font-size: 1.15rem;
    font-weight: 700;
}
.game-review__desc {
    margin: 0 auto 1.2rem;
    max-width: 380px;
    font-size: 0.85rem;
    line-height: 1.45;
    color: color-mix(in srgb, var(--font-color) 80%, transparent);
}
.game-review__start-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 18px;
    background: #b71c1c;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(183, 28, 28, 0.4);
    transition: transform 0.15s ease, background 0.15s ease;
}
.game-review__start-btn:hover {
    background: #c62828;
    transform: translateY(-1px);
}
.game-review__analyzing {
    text-align: center;
    padding: 1.5rem;
    background: rgba(128, 128, 128, 0.08);
    border-radius: 8px;
}
.game-review__spin-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 1rem;
}
.game-review__spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(45, 112, 182, 0.3);
    border-top-color: #2d70b6;
    border-radius: 50%;
    animation: gr-spin 0.8s linear infinite;
}
@keyframes gr-spin {
    to { transform: rotate(360deg); }
}
.game-review__progress-bar-bg {
    width: 100%;
    height: 10px;
    background: rgba(128, 128, 128, 0.2);
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}
.game-review__progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #2d70b6, #e53935);
    transition: width 0.3s ease;
}
.game-review__progress-text {
    margin: 0;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--font-color);
}

/* Dual Accuracy Grid */
.game-review__accuracy-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.accuracy-card {
    padding: 0.75rem;
    border-radius: 6px;
    border: 1px solid rgba(128, 128, 128, 0.25);
    background: rgba(128, 128, 128, 0.06);
}
.accuracy-red {
    border-left: 4px solid #e53935;
}
.accuracy-black {
    border-left: 4px solid #546e7a;
}
.accuracy-card__top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}
.side-label {
    font-size: 0.75rem;
    font-weight: 700;
}
.accuracy-score {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 800;
}
.accuracy-red .accuracy-score {
    color: #e53935;
}
.accuracy-black .accuracy-score {
    color: #546e7a;
}
body.dark .accuracy-black .accuracy-score {
    color: #90a4ae;
}
.accuracy-rank {
    display: block;
    font-size: 0.75rem;
    color: color-mix(in srgb, var(--font-color) 70%, transparent);
    font-weight: 500;
}

/* Breakdown Table */
.game-review__breakdown-section, .game-review__turning-points-section {
    border: 1px solid rgba(128, 128, 128, 0.2);
    border-radius: 6px;
    padding: 0.75rem;
    background: rgba(128, 128, 128, 0.04);
}
.section-title {
    margin: 0 0 0.6rem;
    font-size: 0.92rem;
    font-weight: 700;
}
.review-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.review-table th {
    padding: 4px 6px;
    border-bottom: 1px solid rgba(128, 128, 128, 0.2);
}
.col-red {
    text-align: left;
    color: #e53935;
    font-weight: 700;
}
.col-black {
    text-align: right;
    color: #546e7a;
    font-weight: 700;
}
body.dark .col-black {
    color: #90a4ae;
}
.col-cat {
    text-align: center;
}
.review-row td {
    padding: 5px 6px;
    border-bottom: 1px solid rgba(128, 128, 128, 0.08);
}
.count-red {
    font-weight: 700;
    color: #e53935;
    text-align: left;
}
.count-black {
    font-weight: 700;
    color: #546e7a;
    text-align: right;
}
body.dark .count-black {
    color: #90a4ae;
}
.category-name {
    text-align: center;
    font-weight: 600;
}
.cat-icon {
    margin-right: 4px;
}

/* Turning Point Cards */
.turning-points-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 260px;
    overflow-y: auto;
}
.turning-point-card {
    padding: 6px 8px;
    border-radius: 5px;
    background: rgba(128, 128, 128, 0.08);
    border-left: 3px solid #ffb300;
    cursor: pointer;
    transition: background 0.15s ease;
}
.turning-point-card:hover {
    background: rgba(128, 128, 128, 0.18);
}
.turning-point-card.tp-blunder {
    border-left-color: #d32f2f;
}
.turning-point-card.tp-mistake {
    border-left-color: #f57c00;
}
.tp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
    margin-bottom: 2px;
}
.tp-side-badge {
    display: flex;
    align-items: center;
    gap: 5px;
}
.tp-side-circle {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.tp-verdict-badge {
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.72rem;
    font-weight: 700;
}
.tp-verdict-badge.blunder {
    background: rgba(211, 47, 47, 0.2);
    color: #d32f2f;
}
.tp-verdict-badge.mistake {
    background: rgba(245, 124, 0, 0.2);
    color: #f57c00;
}
.tp-verdict-badge.inaccuracy {
    background: rgba(255, 179, 0, 0.2);
    color: #b28900;
}
.tp-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.76rem;
    color: color-mix(in srgb, var(--font-color) 75%, transparent);
    margin-bottom: 2px;
}
.tp-loss {
    color: #d32f2f;
    font-weight: 600;
}
.tp-jump-hint {
    font-style: italic;
    color: var(--link-color-blue, #2d70b6);
}
.tp-note {
    margin: 0;
    font-size: 0.78rem;
    line-height: 1.35;
}
.tp-empty {
    margin: 0;
    font-size: 0.82rem;
    color: color-mix(in srgb, var(--font-color) 70%, transparent);
    font-style: italic;
    text-align: center;
    padding: 0.75rem;
}
.game-review__footer-actions {
    text-align: center;
}
.game-review__rerun-btn {
    padding: 5px 12px;
    border-radius: 4px;
    border: 1px solid rgba(128, 128, 128, 0.3);
    background: transparent;
    color: var(--font-color);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}
.game-review__rerun-btn:hover {
    background: rgba(128, 128, 128, 0.15);
}

