/* Fixed viewport base - no scrolling */
html, body {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Scaling container - fixed 1920x1080 design that scales to fit viewport */
.scaling-container {
    position: fixed;
    width: 1920px;
    height: 1080px;
    transform-origin: top left;
    overflow: visible;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body { 
    background: #f8f8f8;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Main container layout - fixed pixel values for 1920x1080 */
.main-container {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: stretch;
    width: 1920px;
    height: 1080px;
    padding: 0 20px;
    gap: 20px;
    position: relative;
    margin-left: 180px; /* Add this line to shift everything right */
}

/* Left sidebar: vertically centered */
#sidebar-tabs {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    gap: 10px;
    width: 475px; /* Increased from 200px */
    padding: 8px 8px 8px 8px; /* Add padding for content */
    height: 775px;
    background: #fafdff; /* Add background color */
    border-radius: 18px;  /* Rounded corners */
    box-shadow: 0 6px 24px rgba(24,90,157,0.08); /* Subtle shadow */
    border: 1.5px solid #e0e6ef; /* Light border */
    z-index: 10;
    margin-right: 0; /* Remove margin */
    margin-top: 100px; /* Align with right sidebar */
}

/* Sidebar tab appearance */
.sidebar-tab {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 16px; /* space between icon and content */
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.10);
    padding: 16px;
    font-size: 20px;
    color: #222;
    margin-bottom: 15px;
    width: 100%;
    transition: box-shadow 0.2s;
}
.sidebar-tab:last-child {
    margin-bottom: 0;
}
.sidebar-tab:hover {
    box-shadow: 0 4px 16px rgba(24,90,157,0.13);
}

.sidebar-title {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 8px;
    color: #185a9d;
    letter-spacing: 0.5px;
}

/* Icon on the left of each tab */
.sidebar-tab-icon {
    width: 96px;
    height: 96px;
    flex-shrink: 0;
    border-radius: 8px;
    object-fit: contain;
    background: transparent;
    display: block;
    margin-right: 0;
}

/* Content on the right of the icon */
.sidebar-tab-body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    flex: 1 1 auto;
    min-width: 0;
}

/* Center area: board and eval bar, centered */
.center-area {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    flex: 0 0 auto;
    height: 1080px;
}

#board-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

/* Right sidebar: vertically centered */
.right-sidebar {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 10px;
    width: 475px; /* Increased from 300px */
    padding: 8px 8px 8px 8px; /* Add padding for content */
    height: 775px;
    background: #fafdff; /* Add background color */
    border-radius: 18px;  /* Rounded corners */
    box-shadow: 0 6px 24px rgba(24,90,157,0.08); /* Subtle shadow */
    border: 1.5px solid #e0e6ef; /* Light border */
    z-index: 10;
    margin-left: 50px; /* Remove margin */
    margin-top: 100px; /* Changed from -200px to align properly */
}

/* Previous moves, controls, and player info in right sidebar */
#previous-moves-container,
#player-controls-area,
#player-king-icon,
#player-turn-info {
    width: 100%;
    margin-bottom: 10px;
    margin-left: 0; /* Changed from 36px to 0 to center content */
}

/* Center player king icon and info */
#player-king-icon {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    min-height: 10px;
    gap: 10px;
    /* Remove column direction, use row for icon + text */
}

/* King icon image inside #player-king-icon */
#player-king-icon img {
    width: 100px;
    height: 100px;
    display: block;
    border-radius: 10px;
}

/* Text container to the right of the king icon */
.player-king-texts {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    height: 76px;
    /* Ensures text does not exceed king icon height */
}

/* Move "Your turn" up a bit */
#player-king-turn {
    font-size: 26px;
    font-weight: bold;
    color: #222;
    text-align: left;
    white-space: nowrap;
    margin-top: 20px;
    margin-bottom: 0;
    line-height: 1.1;
    /* Move up relative to the icon */
}

/* Place description just below "Your turn" */
#player-king-desc {
    font-size: 18px;
    color: #333;
    margin-top: 2px;
    margin-bottom: 0;
    text-align: left;
    white-space: nowrap;
    line-height: 1.1;
}

#player-turn-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
}

/* Player controls area in right sidebar */
#player-controls-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin-bottom: 10px;
}

/* Game area - contains board and controls */
.game-area {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
}

/* Board and controls wrapper */
.board-and-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    position: relative;
}

/* Player controls area */
#player-controls-area {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    width: 100%;
    margin-bottom: 1rem;
}

#player-king-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

#explore-controls {
    display: flex;
    margin-top: 20px;
    gap: 8px;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    width: 100%;
    border: 3px solid transparent;
    border-radius: 12px;
    padding: 8px;
    transition: border-color 0.2s;
}

#player-turn-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

#player-king-turn {
    font-size: 32px;
    font-weight: bold;
    color: #222;
    text-align: center;
    white-space: nowrap;
}

#player-king-desc {
    font-size: 24px;
    color: #333;
    margin-top: 4px;
}

.board-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

/* Chess board - increased size from 640px to 700px */
#board {
    display: grid;
    grid-template: repeat(8, 1fr) / repeat(8, 1fr);
    border: 4px solid #333;
    background: #333;
    width: 775px;
    height: 775px;
    transition: filter 0.3s ease, opacity 0.3s ease;
    position: relative; /* Add this for SVG absolute positioning */
}

.square {
    position: relative;
    width: 100%;
    height: 100%;
    transition: background-color 0.1s ease;
}

/* Square colors - add these back */
.light { 
    background: #dee3e6; 
}

.dark { 
    background: #8ca2ad; 
}

.highlight { 
    background: rgba(0, 173, 23, 0.4) !important;
}

.wrong { 
    animation: wrongmove 0.5s; 
}

@keyframes wrongmove { 
    0% { box-shadow: 0 0 0 4px #f00 inset; } 
    100% { box-shadow: none; } 
}

.piece {
    position: absolute;
    width: 100%;
    height: 100%;
    transition: transform 0.2s ease;
    z-index: 2;
    cursor: grab;
    transition: opacity 0.1s ease;
}

.piece:active {
    cursor: grabbing;
}

/* Evaluation bar - updated to match new board height */
#eval-wrap {
    width: 32px;
    height: 775px;
    position: relative;
    border: 2px solid #333;
    background: #333;
}

#eval_bar {
    position: absolute;
    inset: 0;
}

#eval-white {
    background: #eee;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 50%;
    transition: height 0.5s ease;
}

#eval-black {
    background: #777777ff;
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 50%;
    transition: height 0.5s ease;
}

#eval-expected {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: #d22;
    top: 50%;
    transition: top 1s ease;
    pointer-events: none;
}

#eval-zero {
    position: absolute;
    left: 0;
    right: 0;
    height: 6px;
    background: #EAA67F;
    top: 50%;
    pointer-events: none;
}

#eval-ticks {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.eval-tick {
    position: absolute;
    right: 100%;
    width: 24px;
    height: 1px;
    left: 0px;
    background: rgba(83, 83, 83, 1);
    transform-origin: right center;
}

/* Evaluation labels */
.eval-label {
    position: absolute;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.95);
    color: #111;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 20px;
    pointer-events: none;
    white-space: nowrap;
}

#eval-current-label {
    left: calc(100% + 8px);
    top: 50%;
    min-width: 40px;
    text-align: left;
}

.eval-label.expected {
    left: calc(100% + 8px);
    top: 50%;
    min-width: 40px;
    text-align: left;
    background: rgba(210,34,34,0.95);
    color: #fff;
    transition: top 1s ease;
}

/* Info and buttons */
#info {
    text-align: center;
    margin-top: 16px;
    font-size: 16px;
    min-height: 24px;
}

#reset-btn {
    margin-top: 8px;
    padding: 8px 16px;
    border-radius: 4px;
    border: none;
    background: #333;
    color: white;
    cursor: pointer;
    font-size: 16px;
}

#reset-btn:hover {
    background: #444;
}

/* King action buttons - fixed sizes */
.king-action-btn {
    min-width: 240px;
    padding: 12px 24px;
    margin: 0;
    border: none;
    border-radius: 8px;
    font-size: 36px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
    outline: none;
}

.king-action-btn.hint-btn {
    background: linear-gradient(90deg, #f9d423 0%, #ff4e50 100%);
    color: #222;
    padding-left: 62px;
    padding-right: 62px;
}

.king-action-btn.hint-btn:hover {
    background: linear-gradient(90deg, #ffec99 0%, #ff7e5f 100%);
    color: #111;
    box-shadow: 0 4px 16px rgba(255, 126, 95, 0.15);
}

.king-action-btn.solution-btn {
    background: linear-gradient(90deg, #43cea2 0%, #185a9d 100%);
    color: #fff;
}

.king-action-btn.solution-btn:hover {
    background: linear-gradient(90deg, #7de2fc 0%, #185a9d 100%);
    color: #fff;
    box-shadow: 0 4px 16px rgba(67, 206, 162, 0.15);
}

/* Game history button */
/* .king-action-btn.game-history-btn {
    background: linear-gradient(90deg, #a8edea 0%, #fed6e3 100%);
    color: #222;
}

.king-action-btn.game-history-btn:hover {
    background: linear-gradient(90deg, #c9f4f1 0%, #ffeef5 100%);
    color: #111;
    box-shadow: 0 4px 16px rgba(168, 237, 234, 0.15);
} */

/* Exploration buttons (smaller) */
#explore-controls .king-action-btn {
    min-width: 50px;
    padding: 10px 0;
}

/* Exit button styling - invisible overlay on chess board */
/* Now always matches the board size responsively */
#explore-exit {
    position: absolute;
    top: 0;
    left: 0;
    width: 775px;
    height: 775px;
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    background: rgba(255,107,107,0.85);
    border: none !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 8px rgba(201, 42, 42, 0.08) !important;
    cursor: pointer;
    z-index: 10;
    display: none;
    font-size: 56px !important;
    font-weight: bold !important;
    color: #fff !important;
    transition: background 0.2s, box-shadow 0.2s !important;
    justify-content: center;
    align-items: center;
    text-align: center;
    opacity: 0.97;
}

#explore-exit:hover {
    background: linear-gradient(90deg, #ff8787 0%, #e03131 100%) !important;
    box-shadow: 0 4px 16px rgba(201, 42, 42, 0.15) !important;
}

/* Show exit button only in exploration mode */
#board.exploration-mode + #explore-exit,
#board-wrap .exploration-mode ~ #explore-exit,
#board_wrap #explore-exit.active {
    display: flex !important;
}

/* Hide the old small exit button style */
#explore-controls .king-action-btn#explore-exit {
    display: none !important;
}

/* Feedback modal - absolute positioning within scaling container */
#feedback-modal {
    position: absolute;
    z-index: 501;
    background: #e5ffff;
    border-radius: 14px;
    box-shadow: 0 6px 24px rgba(24,90,157,0.08);
    padding: 20px;
    text-align: center;
    display: none;
    width: 450px;
    height: 300px;
    right: -136px;
    bottom: 260px;
    border: 1.5px solid #e0e6ef;
}

#feedback-title {
    font-weight: 700;
    margin-bottom: 14px;
    font-size: 36px;
    color: #185a9d;
    background: none;
    letter-spacing: 0.5px;
}

#feedback-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-bottom: 14px;
}

.fb-btn {
    width: 120px;
    height: 100px;
    font-size: 56px;
    border-radius: 10px;
    border: 1.5px solid #e0e6ef;
    background: #fafdff;
    color: #185a9d;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(24,90,157,0.04);
    transition: background 0.15s, color 0.15s, border 0.15s, transform 0.13s;
}

.fb-btn:hover {
    background: #eaf3fa;
    color: #185a9d;
    border-color: #b7d1ea;
    box-shadow: 0 4px 16px rgba(24,90,157,0.08);
    transform: translateY(-7px);
}

.fb-skip-btn {
    padding: 8px 18px;
    border-radius: 8px;
    border: 1.5px solid #e0e6ef;
    background: #fafdff;
    cursor: pointer;
    font-weight: 600;
    font-size: 36px;
    color: #185a9d;
    box-shadow: 0 2px 8px rgba(24,90,157,0.04);
    transition: background 0.15s, color 0.15s, border 0.15s;
}

.fb-skip-btn:hover {
    background: #eaf3fa;
    color: #185a9d;
    border-color: #b7d1ea;
    box-shadow: 0 4px 16px rgba(24,90,157,0.08);
}

/* Previous moves list - fixed size */
#previous-moves-container {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 14px;
    padding: 0 0 12px 0;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.13);
    height: 475px;
    overflow-y: auto;
    overflow-x: hidden;
    margin: 0 auto 24px auto;
    width: 100%;
    position: relative;
    border: 1.5px solid #e0e6ef;
    /* Slightly more modern look */
}

/* Make the title sticky and visually distinct */
#previous-moves-title {
    font-weight: 700;
    font-size: 22px;
    color: #185a9d;
    text-align: center;
    border-bottom: 2px solid #e0e6ef;
    background: #fff; /* Remove gradient, just white */
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 18px 0 16px 0;
    margin-bottom: 0;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(24,90,157,0.04);
}

/* Moves list with more spacing and better font */
#previous-moves-list {
    font-size: 18px;
    line-height: 1;
    color: #2a2a2a;
    padding: 12px 18px 0 18px;
}

/* Each move pair row: use grid for alignment */
.move-pair {
    display: grid;
    grid-template-columns: 36px 1fr 1fr;
    align-items: center;
    gap: 0;
    margin-bottom: 6px;
    border-radius: 0;
    transition: none;
    padding: 2px 0;
    background: none;
    border: none;
}

.move-pair.last-move {
    background: #fff6f6;
}

.move-white.last-move,
.move-black.last-move {
    border: 2px solid #d22 !important; /* Add !important to ensure it takes precedence */
    border-radius: 8px;
    background: #fff6f6 !important; /* Add !important */
}

/* Currently viewed move in exploration mode */
.move-white.current-view,
.move-black.current-view {
    background: #e0e0e0;
    color: #222;
    border-radius: 8px;
    font-weight: 600;
}

/* Move number styling */
.move-number {
    font-weight: 700;
    color: #185a9d;
    width: 36px;
    flex-shrink: 0;
    text-align: right;
    margin-right: 0;
    font-size: 17px;
    opacity: 0.8;
    /* Remove margin to keep grid alignment */
}

/* White and black move cells: remove background/border/box, align text left */
.move-white, .move-black {
    min-width: 0;
    padding: 3px 8px;
    margin: 0;
    border-radius: 0;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: normal;
    font-size: 17px;
    background: none;
    color: #185a9d;
    border: none;
    text-align: left;
    justify-self: stretch;
}

/* Blue background on hover */
.move-white:hover, .move-black:hover {
    background: #cce4ff;
    color: #222;
    border: none;
}

/* Target indicators */
.target-dot {
    position: absolute;
    width: clamp(12px, 4vw, 18px);
    height: clamp(12px, 4vw, 18px);
    background: rgba(0, 173, 23, 0.75);
    border-radius: 50%;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.capture-overlay {
    position: absolute;
    top: 4px;
    left: 4px;
    right: 4px;
    bottom: 4px;
    border: 3px solid rgba(0, 173, 23, 0.75);
    border-radius: 6px;
    pointer-events: none;
    box-sizing: border-box;
}

/* Coordinate labels */
.coord-label {
    position: absolute;
    font-size: 14px;
    font-weight: 600;
    pointer-events: none;
    z-index: 1;
}

.coord-rank {
    top: 4px;
    right: 4px;
}

.coord-file {
    bottom: 4px;
    left: 4px;
}

.light .coord-label {
    color: #8ca2ad;
}

.dark .coord-label {
    color: #dee3e6;
}

/* Make puzzle rating bold */
#puzzle-rating {
    font-weight: bold;
}

/* Flashing red perimeter animation */
@keyframes flash-red-perimeter {
    0%   { border-color: #ff0000; }
    25%  { border-color: transparent; }
    50%  { border-color: #ff0000; }
    75%  { border-color: transparent; }
    100% { border-color: #ff0000; }
}

#explore-controls.flashing-red {
    animation: flash-red-perimeter 1.2s ease-in-out 1;
    border-width: 4px; /* Even thicker during flash */
}

.king-action-btn.hint-btn,
.king-action-btn.solution-btn {
    background: #ffffff;
    color: #185a9d;
    border: 1.5px solid #e0e6ef;
    box-shadow: 0 2px 8px rgba(24,90,157,0.04);
    transition: background 0.15s, color 0.15s, border 0.15s;
}

/* Exploration mode: SVG/IMG fills the board exactly */
#board svg,
#board img {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: block !important;
}

/* When in exploration mode, ensure board container dimensions */
#board.exploration-mode {
    display: block !important;
    width: 775px !important;
    height: 775px !important;
    position: relative !important;
}

/* Add this at the end of the file or in an appropriate section */

/* Grayscale filter for exploration mode when viewing previous moves */
#board.exploration-grayscale {
    filter: grayscale(70%) brightness(1);
    transition: filter 0.2s ease-in;
}

/* Ensure normal colors when not in grayscale mode */
#board.exploration-mode:not(.exploration-grayscale) {
    filter: none;
    transition: filter 0.2s ease-in;
}

/* Overlay exit button on top of the chess board */
#board-wrap {
    position: relative;
}

#explore-exit {
    position: absolute;
    top: 0;
    left: 0;
    width: 775px;
    height: 775px;
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    cursor: pointer;
    z-index: 10;
    display: none;
    font-size: 0 !important;
    font-weight: normal !important;
    color: transparent !important;
    opacity: 0;
    /* Remove any centering/flex/text styles */
}

/* Show exit button only in exploration mode */
#board.exploration-mode + #explore-exit,
#board-wrap .exploration-mode ~ #explore-exit,
#board_wrap #explore-exit.active {
    display: flex !important;
}

/* Hide the old small exit button style */
#explore-controls .king-action-btn#explore-exit {
    display: none !important;
}