Some checks failed
This commit fixes a visual bug where rows appeared to shrink slightly when a piece was moved and the last-move highlight was applied. Root Cause: 1. Grid used fractional units (1fr) which could cause subpixel recalculations 2. Box-shadow transition was missing, causing jarring visual changes 3. No explicit box-shadow on .last-move class Solution: 1. Changed grid from repeat(8, 1fr) to repeat(8, 75px) for fixed sizing - Prevents browser from recalculating fractional units - Ensures each square is exactly 75px × 75px 2. Added box-shadow to transition property on .square - Changed: transition: background-color 0.2s ease - To: transition: background-color 0.2s ease, box-shadow 0.2s ease - Added default: box-shadow: none 3. Explicitly set box-shadow: none on .square.last-move - Ensures smooth transition when square changes from .selected to .last-move These changes eliminate layout reflow and ensure smooth visual transitions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
139 lines
3.1 KiB
CSS
139 lines
3.1 KiB
CSS
/* Chess Board Styling */
|
|
.chess-board {
|
|
display: grid;
|
|
grid-template-columns: repeat(8, 75px);
|
|
grid-template-rows: repeat(8, 75px);
|
|
width: 600px;
|
|
height: 600px;
|
|
border: 4px solid var(--primary-color);
|
|
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
|
|
background: white;
|
|
}
|
|
|
|
.square {
|
|
position: relative;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
cursor: pointer;
|
|
transition: background-color 0.2s ease, box-shadow 0.2s ease;
|
|
box-shadow: none;
|
|
}
|
|
|
|
.square.light {
|
|
background-color: #f0d9b5;
|
|
}
|
|
|
|
.square.dark {
|
|
background-color: #b58863;
|
|
}
|
|
|
|
.square:hover {
|
|
opacity: 0.8;
|
|
}
|
|
|
|
.square.selected {
|
|
background-color: #baca44 !important;
|
|
box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.3);
|
|
}
|
|
|
|
.square.legal-move::after {
|
|
content: '';
|
|
position: absolute;
|
|
width: 30%;
|
|
height: 30%;
|
|
background-color: rgba(0, 0, 0, 0.2);
|
|
border-radius: 50%;
|
|
pointer-events: none;
|
|
}
|
|
|
|
.square.legal-move.has-piece::after {
|
|
width: 100%;
|
|
height: 100%;
|
|
background-color: transparent;
|
|
border: 4px solid rgba(255, 0, 0, 0.4);
|
|
border-radius: 50%;
|
|
}
|
|
|
|
.square.check {
|
|
background-color: #ff6b6b !important;
|
|
}
|
|
|
|
.square.last-move {
|
|
background-color: rgba(155, 199, 0, 0.4) !important;
|
|
box-shadow: none;
|
|
}
|
|
|
|
/* Coordinates */
|
|
.square.file-label::before,
|
|
.square.rank-label::before {
|
|
position: absolute;
|
|
font-size: 0.7rem;
|
|
font-weight: bold;
|
|
pointer-events: none;
|
|
}
|
|
|
|
.square.file-label::before {
|
|
bottom: 2px;
|
|
right: 4px;
|
|
}
|
|
|
|
.square.rank-label::before {
|
|
top: 2px;
|
|
left: 4px;
|
|
}
|
|
|
|
.square.light::before {
|
|
color: var(--dark-bg);
|
|
}
|
|
|
|
.square.dark::before {
|
|
color: var(--light-bg);
|
|
}
|
|
|
|
/* File labels (a-h) */
|
|
.square[data-file="0"].file-label::before { content: 'a'; }
|
|
.square[data-file="1"].file-label::before { content: 'b'; }
|
|
.square[data-file="2"].file-label::before { content: 'c'; }
|
|
.square[data-file="3"].file-label::before { content: 'd'; }
|
|
.square[data-file="4"].file-label::before { content: 'e'; }
|
|
.square[data-file="5"].file-label::before { content: 'f'; }
|
|
.square[data-file="6"].file-label::before { content: 'g'; }
|
|
.square[data-file="7"].file-label::before { content: 'h'; }
|
|
|
|
/* Rank labels (1-8) */
|
|
.square[data-rank="0"].rank-label::before { content: '1'; }
|
|
.square[data-rank="1"].rank-label::before { content: '2'; }
|
|
.square[data-rank="2"].rank-label::before { content: '3'; }
|
|
.square[data-rank="3"].rank-label::before { content: '4'; }
|
|
.square[data-rank="4"].rank-label::before { content: '5'; }
|
|
.square[data-rank="5"].rank-label::before { content: '6'; }
|
|
.square[data-rank="6"].rank-label::before { content: '7'; }
|
|
.square[data-rank="7"].rank-label::before { content: '8'; }
|
|
|
|
/* Drag and Drop */
|
|
.square.drag-over {
|
|
background-color: rgba(52, 152, 219, 0.3) !important;
|
|
}
|
|
|
|
/* Responsive Board */
|
|
@media (max-width: 768px) {
|
|
.chess-board {
|
|
width: 90vw;
|
|
height: 90vw;
|
|
max-width: 500px;
|
|
max-height: 500px;
|
|
}
|
|
}
|
|
|
|
@media (max-width: 480px) {
|
|
.chess-board {
|
|
border-width: 2px;
|
|
}
|
|
|
|
.square.file-label::before,
|
|
.square.rank-label::before {
|
|
font-size: 0.6rem;
|
|
}
|
|
}
|