:root {
  color-scheme: dark;
  --surface-0: #1f1e1c;
  --surface-1: #262522;
  --surface-2: #312e2b;
  --surface-3: #3b3936;
  --border: rgba(255,255,255,.08);
  --text: #f4f2ed;
  --muted: #a7a39a;
  --green: #81b64c;
  --green-deep: #5f8f35;
  --cream: #eeeed2;
  --board-green: #769656;
  --accent-blue: #5bb7d6;
  --stockfish-blue: #5f9fc2;
  --maia-red: #c96a63;
  --annotation-orange: #f0b95a;
  --danger: #e05a47;
  --warning: #e9a743;
  --shadow: 0 24px 70px rgba(0,0,0,.36);
  /* Classification indicators share these dimensions. The current .85 factor
     reduces the previously enlarged indicators by exactly 15%. */
  --classification-icon-scale: .85;
  --board-classification-size: clamp(calc(24px * var(--classification-icon-scale)), calc(var(--board-size) / 12 * var(--classification-icon-scale)), calc(56px * var(--classification-icon-scale)));
  --move-badge-size: clamp(calc(16px * var(--classification-icon-scale)), calc(var(--board-size) / 22 * var(--classification-icon-scale)), calc(26px * var(--classification-icon-scale)));
  --move-result-badge-size: clamp(calc(20px * var(--classification-icon-scale)), calc(var(--move-badge-size) * 1.25), calc(32px * var(--classification-icon-scale)));
  --classification-mark-size: clamp(calc(40px * var(--classification-icon-scale)), calc(var(--move-badge-size) * 2.5), calc(65px * var(--classification-icon-scale)));
  /* The game title/event block is hidden so the board can use that vertical space. */
  --board-size: min(calc(100dvh - 145px), 940px, calc(100vw - 700px));
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--surface-0); }
body { margin: 0; min-height: 100vh; color: var(--text); background: radial-gradient(circle at 42% 0, #393733 0, var(--surface-0) 43%); }
button, input, textarea { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 3px solid rgba(129,182,76,.65); outline-offset: 3px; }
[hidden] { display: none !important; }
select { font: inherit; color: var(--text); }
select:focus-visible { outline: 3px solid rgba(129,182,76,.65); outline-offset: 3px; }

.skip-link { position: fixed; left: 1rem; top: -4rem; z-index: 100; color: #111; background: #fff; padding: .65rem 1rem; border-radius: .4rem; }
.skip-link:focus { top: 1rem; }
.app-shell { min-height: 100vh; opacity: 1; transition: opacity .25s ease; }
.app-shell[aria-hidden="true"] { opacity: .25; filter: blur(8px); pointer-events: none; user-select: none; }

.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 10; display: flex; flex-direction: column; width: 176px; padding: 24px 16px; background: rgba(38,37,34,.96); border-right: 1px solid var(--border); }
.brand { display: flex; align-items: center; min-width: 0; }
.brand-logo { display: block; width: 100%; height: auto; object-fit: contain; }
.brand--sidebar { width: 100%; }
.side-nav { display: grid; width: 100%; gap: 8px; margin-top: 26px; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.1); }
.side-action { display: flex; align-items: center; gap: 11px; width: 100%; padding: 11px 10px; color: var(--muted); background: transparent; border: 0; border-radius: 9px; cursor: pointer; font-size: 14px; text-align: left; }
.side-action span:first-child { width: 20px; font-size: 19px; }
.side-action > .lucide-icon { width: 20px; height: 20px; stroke-width: 2.15; }
.side-action > .review-nav-mark { display: block; flex: 0 0 22px; width: 22px; height: 22px; object-fit: contain; }
.side-action--active > .review-nav-mark { filter: drop-shadow(0 0 4px rgba(91,183,214,.24)); }
.settings-nav-icon { display: block; flex: 0 0 auto; width: 20px; height: 20px; background-color: currentColor; -webkit-mask: url("../assets/icons/settings-white.png") center / contain no-repeat; mask: url("../assets/icons/settings-white.png") center / contain no-repeat; }
.side-action > .settings-nav-icon { width: 20px; height: 20px; }
.side-action:hover { color: var(--text); background: rgba(255,255,255,.05); }
.side-action--active { color: var(--text); background: rgba(129,182,76,.12); }
.sidebar-bottom { display: grid; width: 100%; gap: 10px; margin-top: auto; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.1); }
.maia-nav { min-height: 62px; padding: 9px; gap: 8px; color: #e9eddf; background: linear-gradient(145deg, rgba(181,205,137,.14), rgba(181,205,137,.055)); border: 1px solid rgba(181,205,137,.22); border-radius: 12px; }
.maia-nav:hover, .maia-nav.side-action--active { color: #f6f9ee; background: rgba(181,205,137,.2); border-color: rgba(181,205,137,.42); }
.side-action > .maia-nav__icon { display: grid; place-items: center; flex: 0 0 32px; width: 32px; height: 32px; color: #c8dea5; background: rgba(181,205,137,.15); border-radius: 8px; font-family: Georgia, serif; font-size: 25px; line-height: 1; }
.side-action > .stockfish-nav__icon { color: #c4d4ef; background: rgba(152,180,226,.15); font-size: 22px; }
.stockfish-nav { background: linear-gradient(145deg, rgba(152,180,226,.13), rgba(152,180,226,.045)); border-color: rgba(152,180,226,.2); }
.stockfish-nav:hover, .stockfish-nav.side-action--active { background: rgba(152,180,226,.19); border-color: rgba(152,180,226,.4); }
.maia-nav__copy { display: grid; min-width: 0; gap: 1px; }
.maia-nav__copy strong { color: inherit; font-size: 13px; font-weight: 700; line-height: 1.1; }
.maia-nav__copy small { color: #b6c3a7; font-size: 11px; line-height: 1.2; white-space: nowrap; }

.review-layout { display: grid; grid-template-columns: minmax(560px, 1fr) minmax(410px, 410px); gap: 16px; height: 100dvh; min-height: 0; margin-left: 176px; padding: 16px; overflow: auto; }
.board-column { display: flex; flex-direction: column; align-items: center; min-width: 0; min-height: 0; padding-bottom: 4px; }
.mobile-header { display: none; }
/* Keep the metadata available to the controller, but remove it from the visual layout. */
.game-meta { display: none; }
.eyebrow { margin: 0 0 4px; color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.game-meta h1 { margin: 0; font-size: clamp(18px, 1.8vw, 24px); line-height: 1.1; letter-spacing: -.025em; }
.game-meta-detail { margin: 0; color: var(--muted); font-size: 12px; text-align: right; }

.player-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto auto; align-items: center; gap: 8px; width: min(100%, var(--board-size)); padding: 9px 0; }
.player-avatar { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 9px; font-family: Georgia, serif; font-weight: 800; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.player-avatar--dark { color: #f0eee8; background: #3d3b38; }
.player-avatar--light { color: #2d2c29; background: #ddd9cd; }
.player-identity { min-width: 0; }
.player-identity > div { display: flex; align-items: baseline; gap: 7px; }
.player-identity strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.elo { color: var(--muted); font-size: 13px; }
.turn-label { color: #817e77; font-size: 10px; }
.player-row.is-active .turn-label { color: var(--green); }
.turn-label--opening { display: block; max-width: min(56vw, 460px); overflow: hidden; color: var(--green) !important; font-size: 11px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.player-row.is-active .player-avatar { box-shadow: 0 0 0 2px var(--green); }
.result-chip { display: grid; place-items: center; min-width: 28px; height: 28px; padding: 0 7px; color: #c7c4bd; background: rgba(255,255,255,.06); border-radius: 7px; font-size: 12px; font-weight: 700; }
.clock { min-width: 94px; padding: 8px 11px; color: #1f1e1c; background: #d6d4ca; border-radius: 7px; font-family: "SFMono-Regular", Consolas, monospace; font-size: 20px; font-weight: 800; letter-spacing: .03em; text-align: center; box-shadow: 0 3px 0 #9d9b94; }
.player-row.is-active .clock { background: #f1efe6; }

.board-stage { display: flex; align-items: stretch; gap: 7px; }
.board-wrap { position: relative; isolation: isolate; width: var(--board-size); height: var(--board-size); overflow: visible; border-radius: 5px; box-shadow: 0 14px 36px rgba(0,0,0,.34); }
.chessboard, .chessboard > div { width: 100%; height: 100%; background: var(--cream); }
.cm-chessboard .board { display: block; width: auto; height: auto; }
.cm-chessboard .piece { position: static; width: auto !important; height: auto !important; transition: none; transform-origin: 0 0 !important; backface-visibility: visible; }
.cm-chessboard .piece.dragging { width: auto !important; height: auto !important; }
.cm-chessboard.chesscom .board .square.white { fill: #ebecd0; }
.cm-chessboard.chesscom .board .square.black { fill: #779556; }
.cm-chessboard.chesscom.border-type-none .board .border { fill: #779556; stroke: #779556; stroke-width: 0; }
.cm-chessboard.chesscom .coordinates { pointer-events: none; user-select: none; }
.cm-chessboard.chesscom .coordinates .coordinate { font-size: 7px; font-weight: 800; }
.cm-chessboard.chesscom .coordinates .coordinate.white { fill: #779556; }
.cm-chessboard.chesscom .coordinates .coordinate.black { fill: #ebecd0; }
.cm-chessboard.chesscom .pieces .piece { filter: drop-shadow(0 1.5px 1px rgba(0,0,0,.24)); }
.cm-chessboard .markers .marker.marker-last-move { fill: var(--move-marker-color, #77746d); opacity: .27; }
.cm-chessboard .markers .marker.marker-last-move--brilliant { --move-marker-color: #3dd6d5; }
.cm-chessboard .markers .marker.marker-last-move--great,
.cm-chessboard .markers .marker.marker-last-move--best-move,
.cm-chessboard .markers .marker.marker-last-move--excellent { --move-marker-color: #1fc360; }
.cm-chessboard .markers .marker.marker-last-move--good { --move-marker-color: #87cb82; }
.cm-chessboard .markers .marker.marker-last-move--inaccuracy { --move-marker-color: #fcce2b; }
.cm-chessboard .markers .marker.marker-last-move--mistake { --move-marker-color: #f64441; }
.cm-chessboard .markers .marker.marker-last-move--blunder,
.cm-chessboard .markers .marker.marker-last-move--missed-win { --move-marker-color: #cd2b2e; }
.cm-chessboard .markers .marker.marker-last-move--book { --move-marker-color: #a3795e; opacity: .34; }
.cm-chessboard .markers .marker.marker-last-move--neutral { --move-marker-color: #77746d; }
.cm-chessboard .markers .marker.marker-last-move--explore { --move-marker-color: var(--stockfish-blue); opacity: .30; }
.cm-chessboard .arrows { pointer-events: none; }
/* Analysis arrows use cm-chessboard's own geometry. offsetTo leaves room for
   the head so its tip stops just short of the destination-square centre. */
.cm-chessboard .arrow-analysis-player { opacity: .62; }
.cm-chessboard .arrow-analysis-player .arrow-head,
.cm-chessboard .arrow-analysis-player .arrow-line { opacity: 1; }
.cm-chessboard .arrow-analysis-player .arrow-head { fill: #f4f2ed; }
.cm-chessboard .arrow-analysis-player .arrow-line { stroke: #f4f2ed; stroke-linecap: round; }
.cm-chessboard .arrow-analysis-stockfish { opacity: .74; }
.cm-chessboard .arrow-analysis-stockfish .arrow-head,
.cm-chessboard .arrow-analysis-stockfish .arrow-line { opacity: 1; }
.cm-chessboard .arrow-analysis-stockfish .arrow-head { fill: var(--stockfish-blue); }
.cm-chessboard .arrow-analysis-stockfish .arrow-line { stroke: var(--stockfish-blue); stroke-linecap: round; }
.cm-chessboard .arrow-analysis-maia { opacity: .73; }
.cm-chessboard .arrow-analysis-maia .arrow-head,
.cm-chessboard .arrow-analysis-maia .arrow-line { opacity: 1; }
.cm-chessboard .arrow-analysis-maia .arrow-head { fill: var(--maia-red); }
.cm-chessboard .arrow-analysis-maia .arrow-line { stroke: var(--maia-red); stroke-linecap: round; }
.cm-chessboard .arrow-analysis-attack { opacity: .78; }
.cm-chessboard .arrow-analysis-attack .arrow-head,
.cm-chessboard .arrow-analysis-attack .arrow-line { opacity: 1; }
.cm-chessboard .arrow-analysis-attack .arrow-head { fill: #e9a743; }
.cm-chessboard .arrow-analysis-attack .arrow-line { stroke: #e9a743; stroke-linecap: round; }
.cm-chessboard .arrow-analysis-defense { opacity: .78; }
.cm-chessboard .arrow-analysis-defense .arrow-head,
.cm-chessboard .arrow-analysis-defense .arrow-line { opacity: 1; }
.cm-chessboard .arrow-analysis-defense .arrow-head { fill: #78c6a3; }
.cm-chessboard .arrow-analysis-defense .arrow-line { stroke: #78c6a3; stroke-linecap: round; }
/* The default right-click annotation is the chess.com-style orange arrow. */
.cm-chessboard .arrow-success { opacity: .80; }
.cm-chessboard .arrow-success .arrow-head,
.cm-chessboard .arrow-success .arrow-line { opacity: 1; }
.cm-chessboard .arrow-success .arrow-head { fill: var(--annotation-orange); }
.cm-chessboard .arrow-success .arrow-line { stroke: var(--annotation-orange); stroke-linecap: round; }
.cm-chessboard .markers .marker.marker-circle-success { stroke: var(--annotation-orange); }
.cm-chessboard .markers .marker.marker-circle-success-filled { stroke: var(--annotation-orange); fill: var(--annotation-orange); }
.cm-chessboard .arrows .arrow-line { filter: none; stroke-linecap: butt; }
.lucide-icon { width: 1em; height: 1em; flex: 0 0 auto; display: inline-block; vertical-align: middle; }
.classification-icon { display: block; width: 100%; height: 100%; max-width: none; max-height: none; object-fit: contain; user-select: none; }
.classification-icon--pending { visibility: hidden; }
.board-classification .lucide-icon { width: 58%; height: 58%; stroke-width: 2.4; }
.board-classification .classification-icon { width: 100%; height: 100%; }
.board-outcomes { position: absolute; z-index: 8; inset: 0; pointer-events: none; }
.board-classification { position: absolute; z-index: 8; display: grid; place-items: center; width: var(--board-classification-size); height: var(--board-classification-size); transform: translate(-50%, -50%); border: 2px solid rgba(255,255,255,.92); border-radius: 50%; color: white; font-size: clamp(11px, calc(var(--board-classification-size) / 2.2), 24px); font-weight: 950; line-height: 1; box-shadow: 0 2px 7px rgba(0,0,0,.5); pointer-events: auto; }
.board-classification::after { content: attr(data-label); position: absolute; top: calc(100% + 7px); right: -2px; width: max-content; max-width: 130px; padding: 5px 7px; color: #fff; background: #242321; border: 1px solid rgba(255,255,255,.14); border-radius: 5px; font-size: 10px; font-weight: 750; opacity: 0; transform: translateY(-3px); transition: .14s ease; pointer-events: none; }
.board-classification:hover::after { opacity: 1; transform: none; }
.board-outcome--checkmate { left: var(--outcome-target-left, auto); top: var(--outcome-target-top, auto); transform: translate(-100%, 0); }
.board-outcome--checkmate .classification-icon { transform: rotate(90deg); transform-origin: 50% 50%; backface-visibility: hidden; filter: drop-shadow(0 3px 3px rgba(0,0,0,.24)); }
.board-outcome--checkmate.board-outcome--animate { animation: checkmate-badge-arrive 1050ms both; }
.board-outcome--checkmate.board-outcome--animate .classification-icon { animation: checkmate-tumble 900ms both; }
@keyframes checkmate-badge-arrive {
  0% {
    left: var(--outcome-center-left);
    top: var(--outcome-center-top);
    width: calc(var(--board-size) / 8 * .93);
    height: calc(var(--board-size) / 8 * .93);
    transform: translate(-50%, -50%) scale(.82);
    opacity: .12;
  }
  14% {
    left: var(--outcome-center-left);
    top: var(--outcome-center-top);
    transform: translate(-50%, -50%) scale(1.04);
    opacity: 1;
  }
  38% {
    left: var(--outcome-center-left);
    top: var(--outcome-center-top);
    transform: translate(-50%, -50%) scale(1);
  }
  73% {
    left: var(--outcome-target-left);
    top: var(--outcome-target-top);
    width: calc(var(--board-classification-size) * 1.08);
    height: calc(var(--board-classification-size) * 1.08);
    transform: translate(-100%, 0) scale(1.08);
  }
  87% {
    left: var(--outcome-target-left);
    top: var(--outcome-target-top);
    transform: translate(-100%, 0) scale(.95);
  }
  100% {
    left: var(--outcome-target-left);
    top: var(--outcome-target-top);
    width: var(--board-classification-size);
    height: var(--board-classification-size);
    transform: translate(-100%, 0) scale(1);
    opacity: 1;
  }
}
@keyframes checkmate-tumble {
  0% { transform: translateY(0) rotate(0deg) scale(1); filter: drop-shadow(0 2px 2px rgba(0,0,0,.22)); }
  16% { transform: translateY(-4px) rotate(-8deg) scale(1.04); filter: drop-shadow(0 7px 5px rgba(0,0,0,.30)); }
  39% { transform: translateY(-2px) rotate(37deg) scale(1.08); filter: drop-shadow(0 8px 6px rgba(0,0,0,.32)); }
  68% { transform: translateY(1px) rotate(99deg) scale(.98); filter: drop-shadow(0 2px 3px rgba(0,0,0,.23)); }
  84% { transform: translateY(0) rotate(87deg) scale(1.015); }
  100% { transform: translateY(0) rotate(90deg) scale(1); filter: drop-shadow(0 3px 3px rgba(0,0,0,.24)); }
}
@media (prefers-reduced-motion: reduce) {
  .board-outcome--checkmate.board-outcome--animate .classification-icon { animation: none; transform: rotate(90deg); }
}
.board-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 10px; color: rgba(255,255,255,.85); background: rgba(38,37,34,.72); backdrop-filter: blur(5px); }
.spinner { width: 22px; height: 22px; border: 3px solid rgba(255,255,255,.2); border-top-color: var(--green); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(1turn); } }

.eval-bar { position: relative; width: 32px; overflow: hidden; color: #1e1d1b; background: #191816; border-radius: 5px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.07); }
.eval-fill { position: absolute; right: 0; bottom: 0; left: 0; height: 50%; background: linear-gradient(180deg, #83c4e0, var(--stockfish-blue)); transition: height .35s cubic-bezier(.2,.8,.2,1); }
.eval-bar.is-flipped .eval-fill { top: 0; bottom: auto; }
.eval-score { position: absolute; z-index: 1; left: 50%; bottom: 7px; transform: translateX(-50%); font-size: 10px; font-variant-numeric: tabular-nums; font-weight: 900; line-height: 1; text-align: center; white-space: nowrap; }
.eval-bar.is-score-top .eval-score { top: 7px; bottom: auto; }
.eval-bar.is-black-favored .eval-score { color: #f1f0eb; }
.maia-bar.is-black-favored .eval-score { top: 7px; bottom: auto; }
.eval-bar.is-loading::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 30%, rgba(129,182,76,.16) 50%, transparent 70%); animation: scan 1.4s ease-in-out infinite; }
.maia-bar { color: #fff2ef; background: #321d1c; }
.maia-fill { background: linear-gradient(180deg, #e18b83, var(--maia-red)); }
.maia-score { color: white !important; text-shadow: 0 1px 2px rgba(0,0,0,.65); }
.engine-tag { position: absolute; z-index: 2; top: 6px; left: 50%; transform: translateX(-50%); color: rgba(255,255,255,.8); font-size: 9px; font-weight: 900; }
.maia-bar.is-flipped .engine-tag { top: auto; bottom: 6px; }
@keyframes scan { from { transform: translateY(-100%); } to { transform: translateY(100%); } }

.board-toolbar { position: sticky; bottom: 10px; z-index: 25; display: grid; grid-template-columns: 48px 48px minmax(86px,1fr) 48px 48px auto 48px; align-items: center; gap: 7px; width: min(100%, var(--board-size)); margin-top: 11px; padding: 5px; background: rgba(31,30,28,.94); border: 1px solid rgba(255,255,255,.10); border-radius: 13px; box-shadow: 0 8px 26px rgba(0,0,0,.38); backdrop-filter: blur(8px); }
.board-toolbar--panel { position: static; flex: 0 0 auto; width: auto; margin: 0 16px 14px; padding: 0; background: transparent; border: 0; box-shadow: none; backdrop-filter: none; }
.nav-button, .icon-button { display: grid; place-items: center; height: 44px; color: #dedbd4; background: linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.045)); border: 1px solid rgba(255,255,255,.13); border-radius: 10px; cursor: pointer; line-height: 1; box-shadow: 0 2px 0 rgba(0,0,0,.22); transition: background .16s ease, color .16s ease, transform .16s ease, border-color .16s ease; }
.nav-button .lucide-icon { width: 21px; height: 21px; stroke-width: 2.25; }
.nav-button:hover:not(:disabled), .icon-button:hover { color: white; background: linear-gradient(180deg, rgba(129,182,76,.28), rgba(129,182,76,.11)); border-color: rgba(129,182,76,.55); transform: translateY(-1px); }
.nav-button:active:not(:disabled) { transform: translateY(1px); }
.nav-button:disabled { opacity: .32; cursor: default; box-shadow: none; }
.nav-button--jump { color: #f0eee8; }
.nav-button--flip { color: #9fc979; }
.ply-indicator { min-width: 0; overflow: hidden; color: #d0cdc5; font-size: 12px; font-weight: 700; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.toolbar-divider { width: 1px; height: 24px; margin: 0 3px; background: var(--border); }
.arrow-legend, .exploration-panel { display: none !important; }
.arrow-legend span { display: inline-flex; align-items: center; gap: 5px; }
.arrow-key { display: inline-block; width: 18px; height: 3px; border-radius: 999px; box-shadow: 0 0 0 1px rgba(0,0,0,.3); }
.arrow-key--player { background: #f4f2ed; }
.arrow-key--stockfish { background: var(--stockfish-blue); }
.arrow-key--maia { background: var(--maia-red); }
.arrow-legend b { color: #b4d5e5; font-weight: 800; }

.exploration-panel { display: flex; align-items: center; justify-content: space-between; gap: 14px; width: min(100%, var(--board-size)); margin-top: 9px; padding: 10px 12px; background: rgba(48,47,44,.96); border: 1px solid rgba(95,159,194,.42); border-radius: 11px; box-shadow: 0 8px 22px rgba(0,0,0,.22); }
.exploration-copy { display: grid; min-width: 0; gap: 2px; }
.exploration-copy strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.exploration-actions { display: flex; flex: 0 0 auto; gap: 7px; }
.exploration-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 34px; padding: 0 10px; color: #dcecf4; background: rgba(95,159,194,.13); border: 1px solid rgba(95,159,194,.35); border-radius: 8px; cursor: pointer; font-size: 10px; font-weight: 800; }
.exploration-button:hover:not(:disabled) { background: rgba(95,159,194,.24); border-color: rgba(131,196,224,.65); }
.exploration-button:disabled { opacity: .38; cursor: default; }
.exploration-button .lucide-icon { width: 15px; height: 15px; }
.exploration-button--exit { color: #dedbd4; background: rgba(255,255,255,.045); border-color: rgba(255,255,255,.12); }

.review-panel { display: flex; flex-direction: column; min-height: 0; overflow: hidden; background: rgba(38,37,34,.96); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 14px 40px rgba(0,0,0,.2); }
.card { margin: 16px 16px 8px; padding: 14px; background: #302f2c; border: 1px solid var(--border); border-radius: 10px; }
.progress-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.progress-heading strong { font-size: 13px; }
.progress-percent { color: var(--green); font-size: 15px; font-weight: 800; }
.engine-loaders { display: grid; margin-top: 12px; }
.engine-loaders[hidden] { display: none; }
.engine-loader { display: grid; gap: 8px; color: var(--muted); }
.engine-loader > strong { color: #f3f1ec; font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.engine-loader__track { height: 7px; overflow: hidden; background: #1d1c1a; border-radius: 999px; }
.engine-loader__track i { display: block; width: 42%; height: 100%; background: linear-gradient(90deg, transparent, #a1cf69, transparent); border-radius: inherit; animation: engine-loader-sweep 1.15s ease-in-out infinite; }
.engine-loader.is-ready .engine-loader__track i { width: 100%; background: var(--green); animation: none; }
.engine-loader.is-failed .engine-loader__track i { width: 100%; background: var(--danger); animation: none; }
.engine-loader.is-failed > strong { color: #e49a90; }
@keyframes engine-loader-sweep { from { transform: translateX(-110%); } to { transform: translateX(240%); } }
.progress-track { height: 6px; margin-top: 10px; overflow: hidden; background: #1d1c1a; border-radius: 999px; }
.analysis-progress.is-engine-loading > .progress-track { display: none; }
.progress-track span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--green-deep), #a1cf69); border-radius: inherit; transition: width .35s ease; }
.progress-copy { margin: 8px 0 0; color: var(--muted); font-size: 10px; }
.analysis-progress.is-complete { border-color: rgba(129,182,76,.35); }
.analysis-progress.is-error { border-color: rgba(224,90,71,.5); }
.analysis-progress.is-error .progress-percent, .analysis-progress.is-error .eyebrow { color: var(--danger); }

.evaluation-graph { flex: 0 0 auto; margin: 0 16px 10px; padding: 10px; background: #302f2c; border: 1px solid var(--border); border-radius: 10px; }
.evaluation-graph__plot { position: relative; height: 82px; }
.evaluation-graph__plot svg { display: block; width: 100%; height: 100%; overflow: visible; background: #302f2c; border-radius: 5px; }
.evaluation-graph__grid-line { stroke: rgba(255,255,255,.14); stroke-width: .35; stroke-dasharray: 1.5 2; }
.evaluation-graph__zero-line { stroke: rgba(255,255,255,.48); stroke-width: .6; }
.evaluation-graph__area { fill: #ffffff; pointer-events: none; }
.evaluation-graph__line { fill: none; stroke: #69665f; stroke-width: 1.35; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.evaluation-graph__cursor { stroke: #ffffff; stroke-width: 1.35; vector-effect: non-scaling-stroke; filter: drop-shadow(0 0 1.5px #1f1e1c); pointer-events: none; }
.evaluation-graph__blunders { position: absolute; z-index: 2; inset: 0; pointer-events: none; }
.evaluation-graph__blunder-dot { position: absolute; width: 8px; height: 8px; transform: translate(-50%, -50%); border-radius: 50%; background: #e85b50; }
.evaluation-graph__tooltip { position: absolute; top: 3px; z-index: 3; min-width: 28px; padding: 3px 5px; color: #1f1e1c; background: #ffffff; border: 1px solid rgba(31,30,28,.25); border-radius: 4px; box-shadow: 0 3px 8px rgba(0,0,0,.28); font-size: 10px; font-weight: 900; line-height: 1; text-align: center; transform: translateX(-50%); pointer-events: none; }

.tabs { display: grid; grid-template-columns: repeat(3,1fr); padding: 0 16px; border-bottom: 1px solid var(--border); }
.tab { position: relative; padding: 14px 4px 12px; color: var(--muted); background: transparent; border: 0; cursor: pointer; font-size: 12px; font-weight: 700; }
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); }
.tab.is-active::after { content: ""; position: absolute; right: 12px; bottom: -1px; left: 12px; height: 2px; background: var(--green); border-radius: 2px 2px 0 0; }
.tab-panel { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 16px 18px; scrollbar-width: thin; scrollbar-color: #4b4945 transparent; }
.moves-panel { flex: 1; }
.opening-card { display: flex; align-items: center; gap: 10px; padding: 10px; margin-bottom: 12px; background: rgba(255,255,255,.035); border-radius: 8px; }
.opening-icon { display: grid; place-items: center; width: 30px; height: 30px; color: #1d2414; background: #94bd64; border-radius: 6px; font-size: 20px; }
.opening-card div { display: grid; }
.opening-card span:not(.opening-icon) { color: var(--muted); font-size: 9px; }
.opening-card strong { margin-top: 2px; font-size: 11px; }
.move-list { display: grid; }
.move-row { display: grid; grid-template-columns: 34px 1fr 1fr; min-height: 38px; border-radius: 6px; }
.move-row:nth-child(odd) { background: rgba(255,255,255,.024); }
.move-number { padding: 10px 4px 8px 9px; color: #77746d; font-size: 11px; }
.move-button { display: flex; align-items: center; gap: 6px; min-width: 0; padding: 5px 8px; background: transparent; border: 0; border-radius: 6px; cursor: pointer; text-align: left; }
.move-button:hover { background: rgba(255,255,255,.07); }
.move-button.is-deepening { min-height: 48px; flex-wrap: wrap; align-content: center; gap: 2px 6px; }
.move-button.is-pending { color: #77746d; }
.move-button.is-pending::after { content: ""; width: 5px; height: 5px; margin-left: auto; background: #706d66; border-radius: 50%; }
.move-button.is-selected { color: #18200f; background: #9ac66a; font-weight: 800; }
.move-san { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.move-depth-info { flex: 0 1 auto; max-width: 76px; margin-left: auto; overflow: hidden; color: var(--muted); font-size: 8px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.move-button.is-deepening .move-depth-info { flex: 0 0 100%; max-width: 100%; margin-left: 0; }
.move-button.is-selected .move-depth-info { color: #354327; }
.move-badge { display: grid; flex: 0 0 auto; place-items: center; width: var(--move-badge-size); height: var(--move-badge-size); border-radius: 50%; color: white; font-size: clamp(9px, calc(var(--move-badge-size) * .5), 13px); font-weight: 900; }
.move-badge .lucide-icon { width: 65%; height: 65%; stroke-width: 2.8; }
.move-badge .classification-icon { width: 100%; height: 100%; }
.move-result-badge { width: var(--move-result-badge-size); height: var(--move-result-badge-size); }
.move-result-slot { display: grid; place-items: center; min-width: 0; }
.move-list-empty { padding: 30px 10px; color: var(--muted); font-size: 12px; text-align: center; }

.selected-move-card { display: flex; align-items: center; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.selected-move-card h2 { margin: 0; font-size: 18px; letter-spacing: -.02em; }
.classification-mark { display: grid; flex: 0 0 auto; place-items: center; width: var(--classification-mark-size); height: var(--classification-mark-size); border-radius: 50%; color: white; background: #777; font-size: clamp(18px, calc(var(--classification-mark-size) * .44), 29px); font-weight: 900; }
.classification-mark .lucide-icon { width: 56%; height: 56%; stroke-width: 2.35; }
.classification-mark .classification-icon { width: 100%; height: 100%; }
.move-explanation { min-height: 92px; margin: 16px 0; color: #c4c1ba; font-size: 13px; line-height: 1.65; }
.move-metrics { display: grid; gap: 1px; overflow: hidden; margin: 0 0 18px; background: var(--border); border: 1px solid var(--border); border-radius: 8px; }
.move-metrics div { display: flex; align-items: center; justify-content: space-between; padding: 11px; background: #2c2b28; }
.move-metrics dt { color: var(--muted); font-size: 11px; }
.move-metrics dd { margin: 0; font-size: 12px; font-weight: 800; }
.primary-button { min-height: 47px; padding: 0 18px; color: #15200d; background: linear-gradient(180deg, #9dcb68, var(--green)); border: 0; border-radius: 9px; box-shadow: 0 4px 0 #567f31; cursor: pointer; font-weight: 800; }
.primary-button:hover:not(:disabled) { filter: brightness(1.06); transform: translateY(-1px); }
.primary-button:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 #567f31; }
.primary-button:disabled { opacity: .48; cursor: not-allowed; }
.full-width { width: 100%; }

.stats-skeleton { display: grid; gap: 14px; padding: 10px 0; }
.skeleton-line, .skeleton-grid span { height: 14px; background: linear-gradient(90deg, #343330 20%, #41403c 50%, #343330 80%); background-size: 300% 100%; border-radius: 5px; animation: shimmer 1.5s infinite; }
.skeleton-line { width: 60%; }
.skeleton-line.wide { width: 100%; }
.skeleton-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.skeleton-grid span { height: 64px; }
@keyframes shimmer { to { background-position: -150% 0; } }
.stats-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 5px 0 12px; color: var(--muted); font-size: 9px; text-align: center; }
.stats-head > div { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 11px; }
.stats-head > div:last-child { justify-content: flex-end; }
.color-dot { width: 8px; height: 8px; border: 1px solid #aaa; border-radius: 50%; }
.color-dot--white { background: #eee; }
.color-dot--black { background: #333; }
.headline-stats { display: grid; gap: 8px; }
.metric-row { display: grid; grid-template-columns: 1fr 1.35fr 1fr; align-items: center; gap: 10px; padding: 15px 12px; background: rgba(255,255,255,.035); border-radius: 10px; text-align: center; }
.metric-row strong { font-size: 22px; }
.metric-row span { color: var(--muted); font-size: 11px; line-height: 1.3; }
.stats-panel h3 { margin: 24px 0 12px; color: var(--muted); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.classification-stats { display: grid; gap: 8px; }
.classification-row { display: grid; grid-template-columns: 1fr 2fr 1fr; align-items: center; gap: 10px; font-size: 16px; text-align: center; }
.classification-label { display: flex; align-items: center; gap: 9px; padding: 10px 12px; background: rgba(255,255,255,.035); border-radius: 8px; text-align: left; }
.classification-label .move-badge { width: var(--move-badge-size); height: var(--move-badge-size); }

.classification--brilliant, [data-classification="brilliant"] { background-color: #1baca6; }
.classification--great, [data-classification="great"] { background-color: #5c9fc6; }
.classification--best-move, [data-classification="best-move"] { background-color: #81b64c; }
.classification--excellent, [data-classification="excellent"] { background-color: var(--green); }
.classification--good, [data-classification="good"] { background-color: #96a56a; }
.classification--inaccuracy, [data-classification="inaccuracy"] { background-color: #f0c15b; color: #28251f; }
.classification--mistake, [data-classification="mistake"] { background-color: #e6912c; }
.classification--blunder, [data-classification="blunder"] { background-color: #ca4b45; }
.classification--book, [data-classification="book"] { background-color: #a98769; }
.classification--neutral { background: #5b5954; }
.board-classification.has-asset,
.move-badge.has-asset,
.classification-mark.has-asset { background: transparent; border: 0; border-radius: 0; box-shadow: none; }

.upload-overlay { position: fixed; z-index: 50; isolation: isolate; inset: 0; display: grid; place-items: center; overflow-y: auto; padding: 24px; background: radial-gradient(circle at 50% 0, rgba(70,68,62,.75), rgba(20,20,18,.94) 58%); backdrop-filter: blur(10px); }
.upload-overlay::before { content: ""; position: absolute; z-index: 0; inset: 0; background-image: linear-gradient(rgba(220,225,217,.14) 1px, transparent 1px), linear-gradient(90deg, rgba(220,225,217,.14) 1px, transparent 1px); background-size: 104px 104px; background-position: center; -webkit-mask-image: radial-gradient(ellipse 54% 54% at 50% 48%, #000 14%, rgba(0,0,0,.56) 52%, rgba(0,0,0,.12) 78%, transparent 96%); mask-image: radial-gradient(ellipse 54% 54% at 50% 48%, #000 14%, rgba(0,0,0,.56) 52%, rgba(0,0,0,.12) 78%, transparent 96%); pointer-events: none; }
.upload-card { position: relative; z-index: 1; isolation: isolate; width: min(100%, 560px); padding: 28px 32px 26px; background: rgba(45,43,40,.98); border: 1px solid rgba(255,255,255,.1); border-radius: 18px; box-shadow: var(--shadow); }
.upload-card::before { content: ""; position: absolute; z-index: 0; top: 4px; right: 7px; width: min(48%, 268px); aspect-ratio: 1; background: url("../assets/icons/stockfish-logo.png") center / contain no-repeat; opacity: .24; transform: rotate(-8deg); filter: drop-shadow(0 0 1.5px rgba(177,255,108,.95)) drop-shadow(0 0 8px rgba(116,237,112,.72)) drop-shadow(0 0 22px rgba(54,196,127,.48)); pointer-events: none; }
.upload-card > :not(.upload-close) { position: relative; z-index: 1; }
.settings-overlay { position: fixed; z-index: 55; inset: 0; display: grid; place-items: center; overflow: hidden; padding: 24px; background: rgba(12,13,11,.82); backdrop-filter: blur(14px); }
.settings-card { display: grid; grid-template-rows: auto minmax(0, 1fr); width: min(100%, 940px); max-height: min(900px, calc(100dvh - 48px)); overflow: hidden; background: #292824; border: 1px solid rgba(255,255,255,.12); border-radius: 24px; box-shadow: 0 32px 100px rgba(0,0,0,.56); }
.settings-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 24px 28px 22px; background: linear-gradient(110deg, rgba(129,182,76,.09), transparent 42%); border-bottom: 1px solid rgba(255,255,255,.075); }
.settings-heading { display: flex; align-items: center; gap: 16px; min-width: 0; }
.settings-heading__icon { display: grid; flex: 0 0 auto; place-items: center; width: 48px; height: 48px; background: rgba(129,182,76,.14); border: 1px solid rgba(147,201,91,.22); border-radius: 14px; }
.settings-heading__icon img { display: block; width: 26px; height: 26px; object-fit: contain; }
.settings-header .eyebrow { margin-bottom: 3px; font-size: 11px; letter-spacing: .15em; }
.settings-card h2 { margin: 0; font-size: 32px; line-height: 1.05; letter-spacing: -.04em; }
.settings-copy { margin: 5px 0 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.settings-close { display: grid; flex: 0 0 auto; place-items: center; width: 38px; height: 38px; color: #b8b4ab; background: rgba(255,255,255,.045); border: 1px solid rgba(255,255,255,.09); border-radius: 11px; cursor: pointer; transition: color .16s ease, background .16s ease, transform .16s ease; }
.settings-close:hover { color: white; background: rgba(255,255,255,.09); transform: translateY(-1px); }
.settings-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 2; }
.settings-content { display: grid; gap: 14px; min-height: 0; overflow-y: auto; padding: 20px 28px 26px; scrollbar-color: #555149 transparent; scrollbar-width: thin; }
.settings-section { min-width: 0; padding: 18px; background: rgba(255,255,255,.026); border: 1px solid rgba(255,255,255,.075); border-radius: 15px; }
.settings-section--arrows { padding-bottom: 16px; }
.settings-section__header { display: flex; align-items: center; gap: 11px; margin-bottom: 16px; }
.settings-section__icon { display: grid; flex: 0 0 auto; place-items: center; width: 32px; height: 32px; color: #9dce64; background: rgba(129,182,76,.1); border-radius: 9px; }
.settings-section__icon svg, .settings-data__icon svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.settings-section__header h3, .settings-data h3 { margin: 0; font-size: 17px; letter-spacing: -.01em; }
.settings-section__header p, .settings-data p { margin: 3px 0 0; color: #aaa69e; font-size: 12px; line-height: 1.45; }
.settings-arrow-grid { display: grid; grid-template-columns: minmax(0, .88fr) minmax(0, 1.12fr); gap: 24px; }
.settings-group { min-width: 0; margin: 0; padding: 0; border: 0; }
.settings-group legend { width: 100%; margin-bottom: 9px; color: #c0bcb4; font-size: 12px; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.settings-group--visibility { display: grid; align-content: start; gap: 0; }
.settings-group--visibility legend { margin-bottom: 0; }
.settings-option__copy { display: grid; min-width: 0; gap: 3px; }
.settings-option__copy strong { color: #efede7; font-size: 14px; font-weight: 720; line-height: 1.35; }
.settings-option__copy small { color: #aaa69e; font-size: 12px; line-height: 1.4; }
.settings-switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-width: 0; padding: 11px 1px; cursor: pointer; }
.settings-switch-row + .settings-switch-row { border-top: 1px solid rgba(255,255,255,.055); }
.settings-switch { position: relative; flex: 0 0 auto; width: 34px; height: 20px; margin: 0; appearance: none; background: #45433e; border: 1px solid rgba(255,255,255,.13); border-radius: 999px; cursor: pointer; transition: background .18s ease, border-color .18s ease; }
.settings-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; background: #aaa79f; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,.35); transition: transform .18s ease, background .18s ease; }
.settings-switch:checked { background: var(--green); border-color: #91c65a; }
.settings-switch:checked::after { background: white; transform: translateX(14px); }
.settings-color-dot { display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255,255,255,.07); }
.settings-color-dot--player { background: #f4f2ed; }
.settings-color-dot--stockfish { background: var(--stockfish-blue); }
.settings-color-dot--maia { background: var(--maia-red); }
.settings-choice-list { display: grid; gap: 8px; }
.settings-choice { position: relative; display: grid; grid-template-columns: 17px minmax(0, 1fr); align-items: start; gap: 10px; min-width: 0; padding: 12px 13px; background: #33312d; border: 1px solid rgba(255,255,255,.075); border-radius: 10px; cursor: pointer; transition: background .16s ease, border-color .16s ease, transform .16s ease; }
.settings-choice:hover { background: #393732; transform: translateY(-1px); }
.settings-choice:has(input:checked) { background: rgba(129,182,76,.085); border-color: rgba(137,190,82,.48); }
.settings-choice > input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.settings-choice__marker { display: grid; place-items: center; width: 15px; height: 15px; margin-top: 1px; border: 1.5px solid #77746d; border-radius: 50%; }
.settings-choice__marker::after { content: ""; width: 7px; height: 7px; background: transparent; border-radius: 50%; }
.settings-choice input:checked + .settings-choice__marker { border-color: #91c957; }
.settings-choice input:checked + .settings-choice__marker::after { background: #91c957; }
.settings-choice input:focus-visible + .settings-choice__marker { outline: 3px solid rgba(129,182,76,.5); outline-offset: 3px; }
.settings-group--draw { margin-top: 14px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.06); }
.settings-segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 4px; background: #211f1c; border-radius: 11px; }
.settings-segmented__option { position: relative; cursor: pointer; }
.settings-segmented__option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.settings-segmented__option > span { display: grid; gap: 3px; min-height: 58px; padding: 10px 12px; border: 1px solid transparent; border-radius: 8px; }
.settings-segmented__option strong { font-size: 13px; }
.settings-segmented__option small { color: #aaa69e; font-size: 12px; line-height: 1.4; }
.settings-segmented__option input:checked + span { background: #3b3934; border-color: rgba(255,255,255,.08); box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.settings-segmented__option input:checked + span::before { content: "✓"; position: absolute; top: 9px; right: 11px; color: #a8d673; font-size: 10px; font-weight: 800; }
.settings-segmented__option input:focus-visible + span { outline: 3px solid rgba(129,182,76,.5); outline-offset: 2px; }
.settings-secondary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.settings-secondary-grid .settings-section { display: flex; flex-direction: column; }
.settings-secondary-grid .settings-choice-list, .settings-secondary-grid .settings-switch-list { flex: 1; }
.settings-recommended { display: inline-block; margin-left: 5px; padding: 3px 6px; color: #c5e89f; background: rgba(129,182,76,.15); border-radius: 4px; font-size: 9px; font-style: normal; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; vertical-align: 1px; }
.beta-badge { display: inline-block; margin-left: 5px; padding: 3px 6px; color: #c5e89f; background: rgba(129,182,76,.16); border-radius: 5px; font-size: 9px; font-style: normal; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; vertical-align: 2px; }
.settings-data { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 14px 16px; background: rgba(224,90,71,.035); border: 1px solid rgba(224,90,71,.13); border-radius: 13px; }
.settings-data__icon { display: grid; place-items: center; width: 30px; height: 30px; color: #dd877a; background: rgba(224,90,71,.09); border-radius: 8px; }
.settings-data .danger-button { min-height: 40px; padding: 8px 13px; font-size: 13px; }
.sr-only, .settings-group legend.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.upload-close { position: absolute; z-index: 2; top: 17px; right: 70px; }
.upload-close[hidden] { display: none; }
.upload-brand { width: min(100%, 360px); justify-content: center; margin: 0 auto 27px; }
.upload-brand .brand-logo { width: 100%; }
.upload-intro { display: block; }
.upload-intro h1 { flex: 1 1 auto; max-width: 460px; margin: 6px 0 9px; font-size: clamp(21px, 3.2vw, 28px); line-height: 1.04; letter-spacing: -.045em; }
.language-toggle { position: fixed; z-index: 60; top: 14px; right: 16px; display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 4px 8px; color: #b8b4ab; background: rgba(38,37,34,.94); border: 1px solid rgba(255,255,255,.14); border-radius: 8px; box-shadow: 0 3px 12px rgba(0,0,0,.22); cursor: pointer; font-size: 10px; font-weight: 750; letter-spacing: .07em; line-height: 1; transition: color .16s ease, background .16s ease, border-color .16s ease; }
.language-toggle--page { display: none; }
.language-toggle:hover { color: #f3f1eb; background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.18); }
.language-toggle:focus-visible { outline: 3px solid rgba(129,182,76,.65); outline-offset: 3px; }
.language-toggle [data-language-option].is-active { color: #c6e99f; }
.language-toggle__slash { color: #77746d; font-weight: 500; }
.upload-intro > p:last-child { max-width: 470px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.upload-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 23px 0 13px; padding: 4px; background: #22211f; border-radius: 9px; }
.upload-tab { padding: 9px; color: var(--muted); background: transparent; border: 0; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 750; }
.upload-tab.is-active { color: var(--text); background: #3b3935; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.drop-zone { display: grid; place-items: center; min-height: 190px; padding: 20px; border: 1.5px dashed #63605a; border-radius: 11px; cursor: pointer; transition: .18s ease; }
.drop-zone:hover, .drop-zone.is-dragging { border-color: var(--green); background: rgba(129,182,76,.06); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-icon { display: grid; place-items: center; width: 45px; height: 45px; margin-bottom: 7px; color: var(--green); background: rgba(129,182,76,.12); border-radius: 50%; font-size: 23px; }
.drop-zone strong { font-size: 13px; }
.drop-zone > span:not(.upload-icon) { margin-top: 4px; color: var(--muted); font-size: 11px; }
.drop-zone small { margin-top: 13px; color: #78756e; font-size: 9px; }
.selected-file { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px; margin-top: 10px; padding: 10px 12px; background: rgba(129,182,76,.08); border: 1px solid rgba(129,182,76,.22); border-radius: 8px; }
.selected-file > span { display: grid; place-items: center; width: 28px; height: 28px; color: #232a1b; background: #a0c974; border-radius: 6px; }
.selected-file div { display: grid; min-width: 0; }
.selected-file strong { overflow: hidden; text-overflow: ellipsis; font-size: 11px; white-space: nowrap; }
.selected-file small { color: var(--muted); font-size: 9px; }
.selected-file button { color: var(--muted); background: transparent; border: 0; cursor: pointer; font-size: 20px; }
.textarea-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; }
textarea { display: block; width: 100%; min-height: 192px; resize: vertical; padding: 13px; color: #e8e6e0; background: #211f1d; border: 1px solid #55524d; border-radius: 9px; font-family: "SFMono-Regular", Consolas, monospace; font-size: 11px; line-height: 1.5; }
textarea:focus { border-color: var(--green); }
.character-count { display: block; margin-top: 5px; color: #77746d; font-size: 9px; text-align: right; }
.upload-error { margin: 10px 0 0; padding: 9px 11px; color: #ffb4aa; background: rgba(224,90,71,.12); border-radius: 7px; font-size: 11px; }
.upload-submit { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; margin-top: 14px; }
.privacy-note { margin: 14px 0 0; color: #79766f; font-size: 9px; text-align: center; }
.privacy-note span { color: var(--green); }
.toast { position: fixed; z-index: 70; right: 24px; bottom: 24px; max-width: 350px; padding: 12px 15px; color: white; background: #373531; border: 1px solid var(--border); border-radius: 9px; box-shadow: var(--shadow); font-size: 12px; }

@media (max-width: 1150px) {
  :root { --board-size: min(66vw, 650px, calc(100vw - 600px)); }
  .sidebar { width: 74px; align-items: center; padding: 20px 11px; }
  .sidebar .brand { width: 38px; height: 38px; flex: 0 0 38px; overflow: hidden; }
  .sidebar .brand-logo { flex: 0 0 190px; width: 190px; max-width: none; height: 38px; }
  .side-action span:last-child { display: none; }
  .side-action { justify-content: center; }
  .maia-nav { justify-content: center; min-height: 52px; padding: 8px; }
  .review-layout { grid-template-columns: minmax(450px, 1fr) 370px; margin-left: 74px; padding: 14px; }
}

@media (min-width: 901px) and (max-height: 780px) {
  :root { --board-size: min(calc(100dvh - 155px), 700px, calc(100vw - 700px)); }
  .review-layout { padding-top: 14px; padding-bottom: 14px; }
  .player-row { padding: 4px 0; }
  .player-avatar { width: 34px; height: 34px; }
  .board-toolbar { margin-top: 6px; bottom: 6px; }
  .board-toolbar--panel { margin: 0 12px 10px; }
  .evaluation-graph { margin-bottom: 8px; padding-top: 8px; padding-bottom: 6px; }
  .evaluation-graph__plot { height: 72px; }
  .arrow-legend { margin-top: 5px; }
}

@media (min-width: 1200px) and (max-width: 1500px) {
  .review-layout { grid-template-columns: minmax(560px, 1fr) minmax(410px, 410px); }
  .board-stage { gap: 7px; }
}

@media (max-width: 900px) {
  :root { --board-size: min(78vw, 640px, calc(100vw - 112px)); }
  .sidebar { display: none; }
  .review-layout { display: block; height: auto; min-height: 100vh; margin: 0; padding: 0; overflow: visible; }
  .board-column { padding: 12px 14px 18px; }
  .mobile-header { display: flex; align-items: center; justify-content: space-between; width: min(100%, calc(var(--board-size) + 42px)); margin-bottom: 17px; }
  .mobile-header-actions { display: flex; align-items: center; gap: 7px; }
  .mobile-header .brand { width: min(170px, 50vw); flex: 0 1 auto; }
  .mobile-header .brand-logo { width: 100%; }
.mobile-header .icon-button { width: 36px; height: 36px; }
.mobile-header .settings-nav-icon { width: 19px; height: 19px; }
  .review-panel { min-height: 520px; border-right: 0; border-bottom: 0; border-left: 0; border-radius: 18px 18px 0 0; }
  .tab-panel { max-height: 560px; }
  .evaluation-graph { margin-right: 14px; margin-left: 14px; }
  .board-toolbar--panel { margin: 0 0 12px; }
}

@media (max-width: 560px) {
  :root { --board-size: calc(100vw - 102px); }
  .board-column { padding: 10px 9px 14px; }
  .mobile-header { width: 100%; }
  .game-meta-detail { max-width: 42%; }
  .eval-bar { width: 30px; }
  .player-row { width: var(--board-size); margin-left: 0; }
  .player-row { grid-template-columns: 34px minmax(0, 1fr) auto auto; gap: 7px; }
  .player-avatar { width: 32px; height: 32px; }
  .clock { min-width: 76px; padding: 7px; font-size: 16px; }
  .board-toolbar { width: var(--board-size); margin-left: 0; grid-template-columns: 40px 40px minmax(54px,1fr) 40px 40px 40px; }
  .board-toolbar--panel { width: auto; margin: 0 0 12px; }
  .exploration-panel { align-items: stretch; flex-direction: column; gap: 8px; }
  .exploration-actions { display: grid; grid-template-columns: 1fr 1.4fr; }
  .toolbar-divider { display: none; }
  .nav-button { height: 40px; }
  .upload-overlay { align-items: start; padding: 12px; }
  .upload-card { padding: 22px 18px; border-radius: 14px; }
  .settings-overlay { align-items: stretch; padding: 0; }
  .settings-card { width: 100%; max-height: 100dvh; border-width: 0; border-radius: 0; }
  .settings-header { padding: 18px 16px; }
  .settings-heading { gap: 11px; }
  .settings-heading__icon { width: 40px; height: 40px; border-radius: 11px; }
  .settings-heading__icon img { width: 23px; height: 23px; }
  .settings-card h2 { font-size: 27px; }
  .settings-copy { margin-top: 3px; font-size: 12px; }
  .settings-content { gap: 10px; padding: 12px 12px 20px; }
  .settings-section { padding: 15px 13px; }
  .settings-arrow-grid, .settings-secondary-grid { grid-template-columns: 1fr; gap: 16px; }
  .settings-segmented { grid-template-columns: 1fr; }
  .settings-data { grid-template-columns: auto minmax(0, 1fr); }
  .settings-data .danger-button { grid-column: 1 / -1; width: 100%; margin-top: 3px; }
  .upload-brand { margin-bottom: 20px; }
  .upload-intro h1 { font-size: 22px; }
  .language-toggle { top: 10px; right: 10px; min-height: 28px; padding: 4px 7px; }
  .drop-zone { min-height: 168px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Persistent library: the same warm surfaces and green accent as the board. */
.secondary-button, .danger-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 10px 16px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-3); cursor: pointer; font-weight: 650; }
.secondary-button:hover { background: #48453f; }
.secondary-button svg { width: 19px; height: 19px; }
.danger-button { color: #f19889; background: rgba(224,90,71,.08); border-color: rgba(224,90,71,.25); }
.danger-button:hover { background: rgba(224,90,71,.16); }
.danger-button:disabled { opacity: .5; cursor: wait; }
.upload-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-top: 16px; }
.upload-actions .upload-submit { margin-top: 0; }
.history-storage-note { margin: 18px 0 0; font-size: 12px; line-height: 1.5; color: var(--muted); text-align: center; }
.upload-license-link { display: flex; justify-content: flex-end; margin-top: 10px; }
.license-link { padding: 2px 0; color: #a7c984; background: transparent; border: 0; font-size: 11px; line-height: 1.4; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.license-link:hover { color: #d3e8be; }
.licenses-dialog[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); width: min(760px, calc(100% - 32px)); max-height: min(850px, calc(100dvh - 32px)); padding: 0; overflow: hidden; color: var(--text); background: var(--surface-1); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); }
.licenses-dialog::backdrop { background: rgba(20,20,18,.84); backdrop-filter: blur(9px); }
.licenses-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 22px 26px 18px; border-bottom: 1px solid var(--border); }
.licenses-header .eyebrow { margin: 0 0 4px; }
.licenses-header h2 { margin: 0; font-size: 25px; letter-spacing: -.035em; }
.licenses-content { display: grid; align-content: start; gap: 14px; overflow-y: auto; padding: 18px 26px 24px; scrollbar-color: #555149 transparent; scrollbar-width: thin; }
.license-status-note, .license-review-note { margin: 0; padding: 11px 13px; border-radius: 9px; font-size: 12px; line-height: 1.5; }
.license-status-note { color: #e3d1a1; background: rgba(202,160,76,.1); border: 1px solid rgba(202,160,76,.22); }
.license-review-note { color: #f0b4a8; background: rgba(224,90,71,.08); border: 1px solid rgba(224,90,71,.22); }
.license-group { display: grid; gap: 7px; }
.license-group h3 { margin: 1px 0; color: #c7c2b8; font-size: 11px; letter-spacing: .09em; text-transform: uppercase; }
.license-list { display: grid; gap: 1px; margin: 0; padding: 0; list-style: none; background: rgba(255,255,255,.055); border: 1px solid rgba(255,255,255,.06); border-radius: 9px; overflow: hidden; }
.license-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 8px 11px; background: var(--surface-2); font-size: 12px; }
.license-list li > a { color: var(--text); text-decoration: none; }
.license-list li > a:hover { color: #b8d892; }
.license-unlinked-name { color: var(--text); }
.license-list small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; line-height: 1.35; }
.license-list li > span { color: #c2d9aa; font-size: 10px; text-align: right; white-space: nowrap; }
.license-footnote { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.license-notices-link { justify-self: end; color: #b8d892; font-size: 11px; text-underline-offset: 3px; }
.history-dialog { width: min(1080px, calc(100% - 40px)); max-height: calc(100dvh - 40px); padding: 28px 32px; color: var(--text); background: var(--surface-1); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); }
.history-dialog::backdrop { background: rgba(20,20,18,.84); backdrop-filter: blur(9px); }
.history-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.history-header h2 { margin: 4px 0 0; font-size: 32px; letter-spacing: -.04em; }
.history-header-actions { display: flex; align-items: center; gap: 12px; }
.history-header .icon-button { font-size: 27px; }
.history-muted { color: var(--muted); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.history-summary { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 14px; }
.history-metric, .history-category { padding: 20px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; }
.history-metric { display: flex; flex-direction: column; gap: 7px; }
.history-metric strong { font-size: 34px; letter-spacing: -.04em; }
.history-metric:last-child { background: linear-gradient(130deg, rgba(129,182,76,.14), var(--surface-2)); border-color: rgba(129,182,76,.25); }
.history-metric:last-child strong { color: #a6d46b; }
.history-metric span { color: var(--muted); font-size: 12px; }
.history-method { padding: 14px 0; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.history-categories { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 10px; }
.history-category h3 { margin: 0 0 16px; font-size: 15px; }
.history-loss { display: block; font-size: 25px; font-weight: 700; }
.history-category p { margin: 6px 0 12px; font-size: 12px; }
.history-category meter { display: block; width: 100%; height: 7px; margin-top: 18px; border: none; background: var(--surface-0); border-radius: 5px; }
.history-category meter::-webkit-meter-bar { background: var(--surface-0); border: 0; }
.history-category meter::-webkit-meter-optimum-value { background: var(--green); }
.history-category meter::-moz-meter-bar { background: var(--green); }
.history-section-title { margin: 26px 0 12px; font-size: 18px; letter-spacing: -.02em; }
.history-openings { max-height: 280px; overflow-y: auto; }
.history-opening { display: flex; justify-content: space-between; align-items: baseline; gap: 20px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.history-opening strong { font-size: 13px; overflow-wrap: anywhere; }
.history-opening span { flex-shrink: 0; }
.history-list { display: grid; gap: 10px; }
.history-game { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.history-game-info { min-width: 0; overflow-wrap: anywhere; }
.history-game h3 { margin: 0; font-size: 15px; }
.history-game p { margin: 7px 0; color: var(--muted); font-size: 12px; }
.history-status { display: block; margin-top: 8px; font-size: 11px; color: var(--warning); }
.history-status.is-complete { color: #a6d46b; }
.history-game-actions { display: flex; gap: 8px; flex-shrink: 0; font-size: 12px; }
.history-empty { text-align: center; padding: 32px 20px; border: 1px dashed var(--border); border-radius: 12px; }
.history-empty > span { color: var(--green); font-size: 42px; }
.history-empty h3 { margin: 8px 0; }
.history-empty p { color: var(--muted); font-size: 13px; line-height: 1.6; }
.history-insufficient { margin: 22px 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
@media (max-width: 800px) {
  .history-categories { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .history-opening { display: grid; gap: 4px; }
  .history-opening span { flex-shrink: 1; }
}
@media (max-width: 520px) {
  .history-dialog { width: calc(100% - 20px); max-height: calc(100dvh - 20px); padding: 20px 16px; border-radius: 14px; }
  .history-header h2 { font-size: 26px; }
  .history-summary { grid-template-columns: 1fr 1fr; gap: 10px; }
  .history-metric:last-child { grid-column: 1 / -1; }
  .history-metric, .history-category { padding: 15px; }
  .history-game { align-items: stretch; flex-direction: column; }
  .history-game-actions button { flex: 1; }
}

/* Statistics: conclusions first, implementation details on demand. */
.history-dialog { width: min(980px, calc(100% - 40px)); padding: 30px 36px 36px; }
.history-subtitle { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.history-summary { grid-template-columns: 1fr 1fr 1.35fr; gap: 10px; }
.history-metric { min-height: 120px; padding: 17px 20px; justify-content: center; gap: 4px; }
.history-metric > span { order: -1; color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .07em; }
.history-metric > strong { font-size: 38px; line-height: 1.05; }
.history-metric > small { color: var(--muted); font-size: 11px; }
.history-metric--risk { background: linear-gradient(135deg, rgba(129,182,76,.19), rgba(49,46,43,.92)); border-color: rgba(129,182,76,.35); }
.history-metric--risk > strong { color: #a8d96b; }
.history-insights { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.history-insight { min-height: 112px; padding: 17px 20px; background: rgba(255,255,255,.025); border: 1px solid var(--border); border-left: 4px solid var(--warning); border-radius: 10px; }
.history-insight > span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; }
.history-insight > strong { font-size: 20px; }
.history-insight > p { margin: 7px 0 0; color: #d0cdc5; font-size: 12px; line-height: 1.45; }
.history-insight--priority { border-left-color: var(--danger); }
.history-insight--improve { border-left-color: #e6912c; }
.history-insight--attention { border-left-color: var(--warning); }
.history-insight--solid, .history-insight--strength { border-left-color: var(--green); }
.history-section-title { margin: 24px 0 10px; font-size: 16px; }
.history-categories { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; }
.history-category { min-height: 148px; padding: 17px 18px; border-left: 4px solid #5b5954; }
.history-category--solid { border-left-color: var(--green); }
.history-category--attention { border-left-color: var(--warning); }
.history-category--improve { border-left-color: #e6912c; }
.history-category--priority { border-left-color: var(--danger); }
.history-category-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.history-category-heading h4 { margin: 0; font-size: 14px; }
.history-category-badge, .history-verdict { padding: 4px 8px; color: var(--muted); background: rgba(255,255,255,.06); border-radius: 999px; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.history-category--solid .history-category-badge, .history-verdict--solid { color: #b1dc80; background: rgba(129,182,76,.13); }
.history-category--attention .history-category-badge, .history-verdict--attention { color: #f0c15b; background: rgba(240,193,91,.12); }
.history-category--improve .history-category-badge, .history-verdict--improve { color: #f1a44c; background: rgba(230,145,44,.13); }
.history-category--priority .history-category-badge, .history-verdict--priority { color: #f28a7b; background: rgba(224,90,71,.13); }
.history-category-result { display: block; font-size: 17px; line-height: 1.35; }
.history-category-severe { display: block; margin-top: 4px; color: #f28a7b; font-size: 11px; font-weight: 700; }
.history-category-copy { margin: 10px 0 0 !important; color: var(--muted); font-size: 12px !important; line-height: 1.45; }
.history-method { margin-top: 12px; padding: 0; color: var(--muted); border: 1px solid var(--border); border-radius: 9px; font-size: 11px; }
.history-method summary { padding: 11px 14px; cursor: pointer; font-weight: 700; }
.history-method p { margin: 0; padding: 0 14px 13px; line-height: 1.55; }
.history-opening { align-items: center; padding: 13px 15px; background: rgba(255,255,255,.025); border: 1px solid var(--border); border-radius: 9px; }
.history-opening + .history-opening { margin-top: 7px; }
.history-opening-info { display: grid; gap: 4px; min-width: 0; }
.history-opening-info strong { line-height: 1.35; }
.history-opening-verdict { display: grid; justify-items: end; gap: 5px; flex-shrink: 0; }
.history-list { gap: 7px; }
.history-game { padding: 14px 15px; }

@media (max-width: 700px) {
  .history-dialog { padding: 22px 20px 28px; }
  .history-summary { grid-template-columns: 1fr 1fr; }
  .history-metric--risk { grid-column: 1 / -1; }
  .history-insights, .history-categories { grid-template-columns: 1fr; }
}

@media (max-width: 440px) {
  .history-dialog { width: calc(100% - 16px); max-height: calc(100dvh - 16px); padding: 18px 14px 24px; }
  .history-header-actions .secondary-button { display: none; }
  .history-summary { grid-template-columns: 1fr; }
  .history-metric--risk { grid-column: auto; }
  .history-metric { min-height: 104px; }
  .history-opening { align-items: flex-start; flex-direction: column; }
  .history-opening-verdict { justify-items: start; }
}

/* Analysis dashboard: only the decisions and metrics that matter. */
.history-dialog {
  width: min(1040px, calc(100% - 40px));
  max-height: calc(100dvh - 40px);
  padding: 28px;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% 0, rgba(129,182,76,.09), transparent 32%),
    #242321;
  border-color: rgba(255,255,255,.1);
}
.history-header { padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.history-header h2 { margin: 0; font-size: clamp(26px, 4vw, 38px); }
.history-header .icon-button { width: 42px; height: 42px; font-size: 27px; border-radius: 50%; }
.history-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.history-metric {
  min-height: 132px;
  padding: 22px 24px;
  justify-content: center;
  background: rgba(255,255,255,.035);
  border-color: rgba(255,255,255,.1);
  border-radius: 16px;
}
.history-metric > span { font-size: 12px; }
.history-metric > strong { margin: 3px 0; font-size: clamp(38px, 6vw, 54px); }
.history-metric--risk {
  background: linear-gradient(135deg, rgba(129,182,76,.17), rgba(255,255,255,.035));
  border-color: rgba(129,182,76,.3);
}
.history-trend-toggle {
  align-self: flex-start;
  min-height: 30px;
  padding: 5px 11px;
  color: #d9f3b9;
  background: rgba(129,182,76,.12);
  border: 1px solid rgba(129,182,76,.3);
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 750;
}
.history-trend-toggle:hover, .history-trend-toggle[aria-expanded="true"] { background: rgba(129,182,76,.22); }
.history-trend-toggle:focus-visible { outline: 2px solid #b6df86; outline-offset: 2px; }
.history-trend-dialog {
  width: min(760px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 18px 20px 14px;
  color: var(--text);
  background: linear-gradient(145deg, #302f2b, #242320);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 16px;
  box-shadow: 0 24px 90px rgba(0,0,0,.55);
  overflow: hidden;
}
.history-trend-dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(3px); }
.history-trend-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.history-trend-header h3 { margin: 0; font-size: 17px; }
.history-trend-header span { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.history-trend-close { width: 40px; min-width: 40px; height: 40px; padding: 0; flex: 0 0 40px; border-radius: 50%; }
.history-trend-close svg { display: block; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.history-trend-chart-wrap { width: 100%; margin-top: 9px; overflow: hidden; }
.history-trend-chart { display: block; width: 100%; height: auto; }
.history-trend-gridline { stroke: rgba(255,255,255,.1); stroke-width: 1; stroke-dasharray: 3 5; }
.history-trend-tick { fill: var(--muted); font-size: 12px; }
.history-trend-axis-label { fill: #d0cdc5; font-size: 12px; font-weight: 700; }
.history-trend-line { fill: none; stroke: #a8d96b; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.history-trend-point { fill: #d9f3b9; stroke: #5f8f35; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.history-trend-note { margin: 4px 0 0; }
.history-dashboard { display: grid; grid-template-columns: minmax(320px, .9fr) minmax(360px, 1.1fr); gap: 12px; margin-top: 12px; }
.history-radar-card, .history-openings-card {
  min-width: 0;
  padding: 20px;
  background: rgba(255,255,255,.025);
  border: 1px solid var(--border);
  border-radius: 16px;
}
.history-radar-card > h3, .history-section-heading h3 { margin: 0; font-size: 17px; letter-spacing: -.02em; }
.history-radar { display: block; width: 100%; max-width: 340px; height: 268px; margin: 4px auto 0; overflow: visible; }
.history-radar__grid polygon, .history-radar__grid path { fill: none; stroke: rgba(255,255,255,.11); stroke-width: 1; }
.history-radar__shape { fill: rgba(129,182,76,.27); stroke: #9bce66; stroke-width: 2.5; stroke-linejoin: round; filter: drop-shadow(0 0 9px rgba(129,182,76,.2)); transition: points .25s ease; }
.history-radar__points circle { fill: #d9f3b9; stroke: #5f8f35; stroke-width: 2; }
.history-radar__labels text { fill: #c7c3ba; font-size: 11px; font-weight: 750; }
.history-radar-legend { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 4px; }
.history-radar-score { display: grid; gap: 2px; text-align: center; }
.history-radar-score small { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .05em; }
.history-radar-score strong { font-size: 15px; }
.history-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 15px; border-bottom: 1px solid var(--border); }
.history-section-heading > span { color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; }
.history-openings { max-height: 348px; padding-right: 5px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #5b5954 transparent; }
.history-opening { gap: 18px; padding: 14px 2px; background: transparent; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; }
.history-opening + .history-opening { margin-top: 0; }
.history-opening-info strong { font-size: 13px; }
.history-opening-rate { display: grid; justify-items: end; gap: 7px; width: 148px; flex: 0 0 148px; }
.history-opening-measures { display: flex; justify-content: space-between; gap: 12px; width: 100%; }
.history-opening-measure { display: grid; justify-items: end; gap: 1px; }
.history-opening-measure > span { color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: .05em; text-transform: uppercase; }
.history-opening-measure > strong { color: #b6df86; font-size: 15px; }
.history-opening-track { display: block; width: 100%; height: 4px; overflow: hidden; background: rgba(255,255,255,.08); border-radius: 999px; }
.history-opening-track i { display: block; height: 100%; background: var(--green); border-radius: inherit; }
@media (max-width: 800px) {
  .history-opening-rate { justify-self: start; justify-items: start; }
  .history-opening-measures { justify-content: flex-start; gap: 18px; }
  .history-opening-measure { justify-items: start; }
}
.history-library-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 58px;
  padding: 0 20px;
  margin-top: 12px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 13px;
  cursor: pointer;
  font-weight: 750;
}
.history-library-button:hover { background: var(--surface-3); border-color: rgba(129,182,76,.32); }
.history-library-button > span { display: inline-flex; align-items: center; gap: 10px; }
.history-library-button svg { width: 19px; height: 19px; color: #a8d96b; }
.history-library-button > strong { display: grid; place-items: center; min-width: 29px; height: 29px; padding: 0 8px; color: #d9f3b9; background: rgba(129,182,76,.13); border-radius: 999px; font-size: 12px; }
.history-games-panel { padding-top: 12px; }
.history-game { background: rgba(255,255,255,.025); }

@media (max-width: 760px) {
  .history-dialog { width: calc(100% - 20px); max-height: calc(100dvh - 20px); padding: 20px; }
  .history-dashboard { grid-template-columns: 1fr; }
  .history-radar { height: 250px; }
  .history-openings { max-height: 320px; }
}

@media (max-width: 480px) {
  .history-dialog { width: calc(100% - 12px); max-height: calc(100dvh - 12px); padding: 16px 13px 18px; }
  .history-trend-dialog { width: calc(100% - 20px); padding: 15px 12px 10px; }
  .history-trend-header { gap: 8px; }
  .history-trend-header h3 { font-size: 15px; }
  .history-trend-header span { font-size: 10px; }
  .history-summary { grid-template-columns: 1fr; }
  .history-metric--risk { grid-column: auto; }
  .history-metric { min-height: 112px; padding: 16px; }
  .history-metric > strong { font-size: 34px; }
  .history-radar-card, .history-openings-card { padding: 16px 13px; }
  .history-radar { height: auto; }
  .history-radar__labels text { font-size: 10px; }
  .history-game { align-items: stretch; flex-direction: column; }
  .history-game-actions button { flex: 1; }
}
