/* ==========================================================================
   KilobyteChess theme — the ONE file that controls the look of the whole site.
   Change the variables in :root to re-skin everything.
   Fonts: Orbitron (headings), Rajdhani (text), Share Tech Mono (code/clocks)
   ========================================================================== */

:root {
  /* Surfaces */
  --bg: #07090f;
  --bg-grid: rgba(0, 229, 255, 0.035);
  --surface: #0d121c;
  --surface-2: #131a28;
  --surface-3: #1a2336;
  --border: #22304a;
  --border-strong: #2f4366;

  /* Text */
  --text: #d8e3f5;
  --text-dim: #8a9bb8;
  --text-faint: #5b6b87;

  /* Accents */
  --accent: #00e5ff;          /* cyan */
  --accent-2: #ff2bd6;        /* magenta */
  --accent-3: #9dff3d;        /* lime */
  --accent-glow: rgba(0, 229, 255, 0.35);
  --warn: #ffb02e;
  --danger: #ff4d6d;
  --ok: #3dffa0;

  /* Board */
  --sq-light: #2a3a57;
  --sq-dark: #16213a;
  --sq-last: rgba(0, 229, 255, 0.28);
  --sq-select: rgba(255, 43, 214, 0.35);
  --sq-target: rgba(157, 255, 61, 0.45);
  --sq-check: rgba(255, 77, 109, 0.55);
  --piece-white: #f4f8ff;
  --piece-black: #0a0d14;
  --piece-white-stroke: #00e5ff;
  --piece-black-stroke: #ff2bd6;

  /* Type */
  --font-display: "Orbitron", "Segoe UI", sans-serif;
  --font-body: "Rajdhani", "Segoe UI", sans-serif;
  --font-mono: "Share Tech Mono", "Consolas", monospace;

  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  --max-width: 1200px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { color-scheme: dark; }

body {
  margin: 0;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 32px 32px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #fff; text-shadow: 0 0 8px var(--accent-glow); }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  line-height: 1.2;
  margin: 0 0 0.6em;
  color: #fff;
}
h1 { font-size: 1.9rem; }
h2 { font-size: 1.3rem; color: var(--accent); }
h3 { font-size: 1.05rem; }

code, pre, .mono { font-family: var(--font-mono); }
code { background: var(--surface-3); padding: 0.1em 0.35em; border-radius: 4px; font-size: 0.92em; color: var(--accent-3); }
pre {
  background: #05070c;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow: auto;
  font-size: 0.86rem;
  line-height: 1.45;
  color: #c9d7ee;
}
pre code { background: none; padding: 0; color: inherit; }

/* ---- Layout -------------------------------------------------------------- */
.container { width: 100%; max-width: var(--max-width); margin: 0 auto; padding: 0 16px; }
main { flex: 1; padding: 28px 0 48px; }

.topbar {
  background: rgba(7, 9, 15, 0.92);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(6px);
}
.topbar .container { display: flex; align-items: center; gap: 22px; height: 60px; }
.brand {
  font-family: var(--font-display); font-weight: 800; font-size: 1.25rem; color: #fff;
  letter-spacing: 0.12em; white-space: nowrap;
}
.brand span { color: var(--accent); text-shadow: 0 0 12px var(--accent-glow); }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav a {
  font-family: var(--font-display); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-dim); padding: 8px 10px; border-radius: var(--radius); white-space: nowrap;
}
.nav a:hover, .nav a.active { color: #fff; background: var(--surface-2); text-shadow: none; }
.userbox { display: flex; gap: 10px; align-items: center; font-size: 0.95rem; white-space: nowrap; }
.userbox form { margin: 0; }

footer { border-top: 1px solid var(--border); color: var(--text-faint); font-size: 0.9rem; padding: 18px 0; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .topbar .container { flex-wrap: wrap; height: auto; padding-top: 8px; padding-bottom: 8px; gap: 8px; }
  .nav { order: 3; flex-basis: 100%; }
}
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.stack > * + * { margin-top: 14px; }

/* ---- Cards & panels ------------------------------------------------------ */
.card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card.glow { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-glow), var(--shadow); }

.hero { padding: 34px 0 20px; }
.hero h1 { font-size: 2.6rem; margin-bottom: 0.2em; }
.hero h1 .accent { color: var(--accent); text-shadow: 0 0 18px var(--accent-glow); }
.hero p { color: var(--text-dim); font-size: 1.2rem; max-width: 720px; }

.stat { font-family: var(--font-display); font-size: 1.6rem; color: #fff; }
.stat-label { color: var(--text-dim); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; }

.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.small { font-size: 0.88rem; }
.center { text-align: center; }

/* ---- Buttons & forms ----------------------------------------------------- */
.btn, button, input[type=submit] {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--font-display); font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase;
  background: transparent; color: var(--accent);
  border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 10px 16px; cursor: pointer; transition: all 0.15s ease;
}
.btn:hover, button:hover, input[type=submit]:hover {
  background: var(--accent); color: #001018; box-shadow: 0 0 16px var(--accent-glow); text-shadow: none;
}
.btn.primary { background: var(--accent); color: #001018; }
.btn.primary:hover { background: #fff; border-color: #fff; }
.btn.secondary { color: var(--accent-2); border-color: var(--accent-2); }
.btn.secondary:hover { background: var(--accent-2); color: #14000f; box-shadow: 0 0 16px rgba(255, 43, 214, 0.4); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.small, button.small { padding: 6px 10px; font-size: 0.68rem; }
.btn.link { border: none; padding: 0; color: var(--accent); }
.btn.link:hover { background: none; color: #fff; box-shadow: none; }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=search],
input[type=url], input[type=datetime-local], select, textarea {
  width: 100%; background: #05070c; color: var(--text); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 9px 11px; font-family: var(--font-body); font-size: 1rem;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
input[type=file] { color: var(--text-dim); font-family: var(--font-body); }
input[type=checkbox] { accent-color: var(--accent); width: 18px; height: 18px; vertical-align: middle; }

.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-weight: 600; margin-bottom: 4px; color: #fff; }
.form-row.check label { display: inline; margin-left: 6px; }
.form-row .help { color: var(--text-faint); font-size: 0.88rem; margin-top: 3px; }
.errorlist { list-style: none; margin: 4px 0; padding: 0; color: var(--danger); font-size: 0.92rem; }
.form-inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.form-inline .form-row { margin: 0; }

/* ---- Tables -------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.97rem; }
th {
  font-family: var(--font-display); font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-dim); text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: rgba(0, 229, 255, 0.03); }
td.num, th.num { text-align: right; font-family: var(--font-mono); }

/* ---- Badges & messages --------------------------------------------------- */
.badge {
  display: inline-block; font-family: var(--font-display); font-size: 0.62rem; letter-spacing: 0.08em;
  text-transform: uppercase; padding: 3px 7px; border-radius: 4px; border: 1px solid var(--border-strong);
  color: var(--text-dim); white-space: nowrap; vertical-align: middle;
}
.badge.live { color: var(--danger); border-color: var(--danger); animation: pulse 1.6s infinite; }
.badge.ok, .badge.passed, .badge.finished { color: var(--ok); border-color: var(--ok); }
.badge.warn, .badge.testing, .badge.queued { color: var(--warn); border-color: var(--warn); }
.badge.bad, .badge.failed, .badge.aborted { color: var(--danger); border-color: var(--danger); }
.badge.agent { color: var(--accent-2); border-color: var(--accent-2); }
.badge.hand { color: var(--accent-3); border-color: var(--accent-3); }
.badge.cls { color: var(--accent); border-color: var(--accent); }
@keyframes pulse { 50% { opacity: 0.45; } }

.messages { list-style: none; padding: 0; margin: 0 0 18px; }
.messages li { padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--border-strong); background: var(--surface-2); margin-bottom: 8px; }
.messages li.success { border-color: var(--ok); }
.messages li.error { border-color: var(--danger); }
.messages li.warning { border-color: var(--warn); }
.notice { border-left: 3px solid var(--warn); background: rgba(255, 176, 46, 0.07); padding: 10px 14px; border-radius: 0 var(--radius) var(--radius) 0; }

/* ---- Chess board --------------------------------------------------------- */
.game-layout { display: grid; grid-template-columns: minmax(0, 560px) minmax(260px, 1fr); gap: 22px; align-items: start; }
@media (max-width: 900px) { .game-layout { grid-template-columns: 1fr; } }

.board-wrap { width: 100%; max-width: 560px; }
.board {
  /* Both axes need explicit equal tracks. With only columns defined, rows are
     implicit "auto" tracks sized by content, so ranks with no pieces collapse. */
  display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(8, minmax(0, 1fr));
  width: 100%; aspect-ratio: 1 / 1;
  border: 2px solid var(--border-strong); border-radius: 4px; overflow: hidden;
  box-shadow: 0 0 0 1px var(--accent-glow), var(--shadow); user-select: none;
}
.sq { position: relative; min-width: 0; min-height: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: clamp(22px, 7.2vw, 54px); line-height: 1; }
.sq.light { background: var(--sq-light); }
.sq.dark { background: var(--sq-dark); }
.sq.last::after, .sq.sel::after, .sq.target::after, .sq.check::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.sq.last::after { background: var(--sq-last); }
.sq.sel::after { background: var(--sq-select); }
.sq.target::after { background: radial-gradient(circle, var(--sq-target) 22%, transparent 24%); }
.sq.check::after { background: radial-gradient(circle, var(--sq-check) 30%, transparent 70%); }
.sq .coord { position: absolute; font-family: var(--font-mono); font-size: 10px; color: var(--text-faint); pointer-events: none; }
.sq .coord.file { right: 3px; bottom: 1px; }
.sq .coord.rank { left: 3px; top: 1px; }
.piece { position: relative; z-index: 1; cursor: default; }
.piece.w { color: var(--piece-white); text-shadow: 0 0 2px var(--piece-white-stroke), 0 0 6px rgba(0, 229, 255, 0.5); }
.piece.b { color: var(--piece-black); text-shadow: 0 0 2px var(--piece-black-stroke), 0 0 1px var(--piece-black-stroke), 0 0 7px rgba(255, 43, 214, 0.6); }
.board.interactive .piece { cursor: pointer; }

.player-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 12px; margin: 8px 0;
}
.player-bar .name { font-weight: 700; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clock {
  font-family: var(--font-mono); font-size: 1.5rem; padding: 2px 10px; border-radius: 4px;
  background: #05070c; border: 1px solid var(--border); color: var(--text-dim); min-width: 96px; text-align: center;
}
.clock.running { color: var(--accent); border-color: var(--accent); box-shadow: 0 0 10px var(--accent-glow); }
.clock.low { color: var(--danger); border-color: var(--danger); }

.movelist {
  font-family: var(--font-mono); font-size: 0.95rem; max-height: 340px; overflow-y: auto;
  display: grid; grid-template-columns: 3em 1fr 1fr; gap: 2px 6px; align-content: start;
}
.movelist .no { color: var(--text-faint); }
.movelist .mv { padding: 1px 4px; border-radius: 3px; cursor: pointer; }
.movelist .mv:hover { background: var(--surface-3); }
.movelist .mv.current { background: var(--accent); color: #001018; }
.movelist .mv sup { font-size: 0.7em; margin-left: 1px; }
.movelist .mv.inaccuracy sup { color: var(--accent-3); }
.movelist .mv.mistake sup { color: var(--warn); }
.movelist .mv.blunder sup { color: var(--danger); }
.movelist .mv.current sup { color: #001018; }
.result-banner { font-family: var(--font-display); font-size: 1.2rem; color: var(--accent-3); }
.controls { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---- Sparkline / charts -------------------------------------------------- */
.spark { width: 100%; height: 80px; }
.spark path.line { fill: none; stroke: var(--accent); stroke-width: 2; }
.spark path.area { fill: rgba(0, 229, 255, 0.08); stroke: none; }
.evalgraph { width: 100%; height: 140px; background: #05070c; border: 1px solid var(--border); border-radius: var(--radius); }
.evalgraph .white-area { fill: rgba(244, 248, 255, 0.75); }
.evalgraph .mid { stroke: var(--border-strong); }

/* ---- Brackets ------------------------------------------------------------ */
.bracket { display: flex; gap: 28px; overflow-x: auto; padding-bottom: 8px; }
.bracket .round { display: flex; flex-direction: column; justify-content: space-around; gap: 14px; min-width: 200px; }
.bracket .round h4 { font-size: 0.72rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.1em; margin: 0 0 4px; }
.match-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; font-size: 0.95rem; }
.match-box .slot { display: flex; justify-content: space-between; gap: 8px; padding: 5px 9px; }
.match-box .slot + .slot { border-top: 1px solid var(--border); }
.match-box .slot.win { color: var(--accent-3); font-weight: 700; }
.match-box .slot .score { font-family: var(--font-mono); }
.match-box.running { border-color: var(--danger); }
.match-box a { color: inherit; }

/* ---- Live TV ------------------------------------------------------------- */
.tv-card { display: flex; flex-direction: column; gap: 6px; color: var(--text); }
.tv-card:hover { border-color: var(--accent); text-shadow: none; }
.tv-board .sq { font-size: clamp(16px, 3.2vw, 34px); }
.tv-board .coord { display: none; }
.clock.small-clock { font-size: 0.95rem; min-width: 64px; padding: 0 6px; }

/* ---- Arrows, dragging ---------------------------------------------------- */
.board svg.arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.board .arrow { stroke-width: 0.17; stroke-linecap: round; opacity: 0.85; }
.board .arrow.best { stroke: var(--accent-3); }
.board .arrow.alt { stroke: var(--accent); opacity: 0.6; }
.board .arrow.bad { stroke: var(--danger); opacity: 0.7; }
.board .ah-best { fill: var(--accent-3); }
.board .ah-alt { fill: var(--accent); }
.board .ah-bad { fill: var(--danger); }
.board.interactive { touch-action: none; }
.piece.ghost { position: fixed; z-index: 100; pointer-events: none; transform: translate(-50%, -50%); text-align: center; line-height: 1; }

/* ---- Analysis board ------------------------------------------------------ */
.analysis-layout { display: grid; grid-template-columns: 34px minmax(0, 560px) minmax(280px, 1fr); gap: 14px; align-items: start; }
@media (max-width: 900px) { .analysis-layout { grid-template-columns: 26px minmax(0, 1fr); } .analysis-side { grid-column: 1 / -1; } }
.evalbar { position: relative; width: 100%; aspect-ratio: 1 / 16; max-height: 560px; background: #0a0d14; border: 1px solid var(--border-strong); border-radius: 4px; overflow: hidden; cursor: pointer; }
.evalbar .fill { position: absolute; left: 0; right: 0; bottom: 0; background: #e8eef9; transition: height 0.3s ease; }
.evalbar .label { position: absolute; left: 0; right: 0; font-family: var(--font-mono); font-size: 11px; text-align: center; z-index: 1; }
.evalbar .label.top { top: 4px; color: #e8eef9; }
.evalbar .label.bottom { bottom: 4px; color: #0a0d14; }
.evalbar.off { opacity: 0.35; }
.engine-lines { font-family: var(--font-mono); font-size: 0.9rem; }
.engine-line { display: flex; gap: 8px; padding: 5px 6px; border-bottom: 1px solid var(--border); cursor: pointer; align-items: baseline; }
.engine-line:hover { background: var(--surface-3); }
.engine-line .ev { min-width: 58px; text-align: center; border-radius: 3px; padding: 0 4px; font-weight: 700; }
.engine-line .ev.white { background: #e8eef9; color: #0a0d14; }
.engine-line .ev.black { background: #05070c; color: #e8eef9; border: 1px solid var(--border-strong); }
.engine-line .pv { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--text-dim); }
.amoves { font-family: var(--font-mono); font-size: 0.93rem; line-height: 1.9; max-height: 360px; overflow-y: auto; }
.amoves .mv { padding: 1px 4px; border-radius: 3px; cursor: pointer; white-space: nowrap; }
.amoves .mv:hover { background: var(--surface-3); }
.amoves .mv.current { background: var(--accent); color: #001018; }
.amoves .no { color: var(--text-faint); margin-left: 4px; }
.amoves .var { color: var(--text-dim); font-size: 0.86rem; }
.amoves .var .mv { color: var(--text-dim); }
.g { font-size: 0.75em; margin-left: 2px; font-weight: 700; }
.g-brilliant { color: #1de9b6; } .g-great { color: #4fa3ff; } .g-best { color: var(--accent-3); } .g-excellent { color: #8fd16a; }
.g-good { color: var(--text-dim); } .g-inaccuracy { color: #f7c948; } .g-mistake { color: var(--warn); } .g-blunder { color: var(--danger); }
.move-verdict { padding: 8px 10px; border-radius: var(--radius); background: var(--surface-3); margin-top: 8px; min-height: 2.4em; }

/* ---- Player bars: ratings, captured pieces, move times --------------------- */
.player-bar .who { display: flex; flex-direction: column; min-width: 0; }
.player-bar .rating { font-family: var(--font-mono); font-size: 0.85rem; color: var(--text-dim); margin-left: 6px; }
.rating .up { color: var(--ok); }
.rating .down { color: var(--danger); }
.rating .cal { color: var(--accent); font-size: 0.8em; }
.captured { min-height: 1.1em; font-size: 1.05rem; line-height: 1.1; white-space: nowrap; overflow: hidden; }
.captured .cap { margin-right: -0.18em; }
.captured .cap.w { color: var(--piece-white); text-shadow: 0 0 2px var(--piece-white-stroke); }
.captured .cap.b { color: var(--piece-black); text-shadow: 0 0 2px var(--piece-black-stroke), 0 0 1px var(--piece-black-stroke); }
.captured .lead { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-dim); margin-left: 6px; }
.mt { color: var(--text-faint); font-size: 0.72em; margin-left: 3px; font-family: var(--font-mono); }
.movelist .mv.current .mt, .amoves .mv.current .mt { color: #003040; }
.analysis-col { display: flex; flex-direction: column; }
.analysis-col .bar-black { order: 0; } .analysis-col #board { order: 1; } .analysis-col .bar-white { order: 2; }
.analysis-col .controls { order: 3; } .analysis-col .move-verdict { order: 4; }
.analysis-col.flipped .bar-black { order: 2; } .analysis-col.flipped .bar-white { order: 0; }


/* ---- Mobile ---------------------------------------------------------------- */
.navtoggle { display: none; }
img, svg, video, canvas { max-width: 100%; }
td, th { overflow-wrap: anywhere; }
th { overflow-wrap: normal; }

@media (max-width: 760px) {
  body { font-size: 16px; }
  .topbar .container { flex-wrap: wrap; height: auto; min-height: 54px; padding-top: 8px; padding-bottom: 8px; gap: 8px 12px; }
  .navtoggle { display: inline-flex; order: 2; margin-left: auto; padding: 6px 12px; font-size: 1.2rem; }
  .userbox { order: 3; font-size: 0.9rem; }
  .nav { display: none; order: 4; flex-basis: 100%; flex-direction: column; gap: 2px; overflow: visible; }
  body.nav-open .nav { display: flex; }
  .nav a { padding: 11px 10px; font-size: 0.8rem; }
  main { padding: 18px 0 36px; }
  h1 { font-size: 1.45rem; }
  h2 { font-size: 1.1rem; }
  .hero { padding: 16px 0 8px; }
  .hero h1 { font-size: 1.8rem; }
  .hero p { font-size: 1.05rem; }
  .card { padding: 14px; }
  .grid { gap: 12px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stat { font-size: 1.3rem; }
  table { font-size: 0.9rem; }
  th, td { padding: 6px 7px; }
  .hide-sm { display: none; }
  .btn, button, input[type=submit] { padding: 10px 14px; }   /* keep a good tap size */
  .row, .spread { gap: 8px; }
  /* Boards fill the width; bars, clocks and move lists stack under them. */
  .game-layout, .analysis-layout { grid-template-columns: 1fr; gap: 14px; }
  .analysis-layout { grid-template-columns: 22px minmax(0, 1fr); }
  .analysis-side { grid-column: 1 / -1; }
  .board-wrap { max-width: 100%; }
  .sq { font-size: clamp(20px, 10.5vw, 46px); }
  .tv-board .sq { font-size: clamp(18px, 9vw, 40px); }
  .player-bar { padding: 6px 8px; margin: 6px 0; }
  .player-bar .rating { font-size: 0.78rem; }
  .clock { font-size: 1.15rem; min-width: 74px; padding: 2px 6px; }
  .movelist, .amoves { max-height: 240px; }
  .controls button { flex: 1 1 auto; }
  .bracket .round { min-width: 170px; }
  pre { font-size: 0.8rem; }
  .form-inline { flex-direction: column; align-items: stretch; }
  footer .container { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 400px) {
  .container { padding: 0 12px; }
  .brand { font-size: 1.05rem; }
  .badge { font-size: 0.56rem; padding: 2px 5px; }
}
