:root {
  --bg: #12161c;
  --panel: #1a2029;
  --panel-2: #212936;
  --line: #2c3645;
  --text: #e8ecf2;
  --muted: #93a0b4;
  --accent: #3ec9a7;
  --accent-ink: #06201a;
  --danger: #ef6b6b;
  --warn: #f0b429;
  --radius: 10px;
  --bs: 100%;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.err { color: var(--danger); min-height: 1.2em; }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }

/* ---------- header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 18px; letter-spacing: .2px; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.btn { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; cursor: pointer; transition: background .12s, border-color .12s, transform .05s; white-space: nowrap; }
.btn:hover:not(:disabled) { background: #2a3445; border-color: #3a4659; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
.btn.primary:hover:not(:disabled) { background: #5ad8b9; border-color: #5ad8b9; }
.btn.danger { color: var(--danger); }
.btn.icon { padding: 7px 11px; min-width: 40px; }
.btn.small { padding: 4px 9px; font-size: 13px; }
.btn:focus-visible, .mv:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible, .moves:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 22px; max-width: 1320px; margin: 0 auto; padding: 18px 16px 40px; align-items: start; }
.board-col { width: min(100%, calc(100vh - 215px)); min-width: 300px; margin: 0 auto; }
.board-wrap { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; align-items: stretch; margin: 6px 0; }
.board-box { position: relative; aspect-ratio: 1 / 1; }

/* ---------- players ---------- */
.player { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 4px; min-height: 40px; }
.pl-avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: var(--panel-2); border: 1px solid var(--line); }
.pl-main { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; }
.pl-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 0 1 auto; }
.pl-badges { display: inline-flex; gap: 4px; align-items: center; flex: 0 0 auto; }
.pl-cap { display: flex; align-items: center; min-height: 22px; font-size: 12px; color: var(--muted); min-width: 0; overflow: hidden; }
.pl-think { color: var(--accent); font-size: 13px; animation: pulse 1s infinite alternate; flex: 0 0 auto; }
@keyframes pulse { from { opacity: .35; } to { opacity: 1; } }
.pl-cap img { width: 17px; height: 17px; margin-right: -7px; }
.pl-cap .adv { margin-left: 12px; font-weight: 650; }
.clock { font: 600 20px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; min-width: 88px; text-align: right; }
.clock.active { background: #e8ecf2; color: #12161c; border-color: #e8ecf2; }
.clock.low { color: var(--danger); }
.clock.active.low { background: var(--danger); color: #fff; border-color: var(--danger); }
.player.turn .pl-name::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 8px; }
/* GM watermark on the Stockfish side (ELO above 2280) */
.player.gm .pl-name::after { content: "GM"; display: inline-block; margin-left: 8px; padding: 1px 5px; border: 1px solid #d8b45a; border-radius: 4px; color: #e9c877; background: rgba(216, 180, 90, .12); font: 700 10px/1.3 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .06em; vertical-align: 1px; }
.board.gm-top::after, .board.gm-bottom::after { content: "GM"; position: absolute; left: 50%; transform: translateX(-50%); color: rgba(232, 200, 119, .22); font: 800 clamp(22px, 4vw, 46px)/1 Georgia, serif; letter-spacing: .12em; pointer-events: none; z-index: 1; }
.board.gm-top::after { top: 28%; }
.board.gm-bottom::after { bottom: 28%; }

/* ---------- eval bar ---------- */
.evalbar { position: relative; background: #14171d; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.ev-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 50%; background: #eceff4; transition: height .25s ease; }
.evalbar.flipped .ev-fill { bottom: auto; top: 0; }
.ev-label { position: absolute; left: 0; right: 0; text-align: center; font: 700 10px/1 ui-monospace, Menlo, Consolas, monospace; padding: 4px 0; white-space: nowrap; }
.ev-label.white-side { color: #12161c; bottom: 0; }
.ev-label.black-side { color: #e8ecf2; top: 0; }
.evalbar.flipped .ev-label.white-side { bottom: auto; top: 0; }
.evalbar.flipped .ev-label.black-side { top: auto; bottom: 0; }

/* ---------- board ---------- */
.board { --light: #eeeed2; --dark: #769656; --last: rgba(246, 246, 105, .55); --sel: rgba(246, 246, 105, .7);
  display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); width: 100%; height: 100%; border-radius: 6px; overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: none; box-shadow: 0 6px 24px rgba(0, 0, 0, .35); }
.board[data-theme="forest"] { --light: #eeeed2; --dark: #769656; }
.board[data-theme="walnut"] { --light: #f0d9b5; --dark: #b58863; }
.board[data-theme="ocean"] { --light: #dee3e6; --dark: #6d8aa3; }
.board[data-theme="slate"] { --light: #d4d6da; --dark: #7b8290; }
.board[data-theme="rose"] { --light: #f3e1e1; --dark: #c47f8e; }
.sq { position: relative; background: var(--light); display: flex; align-items: center; justify-content: center; }
.sq.d { background: var(--dark); }
.sq.last::before, .sq.sel::before { content: ""; position: absolute; inset: 0; background: var(--last); }
.sq.sel::before { background: var(--sel); }
.sq.check { background: radial-gradient(circle, rgba(255, 60, 60, .95) 0%, rgba(255, 60, 60, .6) 40%, transparent 72%), var(--light); }
.sq.d.check { background: radial-gradient(circle, rgba(255, 60, 60, .95) 0%, rgba(255, 60, 60, .6) 40%, transparent 72%), var(--dark); }
.sq.hover::after { content: ""; position: absolute; inset: 2px; border: 4px solid rgba(255, 255, 255, .6); border-radius: 4px; }
.sq .pc { position: relative; width: 100%; height: 100%; z-index: 2; pointer-events: none; -webkit-user-drag: none; }
.sq .pc.opp { transform: rotate(180deg); }
/* Move-quality symbol (! !!) in the mover's square corner. */
.sq .nag { position: absolute; right: 2px; bottom: 0; z-index: 5; font-size: clamp(13px, 3.1vmin, 28px); font-weight: 900; line-height: 1; pointer-events: none; text-shadow: 0 1px 2px #000, 0 0 4px #000; }
.sq .nag.brilliant { color: #2ee6c8; } .sq .nag.great { color: #7be36b; }
.sq .nag.inaccuracy { color: #f2c744; } .sq .nag.mistake { color: #ff9f55; } .sq .nag.blunder { color: #ff6f6f; }
/* Checkmate markers: red # on the mated king, green crown on the winner's. */
.sq .km { position: absolute; top: 0; right: 3px; z-index: 6; width: clamp(15px, 3.4vmin, 30px); height: clamp(15px, 3.4vmin, 30px); font-size: clamp(15px, 3.4vmin, 30px); font-weight: 900; line-height: 1; pointer-events: none; text-shadow: 0 1px 3px #000, 0 0 4px #000; }
.sq .km-lose { color: #ff4040; } .sq .km-win { color: #3ef07e; filter: drop-shadow(0 1px 2px #000); }
.sq .km-win svg { display: block; width: 100%; height: 100%; }
.sq i { position: absolute; z-index: 3; pointer-events: none; }
.sq i.dot { width: 30%; height: 30%; border-radius: 50%; background: rgba(20, 30, 20, .28); }
.sq i.cap { inset: 0; border-radius: 50%; background: radial-gradient(circle, transparent 58%, rgba(20, 30, 20, .28) 60%); }
.sq .co { position: absolute; font: 700 clamp(9px, 1.6vmin, 13px)/1 system-ui, sans-serif; pointer-events: none; z-index: 1; }
.sq .co.rk { top: 3px; left: 4px; }
.sq .co.fl { bottom: 3px; right: 4px; }
.sq.l .co { color: var(--dark); }
.sq.d .co { color: var(--light); }
.ghost { position: fixed; z-index: 1000; pointer-events: none; transform: translate(-50%, -50%); filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .45)); }
.sq.dragging .pc { opacity: .3; }

.arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 4; }

.promo { position: absolute; z-index: 10; width: 12.5%; height: 50%; background: #f2f2f2; border-radius: 6px; box-shadow: 0 8px 30px rgba(0, 0, 0, .6); display: flex; flex-direction: column; }
.promo.up { flex-direction: column-reverse; }
.promo button { flex: 1 1 0; border: 0; background: transparent; padding: 0; cursor: pointer; border-radius: 50%; }
.promo button:hover { background: rgba(62, 201, 167, .45); }
.promo img { width: 100%; height: 100%; }
.promo-shade { position: absolute; inset: 0; z-index: 9; background: rgba(0, 0, 0, .35); }
.mate-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; border-radius: 4px; }

.board-controls { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; padding-left: 36px; }
.board-controls .sep { flex: 1; }

/* ---------- side ---------- */
.side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.opening { font-weight: 650; }
.status { margin-top: 4px; color: var(--muted); min-height: 1.3em; }
.status.over { color: var(--text); font-weight: 650; font-size: 16px; }
.status .tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 650; margin-right: 6px; }
.tag.blunder { background: #ef6b6b33; color: #ff9a9a; } .tag.mistake { background: #f08a3a33; color: #ffb277; } .tag.inaccuracy { background: #f0b42933; color: #f6cd63; }
.tag.brilliant { background: #2ee6c833; color: #5ff2d8; } .tag.great { background: #7be36b33; color: #9cf08c; }
.status-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.status-actions:empty { display: none; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch .slider { width: 36px; height: 20px; border-radius: 999px; background: #3a4659; position: relative; transition: background .15s; flex: none; }
.switch .slider::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::after { transform: translateX(16px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }
label.inline { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
select, input[type=text], input[type=number], textarea { background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; }

.engine-stat { color: var(--muted); font-size: 12.5px; margin-bottom: 6px; min-height: 1.3em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.engine-lines { overflow: hidden; }
.eline { display: flex; gap: 10px; align-items: center; box-sizing: border-box; height: 46px; padding: 4px 0; border-top: 1px solid var(--line); }
.eline:first-child { border-top: 0; }
.ev { flex: none; min-width: 54px; text-align: center; font: 700 13px/1.6 ui-monospace, Menlo, Consolas, monospace; border-radius: 6px; padding: 0 6px; background: #e8ecf2; color: #12161c; }
.ev.neg { background: #2b323d; color: #e8ecf2; }
.pv { font-size: 13.5px; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pv .n { color: var(--muted); margin-right: 2px; }
.pv a { cursor: pointer; margin-right: 5px; border-radius: 3px; }
.pv a:hover { background: var(--panel-2); color: var(--accent); }

/* every legal move, chess.com style — fixed height so rewriting never shifts the card */
.am-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 8px 0 4px; padding-top: 8px; border-top: 1px solid var(--line); }
.am-head b { font-size: 13px; }
.am-head span { white-space: nowrap; }
.engine-all { height: 168px; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; }
.am-row { display: flex; align-items: center; gap: 8px; height: 25px; padding: 0 4px; border-radius: 4px; cursor: pointer; }
.am-row:hover { background: var(--panel-2); }
.am-row.best { background: #2b6f5f33; }
.am-row.best .am-san { color: #6ee0bd; font-weight: 700; }
.am-san { flex: none; width: 44px; font: 600 13px ui-monospace, Menlo, Consolas, monospace; }
.am-meter { flex: 1; min-width: 20px; height: 9px; border-radius: 3px; background: #2b323d; overflow: hidden; }
.am-meter i { display: block; height: 100%; background: #e8ecf2; border-radius: 3px; }
.am-eval { flex: none; width: 48px; text-align: right; font: 600 12px ui-monospace, Menlo, Consolas, monospace; }

.moves-card { display: flex; flex-direction: column; }
.moves { max-height: 300px; min-height: 120px; overflow: auto; line-height: 1.9; padding: 2px; border-radius: 6px; }
.moves .mn { color: var(--muted); margin: 0 3px 0 6px; font-size: 13px; }
.mv { display: inline-block; padding: 0 6px; border-radius: 5px; cursor: pointer; font-weight: 550; }
.mv:hover { background: var(--panel-2); }
/* Every review class is colour-coded in the move list, with a symbol where useful. */
.mv.book, .mv.book .g { color: #c48b57; }
.mv.brilliant, .mv.brilliant .g { color: #2ee6c8; }
.mv.great, .mv.great .g { color: #7be36b; }
.mv.best, .mv.best .g { color: #7bd88f; }
.mv.excellent, .mv.excellent .g { color: #6fd3a0; }
.mv.good, .mv.good .g { color: #a9c47b; }
.mv.inaccuracy, .mv.inaccuracy .g { color: #f2c744; }
.mv.mistake, .mv.mistake .g { color: #ff9f55; }
.mv.blunder, .mv.blunder .g { color: #ff6f6f; }
.mv .g { font-weight: 800; margin-left: 2px; }
.mv.cur { background: var(--accent); color: var(--accent-ink); }
.mv.cur .g { color: var(--accent-ink); }
.var { margin: 2px 0 2px 10px; padding-left: 10px; border-left: 2px solid var(--line); color: #c0c9d6; font-size: 14px; line-height: 1.7; }
.move-actions { display: flex; gap: 8px; margin-top: 8px; }

.review-out .accs { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; text-align: center; margin: 6px 0 10px; align-items: center; }
.acc { font-size: 24px; font-weight: 750; }
.acc small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.review-out table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 8px; }
.review-out td { padding: 2px 4px; } .review-out td:nth-child(2) { text-align: center; color: var(--muted); } .review-out td:nth-child(1) { text-align: right; width: 22%; } .review-out td:nth-child(3) { width: 22%; }
.graph { width: 100%; height: 86px; display: block; border-radius: 6px; background: #14171d; cursor: pointer; }
.progress { position: relative; height: 22px; background: var(--panel-2); border-radius: 6px; overflow: hidden; margin-bottom: 8px; }
.progress .bar { position: absolute; inset: 0 auto 0 0; width: 0; background: #2b6f5f; transition: width .2s; }
.progress span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: #e8ecf2; color: #12161c; padding: 9px 16px; border-radius: 10px; box-shadow: 0 8px 30px rgba(0, 0, 0, .5); z-index: 100; font-weight: 550; max-width: 90vw; }
body.cookie-open .toast { bottom: calc(104px + env(safe-area-inset-bottom, 0px)); }

/* ---------- cookie notice ---------- */
.cookie-banner { position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 120; width: min(640px, calc(100vw - 24px)); display: flex; align-items: center; gap: 16px; padding: 14px 16px; background: var(--panel); border: 1px solid var(--accent); border-radius: 12px; box-shadow: 0 14px 40px #000a; }
.cookie-copy { flex: 1; min-width: 0; }
.cookie-copy strong { display: block; margin-bottom: 3px; }
.cookie-copy p { margin: 0; color: var(--muted); font-size: 13px; }
.cookie-banner .btn { flex: none; }

/* ---------- dialogs ---------- */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px; width: min(560px, 94vw); box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
dialog::backdrop { background: rgba(5, 8, 12, .65); backdrop-filter: blur(2px); }
dialog h2 { margin: 0 0 12px; font-size: 20px; }
dialog fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 12px; padding: 8px 12px; }
dialog legend { color: var(--muted); font-size: 12.5px; padding: 0 6px; }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 16px 0 0; }
dialog textarea { width: 100%; font: 13px/1.5 ui-monospace, Menlo, Consolas, monospace; resize: vertical; }
dialog textarea.drop { outline: 2px dashed var(--accent); }
.row { display: flex; gap: 12px; align-items: flex-end; margin: 10px 0; }
.row.wrap { flex-wrap: wrap; align-items: center; }
.row label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.row label.choice { flex-direction: row; align-items: center; color: var(--text); }
.grow { flex: 1; min-width: 0; }
.grow input[type=text], .grow select { width: 100%; }
.choice { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; }
.sf-pick { display: grid; gap: 2px; }
.sf-pick .choice { padding: 2px 0; }
.sf-status { padding: 2px 0; }
.sf-status.bad { color: var(--danger); }
.sf-local { padding: 4px 0 6px; }
#newElo { width: 9em; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 8px; }
.grid2 label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.btn.file { display: inline-block; }
.setup { display: grid; grid-template-columns: minmax(0, 1fr) 96px; gap: 12px; }
/* piece SVG editor */
.editor { display: grid; grid-template-columns: 108px minmax(0, 1fr); gap: 14px; }
.editor-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; align-content: start; }
.editor-grid button { display: flex; align-items: center; justify-content: center; aspect-ratio: 1; padding: 2px; border: 2px solid transparent; border-radius: 7px; background: var(--panel-2); cursor: pointer; }
.editor-grid button.on { border-color: var(--accent); }
.editor-grid img { width: 100%; height: 100%; }
.editor-main { min-width: 0; }
.editor-preview { float: right; width: 68px; height: 68px; margin: 0 0 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: #e8ecf2; display: flex; align-items: center; justify-content: center; }
.editor-preview img { width: 100%; height: 100%; }
.editor-main textarea { width: 100%; box-sizing: border-box; font: 12px/1.45 ui-monospace, Menlo, Consolas, monospace; resize: vertical; min-height: 190px; clear: both; }
.editor-main .row { margin: 8px 0 0; }
.err { color: #ff9a9a; }
.ok { color: #6ee0bd; }

.small-board { aspect-ratio: 1 / 1; height: auto; }
.palette { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; align-content: start; }
.palette button { background: var(--panel-2); border: 2px solid transparent; border-radius: 8px; padding: 2px; cursor: pointer; aspect-ratio: 1; }
.palette button.on { border-color: var(--accent); }
.palette img { width: 100%; height: 100%; }
.palette .erase { grid-column: span 2; aspect-ratio: auto; padding: 6px; font-size: 13px; }

.engine-card.locked { opacity: .6; }
.engine-card.locked .card-head { filter: grayscale(1); }

/* ---------- online play / account ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.tab { background: none; border: 0; padding: 7px 11px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tab.on { color: var(--text); border-color: var(--accent); font-weight: 650; }
.tab-panel { min-height: 120px; }
.tab-panel hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.room-code { font: 800 34px ui-monospace, Menlo, Consolas, monospace; letter-spacing: 8px; color: var(--accent); text-align: center; padding: 8px; background: var(--panel-2); border-radius: 8px; margin-top: 10px; }
.friend-list { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow: auto; }
.friend { display: flex; align-items: center; gap: 8px; padding: 7px 9px; background: var(--panel-2); border-radius: 7px; }
.friend .dot { width: 8px; height: 8px; border-radius: 50%; background: #5b6675; flex: none; }
.friend .dot.on { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.friend .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend .elo { color: var(--muted); font-size: 12px; }
.friend .btn { padding: 3px 8px; font-size: 12px; }
.req { display: flex; align-items: center; gap: 8px; padding: 6px 9px; border: 1px dashed var(--line); border-radius: 7px; margin-bottom: 6px; }
.req .who { flex: 1; }
.chat-log { height: 190px; overflow: auto; background: var(--panel-2); border-radius: 8px; padding: 8px; margin: 8px 0; display: flex; flex-direction: column; gap: 5px; }
.parrot-screen { height: 190px; overflow: auto; background: #05070a; color: #f8f9fa; border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin: 8px 0; font: 11px/1.05 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre; }
.parrot-screen .ansi-30 { color: #495057; } .parrot-screen .ansi-31 { color: #ff6b6b; }
.parrot-screen .ansi-32 { color: #51cf66; } .parrot-screen .ansi-33 { color: #ffd43b; }
.parrot-screen .ansi-34 { color: #74c0fc; } .parrot-screen .ansi-35 { color: #da77f2; }
.parrot-screen .ansi-36 { color: #66d9e8; } .parrot-screen .ansi-37 { color: #f8f9fa; }
.parrot-screen .ansi-90 { color: #adb5bd; } .parrot-screen .ansi-91 { color: #ffa8a8; }
.parrot-screen .ansi-92 { color: #8ce99a; } .parrot-screen .ansi-93 { color: #ffe066; }
.parrot-screen .ansi-94 { color: #91a7ff; } .parrot-screen .ansi-95 { color: #e599f7; }
.parrot-screen .ansi-96 { color: #9cdbfa; } .parrot-screen .ansi-97 { color: #fff; }
.chat-line { font-size: 13px; }
.chat-line b { color: var(--accent); margin-right: 5px; }
.chat-line.self b { color: var(--warn); }
.chat-empty { color: var(--muted); font-size: 13px; }
.profile-card { background: var(--panel-2); border-radius: 8px; padding: 12px; margin-bottom: 10px; }
.profile-card .big { font-size: 20px; font-weight: 700; }
.profile-card .elo { font-size: 28px; font-weight: 800; color: var(--accent); }
.profile-card .stats { display: flex; gap: 14px; color: var(--muted); font-size: 13px; margin-top: 4px; }
.profile-head { display: flex; align-items: center; gap: 12px; }
.mini-avatar, .friend-avatar, .profile-avatar { object-fit: cover; flex: none; background: #1a2029; }
.mini-avatar { width: 20px; height: 20px; border-radius: 5px; vertical-align: -5px; }
.friend-avatar { width: 26px; height: 26px; border-radius: 6px; }
.profile-avatar { width: 64px; height: 64px; border-radius: 12px; border: 1px solid var(--line); }
.avatar-tools { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.twofa-card { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.twofa-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.twofa-state { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.twofa-state.on { color: #8affb9; background: #07291a; border: 1px solid #26ff96; }
.twofa-state.off { color: var(--muted); background: #1a2029; border: 1px solid var(--line); }
.twofa-setup { margin: 10px 0; padding: 10px; background: #1a2029; border: 1px solid var(--line); border-radius: 8px; }
.twofa-qrwrap { display: flex; justify-content: center; margin: 8px 0; }
.twofa-qrwrap canvas { background: #fff; padding: 8px; border-radius: 8px; width: 180px; height: 180px; image-rendering: pixelated; }
.or { text-align: center; color: var(--muted); font-size: 12px; margin: 12px 0 6px; position: relative; }
.or::before, .or::after { content: ""; position: absolute; top: 50%; width: 32%; height: 1px; background: var(--line); }
.or::before { left: 0; } .or::after { right: 0; }
.invite-pop { position: fixed; right: 14px; bottom: 14px; z-index: 30; background: var(--panel); border: 1px solid var(--accent); border-radius: 10px; padding: 12px 14px; box-shadow: 0 8px 30px #0008; }
.invite-pop .row { margin-top: 8px; }

/* role badges */
.role-badge { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 999px; font-size: 10px; font-weight: 800; letter-spacing: .04em; line-height: 1.5; vertical-align: middle; white-space: nowrap; }
.role-badge.owner { color: #fff; text-shadow: 0 0 4px #000, 0 0 8px #fff; background: linear-gradient(90deg, #ff1744, #ff9100, #ffe600, #00e676, #00d4ff, #b400ff, #ff1744); background-size: 300% 100%; animation: owner-rainbow 3s linear infinite; box-shadow: 0 0 7px #ff3d81, 0 0 15px #00d4ff99; }
@keyframes owner-rainbow { to { background-position: 300% 0; } }
.role-badge.admin { color: #8affb9; background: #07291a; border: 1px solid #26ff96; text-shadow: 0 0 5px #26ff96; box-shadow: 0 0 6px #26ff96, inset 0 0 6px #26ff9655; }
.role-badge.bot { color: #c3ceff; background: #111733; border: 1px solid #7284ff; text-shadow: 0 0 5px #7284ff; box-shadow: 0 0 6px #7284ff66, inset 0 0 6px #7284ff33; }
.role-badge.agent { color: #9ffcff; background: #061e24; border: 1px solid #3ef0ff; text-shadow: 0 0 6px #3ef0ff; box-shadow: 0 0 8px #3ef0ff66, inset 0 0 6px #3ef0ff33; }
.role-badge.gm { color: #fff; background: #3b0a0a; border: 1px solid #ff4d4d; text-shadow: 0 0 5px #ff4d4d; box-shadow: 0 0 6px #ff4d4d66, inset 0 0 6px #ff4d4d33; }
.pl-badges .role-badge, #btnAccount .role-badge { margin-left: 4px; font-size: 9px; }
.admin-list { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow: auto; }
.admin-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 7px 9px; background: var(--panel-2); border-radius: 7px; }
.admin-row .who { flex: 1; min-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-row .meta { color: var(--muted); font-size: 12px; }
.admin-row .btn { padding: 3px 8px; font-size: 12px; }
.admin-row.banned { opacity: .6; text-decoration: line-through; }

.pocket { display: inline-flex; gap: 2px; margin-left: 6px; align-items: center; flex-wrap: wrap; }
.pocket-pc { width: 22px; height: 22px; cursor: pointer; filter: drop-shadow(0 1px 1px #0008); }
.pocket-pc:hover { transform: scale(1.12); }
.pocket-pc.sel { outline: 2px solid var(--accent); border-radius: 4px; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 10px 10px 40px; }
  .board-col { width: 100%; max-width: 680px; }
  .side { max-width: 680px; margin: 0 auto; width: 100%; }
  .moves { max-height: 200px; }
}
@media (max-width: 520px) {
  .top { padding: 8px 10px; }
  .btn { padding: 6px 9px; }
  .board-wrap { grid-template-columns: 14px minmax(0, 1fr); gap: 6px; }
  .player { padding-left: 20px; }
  .board-controls { padding-left: 20px; }
  .clock { font-size: 17px; min-width: 74px; }
  .ev-label { display: none; }
  .cookie-banner { flex-direction: column; align-items: stretch; gap: 10px; padding: 13px 14px; }
  .cookie-banner .btn { width: 100%; }
  body.cookie-open .toast { bottom: calc(160px + env(safe-area-inset-bottom, 0px)); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- recent login ---------- */
.recent-accounts { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.recent-account { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; color: var(--text); cursor: pointer; }
.recent-account:hover { border-color: var(--accent); }
.recent-account img { width: 42px; height: 42px; border-radius: 10px; object-fit: cover; background: #1a2029; flex: none; }
.recent-account .meta { min-width: 0; flex: 1; }
.recent-account .name { font-weight: 650; }
.recent-account .sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-selected-card { display: flex; align-items: center; gap: 12px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.recent-sel-avatar { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; background: #1a2029; flex: none; }
.recent-sel-name { font-size: 18px; font-weight: 700; }
.recent-sel-meta { min-width: 0; }
