:root {
  color-scheme: dark;
  --bg: #302e2b;
  --sidebar: #262522;
  --panel: #262522;
  --deep: #21201e;
  --raised: #3d3b38;
  --line: #494743;
  --text: #f5f4f1;
  --muted: #bbb8b1;
  --accent: #81b64c;
  --accent-hover: #93c85c;
  --dark: #769656;
  --light: #eeeed2;
  --rail-width: 176px;
  --header-height: 60px;
  font: 14px 'Segoe UI', Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { color: inherit; background: none; border: 0; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
:where(button, input, select, textarea, summary, a):focus-visible { outline: 2px solid var(--accent-hover); outline-offset: 3px; }
input, select, textarea { min-width: 0; border: 1px solid var(--line); border-radius: 5px; padding: 9px 11px; color: var(--text); background: var(--deep); }
input::placeholder { color: var(--muted); }
::selection { color: white; background: #4a7228; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #615e57; border-radius: 6px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 19px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }
p { color: var(--muted); line-height: 1.45; }
small, .small-note { font-size: 12px; color: var(--muted); }
.hidden { display: none !important; }
[data-icon] { display: inline-grid; place-items: center; flex-shrink: 0; }
[data-icon] svg, .icon-button > svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 12; width: var(--rail-width); display: flex; flex-direction: column; background: var(--sidebar); }
.brand { height: var(--header-height); padding: 0 12px; display: flex; align-items: center; gap: 6px; font-weight: 750; letter-spacing: -.35px; font-size: 16px; }
.brand img { width: 35px; height: 35px; object-fit: contain; }
nav { display: grid; padding: 6px 7px; gap: 4px; }
nav button { text-align: left; display: flex; align-items: center; gap: 10px; border-radius: 5px; min-height: 43px; padding: 7px 10px; font-weight: 650; color: #dedbd6; transition: background .15s, color .15s; }
nav button:hover { background: #33312e; color: #fff; }
nav button.active { background: #363b2e; color: #f3f6ee; box-shadow: inset 3px 0 #93bb64; }
nav button.active [data-icon] { color: #a4d572; }
.sidebar-bottom { margin-top: auto; padding: 13px 12px; border-top: 1px solid #3b3935; display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 12px; }
.sidebar-bottom b { overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 29px; height: 29px; border-radius: 4px; background: var(--raised); }
main { margin-left: var(--rail-width); }
header { height: var(--header-height); padding: 0 21px; display: flex; justify-content: space-between; align-items: center; gap: 12px; position: sticky; top: 0; background: var(--bg); z-index: 10; border-bottom: 1px solid #3c3935; }
.page-heading { display: flex; align-items: center; gap: 10px; }
.engine-status { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.engine-status i { width: 7px; height: 7px; border-radius: 50%; background: #a69c8b; }
.engine-status[data-ready="true"] i { background: var(--accent); }
#live-board-select { max-width: 28vw; text-overflow: ellipsis; }
.view { padding: 19px 20px 23px; animation: view-enter .16s ease-out both; }
@keyframes view-enter { from { opacity: .5; transform: translateY(3px); } }
.actions { display: flex; align-items: center; gap: 8px; }
.primary, .secondary, .icon-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 7px 12px; border-radius: 5px; font-weight: 700; white-space: nowrap;
  transition: background .14s, box-shadow .14s, transform .14s;
}
.primary { color: #171e11; background: var(--accent); box-shadow: inset 0 -3px #618b38; }
.primary:hover:not(:disabled) { background: var(--accent-hover); }
.secondary, .icon-button { background: var(--raised); box-shadow: inset 0 -2px #34322e; }
.secondary:hover:not(:disabled), .icon-button:hover:not(:disabled) { background: #514d47; }
:where(.primary,.secondary,.icon-button):active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.icon-button { min-width: 36px; padding: 6px 8px; }
.text-button { display: inline-flex; align-items: center; color: var(--muted); padding: 5px; border-radius: 4px; }
.text-button:hover { background: var(--raised); color: var(--text); }
.panel-title { min-height: 51px; padding: 9px 15px; display: flex; align-items: center; gap: 9px; border-bottom: 1px solid #393733; background: var(--deep); }
.panel-title > [data-icon] { color: #d2cfc8; }
.panel-title button { margin-left: auto; }
.library-layout { display: grid; grid-template-columns: minmax(0,1fr) minmax(248px, .38fr); gap: 17px; max-width: 1400px; margin-inline: auto; align-items: start; }
.games-main, .library-summary, .analysis-column, .settings-block { background: var(--panel); border-radius: 12px; overflow: clip; box-shadow: 0 0 0 1px #ffffff0c, 0 3px 12px #16151128; }
.player-search, .library-toolbar { display: flex; align-items: stretch; gap: 8px; margin: 13px 14px 0; }
.search { display: flex; flex: 1; align-items: center; gap: 7px; min-width: 0; padding-left: 9px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); background: var(--deep); }
.search:focus-within { border-color: var(--accent); }
.search input { width: 100%; background: transparent; border: 0; padding-left: 0; outline: none; }
.library-message { padding: 7px 14px 0; min-height: 20px; font-size: 12px; }
.library-message:empty { display: none; }
.library-toolbar { margin-bottom: 12px; }
.table-wrap { overflow: auto; }
.games-table { width: 100%; border-collapse: collapse; text-align: left; font-variant-numeric: tabular-nums; }
.games-table th, .games-table td { padding: 10px 12px; }
.games-table th { background: var(--deep); color: var(--muted); font-size: 12px; }
.games-table tr:nth-child(even) { background: #2b2a27; }
.game-row { cursor: pointer; transition: background .14s; }
.games-table tr.game-row:hover, .games-table tr.game-row:focus-visible { background: #3a3a30; }
.opponent-name { display: block; margin-bottom: 2px; }
.opponent-sub { font-size: 12px; color: var(--muted); }
.result { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; }
.result-dot { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 4px; font-size: 15px; font-weight: 800; background: #425c2c; color: #dfefce; }
.result.loss .result-dot { background: #6b403a; color: #ffe1d8; }
.result.draw .result-dot { background: #514e48; color: #e2dfd8; }
.open-game { color: var(--muted); width: 35px; }
.profile-content { padding: 14px; }
.profile-name { display: block; overflow-wrap: anywhere; font-size: 16px; }
#game-count { margin-top: 3px; font-size: 12px; }
.rating-row { display: flex; justify-content: space-between; align-items: center; text-transform: capitalize; padding: 9px 0; border-bottom: 1px solid #3b3935; }
.rating-row span { color: var(--muted); }
.rating-row b { font-variant-numeric: tabular-nums; }
.archive-actions { display: grid; gap: 8px; margin-top: 15px; }
.profile-content .library-message { padding-inline: 0; }
#new-board { width: 100%; margin-top: 13px; }
#games-more { margin: 12px 14px; }
#brilliant-results { max-height: 340px; overflow: auto; }
#brilliant-results button { text-align: left; }
.empty { padding: 27px 14px; color: var(--muted); text-align: center; }
.analysis-layout { display: grid; grid-template-columns: minmax(390px, min(57%, calc(100vh - 196px))) minmax(310px, 1fr); gap: 22px; max-width: 1600px; margin-inline: auto; }
.board-column { min-width: 0; }
.player-line { display: flex; align-items: center; gap: 7px; height: 37px; padding-left: 26px; }
.player-line > span:not(.player-avatar) { color: var(--muted); font-size: 12px; }
.player-avatar { width: 27px; height: 27px; display: grid; place-items: center; border-radius: 4px; color: #e5e2da; background: #4b4842; }
.player-avatar.white { color: #433e36; background: #dad6cc; }
.push { margin-left: auto; }
.board-with-eval { display: flex; position: relative; gap: 7px; margin-block: 2px; }
.eval-rail { width: 19px; position: relative; flex-shrink: 0; }
.eval-rail > span { position: absolute; z-index: 1; bottom: 4px; width: 100%; text-align: center; font-size: 9px; line-height: 1; font-weight: 750; color: #262522; }
.eval-track { position: absolute; inset: 0; overflow: hidden; background: #41403c; border-radius: 3px; }
.eval-track > div { position: absolute; bottom: 0; width: 100%; height: 50%; background: #f4f4f2; transition: height .28s ease; }
#board { position: relative; aspect-ratio: 1; width: calc(100% - 26px); min-width: 0; border-radius: 3px; overflow: hidden; }
#squares { position: absolute; inset: 0; display: grid; grid-template: repeat(8,1fr) / repeat(8,1fr); }
.square { position: relative; display: block; padding: 0; min-width: 0; min-height: 0; background: var(--light); }
.square.dark { background: var(--dark); }
.square img { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.square .coord { position: absolute; z-index: 1; font-size: clamp(12px, 1.18vw, 18px); font-weight: 700; color: var(--dark); line-height: 1; }
.square.dark .coord { color: var(--light); }
.coord.rank { top: 4px; left: 4px; }
.coord.file { bottom: 3px; right: 4px; }
.square.last { box-shadow: inset 0 0 0 100px #d8df3269; }
.square.selected { box-shadow: inset 0 0 0 100px #c8dc4d9e; }
.legal-dot { position: absolute; inset: 37%; border-radius: 50%; background: #201e1959; }
#board-arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.board-navigation { display: flex; align-items: center; gap: 4px; margin: 5px 0 0 26px; padding: 4px; border-radius: 9px; background: var(--deep); }
.board-navigation button { flex: 1 1 35px; }
.board-navigation > span { padding-inline: 4px; font-variant-numeric: tabular-nums; font-size: 12px; min-width: 105px; text-align: right; color: var(--muted); }
.suggestions { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 17px; padding: 10px 14px; background: #2c2a27; border-bottom: 1px solid #3a3833; }
.suggestions p { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.suggestions span { color: var(--text); font-weight: 650; }
.suggestions p:first-child b { color: #abd481; }
.analysis-column { min-width: 0; display: flex; flex-direction: column; height: calc(100vh - 103px); }
.analysis-panel-title { justify-content: center; position: relative; min-height: 47px; }
.analysis-panel-title button { position: absolute; right: 10px; }
.analysis-heading { display: flex; justify-content: space-between; align-items: center; gap: 9px; padding: 11px 14px 7px; }
.analysis-heading h2 { font-size: 15px; overflow-wrap: anywhere; }
.analysis-heading p { font-size: 12px; margin-top: 2px; }
.analysis-heading p:empty { display: none; }
.analysis-heading .primary { font-size: 12px; min-height: 33px; }
.review-progress { height: 3px; margin: 1px 14px 0; flex-shrink: 0; }
.review-progress > div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
#review-status { padding: 4px 14px; }
#review-status:empty { display: none; }
.chart-wrap { position: relative; flex-shrink: 0; height: clamp(72px, 11vh, 104px); margin: 9px 14px; padding-left: 24px; }
.chart-labels { position: absolute; left: 0; top: 0; bottom: 0; display: flex; flex-direction: column; justify-content: space-between; color: var(--muted); font-size: 11px; }
#eval-chart { width: 100%; height: 100%; cursor: pointer; }
.review-summary { padding: 0 12px; }
.moves-heading, .move-row { display: grid; grid-template-columns: 32px 1fr 1fr; }
.moves-heading { padding: 6px 9px; color: var(--muted); background: var(--deep); font-size: 12px; }
.moves-heading span:not(:first-child) { padding-left: 8px; }
.move-list { flex: 1; min-height: 78px; overflow: auto; }
.move-row { min-height: 30px; padding-inline: 9px; }
.move-row:nth-child(even) { background: #2d2b28; }
.move-row > span { align-self: center; color: var(--muted); font-size: 12px; }
.move-cell { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 3px; text-align: left; font-weight: 600; min-width: 0; transition: background .13s; }
.move-cell:hover { background: var(--raised); }
.move-cell.active { background: #404d33; box-shadow: inset 3px 0 #a3c67a; color: #f4f8ed; }
.move-cell > span { margin-left: auto; display: inline-flex; }
.move-cell svg { width: 17px; height: 17px; }
.move-cell small { text-align: right; font-size: 11px; }
.analysis-bottom { display: flex; justify-content: space-around; gap: 3px; flex-wrap: wrap; border-top: 1px solid #3b3935; padding: 5px 8px; }
.analysis-bottom button { font-size: 12px; }
.settings-page { display: grid; gap: 14px; max-width: 720px; margin-inline: auto; }
.settings-block { padding: 15px 18px; }
.settings-block h3 { margin-bottom: 9px; }
.settings-block > label:not(.check) { display: block; color: var(--muted); margin: 12px 0 5px; }
.settings-block small { display: block; margin-top: 4px; }
.input-action { display: flex; gap: 8px; }
.input-action input { flex: 1; }
.check { display: flex; align-items: center; gap: 8px; margin: 10px 0; cursor: pointer; }
.check input { accent-color: var(--accent); width: 17px; height: 17px; }
#toast { position: fixed; z-index: 20; bottom: 18px; left: calc(50% + var(--rail-width)/2); transform: translateX(-50%); padding: 10px 15px; max-width: 75%; border-radius: 5px; background: #e8e5de; color: #262522; box-shadow: 0 5px 18px #0005; animation: notice-in .18s ease-out; }
@keyframes notice-in { from { opacity: 0; translate: 0 6px; } }
dialog { color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 7px; width: min(510px, calc(100vw - 24px)); padding: 18px; }
dialog::backdrop { background: #0009; }
dialog p { margin: 8px 0; }
dialog textarea { width: 100%; resize: vertical; margin-bottom: 9px; }
dialog .actions { justify-content: flex-end; }
@media (max-width: 1200px) {
  .view { padding-inline: 13px; }
  .analysis-layout { gap: 12px; grid-template-columns: minmax(370px, 1.14fr) minmax(305px, 1fr); }
}
@media (max-width: 860px) {
  :root { --rail-width: 50px; }
  nav button { font-size: 0; padding: 6px; justify-content: center; }
  .brand { padding: 0 7px; }
  .brand span, .sidebar-bottom b { display: none; }
  .library-layout, .analysis-layout { grid-template-columns: 1fr; }
  .analysis-column { height: auto; min-height: 440px; }
  .move-list { max-height: 50vh; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

.brilliant-result {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 7px; border-radius: 4px; transition: background .14s;
}
.brilliant-result:hover { background: var(--raised); }
.brilliant-result-badge { display: inline-flex; flex-shrink: 0; }
.brilliant-result-badge svg { width: 20px; height: 20px; }
.board-navigation .primary { background: #425635; color: #e7f4d8; box-shadow: none; }
.board-navigation .primary:hover { background: #526941; }

.game-rating { background: #21201e; border-radius: 5px; margin: 0 12px 9px; }
.game-rating-title { display: flex; align-items: center; justify-content: center; gap: 7px; padding: 7px 10px; }
.game-rating-title h3 { font-size: 13px; }
.game-rating-title svg { width: 16px; height: 16px; color: #bbb8b1; }
.game-rating-info { color: var(--muted); cursor: help; }
.game-rating-scores { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid #393733; }
.game-rating-scores > div { display: grid; grid-template-columns: 9px minmax(0, 1fr) auto; align-items: center; gap: 6px; padding: 6px 9px 8px; font-size: 12px; }
.game-rating-scores > div + div { border-left: 1px solid #393733; }
.game-rating-scores span:nth-child(2) { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-rating-scores strong { color: var(--text); font-size: 18px; font-variant-numeric: tabular-nums; }
.game-rating-side { width: 8px; height: 8px; border-radius: 2px; background: #585550; border: 1px solid #817b71; }
.game-rating-side.white { background: #f4f2ea; border-color: #f4f2ea; }

.retry-panel { padding: 12px 14px; border-block: 1px solid #393733; }
.retry-panel h3 { margin-bottom: 5px; }
.retry-panel .actions { margin-top: 9px; flex-wrap: wrap; }
.retry-panel p { min-height: 18px; }
.retry-panel [data-verdict="good"] { color: #a7cf7c; }
.retry-panel [data-verdict="bad"] { color: #ff9a83; }
.retry-active .board-navigation, .retry-active .suggestions, .retry-active .chart-wrap,
.retry-active .moves-heading, .retry-active .move-list, .retry-active .analysis-bottom,
.retry-active .analysis-heading, .retry-active #review-status { display: none; }
