/* 4PC Lab: a dark game UI modelled on chess.com's 4-player screen */
:root {
  --bg: #312e2b;
  --panel: #262421;
  --panel-2: #1f1d1b;
  --line: #3c3936;
  --text: #e6e3df;
  --muted: #9b968f;
  --accent: #81b64c; /* green stays for good news: 1st place, rating up, a win */
  --btn: #3b7fc4; --btn-hover: #4b91d6; --btn-edge: #285c93; /* buttons are blue */
  --mark: #e9a55c;
  --sq-light: #f0d9b5; /* brown by default; the board settings can change it */
  --sq-dark: #b58863;
  --red: #bf3b43;
  --blue: #4185bf;
  --yellow: #c09526;
  --green: #4e9161;
  --dead: #8b8b8b;
  --radius: 8px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button, a.btn {
  font: inherit; color: var(--text); background: #403d39; border: 0; border-radius: 6px;
  padding: 8px 14px; cursor: pointer; font-weight: 600; transition: background .15s, transform .05s;
  box-shadow: 0 3px 0 #2a2826;
}
button:hover, a.btn:hover { background: #4b4844; }
button:active { transform: translateY(2px); box-shadow: 0 1px 0 #2a2826; }
button.primary { background: var(--btn); color: #fff; box-shadow: 0 4px 0 var(--btn-edge); font-size: 1.05rem; }
button.primary:hover { background: var(--btn-hover); }
button:disabled { opacity: .45; cursor: default; }
input, select {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 8px 10px;
}
.mono { font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; }
.muted { color: var(--muted); }

/* top bar */
.nav {
  display: flex; align-items: center; justify-content: center; gap: 4px; padding: 0 18px; min-height: 56px; flex-wrap: wrap;
  background: var(--panel-2); border-bottom: 1px solid #000; position: sticky; top: 0; z-index: 100;
}
/* the logo stays on the left; the tabs are centred on the page */
.logo { font-weight: 800; font-size: 1.3rem; display: flex; align-items: center; gap: 8px; position: absolute; left: 18px; top: 0; height: 56px; }
@media (max-width: 900px) { .logo { position: static; height: auto; margin-right: 12px; } }
.logo img { display: block; }
.logo .tld { font-weight: 500; opacity: .5; margin-left: -6px; }
.nav a.tab { padding: 8px 14px; border-radius: 6px; color: var(--muted); font-weight: 600; }
.nav a.tab:hover { color: var(--text); background: #2c2a27; }
.nav a.tab.active { color: var(--text); background: #3a3734; }

.page { max-width: 1760px; margin: 0 auto; padding: 20px; }
.card { background: var(--panel); border-radius: var(--radius); padding: 16px; }
.card h2 { margin: 0 0 12px; font-size: 1.05rem; }

/* game screen: board + side panel */
/* the board takes what the side panel leaves, capped by the window height so it never runs under the panel */
.game { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 400px); gap: 20px; align-items: start; }
@media (max-width: 1023px) { .game { grid-template-columns: minmax(0, 1fr); } }
.side { display: flex; flex-direction: column; gap: 12px; }

/* board */
.board-wrap { width: 100%; max-width: calc(100vh - 100px); min-width: 280px; margin-left: auto; }
@media (max-width: 1023px) { .board-wrap { margin: 0 auto; } }
.game.wide { grid-template-columns: minmax(0, 1fr) minmax(340px, 520px); }
.game.wide .board-wrap { margin-left: 0; }
/* desktop (from 1024px; narrower screens stack the panel under the board): like chess.com, the board fills the height under the nav (56px + 2x20px padding) unless the
   panel needs the width; board and panel sit together in the middle, and the panel is never taller
   than the board (it scrolls inside), so the page itself doesn't scroll */
@media (min-width: 1024px) {
  /* --board: as tall as the window allows, unless the panel's minimum width needs the room
     (40px page padding + 20px gap + panel minimum + 15px scrollbar) */
  .game { --board: min(calc(100vh - 96px), calc(100vw - 375px)); grid-template-columns: auto minmax(300px, 400px); justify-content: center; }
  .game.wide { --board: min(calc(100vh - 96px), calc(100vw - 415px)); grid-template-columns: auto minmax(340px, 460px); }
  .game .board-wrap { width: var(--board); max-width: none; margin: 0; }
  .game .side { height: var(--board); overflow-y: auto; scrollbar-width: thin; }
  /* the move list takes what the panel has left (the rest keep their size) */
  .game .side > * { flex-shrink: 0; }
  .game .side > .moves { flex: 1 1 0; min-height: 150px; height: auto; max-height: none; }
  /* the opening book: only the panel scrolls, not three boxes inside it */
  .game .side .book-box, .game .side .book-index { max-height: none; overflow: visible; }
}
.board {
  display: grid; grid-template-columns: repeat(14, 1fr); aspect-ratio: 1; user-select: none;
  border-radius: 4px; overflow: hidden; touch-action: none;
}
.sq { position: relative; aspect-ratio: 1; }
.sq.l { background: var(--sq-light); }
.sq.d { background: var(--sq-dark); }
.sq.off { background: transparent; }
.sq.last::before { content: ""; position: absolute; inset: 0; background: rgba(27, 26, 24, .34); }
.sq.sel::before { content: ""; position: absolute; inset: 0; background: rgba(20, 85, 30, .5); }
.sq.check::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle, rgba(255, 0, 0, .95) 0%, rgba(231, 0, 0, .6) 35%, rgba(169, 0, 0, 0) 75%);
}
.sq.dot::after {
  content: ""; position: absolute; left: 36%; top: 36%; width: 28%; height: 28%;
  border-radius: 50%; background: rgba(0, 0, 0, .22); pointer-events: none;
}
.sq.dot.occ::after { left: 4%; top: 4%; width: 92%; height: 92%; background: none; border: max(2px, .4cqw) solid rgba(0, 0, 0, .22); }
.sq.click { cursor: pointer; }

.pc { position: absolute; inset: 4%; z-index: 1; pointer-events: none; }
.pc svg { width: 100%; height: 100%; filter: drop-shadow(0 2px 1px rgba(0,0,0,.35)); }
.pc.moved { animation: slide .18s ease-out; }
@keyframes slide { from { transform: translate(var(--dx), var(--dy)); } to { transform: none; } }
/* a promoted queen (dama, worth 1 point): a queen with a dark "1" coin at its bottom right (symbol D in pieces.svg) */
.c0 { color: var(--red); --seat: var(--red); } .c1 { color: var(--blue); --seat: var(--blue); }
.c2 { color: var(--yellow); --seat: var(--yellow); } .c3 { color: var(--green); --seat: var(--green); }
.pc.dead { color: var(--dead); opacity: .85; }

/* player bars, like chess.com's coloured name plates */
.players { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pbar {
  border-radius: 6px; padding: 6px 10px; color: #fff; position: relative; overflow: hidden;
  display: flex; justify-content: space-between; align-items: center; font-weight: 700;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.25); transition: opacity .2s, outline-color .2s;
  outline: 3px solid transparent; outline-offset: 1px;
}
.pbar.b0 { background: var(--red); } .pbar.b1 { background: var(--blue); }
.pbar.b2 { background: var(--yellow); } .pbar.b3 { background: var(--green); }
.pbar.turn { outline-color: #fff; }
.pbar.out { opacity: .4; filter: grayscale(.6); }
.pbar { gap: 10px; }
.pbar .name { display: flex; align-items: baseline; white-space: nowrap; overflow: hidden; flex: 1; min-width: 0; }
.pbar .elo { font-weight: 500; opacity: .85; font-size: .85rem; margin-left: 6px; }
.pbar .pts { font-size: 1.35rem; font-family: "JetBrains Mono", ui-monospace, monospace; }
.evalbar { position: absolute; left: 0; bottom: 0; height: 4px; background: rgba(255,255,255,.85); transition: width .4s; }

/* move list */
.moves { background: var(--panel-2); border-radius: 6px; height: 320px; overflow-y: auto; padding: 6px 0; font-size: .92rem; }
.mrow { display: grid; grid-template-columns: 38px repeat(4, 1fr); padding: 1px 8px; }
.mrow:nth-child(odd) { background: rgba(255,255,255,.025); }
.mrow .n { color: var(--muted); }
.mv { padding: 1px 4px; border-radius: 3px; cursor: pointer; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mv:hover { background: rgba(255,255,255,.08); }
.mv.cur { background: rgba(255,255,255,.18); }
.mv.p0 { color: #e0565e; } .mv.p1 { color: #5aa0dc; } .mv.p2 { color: #ddb13c; } .mv.p3 { color: #66b07c; }

.controls { display: flex; gap: 6px; justify-content: center; align-items: center; }
.controls button { min-width: 48px; font-size: 1.1rem; white-space: nowrap; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.badge { background: #403d39; border-radius: 4px; padding: 2px 8px; font-size: .8rem; color: var(--muted); }
.badge.green { background: var(--accent); color: #fff; }
.error { color: #ff8b8b; }

/* games table */
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.seg { display: flex; background: var(--panel-2); border-radius: 6px; padding: 3px; }
.seg button { background: none; box-shadow: none; color: var(--muted); padding: 6px 12px; }
.seg button.on { background: #403d39; color: var(--text); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: .85rem; padding: 8px; border-bottom: 1px solid var(--line); }
td { padding: 8px; border-bottom: 1px solid #2c2a27; font-size: .92rem; }
tr.click { cursor: pointer; transition: background .1s; }
tr.click:hover { background: #2e2c29; }
.chip { display: inline-flex; gap: 5px; align-items: baseline; margin-right: 10px; }
.chip i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; align-self: center; }
.chip b { font-weight: 600; }
.chip.win b::after { content: " ★"; color: #f5c84c; }

/* play setup */
.seats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 12px 0; }
.seat { border-radius: 8px; padding: 12px; color: #fff; display: flex; flex-direction: column; gap: 8px; font-weight: 700; }
.seat select { width: 100%; }
.thinking { display: inline-flex; gap: 4px; }
.thinking i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: pulse 1s infinite; }
.thinking i:nth-child(2) { animation-delay: .15s; } .thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes pulse { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }

/* status */
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.stat { font-size: 2rem; font-weight: 800; }
pre.log { background: var(--panel-2); border-radius: 6px; padding: 10px; max-height: 260px; overflow: auto; font-size: .78rem; margin: 8px 0 0; white-space: pre-wrap; }
.chart polyline { fill: none; stroke-width: 2.5; }
.chart text { fill: var(--muted); font-size: 10px; }

/* drag and drop */
.board.can-move { cursor: pointer; }
.pc.dragging { z-index: 10; transition: none; animation: none; filter: drop-shadow(0 8px 6px rgba(0,0,0,.45)); }
.board.grabbing, .board.grabbing * { cursor: grabbing !important; }

/* clocks in the player bars */
.clock { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: .95rem; background: rgba(0,0,0,.28);
  border-radius: 4px; padding: 1px 7px; margin-left: 8px; font-weight: 700; }
.pbar.turn .clock { background: #fff; color: #222; }
.clock.hist { opacity: .5; font-style: italic; }
.clock.low { background: #ff4d4d !important; color: #fff !important; animation: pulse 1s infinite; }
.pbar .right { display: flex; align-items: center; }
.tc { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tc button { box-shadow: none; padding: 6px 12px; background: var(--panel-2); color: var(--muted); }
.tc button.on { background: var(--btn); color: #fff; }
.tc input { width: 70px; }

/* engine arrows (analysis) */
.board { position: relative; }
.arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }
.best { display: flex; flex-direction: column; gap: 6px; }
.best .line { display: grid; grid-template-columns: 26px 1fr 60px; align-items: center; gap: 8px; padding: 6px 10px;
  background: var(--panel-2); border-radius: 6px; cursor: pointer; font-weight: 700; }
.best .line:hover { background: #2e2c29; }
.best .rank { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: .8rem; }
.best .share { text-align: right; color: var(--muted); }
.meter { height: 4px; background: #403d39; border-radius: 2px; overflow: hidden; grid-column: 2 / 4; }
.meter i { display: block; height: 100%; }

/* analysis: players' ratings */
.ratings { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.ratings label { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: .85rem; }
.ratings input { width: 100%; }

/* the Top-3 Formula post fills the page under the navigation bar */
.post-frame { display: block; width: 100%; height: calc(100dvh - 57px); border: 0; background: var(--bg); }

/* analysis: board | side, sized like every game page */
.page:has(.game.analysis) { max-width: none; }
.controls.grid2 { display: grid; grid-template-columns: 1fr 1fr; }
.controls.grid2 button { font-size: .95rem; }
.nav-status { text-align: center; font-size: .82rem; height: 1.2em; margin-top: -4px; }
/* a queued premove */
.sq.pre::before { content: ""; position: absolute; inset: 0; background: rgba(214, 64, 64, .45); pointer-events: none; }

/* who is most likely to win: one segment per player, widths sum to 100% */
.winbar { display: flex; height: 22px; border-radius: 6px; overflow: hidden; margin-bottom: 6px; gap: 2px; grid-column: 1 / -1; } /* spans both player columns */
.winseg { display: flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 700;
          color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6); transition: width .4s; min-width: 4px; }
.winseg.b0 { background: var(--red); } .winseg.b1 { background: var(--blue); }
.winseg.b2 { background: var(--yellow); } .winseg.b3 { background: var(--green); }

/* accounts */
.textbox { font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; width: 100%; box-sizing: border-box; resize: vertical; }
.account { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.post { padding: 10px 0; border-top: 1px solid var(--line); }

/* openings: the book moves scroll inside a box showing about 2-3 entries */
.book-box { max-height: 280px; overflow-y: auto; padding-right: 4px; }
.book-index { max-height: 360px; overflow-y: auto; }
/* the Openings page move history stays short: the book moves and the index matter more there */
.book-history .moves, .book-history > * { max-height: 140px; overflow-y: auto; }

/* sound toggle */
.mute { background: none; border: 0; cursor: pointer; font-size: 1rem; }

/* game-end overlay */
.end-overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(0, 0, 0, .45); animation: end-in .4s ease-out; }
.end-overlay.sad { backdrop-filter: grayscale(1) brightness(.75); -webkit-backdrop-filter: grayscale(1) brightness(.75); background: rgba(20, 20, 30, .5); }
.end-card { background: var(--panel); border-radius: 14px; padding: 22px 26px; max-width: 420px; width: 100%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .4); text-align: center; }
.end-overlay.good .end-card { border: 2px solid var(--accent); }
.end-overlay.good h2 { color: var(--accent); }
.standings { text-align: left; margin: 14px 0; padding-left: 1.6em; }
.standings li { display: flex; justify-content: space-between; padding: 3px 0; }
.standings li.me { font-weight: 700; }
@keyframes end-in { from { opacity: 0; } to { opacity: 1; } }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; }
@media (prefers-reduced-motion: reduce) { .end-overlay { animation: none; } }

/* game review */
table.review { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.review th, table.review td { padding: 4px 6px; text-align: left; border-bottom: 1px solid rgba(128, 128, 128, .2); }
table.review tr.off td { color: var(--red); }
table.review .meter { min-width: 60px; }

/* Study dropdown in the top bar: hover (with a mouse), click/tap or keyboard opens it */
.nav button.tab { background: none; box-shadow: none; padding: 8px 14px; color: var(--muted); font-weight: 600; transform: none; }
.nav button.tab:hover { color: var(--text); background: #2c2a27; }
.nav button.tab.active { color: var(--text); background: #3a3734; }
.dropdown { position: relative; }
.dropdown .menu {
  display: none; position: absolute; top: 100%; left: 0; z-index: 50; min-width: 170px; flex-direction: column; padding: 4px;
  background: var(--panel-2); border: 1px solid #000; border-radius: 6px; box-shadow: 0 6px 18px rgba(0, 0, 0, .5);
}
.dropdown.open .menu { display: flex; }
@media (hover: hover) { .dropdown:hover .menu { display: flex; } }
a.btn { display: inline-block; }

/* coordinates on the edge squares, sized with the board */
.board { container-type: inline-size; }
.coord { position: absolute; z-index: 2; pointer-events: none; font-size: max(7px, 1.5cqw); font-weight: 700; line-height: 1; }
.coord.f { right: 6%; bottom: 4%; }
.coord.r { left: 6%; top: 4%; }
.sq.l .coord { color: var(--sq-dark); }
.sq.d .coord { color: var(--sq-light); }

/* TV: list of games to watch */
.tv-list button { width: 100%; text-align: left; margin-bottom: 6px; }
.tv-list button.on { background: var(--btn); color: #fff; }

/* the viewer's own marks (right-click): soft amber, sharp arrows with a thin outline */
.marks .mark-arrow { fill: var(--mark); fill-opacity: .78; stroke: rgba(40, 22, 0, .55); stroke-width: .035; stroke-linejoin: miter;
  filter: drop-shadow(0 .04px .05px rgba(0,0,0,.45)); }
.marks .mark-ring { fill: none; stroke: var(--mark); stroke-width: .09; stroke-opacity: .85; }
/* while playing, the viewer's marks take their own piece colour */
.marks.mark-c0 { --mark: var(--red); } .marks.mark-c1 { --mark: var(--blue); }
.marks.mark-c2 { --mark: var(--yellow); } .marks.mark-c3 { --mark: var(--green); }


/* analysis: engine lines pop up at the right edge, beside the side column (fixed, so the scrolling column cannot clip it) while the status card is hovered */
.lines-host { position: relative; cursor: help; }
.lines-pop { display: none; position: fixed; top: 76px; right: 16px; width: 400px; max-height: calc(100vh - 90px); overflow-y: auto; z-index: 30; cursor: default; }
.lines-host:hover .lines-pop { display: block; }
@media (max-width: 800px) { .lines-pop { left: 8px; right: 8px; width: auto; } }
.game.analysis .side > .moves { height: 440px; }

.lines-pop { width: 330px; }

/* engine lines: one compact row per line, share on the left, moves in numbered rounds */
.eng { padding: 0; overflow: hidden; }
.eng-head { padding: 8px 12px; font-size: .78rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); border-bottom: 1px solid rgba(255,255,255,.06); }
.eng-empty { margin: 0; padding: 10px 12px; font-size: .85rem; color: var(--muted); }
.eng-row { display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: baseline; padding: 7px 12px;
  border-bottom: 1px solid rgba(255,255,255,.04); }
.eng-row:last-child { border-bottom: 0; }
.eng-row:hover { background: rgba(255,255,255,.03); }
.eng-share { font: 600 .8rem/1.6 "JetBrains Mono", ui-monospace, monospace; text-align: center; border-radius: 4px;
  background: color-mix(in srgb, var(--mover) 22%, transparent); color: #fff; }
.eng-moves { display: flex; flex-wrap: wrap; gap: 2px 8px; font: .8rem/1.6 "JetBrains Mono", ui-monospace, monospace; color: #cfcac3; }
.eng-n { color: var(--muted); margin-left: 2px; }
.eng-m { white-space: nowrap; }
.eng-m i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 4px; vertical-align: 1px; }
.eng-m.first { color: #fff; font-weight: 700; }
.eng-m.mate, .eng-row.mate .eng-share { color: #ff6bdf; }
.lines-pop .eng { background: #1b1a18; border: 1px solid rgba(255,255,255,.12); border-radius: 8px; box-shadow: 0 12px 32px rgba(0,0,0,.55); }

/* menu chevron */
.nav .chev { margin-left: 4px; vertical-align: -2px; transition: transform .15s; }
.dropdown.open .chev { transform: rotate(180deg); }

/* profile, laid out like chess.com's: header card, stat tiles, game history, friends and posts on the side */
.profile { max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.phead { display: flex; gap: 22px; align-items: flex-start; padding: 22px; }
.avatar { width: 112px; height: 112px; flex: none; border-radius: 6px; display: grid; place-items: center;
  font: 800 3.2rem/1 system-ui, sans-serif; color: rgba(255,255,255,.92); box-shadow: inset 0 -4px 0 rgba(0,0,0,.2); }
.pmain { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.pmain h1 { margin: 0; font-size: 1.7rem; }
.pbio { margin: 0; white-space: pre-wrap; color: var(--text); }
.pmeta { display: flex; gap: 22px; flex-wrap: wrap; color: var(--muted); font-size: .92rem; margin-top: auto; }
.pmeta b { color: var(--text); }
.pgrid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.pcol { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.pcol h3 { margin: 0 0 10px; font-size: 1.05rem; }
.pstats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.pstat { background: var(--panel); border-radius: 8px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-height: 92px; }
.pstat-label { color: var(--muted); font-size: .8rem; }
.pstat-value { font-size: 1.6rem; font-weight: 800; display: flex; align-items: baseline; gap: 8px; }
.delta { font-size: .8rem; font-weight: 700; color: var(--accent); }
.delta.down { color: #e05a4f; }
.delta.flat { color: var(--muted); }
.spark { width: 100%; height: 30px; margin-top: auto; }
.spark polyline { fill: none; stroke: #5fb0e8; stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.ghist { padding: 0; overflow: hidden; }
.ghist-title { padding: 14px 18px; font-weight: 700; font-size: 1.1rem; border-bottom: 1px solid var(--line); }
.ghist-empty { padding: 14px 18px; margin: 0; }
.ghist table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.ghist th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px 12px; background: var(--panel-2); }
.ghist td { padding: 10px 12px; border-top: 1px solid rgba(255,255,255,.05); vertical-align: middle; }
.ghist tr:hover td { background: rgba(255,255,255,.025); }
.ghist .tc { color: var(--muted); white-space: nowrap; text-align: center; width: 56px; }
.gplayers { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; color: var(--text); }
.gp { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gp i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.gp.me { font-weight: 700; }
.gpts { display: grid; grid-template-columns: repeat(2, auto); gap: 2px 10px; font-family: "JetBrains Mono", ui-monospace, monospace; color: var(--muted); }
.gpts .me { color: var(--text); font-weight: 700; }
.place { display: inline-block; min-width: 38px; text-align: center; border-radius: 4px; padding: 2px 6px; font-weight: 700; font-size: .8rem; background: #3a3734; color: var(--muted); }
.place.p1 { background: var(--accent); color: #fff; }
.place.p2 { background: #5a7d9a; color: #fff; }
.gdate { color: var(--muted); white-space: nowrap; }
.friends .row { justify-content: space-between; padding: 4px 0; }
button.link { background: none; box-shadow: none; padding: 0; color: var(--muted); font-size: .82rem; }
@media (max-width: 1000px) { .pgrid { grid-template-columns: 1fr; } .pstats { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .phead { flex-direction: column; } .avatar { width: 80px; height: 80px; font-size: 2.2rem; } }

/* login and sign-up, like chess.com's: logo over a centred card on a faint 4PC-board cross */
.auth-page {
  min-height: calc(100dvh - 56px); display: grid; place-items: start center; padding-top: 12vh !important; padding: 32px 16px; box-sizing: border-box;
  background:
    linear-gradient(90deg, transparent 30%, rgba(255,255,255,.025) 30% 70%, transparent 70%),
    linear-gradient(0deg, transparent 30%, rgba(255,255,255,.025) 30% 70%, transparent 70%);
}
.auth { width: 100%; max-width: 400px; display: flex; flex-direction: column; align-items: center; gap: 22px; }
.auth-logo { display: flex; align-items: center; gap: 8px; font-size: 2rem; font-weight: 800; color: var(--text); text-decoration: none; }
.auth-logo .tld { color: var(--muted); font-weight: 600; margin-left: -8px; }
.auth-card { width: 100%; background: var(--panel); border-radius: 10px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.auth-form { display: flex; flex-direction: column; gap: 14px; padding: 32px 32px 26px; }
.auth-form h1 { margin: 0 0 4px; font-size: 1.3rem; text-align: center; }
.auth-field { position: relative; display: flex; align-items: center; }
.auth-field > .auth-ico { position: absolute; left: 13px; color: var(--muted); pointer-events: none; }
.auth-field input { width: 100%; box-sizing: border-box; height: 46px; padding: 0 44px 0 42px; font-size: 1rem;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; color: var(--text); }
.auth-field input:focus { outline: none; border-color: #6b6762; box-shadow: 0 0 0 3px rgba(59,127,196,.35); }
.auth-field:focus-within > .auth-ico { color: var(--text); }
button.auth-eye { position: absolute; right: 6px; background: none; box-shadow: none; padding: 6px; color: var(--muted); line-height: 0; }
button.auth-eye:hover { color: var(--text); background: none; }
button.auth-submit { height: 56px; margin-top: 6px; font-size: 1.35rem; font-weight: 800; border-radius: 8px; }
.auth-error { margin: 0; padding: 9px 12px; border-radius: 6px; background: rgba(224,90,79,.12); color: #f08a80; font-size: .9rem; }
.auth-foot { padding: 16px; text-align: center; font-weight: 600; font-size: .92rem; background: var(--panel-2); color: var(--muted); }
.auth-foot a { color: var(--text); }
.auth-foot a:hover { color: var(--btn-hover); }
.soon { margin-left: 6px; padding: 2px 8px; border-radius: 999px; background: #3a3734; color: var(--muted); font-size: .72rem; font-weight: 600; vertical-align: 2px; }
.dropdown .menu.right { left: auto; right: 0; }
.dropdown .menu button.tab { text-align: left; width: 100%; }
.bio-row { display: flex; gap: 10px; align-items: center; }
.bio-row .textbox { flex: 1; }
.bio-row button, .bio-row .saved { flex: none; min-width: 84px; }
.saved { color: var(--accent); font-weight: 700; text-align: center; animation: fade-in .2s; }
@keyframes fade-in { from { opacity: 0; } }

/* friends page */
.friends-page { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.friends-page h2 { margin: 0 0 12px; font-size: 1.15rem; }
.friends-page .auth-field { margin-bottom: 6px; }
.people { display: flex; flex-direction: column; margin-top: 6px; }
.person { display: flex; align-items: center; gap: 12px; padding: 9px 4px; border-top: 1px solid rgba(255,255,255,.05); }
.person:first-child { border-top: 0; }
.mini-avatar { width: 34px; height: 34px; border-radius: 5px; flex: none; display: grid; place-items: center; font-weight: 800; color: rgba(255,255,255,.92); }
.person-name { font-weight: 700; color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.person-actions { display: flex; align-items: center; gap: 10px; }
button.small { padding: 5px 12px; font-size: .88rem; }
.tag { padding: 3px 9px; border-radius: 999px; background: #3a3734; color: var(--muted); font-size: .78rem; font-weight: 600; }
/* the bio box keeps one size: no dragging it bigger, long words wrap */
.bio-row .textbox { resize: none; height: 64px; overflow-y: auto; overflow-wrap: anywhere; }
.pbio { max-height: 4.8em; overflow-y: auto; overflow-wrap: anywhere; }

.avatar-hash { font-size: .45em; opacity: .6; margin-right: 2px; align-self: center; }
.avatar { display: flex; align-items: center; justify-content: center; }
.pbar a.pname { color: inherit; text-decoration: none; border-bottom: 1px dashed rgba(255,255,255,.55); }
.pbar a.pname:hover { border-bottom-style: solid; }

/* puzzles, laid out like lichess training: info and rating on the left, board, verdict on the right */
.puzzle-page { display: grid; grid-template-columns: 300px auto 340px; gap: 18px; justify-content: center; align-items: start; }
.pz-board .board-wrap { width: min(calc(100vh - 96px), calc(100vw - 760px)); max-width: none; margin: 0; }
.pz-side { display: flex; flex-direction: column; gap: 14px; }
.pz-title { display: flex; gap: 14px; align-items: center; padding-bottom: 14px; border-bottom: 1px solid var(--line); line-height: 1.45; }
.pz-icon { width: 48px; height: 48px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 7px rgba(0,0,0,.25), inset 0 0 0 14px rgba(255,255,255,.2); }
.pz-hard { color: var(--text); }
.pz-game { display: flex; flex-direction: column; gap: 4px; padding-top: 14px; font-size: .92rem; }
.pz-rated { text-align: center; }
.pz-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.pz-big { font-size: 3.2rem; font-weight: 800; line-height: 1.15; letter-spacing: -.02em; }
.pz-delta { font-weight: 800; font-size: 1.15rem; color: var(--accent); animation: pz-pop .35s ease-out; }
.pz-delta.down { color: #e0675c; }
.pz-note { margin: 6px 0 2px; font-size: .9rem; }
@keyframes pz-pop { from { transform: translateY(6px); opacity: 0; } }
.pz-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.pz-stats div { display: flex; flex-direction: column; }
.pz-stats b { font-size: 1.2rem; }
.pz-stats .muted { font-size: .75rem; }
.switch-row { display: flex; gap: 12px; align-items: center; cursor: pointer; font-size: .95rem; }
input.switch { appearance: none; flex: none; width: 42px; height: 24px; border-radius: 12px; background: #4a4643; position: relative; cursor: pointer; transition: background .2s; margin: 0; }
input.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #d6d3d0; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.4); }
input.switch:checked { background: var(--btn); }
input.switch:checked::after { transform: translateX(18px); background: #fff; }
input.switch:focus-visible { outline: 2px solid var(--btn-hover); outline-offset: 2px; }
.pz-panel { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.pz-error { padding: 22px; }
.pz-prompt { display: flex; gap: 12px; align-items: center; padding: 20px 22px; }
.pz-prompt b { font-size: 1.05rem; font-weight: 600; }
.pz-dot { width: 24px; height: 24px; border-radius: 50%; flex: none; box-shadow: 0 0 0 3px rgba(255,255,255,.15); }
.pz-mark { width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: .95rem; font-weight: 700; border: 2px solid #5a5651; color: #bdb8b2; }
.pz-prompt.good .pz-mark { border-color: var(--accent); color: var(--accent); }
.pz-prompt.bad .pz-mark { border-color: #c0453a; color: #c0453a; }
.pz-actions { display: flex; gap: 22px; padding: 4px 22px 22px; }
.pz-actions button.link { text-transform: uppercase; letter-spacing: .05em; font-size: .85rem; font-weight: 700; color: var(--btn-hover); }
.pz-actions button.link:disabled { opacity: .4; cursor: default; }
button.pz-continue { display: block; width: calc(100% - 44px); margin: 0 22px 22px; height: 42px; border-radius: 6px; font-size: .95rem; font-weight: 600; box-shadow: none; }
/* a mated king, cartoon style: a comic "POW" star pops behind it, the king squashes, hops and greys */
.sq.boom { z-index: 5; }
/* the POW star reaches past the board edge (a king mated on the rim): no clipping while it shows */
.board:has(.sq.boom) { overflow: visible; }
.sq.boom .pc { animation: boom-king .6s cubic-bezier(.3,1.6,.5,1); transform-origin: 50% 90%; }
.sq.boom::before { content: ""; position: absolute; inset: -18%; z-index: 0; pointer-events: none; background: #ffd23f;
  clip-path: polygon(50% 0%, 61% 30%, 93% 18%, 72% 45%, 100% 62%, 67% 66%, 72% 100%, 50% 76%, 28% 100%, 33% 66%, 0% 62%, 28% 45%, 7% 18%, 39% 30%);
  filter: drop-shadow(0 0 0 #2b2926); animation: boom-star .7s ease-out forwards; }
.sq.boom::after { content: "POW!"; position: absolute; left: 50%; top: -6%; z-index: 7; pointer-events: none; font: 900 clamp(10px, 1.1vw, 18px)/1 system-ui, sans-serif;
  color: #fff; -webkit-text-stroke: 1.5px #2b2926; paint-order: stroke; transform: translate(-50%, 0) rotate(-12deg); animation: boom-word .9s ease-out forwards; }
@keyframes boom-king { 0% { transform: none; } 20% { transform: scale(1.25, .7); } 45% { transform: translateY(-18%) scale(.9, 1.15) rotate(-8deg); } 70% { transform: scale(1.08, .92); } 100% { transform: none; } }
@keyframes boom-star { 0% { transform: scale(0) rotate(-20deg); opacity: 1; } 35% { transform: scale(1.05) rotate(5deg); opacity: 1; } 100% { transform: scale(1.15) rotate(10deg); opacity: 0; } }
@keyframes boom-word { 0% { transform: translate(-50%, 30%) rotate(-12deg) scale(0); opacity: 0; } 25% { transform: translate(-50%, -30%) rotate(-12deg) scale(1.2); opacity: 1; } 75% { opacity: 1; } 100% { transform: translate(-50%, -60%) rotate(-12deg) scale(1); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sq.boom .pc, .sq.boom::before, .sq.boom::after { animation: none; display: none; } .sq.boom .pc { display: block; } }
@media (max-width: 1300px) { .puzzle-page { grid-template-columns: auto 340px; } .pz-board { grid-column: 1; grid-row: 1 / span 2; } .pz-panel { grid-column: 2; grid-row: 1; } .pz-side { grid-column: 2; grid-row: 2; } .pz-board .board-wrap { width: min(calc(100vh - 96px), calc(100vw - 413px)); } }
@media (max-width: 800px) { .puzzle-page, .pz-side { grid-template-columns: 1fr; } .pz-board, .pz-panel, .pz-side { grid-column: 1; grid-row: auto; } .pz-board { order: -1; } .pz-board .board-wrap { width: 100%; } }

/* player hover card (TV and games), like chess.com's */
.pname-wrap { position: relative; display: inline-block; }
.pname-wrap .pname { color: inherit; text-decoration: none; cursor: pointer; }
.pname-wrap a.pname:hover { text-decoration: underline; }
.pname-wrap .pname.plain { cursor: default; }
.pcard { position: fixed; z-index: 50; pointer-events: none; width: 270px; padding: 14px; border-radius: 8px;
  background: #fff; color: #312e2b; box-shadow: 0 8px 24px rgba(0,0,0,.45); font-weight: 400; white-space: normal; text-shadow: none; }
.pcard .muted { color: #7a756f; font-size: .85rem; }
.pc-head { display: flex; gap: 12px; align-items: flex-start; }
.pc-av { position: relative; width: 56px; height: 56px; flex: none; border-radius: 6px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 1rem; }
.pc-av.none { background: #c9c5c0; font-size: 1.6rem; }
.pc-on { position: absolute; right: -3px; bottom: -3px; width: 14px; height: 14px; border-radius: 50%; background: #5d9d3a; border: 2px solid #fff; }
.pc-name { color: #2f6db5; font-size: 1.05rem; }
.pc-status { color: #7a756f; font-size: .9rem; }
.pc-status.on { color: #5d9d3a; font-weight: 600; }
.pc-row { display: flex; justify-content: space-between; margin-top: 12px; padding-top: 10px; border-top: 1px solid #e3e0dc; }
.pc-row b { color: #2f6db5; font-size: 1.1rem; }
.pc-foot { margin-top: 8px; font-size: .78rem; }
/* long names shrink with an ellipsis; the rating always stays visible */
.pname-wrap { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.pname-wrap .pname { overflow: hidden; text-overflow: ellipsis; }
.pbar .elo { flex: none; }

/* board tools (rotate, settings) in the game's header card */
.board-tools { display: inline-flex; gap: 6px; }
.icon-btn { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; font-size: 1.05rem; }
.settings-wrap { position: relative; }
.settings-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; width: 260px; box-shadow: 0 8px 24px rgba(0,0,0,.45); }
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.theme { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; font-size: .8rem; background: transparent; border: 2px solid transparent; }
.theme.on { border-color: var(--accent); }
.swatch { display: grid; grid-template-columns: 1fr 1fr; width: 40px; height: 40px; border-radius: 4px; overflow: hidden; }
.swatch i { display: block; }

/* leaderboard */
.lb-page { max-width: 640px; }
.lb-title { margin: 0 0 12px; font-size: 1.4rem; }
.lb-tabs { margin-bottom: 14px; }
.lb-sub { text-align: center; margin: 0 0 18px; }
.lb-podium { display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: end; gap: 10px; margin-bottom: 18px; }
.lb-step { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--text); text-decoration: none; }
.lb-step.first { transform: translateY(-14px); }
.lb-step.first .lb-name { color: #f2b632; }
.lb-trophy { width: 40px; height: 40px; }
.lb-step.first .lb-trophy { width: 54px; height: 54px; }
.lb-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-rating { font-weight: 700; }
.lb-av { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 4px; color: #fff; font-weight: 800; font-size: .72rem; flex: none; }
.lb-av.big { width: 64px; height: 64px; font-size: 1rem; }
.lb-list { list-style: none; margin: 0; padding: 0; }
.lb-list li { display: flex; align-items: center; gap: 12px; padding: 7px 8px; border-radius: 6px; }
.lb-list li:nth-child(odd) { background: var(--panel-2); }
.lb-list li.me { outline: 2px solid var(--btn); }
.lb-rank { width: 38px; color: var(--muted); font-weight: 700; }
.lb-user { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 700; text-decoration: none; }
.lb-user:hover { text-decoration: underline; }
.lb-games { font-size: .85rem; }
.lb-score { width: 54px; text-align: right; }
.lb-note { text-align: center; font-size: .85rem; margin: -6px 0 12px; }
/* lobby */
.lobby-h { margin: 14px 0 8px; }
.lobby-list { display: flex; flex-direction: column; gap: 8px; }
.lobby-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--panel-2); border-radius: 6px; }
.lobby-seats { display: grid; grid-template-columns: 12px 12px; gap: 2px; flex: none; }
.lobby-seats i { width: 12px; height: 12px; border-radius: 2px; }
.lobby-seats i.free { opacity: .35; }
.lobby-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lobby-info .muted { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lobby-count { font-size: .85rem; }
/* captured pieces */
.caps-list { display: flex; flex-direction: column; gap: 3px; padding: 6px 8px; background: var(--panel-2); border-radius: 6px; grid-column: 1 / -1; }
.caps-row { display: flex; align-items: center; gap: 6px; min-height: 18px; font-size: .8rem; }
.caps-row > i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.caps-row > i.b0 { background: var(--red); } .caps-row > i.b1 { background: var(--blue); } .caps-row > i.b2 { background: var(--yellow); } .caps-row > i.b3 { background: var(--green); }
.caps { display: flex; flex-wrap: nowrap; overflow: hidden; flex: 1; min-width: 0; }
.stat-link { color: inherit; text-decoration: none; } .stat-link:hover { text-decoration: underline; }
.watchers { position: relative; }
.watchers > button { background: none; border: 0; color: inherit; cursor: pointer; padding: 0 4px; }
.watch-pop { position: absolute; right: 0; top: 120%; z-index: 30; background: var(--panel); border: 1px solid rgba(127,127,127,.3); border-radius: 6px; padding: 8px 10px; min-width: 160px; box-shadow: 0 6px 18px rgba(0,0,0,.3); display: flex; flex-direction: column; gap: 4px; }
.mref { background: rgba(127,127,127,.18); padding: 0 3px; border-radius: 3px; }
.cap { position: relative; width: 16px; height: 16px; margin-right: -3px; }
.cap .pc { inset: 0; }
/* game chat */
.chat { display: flex; flex-direction: column; gap: 6px; padding: 10px; }
.chat-log { max-height: 220px; min-height: 90px; overflow-y: auto; font-size: .9rem; }
.chat-line { margin: 2px 0; word-wrap: break-word; }
.chat-sys { margin: 2px 0; font-style: italic; opacity: .7; font-size: .85rem; }
.chat-form input { width: 100%; box-sizing: border-box; }
.mref { font-weight: 700; text-decoration: underline dotted; cursor: pointer; }
/* rules help */
.help-card { width: min(1240px, 95vw); max-width: none; max-height: 94vh; overflow-y: auto; text-align: left; position: relative; padding: 22px 26px; box-sizing: border-box; }
.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; margin-top: 10px; }
.help-sec { background: rgba(127,127,127,.1); border-radius: 8px; padding: 12px 14px; font-size: .92rem; }
.help-sec h3 { margin: 0 0 6px !important; }
.help-card h3 { margin: 14px 0 4px; font-size: 1rem; }
.help-card ul { margin: 0; padding-left: 20px; line-height: 1.5; }
.help-card code { background: rgba(127,127,127,.18); padding: 0 4px; border-radius: 3px; }
.help-x { position: absolute; top: 10px; right: 10px; background: none; border: 0; font-size: 1.1rem; cursor: pointer; color: inherit; }
/* end-of-game card */
.end-card2 { background: #fff; color: #222; border-radius: 10px; overflow: hidden; width: min(380px, 92vw); box-shadow: 0 20px 50px rgba(0,0,0,.45); animation: pop .25s ease-out; }
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
.end-head { position: relative; padding: 26px 20px 18px; text-align: center; color: #fff; }
.end-head.b0 { background: var(--red); } .end-head.b1 { background: var(--blue); } .end-head.b2 { background: var(--yellow); } .end-head.b3 { background: var(--green); }
.end-head h2 { margin: 12px 0 0; font-size: 1.6rem; }
.end-x { position: absolute; top: 10px; right: 12px; background: none; border: 0; color: #fff; font-size: 1.2rem; cursor: pointer; }
.end-av { width: 72px; height: 72px; font-size: 1.1rem; border-radius: 8px; margin: 0 auto; display: grid; place-items: center; box-shadow: 0 0 0 3px rgba(255,255,255,.6); }
.end-rows { padding: 16px 22px 6px; display: flex; flex-direction: column; gap: 10px; }
.end-row { display: flex; align-items: center; border-radius: 6px; }
.end-row.me { outline: 2px solid rgba(0,0,0,.15); outline-offset: 3px; }
.end-av-sm { width: 46px; height: 46px; border-radius: 6px 0 0 6px; display: grid; place-items: center; font-size: .75rem; flex: none; }
.end-pts { width: 62px; height: 46px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 1.15rem; border-radius: 0 6px 6px 0; }
.end-pts.b0 { background: var(--red); } .end-pts.b1 { background: var(--blue); } .end-pts.b2 { background: var(--yellow); } .end-pts.b3 { background: var(--green); }
.end-who { display: flex; flex-direction: column; margin-left: 14px; min-width: 0; line-height: 1.35; }
.end-who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.end-who .up { color: #3d8b2f; font-weight: 700; } .end-who .down { color: #c0392b; font-weight: 700; }
.end-actions { display: flex; justify-content: center; gap: 10px; padding: 16px 0 20px; }
.end-actions button { min-width: 96px; }
.bio-row { white-space: pre-line; }
.site-foot { display: flex; justify-content: center; gap: 18px; padding: 28px 0 20px; font-size: .8rem; opacity: .55; }
.site-foot a { color: inherit; text-decoration: none; } .site-foot a:hover { text-decoration: underline; }
.privacy ul { line-height: 1.6; } .privacy h3 { margin-top: 20px; }
.friend-list { display: flex; flex-direction: column; gap: 6px; } .friend-item { padding: 8px 10px; background: var(--panel-2); border-radius: 6px; }
/* game library */
.lib { max-width: 1200px; margin: 0 auto; }
.lib-grid { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 14px; margin-top: 12px; align-items: start; }
@media (max-width: 860px) { .lib-grid { grid-template-columns: 1fr; } }
.lib-import { display: flex; flex-direction: column; gap: 10px; }
.lib-import h3 { margin: 0; }
.lib-list { display: flex; flex-direction: column; gap: 6px; max-height: 70vh; overflow-y: auto; margin-top: 10px; }
.lib-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 8px 10px; background: var(--panel-2); border-radius: 6px; align-items: center; }
.lib-seats { display: flex; gap: 10px; flex-wrap: wrap; font-weight: 600; font-size: .9rem; }
.lib-seats span { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-meta { grid-column: 1; font-size: .82rem; } .lib-meta .up { color: #3d8b2f; } .lib-meta .down { color: #c0392b; }
.lib-actions { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 6px; }
.btn.small { padding: 4px 9px; font-size: .82rem; }
/* captures in the board's empty corners (3x3 squares each) */
.corner-caps { position: absolute; width: 21.4%; height: 21.4%; box-sizing: border-box; padding: 1.2%; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 2px 6px; pointer-events: none; z-index: 2; }
.corner-caps.bl { left: 0; bottom: 0; } .corner-caps.tl { left: 0; top: 0; } .corner-caps.tr { right: 0; top: 0; } .corner-caps.br { right: 0; bottom: 0; }
/* packed toward the capturer: bottom seat -> bottom-left of its corner, left seat -> top-left,
   top seat -> top-right, right seat -> bottom-right */
.corner-caps.br { align-content: flex-end; justify-content: flex-start; }
.corner-caps.bl { align-content: flex-start; justify-content: flex-start; }
.corner-caps.tl { align-content: flex-start; justify-content: flex-end; }
.corner-caps.tr { align-content: flex-end; justify-content: flex-end; }
.cc { display: inline-flex; align-items: flex-end; }
.cc .cap { position: relative; width: clamp(14px, 2.2vw, 26px); height: clamp(14px, 2.2vw, 26px); }
.cc .cap .pc { inset: 0; }
.cc small { font-size: .62rem; font-weight: 700; opacity: .85; margin-left: -2px; }
.cc-pts { width: 100%; font-size: .75rem; opacity: .8; }
.corner-caps.tl .cc-pts, .corner-caps.tr .cc-pts { text-align: right; }
.danger-btn { background: #a33a32; color: #fff; } .danger-btn:hover { background: #bf4339; }
.menu a.tab.danger { color: #e07a70; }
/* board editor */
/* same size as the board on the game pages */
.editor { display: grid; grid-template-columns: auto minmax(300px, 400px); gap: 20px; align-items: start; justify-content: center; }
.ed-board-wrap { width: min(calc(100vh - 96px), calc(100vw - 520px)); min-width: 280px; }
@media (min-width: 801px) { .ed-side { max-height: calc(100vh - 96px); overflow-y: auto; scrollbar-width: thin; } }
@media (max-width: 800px) { .editor { grid-template-columns: 1fr; } .ed-board-wrap { width: 100%; } }
.ed-board { display: grid; grid-template-columns: repeat(14, 1fr); aspect-ratio: 1; width: 100%; border-radius: 4px; overflow: hidden; user-select: none; }
.ed-sq { position: relative; cursor: pointer; }
.ed-sq.light { background: var(--sq-light); } .ed-sq.dark { background: var(--sq-dark); } .ed-sq.off { background: transparent; cursor: default; }
.ed-sq:hover:not(.off) { box-shadow: inset 0 0 0 3px rgba(129,182,76,.7); }
.ed-side { display: flex; flex-direction: column; gap: 12px; }
.ed-palette { display: flex; flex-direction: column; gap: 4px; }
.ed-row { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.ed-tool { position: relative; aspect-ratio: 1; padding: 0; background: var(--panel-2); box-shadow: none; }
.ed-tool .pc { inset: 8%; }
.ed-tool.on, .ed-erase.on { background: var(--accent); }
label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
label.field input { width: 100%; box-sizing: border-box; padding: 10px 12px; font-weight: 400; }
.nav .tab.mute { padding-inline: 8px; }
.nav .dropdown.sound { margin-right: 6px; } /* the account button sat over it */
.admin-users { overflow-x: auto; }
.admin-users table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.admin-users th, .admin-users td { padding: 6px 10px; text-align: left; border-bottom: 1px solid #3c3936; white-space: nowrap; }
.admin-users th { color: var(--muted); font-weight: 600; }
/* Live now: about five games in view, the rest by scrolling */
.tv-list { max-height: 330px; overflow-y: auto; }
.tv-list button { display: flex; justify-content: space-between; gap: 8px; width: 100%; }
.tv-list .tv-elo { color: var(--muted); font-size: .85em; font-weight: 400; }
.admin h3 { margin: 22px 0 8px; }
.admin-msg { background: #2b3a22; border-radius: 6px; padding: 8px 12px; }
.admin-set { gap: 12px; align-items: end; flex-wrap: wrap; }
.admin-set label { display: flex; flex-direction: column; gap: 4px; }
.admin-set input { width: 90px; }
.admin-act { display: flex; gap: 6px; }
.admin-act button { padding: 4px 10px; }
.playing-now { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.live-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #e0565e; margin-right: 8px; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
/* the engine's candidate moves: dark and thin, not competing with the pieces */
@media (max-width: 1023px) { .game.wide { grid-template-columns: minmax(0, 1fr); } }
/* profile rating charts */
.pstat-click { cursor: pointer; border-radius: 6px; transition: background .15s; }
.pstat-click:hover { background: rgba(255,255,255,.05); }
.modal-back { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 16px; }
.rating-chart { width: min(720px, 100%); display: flex; flex-direction: column; gap: 10px; box-shadow: 0 12px 40px rgba(0,0,0,.5); }
.rating-chart button.on { border-color: var(--accent); color: var(--accent); }
.rc-svg { width: 100%; height: auto; cursor: crosshair; }
.rc-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.rc-grid { stroke: rgba(255,255,255,.08); }
.rc-label { fill: var(--muted); font-size: 11px; }
.rc-cross { stroke: rgba(255,255,255,.35); stroke-dasharray: 3 3; }
.rc-dot { fill: var(--accent); stroke: #1b1a18; stroke-width: 2; }
.rc-info { font-size: .85rem; min-height: 1.2em; }
/* review fixes: no sideways shift between pages; clean history rows; phones */
.ghist td { border-bottom: 0; }
@media (max-width: 640px) {
  .nav { position: static; gap: 2px; }
  .nav a.tab, .nav .tab { padding: 6px 9px; }
  .gplayers { grid-template-columns: 1fr; }
  .ghist .gdate, .ghist .tc { display: none; }
  .lb-list .lb-av { display: none; }
  .pz-board { order: -1; }
  .nav a.tab, .nav .tab { min-height: 40px; display: inline-flex; align-items: center; }
  .post-frame { height: calc(100dvh - 80px); }
  /* the board runs edge to edge, like chess.com (the 4PC corners are empty anyway) */
  .page > .game > .board-wrap, .page > .game > div > .board-wrap { margin-inline: -20px; width: calc(100% + 40px); min-width: 0; max-width: none; }
  /* player bars: room for the names next to points and clock */
  .pbar { gap: 2px 6px; padding-inline: 8px; flex-wrap: wrap; }
  /* the whole name on its own line, points and clock under it */
  .pbar .name { flex-basis: 100%; font-size: .9rem; }
  .pbar .right { margin-left: auto; }
  .pbar .pts { font-size: 1rem; }
  .pbar .clock { padding: 2px 6px; font-size: .95rem; }
  .moves { font-size: .8rem; }
}
/* the move list: room for long moves like "Bh11xNi10+" */
.mrow { grid-template-columns: 28px repeat(4, 1fr); padding: 1px 4px; }
.mv { padding: 1px 2px; }
/* dark scrollbars, selects and form controls everywhere */
:root { color-scheme: dark; }
/* touch screens: every control at least 40px to tap */
@media (pointer: coarse) {
  .icon-btn, .seg button, button.auth-eye, .btn.small, .pz-actions .link, .watchers > button { min-height: 40px; min-width: 40px; }
  a.lb-user, .auth-foot a, .site-foot a, .stat-link { display: inline-block; padding-block: 9px; }
}
/* nav sound menu: switches and the music volume */
.dropdown .menu.sound-menu { min-width: 220px; gap: 4px; padding: 8px 14px; }
.sound-menu .switch-row { min-height: 40px; }
.dropdown.sound > .mute { min-width: 40px; min-height: 40px; }
.sound-menu input[type=range] { width: 100%; margin: -4px 0 0; accent-color: var(--btn); }
.sound-menu:focus { outline: none; } /* tabindex=-1 only so clicks on its padding keep the menu open */
/* the turn's colour glows softly around the board and fades into the next player's (a registered
   colour property, so the colour itself can transition) */
@property --turn { syntax: "<color>"; inherits: true; initial-value: transparent; }
@property --urg { syntax: "<number>"; inherits: true; initial-value: 0; }
.board-wrap { position: relative; isolation: isolate; transition: --turn 1.6s ease, --urg 1s linear; }
.board-wrap::before {
  content: ""; position: absolute; z-index: -1; pointer-events: none; border-radius: 50%;
  /* --urg 0..1: a clock running out makes the glow stronger and spread over more of the page */
  inset: calc(-3% - 14% * var(--urg));
  background: radial-gradient(closest-side, color-mix(in srgb, var(--turn) calc(38% + 47% * var(--urg)), transparent) 60%, transparent);
  filter: blur(calc(28px + 20px * var(--urg)));
}
/* the last seconds: a slow pulse, to catch the eye of a player who looked away */
.board-wrap.critical::before { animation: glow-pulse 1.1s ease-in-out infinite; }
@keyframes glow-pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .board-wrap { transition: none; } .board-wrap.critical::before { animation: none; } }
.page { overflow-x: clip; } /* the board glow never widens the page */
.page:has(.board-wrap) { overflow: clip; } /* nor lengthens it when it grows under time pressure */
/* engine arrows: smooth faded near-black, no outline or shadow */
.marks.engine { --mark: #1b1a18; }
.marks.engine .mark-arrow { fill-opacity: 1; stroke: none; filter: none; }
/* each player's latest move in a soft grey; the very last move a little darker */
.sq.lm0::before, .sq.lm1::before, .sq.lm2::before, .sq.lm3::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .32; }
.sq.lm0::before, .sq.lm1::before, .sq.lm2::before, .sq.lm3::before { background: #1b1a18; opacity: .2; }
