/* Chess Games Database — Road of Knowledge (v20261011f). Same look as /chess/review/ */
:root, [data-theme="light"] {
  --bg: #eceae3; --panel: #ffffff; --panel-2: #f3f1ea; --text: #3c3934; --bright: #1a1917;
  --muted: #74716a; --accent: #5a8a1a; --border: #d5d2c8; --topbar-bg: #f7f5ef; --topbar-border: #d5d2c8;
  --input-bg: #f7f5ef; --btn-border: #c8c4b8; --btn-hover: #e7e4da; --row-hover: rgba(90,138,26,.1);
  --sel: rgba(90,138,26,.25); --win: #4f8a12; --loss: #d23f3f; --draw: #77736b;
  --hl: rgba(155,199,0,.41);
  font-family: "Noto Sans", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #161512; --panel: #262421; --panel-2: #302e2c; --text: #bababa; --bright: #f0f0f0;
  --muted: #8a877f; --accent: #629924; --border: #3c3935; --topbar-bg: #21201d; --topbar-border: #3c3935;
  --input-bg: #1b1a18; --btn-border: #4a4742; --btn-hover: #3a3834; --row-hover: rgba(98,153,36,.12);
  --sel: rgba(98,153,36,.35); --win: #629924; --loss: #df5353; --draw: #a8a39a;
  --hl: rgba(155,199,0,.41);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.app { min-height: 100vh; display: flex; flex-direction: column; }

/* Top bar (same look as /chess/analysis/ and /chess/review/) */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 14px;
  background: var(--topbar-bg); border-bottom: 1px solid var(--topbar-border); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; }
.brand-text { min-width: 0; }
.brand h1 { margin: 0; font-size: 18px; color: var(--bright); font-weight: 700; letter-spacing: .02em; }
.tag { margin: 0; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.knight { font-size: 28px; line-height: 1; color: var(--accent); }
.top-actions { display: flex; align-items: center; gap: 8px; }

.btn { background: var(--panel-2); border: 1px solid var(--btn-border); color: var(--bright);
  border-radius: 4px; padding: 6px 10px; cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; gap: 4px; font-size: 14px; touch-action: manipulation; white-space: nowrap; }
.btn:hover { background: var(--btn-hover); }
.btn:disabled, .btn.disabled { opacity: .5; cursor: default; pointer-events: none; }
.btn.primary { background: #3d5c16; border-color: #5a8a22; color: #fff; }
.btn.primary:hover:not(:disabled) { background: #4a701c; }
[data-theme="light"] .btn.primary { background: #5a8a1a; border-color: #4a7a12; }
.btn-icon { font-size: 17px; line-height: 1; min-width: 36px; padding: 5px 8px; }
.small-btn { font-size: 12.5px; padding: 4px 9px; }
.row { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.row.tight { margin-top: 0; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
.card h2 { margin: 0 0 6px; font-size: 16px; color: var(--bright); }

.db-main { width: 100%; max-width: 1180px; margin: 0 auto; padding: 14px 16px 24px; display: flex; flex-direction: column; gap: 12px; }

/* Search form */
input[type=text], input[type=search], input[type=number], select {
  width: 100%; background: var(--input-bg); border: 1px solid var(--border); border-radius: 5px;
  padding: 6px 8px; color: var(--bright); font-size: 14px; min-width: 0; }
input:focus, select:focus { outline: none; border-color: var(--accent); }
.fields { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px 10px; margin-top: 0; }
.field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); position: relative; }
.field > span { font-weight: 600; }
.fields .field:nth-child(1), .fields .field:nth-child(2) { grid-column: span 2; }
.examples { margin: 0 0 10px; line-height: 1.45; }

/* Autocomplete */
.ac-list { position: absolute; top: 100%; left: 0; right: 0; z-index: 50; margin-top: 2px; background: var(--panel);
  border: 1px solid var(--accent); border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.35); max-height: 320px; overflow-y: auto; }
.ac-item { padding: 6px 9px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; color: var(--bright); font-size: 13.5px; }
.ac-item .ac-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.ac-item.active, .ac-item:hover { background: var(--sel); }

.msg { padding: 9px 12px; border-radius: 6px; background: rgba(223,83,83,.14); border: 1px solid rgba(223,83,83,.45); color: var(--bright); font-size: 14px; }
.msg.info { background: rgba(98,153,36,.12); border-color: rgba(98,153,36,.4); }

/* Player card */
.player-card h2 { font-size: 20px; margin-bottom: 2px; }
.player-card .title-badge { color: #e69f00; font-weight: 700; margin-right: 6px; }
.pstats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin: 10px 0; }
.pstat { background: var(--panel-2); border-radius: 6px; padding: 7px 10px; }
.pstat b { display: block; color: var(--bright); font-size: 17px; }
.pstat span { font-size: 12px; color: var(--muted); }
.wdl { font-variant-numeric: tabular-nums; }
.wdl .w { color: var(--win); } .wdl .l { color: var(--loss); } .wdl .d { color: var(--draw); }
.pcols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pcols h3 { margin: 4px 0 4px; font-size: 13px; color: var(--bright); }
.mini { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini td { padding: 3px 4px; border-top: 1px solid var(--border); }
.mini td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mini a { color: var(--bright); text-decoration: none; cursor: pointer; }
.mini a:hover { color: var(--accent); text-decoration: underline; }
.eco-tag { color: var(--muted); font-size: 12px; margin-right: 4px; font-variant-numeric: tabular-nums; }

/* Results */
.results-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.results-head h2 { margin: 0; }
.results-head .btn { margin-left: auto; }
.table-scroll { overflow-x: auto; }
.gtable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.gtable th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 5px 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.gtable td { padding: 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.gtable tbody tr { cursor: pointer; }
.gtable tbody tr:hover, .gtable tbody tr:focus { background: var(--row-hover); outline: none; }
.gtable td.c-date, .gtable td.c-elo, .gtable td.c-moves, .gtable td.c-res, .gtable td.c-eco { white-space: nowrap; font-variant-numeric: tabular-nums; }
.gtable td.c-elo { color: var(--muted); }
.gtable td.c-res { font-weight: 700; color: var(--bright); }
.gtable td.c-event { color: var(--muted); max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gtable .me { color: var(--bright); font-weight: 700; }
.gtable .pname { color: var(--bright); }
.gtable .ttl { color: #e69f00; font-size: 11px; font-weight: 700; margin-right: 3px; }
.gtable .sub { display: none; }
.res-w { color: var(--win) !important; } .res-l { color: var(--loss) !important; } .res-d { color: var(--draw) !important; }
.gtable tr.empty td { text-align: center; color: var(--muted); padding: 18px; cursor: default; }
/* Selection (checkbox column + "Download selected") */
.sel-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-bottom: 6px; }
.sel-info { margin-right: auto; }
.sel-info b { color: var(--bright); }
.link-btn { background: none; border-color: transparent; color: var(--accent); }
.link-btn:hover { background: var(--row-hover); }
.gtable th.c-sel, .gtable td.c-sel { width: 34px; padding: 0; text-align: center; vertical-align: middle; cursor: pointer; }
.gtable .c-sel label { display: flex; align-items: center; justify-content: center; min-height: 34px; padding: 4px 6px; cursor: pointer; }
.gtable .c-sel input { width: 17px; height: 17px; margin: 0; cursor: pointer; accent-color: var(--accent); }
.gtable tbody tr.selected { background: var(--sel); }
.gtable tbody tr.selected:hover { background: var(--sel); }
.pager { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.pager .cur { padding: 0 8px; color: var(--muted); font-size: 13px; }
.loading { opacity: .55; transition: opacity .15s; }

/* Game viewer */
.review-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.game-title { color: var(--bright); font-weight: 600; font-size: 15px; }
.game-layout { display: grid; grid-template-columns: minmax(0, auto) minmax(300px, 1fr); gap: 16px; align-items: start; }
.col-board { width: min(560px, calc(100vh - 210px)); min-width: 280px; }
.board-box { position: relative; }
.pl { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 2px; color: var(--bright); font-weight: 600; font-size: 14px; gap: 8px; }
.pl .elo { color: var(--muted); font-weight: 400; }
.pl .ttl { color: #e69f00; font-size: 12px; font-weight: 700; margin-right: 4px; }
.pl .clr { display: inline-block; width: 11px; height: 11px; border-radius: 50%; border: 1px solid var(--muted); margin-right: 6px; vertical-align: -1px; }
.pl .clr.w { background: #f0f0f0; } .pl .clr.b { background: #111; }
.nav-row { display: flex; gap: 6px; margin-top: 8px; }
.nav-row .btn { flex: 1; }
.btn.nav { font-size: 16px; padding: 6px 4px; }
.col-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.headers table { border-collapse: collapse; font-size: 13px; width: 100%; }
.headers td { padding: 2px 6px 2px 0; vertical-align: top; }
.headers td:first-child { color: var(--muted); white-space: nowrap; width: 1%; }
.headers td:last-child { color: var(--bright); }
.headers .gres { font-size: 18px; font-weight: 700; color: var(--bright); margin-bottom: 4px; }
.moves-card { padding: 6px; }
.moves { max-height: min(420px, calc(100vh - 380px)); min-height: 120px; overflow-y: auto; display: grid; grid-template-columns: 42px 1fr 1fr; font-size: 14px; }
.moves .num { color: var(--muted); padding: 3px 6px; text-align: right; background: var(--panel-2); font-variant-numeric: tabular-nums; }
.moves .mv { padding: 3px 8px; cursor: pointer; color: var(--bright); border-radius: 3px; }
.moves .mv:hover { background: var(--row-hover); }
.moves .mv.cur { background: var(--sel); font-weight: 700; }
.moves .mres { grid-column: 1 / -1; text-align: center; padding: 6px; color: var(--muted); font-weight: 600; }
.moves .warn { grid-column: 1 / -1; color: #e69f00; padding: 6px; font-size: 12.5px; }
#board .hl-from, #board .hl-to { box-shadow: inset 0 0 0 999px var(--hl); }
.ssr-pgn { white-space: pre-wrap; font-size: 12px; }

.seo-about { max-width: 1180px; width: 100%; margin: auto auto 0; padding: 14px 18px 22px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.seo-about h2 { margin: 0 0 4px; font-size: 13px; font-weight: 600; }
.seo-about p { margin: 0 0 6px; max-width: 920px; }

/* Site hamburger menu (same as other chess pages) */
.site-menu-btn { appearance: none; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 32px; padding: 0;
  border-radius: 6px; cursor: pointer; flex-shrink: 0; border: 1px solid var(--topbar-border); background: rgba(128,128,128,.08); color: var(--bright); touch-action: manipulation; }
.site-menu-btn:hover { border-color: var(--accent); background: rgba(98,153,36,.14); }
.site-menu-btn[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.site-menu { position: fixed; inset: 0; z-index: 200; pointer-events: none; }
.site-menu.is-open { pointer-events: auto; }
.site-menu[hidden] { display: none !important; }
.site-menu-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); opacity: 0; transition: opacity .18s ease; }
.site-menu.is-open .site-menu-backdrop { opacity: 1; }
.site-menu-panel { position: absolute; top: 0; right: 0; width: min(300px, 88vw); height: 100%; max-height: 100dvh; overflow-y: auto;
  display: flex; flex-direction: column; gap: .15rem; padding: .9rem .7rem 1.4rem; background: var(--topbar-bg); border-left: 1px solid var(--topbar-border);
  box-shadow: -12px 0 32px rgba(0,0,0,.45); transform: translateX(100%); transition: transform .2s ease; color: var(--bright); }
.site-menu.is-open .site-menu-panel { transform: none; }
.site-menu-section { margin: .75rem .5rem .3rem; padding-top: .5rem; border-top: 1px solid var(--topbar-border); color: var(--muted);
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.site-menu-link { display: block; padding: .65rem .8rem; border-radius: 8px; color: var(--bright); font-weight: 600; font-size: .95rem; text-decoration: none; line-height: 1.25; }
.site-menu-link:hover { background: rgba(128,128,128,.12); }
.site-menu-link.is-current, .site-menu-link[aria-current="page"] { background: rgba(98,153,36,.18); color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
html.site-menu-open { overflow: hidden; }

/* Tablet */
@media (max-width: 980px) {
  .fields { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .game-layout { grid-template-columns: minmax(0, 1fr); }
  .col-board { width: 100%; max-width: 560px; margin: 0 auto; }
  .moves { max-height: 300px; }
  .gtable td.c-event { max-width: 180px; }
}
/* Phone */
@media (max-width: 640px) {
  .topbar { padding: 6px 8px; gap: 6px; }
  .brand h1 { font-size: 16px; }
  .knight { font-size: 24px; }
  .site-menu-btn { width: 32px; height: 30px; }
  .btn { font-size: 13px; padding: 6px 8px; }
  .db-main { padding: 8px 8px 18px; gap: 8px; }
  .card { padding: 10px; }
  .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 8px; }
  .search-card.collapsed .fields .field:nth-child(n+3) { display: none; }
  .pcols { grid-template-columns: 1fr; }
  .gtable { font-size: 13px; }
  .gtable th.c-elo, .gtable td.c-elo, .gtable th.c-event, .gtable td.c-event, .gtable th.c-eco, .gtable td.c-eco, .gtable th.c-moves, .gtable td.c-moves { display: none; }
  .gtable { table-layout: fixed; }
  .gtable th.c-sel { width: 38px; }
  .gtable th:nth-child(2) { width: 21%; } .gtable th:nth-child(7) { width: 13%; }
  .gtable td.c-sel { padding: 0; }
  .gtable .c-sel label { min-height: 44px; padding: 4px; }
  .gtable .c-sel input { width: 20px; height: 20px; }
  .sel-bar { justify-content: flex-start; }
  .sel-info { width: 100%; }
  #btn-dl-sel { flex: 1; }
  .gtable .sub { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .gtable td { padding: 6px 4px; overflow-wrap: anywhere; }
  .gtable td.c-date { font-size: 11.5px; white-space: normal; }
  .gtable td.c-res { text-align: center; }
  .table-scroll { overflow-x: visible; }
  .col-board { min-width: 0; }
}
.more-toggle { display: none; }
@media (max-width: 640px) { .more-toggle { display: inline-flex; } }
