feat(ui): floating moves under board, chat full-height right, refined eval bar

Layout (after iterative feedback):
- Two columns: board+eval (left, square) | chat full-height (right).
- Moves row floats just under the board as a compact one-row strip with
  the controls (new game / settings) — replaces the old right sidebar.
- Board sized imperatively via fitBoard + ResizeObserver; eval bar height
  matches the board exactly (no overflow into neighbours).

Eval bar:
- 36px wide (was 28); text fits without pill background.
- System sans-serif, 10.5px / 700 weight, tabular-nums.
- Text positioned on whichever side is winning (bottom-white-half when
  white ahead → dark text; top-black-half when black ahead → light).
- Sign now correct: backend stores raw cp from side-to-move; frontend
  flips when FEN says "b" so the bar always reflects white POV.

Replay:
- evalByFen on the client gets backfilled from /api/state's new `evals`
  list (backend keeps state.eval_cache per game). Clicking past bubbles
  now restores the stockfish eval for that ply.
- renderBoard clears stockfish arrow when no eval is known yet for the
  shown FEN, so the arrow no longer 'lags' onto the next position.

Auto-focus:
- Latest played move is highlighted in both the chat bubble list and
  the moves strip when in live mode (viewPly === null).
- scrollIntoView keeps the active bubble/SAN visible after each move.
This commit is contained in:
ai-chess
2026-05-15 00:17:33 +03:00
parent 3a9ba2ea49
commit 0eec263fd8
14 changed files with 253 additions and 160 deletions
+104 -87
View File
@@ -7,77 +7,67 @@ body {
font-size: 13px;
}
/* ============ layout: 2 columns ============ */
#layout {
display: grid;
grid-template-columns: minmax(280px, 1.1fr) 28px minmax(420px, 700px) minmax(180px, 240px);
grid-template-rows: 1fr 110px;
grid-template-areas:
"chat eval board moves"
"log log log log";
grid-template-columns: minmax(440px, min(900px, 60vw)) minmax(380px, 1fr);
grid-template-rows: 1fr;
grid-template-areas: "board chat";
height: 100vh;
gap: 8px;
padding: 8px;
width: 100vw;
gap: 20px;
padding: 14px;
overflow: hidden;
}
#chat-col { grid-area: chat; min-width: 0; min-height: 0; }
#eval-col { grid-area: eval; min-width: 0; min-height: 0; }
#board-col { grid-area: board; min-width: 0; min-height: 0; }
#moves-col { grid-area: moves; min-width: 0; min-height: 0; }
#log-strip { grid-area: log; min-width: 0; min-height: 0; }
#board-col { grid-area: board; min-width: 0; min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 10px; }
#chat-col { grid-area: chat; min-width: 0; min-height: 0; overflow: hidden; }
/* ----- columns shared header ----- */
.col-header {
display: flex; justify-content: space-between; align-items: center;
padding: 4px 8px; opacity: 0.6; font-size: 11px; text-transform: uppercase;
letter-spacing: 0.08em; border-bottom: 1px solid #2a2a30;
/* ============ board area ============ */
#board-row {
display: flex;
align-items: center;
justify-content: flex-start;
gap: 12px;
flex: 1 1 auto;
min-height: 0;
min-width: 0;
}
#board {
/* size set imperatively by fitBoard() */
background: #444;
border-radius: 4px;
overflow: hidden;
flex: 0 0 auto;
}
#board cg-container { width: 100% !important; height: 100% !important; }
/* ----- chat (left) ----- */
#chat-col { display: flex; flex-direction: column; background: #15151a; border-radius: 6px; overflow: hidden; }
#chat-list {
flex: 1; overflow-y: auto; padding: 8px;
display: flex; flex-direction: column; gap: 6px;
#board-footer {
display: flex; gap: 10px; align-items: center;
padding: 4px 2px;
font-size: 12.5px;
}
.bubble {
padding: 6px 9px 8px;
border-radius: 8px;
border: 1px solid transparent;
cursor: pointer;
line-height: 1.35;
word-wrap: break-word;
transition: outline-color 0.1s ease;
outline: 1px solid transparent;
outline-offset: 2px;
}
.bubble:hover { outline-color: #777; }
.bubble.active { outline-color: #c0a060; }
.bubble-white { background: #f0eee6; color: #16161a; align-self: flex-start; max-width: 92%; }
.bubble-black { background: #1f1e22; color: #e7e5e4; align-self: flex-end; max-width: 92%; border-color: #2a2a30; }
.bubble-meta {
font-size: 10px; opacity: 0.65; margin-bottom: 3px;
display: flex; justify-content: space-between; gap: 6px; align-items: center;
}
.bubble-san { font-weight: 700; opacity: 0.95; }
.bubble-body { font-size: 12.5px; }
.bubble-empty { font-style: italic; opacity: 0.55; }
#status-line { flex: 0 0 auto; opacity: 0.85; }
#sf-pv { flex: 1; opacity: 0.5; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* ----- eval bar (lichess-style two-bar) ----- */
/* ============ eval bar ============ */
#eval-col {
position: relative;
background: #2a2a30; /* the BLACK half — sits at the top */
width: 36px;
flex: 0 0 36px;
background: #2a2a30; /* BLACK half on top */
border-radius: 4px;
overflow: hidden;
box-shadow: inset 0 0 0 1px #3a3a40;
}
/* center reference line (50/50) */
#eval-col::after {
#eval-col::after { /* 50/50 reference line */
content: "";
position: absolute;
left: 0; right: 0; top: 50%;
height: 1px; background: rgba(255,255,255,0.12);
pointer-events: none; z-index: 2;
}
#eval-fill { /* the WHITE half — anchored at bottom */
#eval-fill { /* WHITE half from bottom */
position: absolute;
left: 0; right: 0; bottom: 0;
height: 50%;
@@ -86,59 +76,86 @@ body {
z-index: 1;
}
#eval-text {
position: absolute; left: 0; right: 0; bottom: 4px;
text-align: center; font-size: 10px;
color: #18181c; mix-blend-mode: difference; z-index: 3;
font-weight: 700; letter-spacing: 0.04em;
position: absolute;
left: 0; right: 0;
font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
font-size: 10.5px;
font-weight: 700;
letter-spacing: -0.03em;
text-align: center;
font-variant-numeric: tabular-nums;
pointer-events: none; z-index: 3;
transition: color 0.2s, top 0.4s, bottom 0.4s;
/* default — slight white or even: text near bottom on white half, dark */
bottom: 4px; top: auto;
color: #1a1a1a;
}
#eval-col.advantage-black #eval-text {
bottom: auto; top: 4px; /* flip text to top when black is ahead */
bottom: auto; top: 4px;
color: #e7e5e4;
}
/* ----- board ----- */
#board-col {
display: flex; flex-direction: column; align-items: center; gap: 8px;
min-width: 0; min-height: 0;
}
#board {
width: min(100%, calc(100vh - 220px));
aspect-ratio: 1 / 1;
max-width: 100%;
background: #444;
border-radius: 4px;
/* ============ floating moves panel (below board) ============ */
#moves-floating {
display: flex; align-items: flex-start; gap: 8px;
background: #15151a;
border: 1px solid #2a2a30;
border-radius: 8px;
padding: 6px 10px;
max-height: 84px;
overflow: hidden;
box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
#board cg-container { width: 100% !important; height: 100% !important; }
#board-footer {
display: flex; gap: 8px; align-items: center; width: 100%; padding: 0 4px;
font-size: 12px;
.moves-label {
font-size: 10px; opacity: 0.45; text-transform: uppercase;
letter-spacing: 0.1em; padding-top: 2px; flex: 0 0 auto;
}
#status-line { flex: 0 0 auto; opacity: 0.85; }
#sf-pv { flex: 1; opacity: 0.55; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* ----- moves history ----- */
#moves-col { display: flex; flex-direction: column; background: #15151a; border-radius: 6px; overflow: hidden; }
#history-list {
flex: 1; overflow-y: auto; padding: 4px 8px; margin: 0;
list-style: none;
display: grid; grid-template-columns: 28px 1fr 1fr; row-gap: 1px;
align-content: start;
list-style: none; padding: 0; margin: 0;
display: flex; flex-wrap: wrap; gap: 2px 8px;
font-size: 12.5px; overflow-y: auto; flex: 1;
font-variant-numeric: tabular-nums;
}
#history-list li { padding: 2px 6px; border-radius: 3px; cursor: pointer; font-size: 12.5px; }
#history-list li.ply-num { opacity: 0.4; cursor: default; }
#history-list li { padding: 1px 4px; border-radius: 3px; cursor: pointer; }
#history-list li.ply-num { opacity: 0.4; cursor: default; padding-right: 2px; }
#history-list li:not(.ply-num):hover { background: #25252b; }
#history-list li.active { background: #3d342a; color: #f0d090; }
/* ----- log strip ----- */
#log-strip {
background: #0c0c0e; border: 1px solid #1f1f24; border-radius: 6px;
overflow: auto; padding: 4px 8px;
/* ============ chat panel (right, full height) ============ */
#chat-col { display: flex; flex-direction: column; background: #15151a; border-radius: 8px; overflow: hidden; border: 1px solid #2a2a30; }
.col-header {
display: flex; justify-content: space-between; align-items: center;
padding: 6px 10px; opacity: 0.6; font-size: 10px; text-transform: uppercase;
letter-spacing: 0.1em; border-bottom: 1px solid #2a2a30;
}
#log-text {
font-size: 11px; margin: 0; color: #888; white-space: pre-wrap;
#chat-list {
flex: 1; overflow-y: auto; padding: 10px;
display: flex; flex-direction: column; gap: 8px;
}
.bubble {
padding: 7px 10px 9px;
border-radius: 9px;
border: 1px solid transparent;
cursor: pointer;
line-height: 1.4;
word-wrap: break-word;
transition: outline-color 0.1s ease;
outline: 1px solid transparent;
outline-offset: 2px;
}
.bubble:hover { outline-color: #555; }
.bubble.active { outline-color: #c0a060; }
.bubble-white { background: #f0eee6; color: #16161a; align-self: flex-start; max-width: 92%; }
.bubble-black { background: #1f1e22; color: #e7e5e4; align-self: flex-end; max-width: 92%; border-color: #2a2a30; }
.bubble-meta {
font-size: 10px; opacity: 0.65; margin-bottom: 3px;
display: flex; justify-content: space-between; gap: 6px; align-items: center;
}
.bubble-san { font-weight: 700; opacity: 0.95; }
.bubble-body { font-size: 13px; }
.bubble-empty { font-style: italic; opacity: 0.5; }
/* ----- buttons + dialog ----- */
/* ============ buttons + dialog ============ */
button {
background: #25252b; color: #e7e5e4; border: 1px solid #34343a;
padding: 4px 10px; cursor: pointer; border-radius: 4px; font-size: 12px;