:root {
  --bg: #221c18; --panel: #302822; --panel-2: #3a3029; --line: #4c3f35;
  --text: #f5ecdc; --muted: #beaf96; --accent: #d9a441; --good: #46a05a; --bad: #d2322d;
  --wood-a: #ecd096; --wood-b: #deb87c; --grid: #5c3a1c; --river: #b08a5c;
  --face: #f7e6c4; --edge: #c4a06e; --rim: #aa804e; --red: #ba241e; --black: #1e1a18;
  --hilite: #78aa3c; --speed: 280ms;
  font-family: "Segoe UI", "Noto Sans", Roboto, Arial, sans-serif;
}
body[data-theme="ngoc"] { --wood-a: #cfe3d2; --wood-b: #9fc7ae; --grid: #1f4d3d; --river: #5f9a82; --face: #fbf7ea; --edge: #b9c9b0; --rim: #7da08a; }
body[data-theme="dem"] { --wood-a: #46505c; --wood-b: #323a45; --grid: #c9d3de; --river: #8693a3; --face: #efe7d6; --edge: #b5a88e; --rim: #8a7c62; --hilite: #9fd45a; }
body[data-theme="giay"] { --wood-a: #f6efdc; --wood-b: #ece2c6; --grid: #3b3530; --river: #a59a83; --face: #fffaf0; --edge: #d6c9a8; --rim: #a8997a; }

* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: #6a5848 transparent; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; -webkit-tap-highlight-color: transparent; }
h1, h2, h3 { margin: 0; font-weight: 650; }
h2 { font-size: 15px; margin-bottom: 8px; }
h3 { font-size: 13px; color: var(--muted); margin: 14px 0 6px; font-weight: 600; }
.muted { color: var(--muted); font-weight: 400; font-size: 13px; }
button, select, input, textarea { font: inherit; color: inherit; }
button {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px;
  cursor: pointer; white-space: nowrap; transition: background .15s, transform .05s;
}
button:hover:not(:disabled) { background: #4a3d33; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #2a1c05; font-weight: 650; }
button.primary:hover:not(:disabled) { background: #e8b655; }
button.small { padding: 4px 9px; font-size: 13px; }
/* nút chỉ có biểu tượng, chú thích hiện khi rê chuột hoặc khi chọn bằng bàn phím */
.icon-btn { position: relative; width: 36px; height: 36px; padding: 0; display: inline-grid; place-items: center; flex: none; }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn::after {
  content: attr(data-tip); position: absolute; top: calc(100% + 7px); right: 0; z-index: 40; pointer-events: none;
  background: #14100e; color: var(--text); border: 1px solid var(--accent); border-radius: 6px; padding: 4px 9px;
  font-size: 12.5px; font-weight: 500; white-space: nowrap; opacity: 0; transform: translateY(-3px); transition: opacity .12s .25s, transform .12s .25s;
}
.icon-btn:hover::after, .icon-btn:focus-visible::after { opacity: 1; transform: none; }
.controls .icon-btn::after { top: auto; bottom: calc(100% + 7px); }
.top-actions .icon-btn::after { right: auto; left: 0; } /* nút nằm sát mép trái trang: chú thích mở sang phải */
/* nút bị khóa: chỉ làm mờ hình vẽ, không làm mờ cả nút (nếu không chú thích cũng mờ theo, không đọc được) */
.icon-btn:disabled { opacity: 1; background: transparent; }
.icon-btn:disabled svg { opacity: .32; }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
select, input[type="text"], textarea {
  background: #251e19; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; width: 100%;
}
textarea { resize: vertical; font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 8px 10px; flex-wrap: wrap; min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand h1 { font-size: 19px; }
.logo {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--face); color: var(--red); font-weight: 700; font-size: 19px;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif; box-shadow: inset 0 0 0 2px var(--edge);
}
.opening { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.top-actions { display: flex; gap: 6px; flex: none; }

/* ---------- bố cục ----------
 * Cỡ bàn cờ do app.js (fitBoard) tính từ số đo thật của cửa sổ:
 *   --board-w: bề rộng bàn cờ, --stage-w: cột giữa, --side-w: mỗi cột bên.
 * Máy tính: [tiêu đề + trạng thái + biểu đồ] [bàn cờ] [biên bản], bàn cờ ở chính giữa.
 * Điện thoại (body.mobile): tiêu đề, bàn cờ rộng hết màn hình, các bảng xếp bên dưới. */
main {
  display: grid; justify-content: center; align-items: start; align-content: start;
  grid-template-columns: var(--side-w, 300px) var(--stage-w, 560px) var(--side-w, 300px);
  grid-template-rows: auto 1fr;
  grid-template-areas: "head stage right" "left stage right";
  column-gap: var(--gap, 18px); row-gap: 12px; padding: 8px var(--pad, 16px) 8px;
}
main > .top { grid-area: head; }
.stage { grid-area: stage; width: var(--stage-w, 560px); padding-right: var(--stage-pad, 0px); }
.side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.side.left { grid-area: left; }
.side.right { grid-area: right; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.row.tight { margin-top: 6px; }
.row.end { justify-content: flex-end; margin-top: 16px; }

/* ---------- người chơi ---------- */
.player { display: flex; align-items: center; gap: 8px; padding: 2px 2px 2px var(--eval-w, 32px); min-height: 34px; min-width: 0; }
.player .dot { width: 14px; height: 14px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px var(--line); }
.player .dot.red { background: var(--red); } .player .dot.black { background: #111; }
.player .name { font-weight: 650; white-space: nowrap; flex: 0 1 auto; min-width: 48px; overflow: hidden; text-overflow: ellipsis; }
.player.turn .name::after { content: " ●"; color: var(--accent); animation: blink 1.2s infinite; }
.player .caps { flex: 1 1 0; display: flex; flex-wrap: nowrap; gap: 2px; align-items: center; min-width: 0; overflow: hidden; height: 24px; }
.player .cap {
  width: 22px; height: 22px; border-radius: 50%; background: var(--face); display: grid; place-items: center;
  font-size: 13px; font-weight: 700; box-shadow: inset 0 0 0 1px var(--edge); flex: none;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}
.player .capn { font-size: 11px; color: var(--muted); margin-right: 3px; flex: none; }
.player .cap.red { color: var(--red); } .player .cap.black { color: var(--black); }
body[data-glyph="viet"] .player .cap { font-family: inherit; font-size: 11px; }
.player .diff { color: var(--muted); font-size: 13px; flex: none; white-space: nowrap; }
.player .clock { flex: none; font-variant-numeric: tabular-nums; font-weight: 650; background: #1a1512; border-radius: 6px; padding: 3px 9px; }
.player .clock.low { color: #ff7b6b; }
@keyframes blink { 50% { opacity: .25; } }

/* ---------- bàn cờ ---------- */
.board-row { display: flex; gap: var(--eval-gap, 10px); align-items: stretch; }
.board-col { width: var(--board-w, 500px); flex: none; }
.evalbar {
  width: var(--eval-bar, 22px); flex: none; margin: var(--nums-h, 18px) 0; border-radius: 6px; overflow: hidden; position: relative;
  background: #141110; border: 1px solid var(--line);
}
.eval-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 50%; background: linear-gradient(#d2382f, #a51f1a); transition: height .5s cubic-bezier(.3, .8, .3, 1); }
.evalbar.flip .eval-fill { bottom: auto; top: 0; }
.evalbar::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 2px; background: var(--accent); opacity: .8; }
.eval-num { position: absolute; left: 0; right: 0; text-align: center; font-size: 10px; font-weight: 700; z-index: 1; padding: 3px 0; letter-spacing: -.3px; }
.eval-num.at-red { bottom: 0; color: #fff; } .eval-num.at-black { top: 0; color: #e8dcc6; }
.evalbar.flip .eval-num.at-red { bottom: auto; top: 0; } .evalbar.flip .eval-num.at-black { top: auto; bottom: 0; }
body.no-eval .evalbar, body.no-eval #chartCard { display: none; }
body.no-eval .player { padding-left: 2px; }

.nums { position: relative; height: var(--nums-h, 18px); font-size: 12px; font-weight: 700; color: var(--muted); }
.nums span { position: absolute; top: 50%; transform: translate(-50%, -50%); }
.nums.red span { color: #e17864; }

.board {
  position: relative; width: 100%; aspect-ratio: 9 / 10; border-radius: 2.2% / 2%; container-type: inline-size;
  background: linear-gradient(var(--wood-a), var(--wood-b)); box-shadow: 0 10px 28px rgba(0, 0, 0, .55);
  touch-action: none; user-select: none; -webkit-user-select: none; overflow: hidden;
}
.board svg, .board .layer { position: absolute; inset: 0; width: 100%; height: 100%; }
.board .layer { pointer-events: none; }
#grid .ln { stroke: var(--grid); stroke-width: 2.6; fill: none; stroke-linecap: square; }
#grid .frame { stroke: var(--grid); stroke-width: 4; fill: none; }
#grid text { fill: var(--river); font: 700 50px "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif; text-anchor: middle; dominant-baseline: central; }

.piece {
  position: absolute; width: 10cqw; height: 10cqw; margin: -5cqw 0 0 -5cqw; border-radius: 50%;
  background: radial-gradient(circle at 46% 42%, var(--face) 0 82%, var(--edge) 84% 100%);
  box-shadow: .3cqw .55cqw .8cqw rgba(40, 20, 0, .5), inset 0 -.35cqw .4cqw rgba(120, 80, 30, .25);
  display: grid; place-items: center; font-weight: 700; line-height: 1;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif; font-size: 5.3cqw;
  transition: left var(--speed) cubic-bezier(.25, .8, .25, 1), top var(--speed) cubic-bezier(.25, .8, .25, 1), transform .18s, box-shadow .18s, opacity .25s;
  z-index: 2; will-change: left, top;
}
.piece::before { content: ""; position: absolute; inset: 9%; border-radius: 50%; border: .38cqw solid currentColor; opacity: .8; }
.piece.red { color: var(--red); } .piece.black { color: var(--black); }
.piece span { position: relative; top: -.15cqw; }
body[data-glyph="viet"] .piece { font-family: inherit; font-size: 2.9cqw; letter-spacing: -.05cqw; }
body[data-glyph="viet"] .piece.w2 { font-size: 3.9cqw; } body[data-glyph="viet"] .piece.w5 { font-size: 2.35cqw; }
.piece.notrans { transition: none !important; }
.piece.lift { transform: scale(1.13); z-index: 6; box-shadow: .7cqw 1.3cqw 1.8cqw rgba(40, 20, 0, .5); }
.piece.sel { transform: scale(1.1); z-index: 5; box-shadow: 0 0 0 .5cqw var(--hilite), .5cqw 1cqw 1.4cqw rgba(40, 20, 0, .5); }
.piece.dragging { transition: none !important; transform: scale(1.18); z-index: 9; box-shadow: .9cqw 1.6cqw 2.2cqw rgba(40, 20, 0, .5); cursor: grabbing; }
.piece.captured { animation: captured calc(var(--speed) + 160ms) ease-in forwards; z-index: 1; }
.piece.appear { animation: appear .3s ease-out; }
.piece.in-check { animation: checkpulse .9s ease-in-out infinite; }
.piece.dead { filter: grayscale(1) brightness(.7); transform: rotate(28deg) scale(.92); transition: transform .6s, filter .6s; }
.piece.hanging { box-shadow: 0 0 0 .45cqw #ff9a2e, .3cqw .55cqw .8cqw rgba(40, 20, 0, .5); }
@keyframes captured { 0%, 45% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(.35) rotate(40deg); } }
@keyframes appear { from { opacity: 0; transform: scale(.4); } }
@keyframes checkpulse { 0%, 100% { box-shadow: 0 0 0 .3cqw rgba(230, 40, 30, .9), 0 0 1cqw .4cqw rgba(230, 40, 30, .5); } 50% { box-shadow: 0 0 0 .7cqw rgba(230, 40, 30, .95), 0 0 3cqw 1.4cqw rgba(230, 40, 30, .75); } }

.mark { position: absolute; transform: translate(-50%, -50%); border-radius: 50%; }
.mark.from { width: 4cqw; height: 4cqw; border: .45cqw solid var(--hilite); }
.mark.to { width: 11.2cqw; height: 11.2cqw; border: .5cqw solid var(--hilite); z-index: 1; opacity: .95; }
.mark.dot { width: 3cqw; height: 3cqw; background: var(--hilite); opacity: .85; z-index: 4; box-shadow: 0 0 0 .3cqw rgba(255, 255, 255, .35); animation: appear .15s; }
.mark.ring { width: 11.4cqw; height: 11.4cqw; border: .6cqw solid #e0532f; z-index: 4; animation: appear .15s; }
.mark.burst { width: 10cqw; height: 10cqw; border: .5cqw solid #ffcf66; z-index: 7; animation: burst .45s ease-out forwards; }
@keyframes burst { from { opacity: .95; transform: translate(-50%, -50%) scale(.6); } to { opacity: 0; transform: translate(-50%, -50%) scale(1.9); } }

#arrows { z-index: 8; }
#arrows .arrow { stroke-linecap: round; fill: none; }
#confetti { z-index: 12; }

.flash {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); text-align: center; z-index: 11; pointer-events: none;
  font-size: 11cqw; font-weight: 800; letter-spacing: .6cqw; color: #fff; text-shadow: 0 .4cqw 0 #8e1712, 0 0 3cqw rgba(200, 30, 20, .9); opacity: 0;
}
.flash.show { animation: flash 1.1s ease-out; }
@keyframes flash { 0% { opacity: 0; transform: translateY(-50%) scale(2.2); } 18% { opacity: 1; transform: translateY(-50%) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-50%) scale(1.05); } }

.result {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 13; width: min(86%, 380px);
  background: rgba(34, 28, 24, .95); border: 1px solid var(--accent); border-radius: 14px; padding: 16px; text-align: center;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .6); animation: pop .35s cubic-bezier(.2, 1.4, .4, 1);
}
.result h2 { font-size: 22px; margin-bottom: 2px; } .result .why { color: var(--muted); margin-bottom: 10px; }
.result table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0; }
.result td, .result th { padding: 3px 4px; border-bottom: 1px solid var(--line); text-align: center; font-variant-numeric: tabular-nums; }
.result th:first-child, .result td:first-child { text-align: left; color: var(--muted); font-weight: 400; }
.result .row { justify-content: center; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -50%) scale(.7); } }

/* tên người chơi phía dưới và hàng nút nằm chung một dòng */
.under { display: flex; align-items: center; gap: 8px; min-width: 0; }
.under .player { flex: 1 1 auto; min-width: 0; }
.controls { display: flex; gap: 6px; flex: none; }

/* ---------- bảng bên ---------- */
.status { font-weight: 600; min-height: 22px; display: flex; align-items: center; gap: 8px; }
.spinner { width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.coach { margin-top: 8px; padding: 9px 10px; border-radius: 8px; background: #3d2a1c; border-left: 4px solid #e16e28; font-size: 14px; }
.coach.blunder { border-left-color: var(--bad); background: #40201d; }
.coach.good { border-left-color: var(--good); background: #22352a; }
.coach .row { margin-top: 8px; }
.pv { margin-top: 6px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.pv .ln { display: flex; gap: 8px; } .pv .sc { font-weight: 700; color: var(--text); min-width: 48px; font-variant-numeric: tabular-nums; }
.pv .sw { width: 10px; height: 10px; border-radius: 50%; flex: none; margin-top: 5px; }

#chart { width: 100%; height: 110px; display: block; border-radius: 8px; background: #1a1512; cursor: pointer; }

.moves-card { flex: 1 1 auto; min-height: 150px; display: flex; flex-direction: column; overflow: hidden; }
.movelist { position: relative; flex: 1 1 auto; overflow-y: auto; min-height: 60px; max-height: var(--moves-h, 50vh); font-variant-numeric: tabular-nums; }
.mrow { display: grid; grid-template-columns: 34px 1fr 1fr; align-items: center; }
.mrow .no { color: var(--muted); font-size: 12px; }
.mv { padding: 3px 6px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.mv:hover { background: var(--panel-2); }
.mv.cur { background: var(--accent); color: #2a1c05; font-weight: 650; }
.mv.red-m { color: #f09a8c; } .mv.cur.red-m { color: #7c130e; }
.badge { font-size: 10px; font-weight: 800; border-radius: 4px; padding: 0 4px; line-height: 15px; color: #fff; }
.badge.best { background: #2f8f55; } .badge.good { background: #5d7f4a; } .badge.inacc { background: #c79a22; }
.badge.mistake { background: #e16e28; } .badge.blunder { background: #d2322d; } .badge.mate { background: #7a1612; }
.nav { display: flex; gap: 6px; margin-top: 8px; } .nav button { padding: 5px 10px; }
#navBranch { margin-left: auto; }

/* ---------- xếp thế cờ ---------- */
.palette { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; margin: 8px 0; }
.palette button { padding: 0; aspect-ratio: 1; border-radius: 50%; background: var(--face); font-weight: 700; font-size: 17px; border: 2px solid var(--edge);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif; }
.palette button.red { color: var(--red); } .palette button.black { color: var(--black); }
.palette button.tool { background: var(--panel-2); color: var(--text); font-size: 12px; font-family: inherit; }
.palette button.on { outline: 3px solid var(--hilite); outline-offset: 1px; }
.palette button:hover:not(:disabled) { background: #fff3d6; } .palette button.tool:hover { background: #4a3d33; }
.field { display: block; margin-top: 10px; font-size: 13px; color: var(--muted); }
.field select, .field input[type="text"] { margin-top: 4px; color: var(--text); }
.field input[type="range"] { width: 100%; }
.check { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--accent); }
.msg { color: #ffb48a; font-size: 13px; min-height: 18px; margin-top: 6px; }
.msg.ok { color: #9fd49a; }

/* ---------- hộp thoại ---------- */
/* thân hộp thoại cuộn riêng, hàng nút bên dưới luôn nhìn thấy */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(94vw, 460px); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow: hidden; }
dialog[open] { display: flex; flex-direction: column; }
dialog form { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.dlg-body { padding: 18px 18px 12px; overflow-y: auto; min-height: 0; flex: 1 1 auto; scrollbar-color: #8a7560 transparent; }
.dlg-foot { flex: none; display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--panel-2); }
.dlg-body > p.muted { margin: -6px 0 4px; }
dialog::backdrop { background: rgba(10, 6, 4, .6); }
dialog h2 { font-size: 18px; margin-bottom: 12px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg label { flex: 1 1 0; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; text-align: center; padding: 8px 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); cursor: pointer; white-space: nowrap; }
.seg input:checked + span { background: var(--accent); border-color: var(--accent); color: #2a1c05; font-weight: 650; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type="range"] { accent-color: var(--accent); width: 100%; }
.lib { max-height: 180px; overflow: auto; font-size: 13px; }
.lib .item { display: flex; gap: 8px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--line); }
.lib .item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toast {
  position: fixed; left: 50%; top: 58px; /* phía trên để không che hàng nút dưới bàn cờ */ transform: translateX(-50%); background: #14100e; border: 1px solid var(--accent);
  padding: 10px 16px; border-radius: 10px; z-index: 50; max-width: 92vw; box-shadow: 0 8px 24px rgba(0, 0, 0, .5); animation: appear .2s;
}

/* ---------- cửa sổ vừa (app.js gắn body.two-col): bàn cờ bên trái, mọi bảng gộp một cột bên phải ---------- */
body.two-col main {
  grid-template-columns: var(--stage-w) var(--side-w); grid-template-rows: auto auto 1fr;
  grid-template-areas: "stage head" "stage left" "stage right";
}
body.two-col .top-actions .icon-btn::after { left: auto; right: 0; }

/* ---------- điện thoại / cửa sổ hẹp (app.js gắn body.mobile) ---------- */
body.mobile main {
  grid-template-columns: var(--stage-w); grid-template-rows: auto;
  grid-template-areas: "head" "stage" "left" "right"; row-gap: 8px; padding: 6px var(--pad, 8px) 12px;
}
body.mobile .side { width: var(--stage-w); }
body.mobile .brand h1 { font-size: 17px; } body.mobile .logo { width: 30px; height: 30px; font-size: 17px; }
body.mobile .opening { display: none; }
body.mobile .player { min-height: 30px; font-size: 14px; }
body.mobile .nums { font-size: 11px; }
body.mobile .eval-num { display: none; } /* thanh điểm quá mảnh để ghi số; số điểm vẫn có ở bảng trạng thái */
body.mobile .under { flex-wrap: wrap; row-gap: 4px; }
body.mobile .under .player { flex-basis: 100%; }
/* nút dưới bàn cờ trải đều cả hàng, to dễ bấm */
body.mobile .controls { flex: 1 1 100%; display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; padding-left: var(--eval-w, 0); }
body.mobile .controls .icon-btn { width: auto; height: 44px; }
body.mobile .controls .icon-btn svg { width: 22px; height: 22px; }
body.mobile .icon-btn::after { display: none; } /* màn cảm ứng không rê chuột được */
body.mobile .movelist { max-height: 240px; }
body.mobile .card { padding: 10px; }
@media (prefers-reduced-motion: reduce) {
  .piece, .eval-fill { transition: none; } .piece.in-check, .flash.show { animation-duration: .01s; }
}
