/* Chess Board Styles */
.chess-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 600px;
    height: 600px;
    position: relative;
    transition: transform 0.6s ease;
}

/* Flipped board for black perspective */
.chess-board.flipped {
    transform: rotate(180deg);
}

/* Flip pieces back when board is flipped so they appear upright */
.chess-board.flipped .chess-piece:not(.animating-piece) {
    transform: rotate(180deg);
}

/* Flip coordinate labels back when board is flipped */
.chess-board.flipped .chess-square::before,
.chess-board.flipped .chess-square::after {
    transform: rotate(180deg);
}

/* Flip all interactive elements back when board is flipped */
.chess-board.flipped .square-highlight,
.chess-board.flipped .legal-move,
.chess-board.flipped .square-highlight-red,
.chess-board.flipped .square-highlight-green,
.chess-board.flipped .move-indicator,
.chess-board.flipped .check-indicator,
.chess-board.flipped .promotion-overlay,
.chess-board.flipped .drag-preview,
.chess-board.flipped .square-winner-bg,
.chess-board.flipped .square-loser-bg {
    transform: rotate(180deg);
}

/* Keep dragging pieces upright and positioned correctly */
.chess-piece.dragging {
    transform: none !important;
    position: fixed !important;
    z-index: 1000 !important;
    pointer-events: none !important;
    /* Completely escape the board's transform context */
    transform-origin: 0 0 !important;
}

/* Ensure dragging pieces are never rotated, regardless of board state */
.chess-board.flipped .chess-piece.dragging {
    transform: none !important;
    transform-origin: 0 0 !important;
}

/* Flip any text or icons inside highlights */
.chess-board.flipped .square-highlight .icon,
.chess-board.flipped .legal-move .icon,
.chess-board.flipped .move-indicator .icon {
    transform: rotate(180deg);
}

.chess-square {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
}

/* Board notation (coordinates) */
.chess-square::before,
.chess-square::after {
    position: absolute;
    font-size: 12px;
    font-weight: bold;
    pointer-events: none;
    z-index: 15;
}

/* File letters (a-h) on bottom rank */
.chess-square[data-rank="7"]::after {
    content: attr(data-file-letter);
    bottom: 2px;
    right: 3px;
}

/* Rank numbers (1-8) on left file */
.chess-square[data-file="0"]::before {
    content: attr(data-rank-number);
    top: 2px;
    left: 3px;
}

/* Color notation based on square color - Default (brown) */
.chess-square.light::before,
.chess-square.light::after {
    color: #BAA381;
}

.chess-square.dark::before,
.chess-square.dark::after {
    color: #ECD3AB;
}

/* Default board colors */
.chess-square.light {
    background-color: #ECD3AB;
}

.chess-square.dark {
    background-color: #BAA381;
}

/* Board color themes */
.board-brown .chess-square.light {
    background-color: #F0D9B5;
}

.board-brown .chess-square.dark {
    background-color: #B58863;
}

.board-brown .chess-square.light::before,
.board-brown .chess-square.light::after {
    color: #B58863;
}

.board-brown .chess-square.dark::before,
.board-brown .chess-square.dark::after {
    color: #F0D9B5;
}

.board-green .chess-square.light {
    background-color: #EEEEEE;
}

.board-green .chess-square.dark {
    background-color: #769656;
}

.board-green .chess-square.light::before,
.board-green .chess-square.light::after {
    color: #769656;
}

.board-green .chess-square.dark::before,
.board-green .chess-square.dark::after {
    color: #EEEEEE;
}

.board-blue .chess-square.light {
    background-color: #E6E6FA;
}

.board-blue .chess-square.dark {
    background-color: #4682B4;
}

.board-blue .chess-square.light::before,
.board-blue .chess-square.light::after {
    color: #4682B4;
}

.board-blue .chess-square.dark::before,
.board-blue .chess-square.dark::after {
    color: #E6E6FA;
}

.board-purple .chess-square.light {
    background-color: #E8D5F2;
}

.board-purple .chess-square.dark {
    background-color: #8B5A9F;
}

.board-purple .chess-square.light::before,
.board-purple .chess-square.light::after {
    color: #8B5A9F;
}

.board-purple .chess-square.dark::before,
.board-purple .chess-square.dark::after {
    color: #E8D5F2;
}

.board-grey .chess-square.light {
    background-color: #d4d4d4;
}

.board-grey .chess-square.dark {
    background-color: #959494;
}

.board-grey .chess-square.light::before,
.board-grey .chess-square.light::after {
    color: #959494;
}

.board-grey .chess-square.dark::before,
.board-grey .chess-square.dark::after {
    color: #d4d4d4;
}

/* Piece styles */
.chess-piece {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    cursor: grab;
    transition: opacity 0.2s ease;
    z-index: 102; /* Above all highlights (1-100), arrows (50), and classification badges (101) */
}

.chess-piece.dragging {
    position: fixed !important;
    cursor: grabbing;
    z-index: 1000;
    pointer-events: none;
    opacity: 1;
    filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.4));
    transition: none;
}

.chess-piece.ghost-piece {
    opacity: 0.2;
    pointer-events: none;
    z-index: 2;
    transition: none;
}

.chess-piece.winning-king {
    box-shadow: 
        0 0 0 3px #4CAF50,
        0 0 0 5px rgba(76, 175, 80, 0.4),
        0 0 10px rgba(76, 175, 80, 0.6);
    border-radius: 2px;
}

/* Animation piece - GPU-accelerated transform animation like Chess.com/Lichess */
.chess-piece.animating-piece {
    opacity: 1 !important;
    will-change: transform !important;
    backface-visibility: hidden !important;
    transform-origin: center center !important;
    /* Let JavaScript handle the transition and transform */
}

/* Checkmate and Resign badges */

/* Checkmate badge - black # in white circle (same position as classification badges) */
.checkmate-badge {
    position: absolute;
    top: -16px;
    right: -16px;
    width: 40px;
    height: 40px;
    background-color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 101; /* Same as classification badges */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

/* When board is flipped, reposition badge to stay in top-right corner */
.chess-board.flipped .checkmate-badge {
    top: auto;
    right: auto;
    bottom: -16px;
    left: -16px;
}

.checkmate-badge svg {
    width: 24px;
    height: 24px;
}

/* Rotate badge content back when board is flipped so it appears right-side up */
.chess-board.flipped .checkmate-badge svg {
    transform: rotate(180deg);
}

/* Resign badge - white flag in orange circle (same position as classification badges) */
.resign-badge {
    position: absolute;
    top: -16px;
    right: -16px;
    width: 40px;
    height: 40px;
    background-color: #FF9800; /* Orange */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 101; /* Same as classification badges */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

/* When board is flipped, reposition badge to stay in top-right corner */
.chess-board.flipped .resign-badge {
    top: auto;
    right: auto;
    bottom: -16px;
    left: -16px;
}

.resign-badge svg {
    width: 24px;
    height: 24px;
}

/* Rotate badge content back when board is flipped so it appears right-side up */
.chess-board.flipped .resign-badge svg {
    transform: rotate(180deg);
}

/* Legacy animations - kept for compatibility but not used */
/* Winner square background - stays solid green */
.square-winner-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(129, 182, 76, 0.85);
    z-index: 2;
    animation: flash-in 0.5s ease-out;
}

@keyframes flash-in {
    0% { opacity: 0; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.05); }
    100% { opacity: 1; transform: scale(1); }
}

/* Loser square background - stays solid red */
.square-loser-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 58, 48, 0.85);
    z-index: 2;
    animation: flash-in 0.5s ease-out;
}

/* Winner crown animation with green circle */
@keyframes winner-badge-shrink {
    0% {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 80px;
        height: 80px;
        opacity: 0;
    }
    20% {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 80px;
        height: 80px;
        opacity: 1;
    }
    70% {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 80px;
        height: 80px;
        opacity: 1;
    }
    100% {
        top: 10%;
        left: 85%;
        transform: translate(-50%, -50%);
        width: 28px;
        height: 28px;
        opacity: 1;
    }
}

.king-winner-badge {
    position: absolute;
    background-color: #81b64c;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: winner-badge-shrink 1.2s ease-out forwards;
    box-shadow: 0 0 0 3px rgba(129, 182, 76, 0.4);
}

.king-winner-badge::before {
    content: '♔';
    color: white;
    font-size: 48px;
}

/* Loser king animation - falls over with red circle */
@keyframes loser-badge-fall {
    0% {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) rotate(0deg);
        width: 80px;
        height: 80px;
        opacity: 0;
    }
    20% {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) rotate(0deg);
        width: 80px;
        height: 80px;
        opacity: 1;
    }
    40% {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) rotate(45deg);
        width: 80px;
        height: 80px;
        opacity: 1;
    }
    70% {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) rotate(90deg);
        width: 80px;
        height: 80px;
        opacity: 1;
    }
    100% {
        top: 10%;
        left: 85%;
        transform: translate(-50%, -50%) rotate(90deg);
        width: 28px;
        height: 28px;
        opacity: 1;
    }
}

.king-loser-badge {
    position: absolute;
    background-color: #ff3a30;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: loser-badge-fall 1.2s ease-out forwards;
    box-shadow: 0 0 0 3px rgba(255, 58, 48, 0.4);
    background-image: url('../images/bk.svg');
    background-size: 70%;
    background-repeat: no-repeat;
    background-position: center;
}

/* Resigned king animation - flag icon */
@keyframes resigned-badge-shrink {
    0% {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 80px;
        height: 80px;
        opacity: 0;
    }
    20% {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 80px;
        height: 80px;
        opacity: 1;
    }
    70% {
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 80px;
        height: 80px;
        opacity: 1;
    }
    100% {
        top: 10%;
        left: 85%;
        transform: translate(-50%, -50%);
        width: 28px;
        height: 28px;
        opacity: 1;
    }
}

.king-resigned-badge {
    position: absolute;
    background-color: #ff3a30;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: resigned-badge-shrink 1.2s ease-out forwards;
    box-shadow: 0 0 0 3px rgba(255, 58, 48, 0.4);
}

.king-resigned-badge::before {
    content: '⚑';
    color: black;
    font-size: 40px;
}

/* Move indicators */
.legal-move {
    position: absolute;
    width: 33%;
    height: 33%;
    border-radius: 50%;
    background-color: rgba(25, 70, 120, 0.6);
    pointer-events: none;
    z-index: 5;
}

.legal-move.capture {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        linear-gradient(135deg, rgba(25, 70, 120, 0.6) 0%, rgba(25, 70, 120, 0.6) 22%, transparent 22%, transparent 100%),
        linear-gradient(225deg, rgba(25, 70, 120, 0.6) 0%, rgba(25, 70, 120, 0.6) 22%, transparent 22%, transparent 100%),
        linear-gradient(315deg, rgba(25, 70, 120, 0.6) 0%, rgba(25, 70, 120, 0.6) 22%, transparent 22%, transparent 100%),
        linear-gradient(45deg, rgba(25, 70, 120, 0.6) 0%, rgba(25, 70, 120, 0.6) 22%, transparent 22%, transparent 100%);
    background-position: top left, top right, bottom right, bottom left;
    background-size: 50% 50%;
    background-repeat: no-repeat;
    border-radius: 0;
    pointer-events: none;
    z-index: 5;
    box-sizing: border-box;
}

/* Hover highlight on squares with legal moves */
.chess-square:has(.legal-move):hover {
    cursor: pointer;
}

/* Hide move indicators and last-move highlight when hovering */
.chess-square:hover .legal-move {
    visibility: hidden !important;
}

.chess-square:has(.legal-move):hover .square-highlight.last-move {
    display: none !important;
}

.chess-square:has(.legal-move):hover::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(25, 70, 120, 0.55);
    z-index: 20;
    pointer-events: none;
}

/* Highlighting */
.square-highlight {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.square-highlight.selected {
    background-color: rgba(25, 70, 120, 0.6);
}

.square-highlight.last-move {
    background-color: rgba(255, 255, 0, 0.3);
}

.square-highlight.drag-over {
    background-color: transparent;
}

/* Different highlights for light and dark squares */
.chess-square.light .square-highlight.selected {
    background-color: rgba(25, 70, 120, 0.6);
}

.chess-square.dark .square-highlight.selected {
    background-color: rgba(25, 70, 120, 0.6);
}

.chess-square.light .square-highlight.last-move {
    background-color: rgba(255, 255, 0, 0.4);
}

.chess-square.dark .square-highlight.last-move {
    background-color: rgba(255, 255, 0, 0.2);
}

/* Green highlighting for right-click annotations */
.square-highlight-green {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
}

.chess-square.light .square-highlight-green {
    background-color: rgba(76, 175, 80, 0.7);
}

.chess-square.dark .square-highlight-green {
    background-color: rgba(76, 175, 80, 0.6);
}

/* Purple highlighting for hints */
.square-highlight-purple {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3;
}

.chess-square.light .square-highlight-purple {
    background-color: rgba(156, 39, 176, 0.7);
}

.chess-square.dark .square-highlight-purple {
    background-color: rgba(156, 39, 176, 0.6);
}

/* Arrow overlay for drawing arrows */
#arrow-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 150; /* Above pieces (102) but below dragging pieces (1000) */
}

/* Game content layout */
.game-content {
    display: flex;
    gap: 0;
    align-items: flex-start;
    justify-content: center;
}

/* Move list panel */
.move-list-container {
    width: 350px;
    height: 600px;
    background: #262421;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.move-list-header {
    padding: 12px 18px;
    background: #1d1b19;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    border-bottom: 1px solid #3c3937;
}

.move-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
    white-space: normal;
    word-wrap: break-word;
}

/* Current player info above action buttons */
.current-player-info {
    padding: 12px 20px 8px 20px;
    border-top: 1px solid #3c3937;
    background: rgba(29, 27, 25, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    text-align: center;
}

.current-player-info #current-player {
    color: white;
    font-size: 14px;
    font-weight: 600;
    display: block;
}

/* Captured pieces container */
.captured-pieces-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px 15px 20px;
    background: rgba(29, 27, 25, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid #3c3937;
}

.captured-pieces {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.captured-pieces.captured-black {
    justify-content: flex-start;
}

.captured-pieces.captured-white {
    justify-content: flex-end;
}

.captured-pieces-list {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: wrap;
}

.captured-piece-img {
    width: 16px;
    height: 16px;
    object-fit: contain;
    image-rendering: crisp-edges;
}

.captured-count {
    color: white;
    font-size: 12px;
    font-weight: 600;
    margin: 0 4px;
    display: none;
}

/* Game action buttons inside move list container */
.game-action-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.action-btn {
    width: 48px;
    height: 48px;
    background: rgba(138, 138, 138, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: white;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.action-btn:hover {
    background: rgba(138, 138, 138, 0.5);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.action-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.action-btn:disabled:hover {
    background: rgba(138, 138, 138, 0.3);
    border-color: rgba(255, 255, 255, 0.15);
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.action-btn.hidden {
    display: none;
}

/* Evaluation bar (Study Mode) - matches game-review.html */
.evaluation-bar-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    margin: 0;
    padding: 0;
}

.evaluation-bar {
    width: 50px;
    height: 700px;
    border-radius: 0;
    overflow: hidden;
    position: relative;
    background: #000;
}

.eval-white-section {
    position: absolute;
    bottom: 0;
    width: 100%;
    background: linear-gradient(to top, #f0f0f0, #ffffff);
    transition: height 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    height: 50%;
}

.eval-black-section {
    position: absolute;
    top: 0;
    width: 100%;
    background: #000000;
    transition: height 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    height: 50%;
}

.eval-score {
    font-size: 11px;
    font-weight: bold;
    color: #333;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.8);
    white-space: nowrap;
    transition: color 0.4s ease, text-shadow 0.4s ease;
    display: inline-block;
    min-width: 20px;
    text-align: center;
}

.eval-score-normal {
    transform: none !important;
    writing-mode: horizontal-tb !important;
    display: inline-block !important;
    white-space: nowrap !important;
    text-orientation: mixed !important;
}

/* Best move display (Study Mode) */
.best-move-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    background: rgba(40, 40, 40, 0.6);
    border-radius: 6px;
    margin: 8px 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.best-move-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 600;
}

.best-move-text {
    font-size: 14px;
    color: white;
    font-weight: 700;
    font-family: monospace;
    letter-spacing: 1px;
}

.action-btn svg {
    width: 20px;
    height: 20px;
    stroke: white;
}

/* Blue variant for flip board button */
.action-btn-blue {
    background: #2196F3 !important; /* Vibrant blue */
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

.action-btn-blue:hover {
    background: #1976D2 !important; /* Darker blue on hover */
    border-color: rgba(255, 255, 255, 0.3) !important;
}

.action-btn-blue:active {
    background: #1565C0 !important; /* Even darker on click */
}

.action-btn-blue svg {
    stroke: white;
}

.move-list::-webkit-scrollbar {
    width: 8px;
}

.move-list::-webkit-scrollbar-track {
    background: #1d1b19;
}

.move-list::-webkit-scrollbar-thumb {
    background: #3c3937;
    border-radius: 4px;
}

.move-list::-webkit-scrollbar-thumb:hover {
    background: #4a4744;
}

.move-row {
    display: inline;
    color: #e8e8e8;
    font-size: 15px;
}

.move-number {
    color: #999;
    font-weight: 600;
    font-size: 13px;
    display: inline;
    margin-right: 4px;
}

.move-item {
    display: inline;
    color: #e8e8e8;
    font-size: 13px;
    cursor: pointer;
    margin-right: 8px;
}

.move-item:hover .move-notation {
    background: #3c3937;
    border-radius: 3px;
}

.move-item.active .move-notation {
    background: #8a8a8a;
    color: #1d1b19;
    font-weight: 600;
    border-radius: 3px;
    padding: 2px 4px;
}

.move-item .piece-symbol {
    font-size: 14px;
    display: inline;
}

.move-item .move-notation {
    font-weight: 500;
    display: inline;
    padding: 1px 2px;
}

/* Move navigation buttons */
.move-navigation {
    display: flex;
    gap: 0;
    padding: 0;
    border-top: 1px solid #2a2a2a;
    background: #1a1a1a;
    flex-wrap: nowrap;
}

.nav-btn {
    flex: 1;
    min-width: 60px;
    padding: 1.2rem 0.5rem;
    background: #1a1a1a;
    border: none;
    border-right: 1px solid #2a2a2a;
    border-radius: 0;
    cursor: pointer;
    font-size: 1.5rem;
    color: #ffffff;
    font-weight: 300;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.nav-btn:last-child {
    border-right: none;
}

.nav-btn:hover:not(:disabled) {
    background: #2a2a2a;
    color: #ffffff;
}

.nav-btn:active:not(:disabled) {
    background: #333333;
}

.nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.nav-btn.play-btn {
    background: #1a1a1a;
    color: #ffffff;
}

.nav-btn.play-btn:hover:not(:disabled) {
    background: #2a2a2a;
}

.nav-btn.play-btn.playing {
    background: #2a2a2a;
}

/* Make prev/next buttons (thin arrows) slightly larger */
#prev-btn, #next-btn {
    font-size: 2rem;
    font-weight: 200;
}

.move-times-container {
    display: flex;
    gap: 6px;
    align-items: center;
}

.move-time-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.time-text {
    font-size: 11px;
    color: #999;
    white-space: nowrap;
    text-align: center;
}

.time-bar {
    width: 100%;
    height: 4px;
    background: #1d1b19;
    border-radius: 2px;
    overflow: hidden;
}

.time-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.time-bar-fill.white {
    background: #e8e8e8;
}

.time-bar-fill.black {
    background: #4a4744;
}

/* Responsive board */
@media (max-width: 1200px) {
    .game-content {
        flex-direction: column;
        align-items: center;
    }
    
    .move-list-container {
        width: 700px;
        height: 280px;
    }
}

@media (max-width: 768px) {
    .chess-board {
        width: 90vw;
        height: 90vw;
        max-width: 500px;
        max-height: 500px;
    }
    
    .move-list-container {
        width: 90vw;
        max-width: 500px;
        height: 350px;
        min-height: 350px;
    }
}

@media (max-width: 768px) {
    .game-content {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
        padding-top: 0;
        margin-top: 0;
    }
    
    .game-content-wrapper {
        padding-top: 0.5rem !important;
    }
    
    .evaluation-bar-container {
        order: -1;
        width: 100%;
        max-width: 500px;
    }
    
    .evaluation-bar {
        width: 100%;
        height: 50px;
        flex-direction: row;
    }
    
    .eval-white-section {
        position: absolute;
        left: 0;
        top: 0;
        width: 50%;
        height: 100%;
        align-items: center;
    }
    
    .eval-black-section {
        position: absolute;
        right: 0;
        top: 0;
        width: 50%;
        height: 100%;
        align-items: center;
    }
    
    .eval-score {
        font-size: 12px;
    }
    
    .best-move-display {
        margin: 0.5rem 0;
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    
    .action-buttons {
        flex-wrap: wrap;
        gap: 0.5rem;
        justify-content: center;
    }
    
    .action-btn {
        min-height: 44px; /* Touch target size */
        padding: 0.75rem 1.25rem;
        font-size: 0.9rem;
    }
    
    .captured-pieces {
        gap: 0.25rem;
    }
    
    .captured-piece {
        width: 24px;
        height: 24px;
    }
    
    .material-count {
        font-size: 0.85rem;
        padding: 0.5rem;
    }
    
    .move-list-container {
        width: 100%;
        max-width: 500px;
        height: 350px;
        min-height: 350px;
    }
    
    .move-list-header {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    
    .move-item {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
    
    .nav-btn {
        min-height: 48px; /* Touch target size */
        padding: 1rem 0.5rem;
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .chess-board {
        width: min(95vw, 95vh - 300px);
        height: min(95vw, 95vh - 300px);
        max-width: 400px;
        max-height: 400px;
    }
    
    .move-list-container {
        width: 95vw;
        height: 280px;
        min-height: 280px;
    }
    
    .move-list-header {
        padding: 0.6rem;
        font-size: 0.85rem;
    }
    
    .move-item {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
    }
    
    .action-btn {
        min-height: 48px;
        padding: 0.85rem 1rem;
        font-size: 0.85rem;
    }
    
    .captured-piece {
        width: 20px;
        height: 20px;
    }
    
    .material-count {
        font-size: 0.75rem;
        padding: 0.4rem;
    }
    
    .evaluation-bar {
        height: 40px;
    }
    
    .eval-score {
        font-size: 10px;
    }
    
    .best-move-display {
        padding: 0.6rem;
        font-size: 0.8rem;
    }
    
    .nav-btn {
        min-height: 50px;
        padding: 1.1rem 0.4rem;
        font-size: 1.1rem;
    }
    
    /* Make checkmate/resign badges smaller on mobile */
    .checkmate-badge, .resign-badge {
        width: 24px;
        height: 24px;
        top: 4px;
        right: 4px;
    }
    
    .checkmate-badge svg, .resign-badge svg {
        width: 16px;
        height: 16px;
    }
}

/* Touch-friendly styles */
@media (hover: none) and (pointer: coarse) {
    /* Mobile touch devices */
    .chess-square {
        -webkit-tap-highlight-color: rgba(25, 70, 120, 0.3);
    }
    
    .action-btn, .control-btn, .nav-btn, .menu-sidebar-btn {
        -webkit-tap-highlight-color: rgba(255, 255, 255, 0.2);
    }
    
    /* Prevent text selection on buttons */
    .action-btn, .control-btn, .nav-btn, .menu-sidebar-btn, .bot-card, .color-card, .mode-card {
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
    }
    
    /* Larger touch targets */
    .bot-card, .color-card, .mode-card {
        min-height: 48px;
    }
}
