* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #2b2b2b;
    font-family: Arial, Helvetica, sans-serif;
    color: white;

    display: flex;
    flex-direction: column;
    align-items: center;

    min-height: 100vh;
    padding: 20px;
}

#board {
    width: min(70vw, 750px);
    height: min(70vw, 750px);

    border: 4px solid #1a1a1a;

    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
}

.square {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 48px;
    user-select: none;
}

.light {
    background-color: #f0d9b5;
}

.dark {
    background-color: #b58863;
}

.selected {
    box-shadow: inset 0 0 0 4px red;
}

.legal {
    box-shadow: inset 0 0 0 4px limegreen;
}

#promotion-overlay {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, 0.55);
    z-index: 100;
}

#promotion-menu {
    background: #f8f8f8;
    border: 2px solid #333;
    border-radius: 16px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
    padding: 18px 18px 12px;
    display: grid;
    gap: 14px;
    min-width: 320px;
    box-sizing: border-box;
}

.promotion-title {
    font-size: 1rem;
    font-weight: 700;
    color: #111;
    text-align: center;
}

.promotion-options {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.promotion-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    background: white;
    border: 2px solid #bbb;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.promotion-option:hover,
.promotion-option:focus-visible {
    transform: translateY(-2px);
    border-color: #444;
    background: #f3f3f3;
    outline: none;
}

.promotion-option img {
    width: 48px;
    height: 48px;
}

.promotion-option span {
    font-size: 0.9rem;
    color: #222;
}

#promotion-cancel {
    border: none;
    background: #222;
    color: white;
    border-radius: 10px;
    padding: 12px 16px;
    cursor: pointer;
    font-size: 0.95rem;
}

#promotion-cancel:hover,
#promotion-cancel:focus-visible {
    background: #000;
    outline: none;
}

.hidden {
    display: none !important;
}

.check {
    background-color: red;
    box-shadow: inset 0 0 10px 2px #b71c1c;
    border-radius: 0;
}

.legal-capture {
    position: relative;
}

.legal-capture::after {
    content: "";
    position: absolute;
    inset: 8%;
    border: 5px solid #e53935;
    border-radius: 50%;
    box-sizing: border-box;
}

#checkmate-message {
    position: fixed;
    top: 50%;
    left: 50%;
     transform: translate(-50%, -50%);
    background: white;
    color: black;
    padding: 30px 50px;
    font-size: 40px;
    font-weight: bold;
    border-radius: 15px;
    z-index: 100;
}

.hidden {
    display: none !important;
}

.last-move.light {
    background-color: #f7ec74;
}

.last-move.dark {
    background-color: #d8c14b;
}

#game-container {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

#sidebar {
    width: 260px;
    height: min(85vw, 900px);
    background: #1e1e1e;
    border-radius: 12px;
    padding: 20px;
}

#sidebar h2 {
    margin-bottom: 20px;
}

#move-history {
    overflow-y: auto;
    height: calc(100% - 50px);
    font-family: monospace;
    font-size: 18px;
}
#difficulty {
    margin-top: 20px;
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

#difficulty button {
    padding: 10px 20px;
    font-size: 16px;
    border-radius: 8px;
    background: #444;
    color: white;
    cursor: pointer;
}

#game-over-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    color: black;
    padding: 35px 60px;
    border-radius: 15px;
    font-size: 36px;
    font-weight: bold;
    text-align: center;
}

#eval-container {
    width: 100%;
}

#eval-bar {
    width: 160px;
    height: 18px;
    background: #333;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
}

#eval-fill {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%; /* center zero */
    width: 0%;
    background: linear-gradient(90deg, #4caf50, #8bc34a); /* white advantage (green) */
    transform-origin: left center;
    transition: width 220ms ease, left 220ms ease, background 220ms ease;
}

#eval-bar.negative #eval-fill {
    background: linear-gradient(90deg, #e57373, #ef5350); /* black advantage (red) */
}

#eval-center {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(255,255,255,0.08);
    transform: translateX(-50%);
}

#eval-label {
    color: #fff;
    font-size: 14px;
}

.file-label {
    position: absolute;
    bottom: 3px;
    right: 4px;
    font-size: 12px;
    font-weight: bold;
    pointer-events: none;
    color:#000;
}

.rank-label {
    position: absolute;
    top: 3px;
    left: 4px;
    font-size: 12px;
    font-weight: bold;
    pointer-events: none;
    color:#000;
}
