body {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100vh;
    background-color: #f0f0f0;
    margin: 0;
}


body.modal-open {
    overflow: hidden;
}

.top-bar {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 12px 16px 0 16px;
    box-sizing: border-box;
}

.auth-buttons {
    display: flex;
    gap: 12px;
}

.auth-status {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: 16px;
    font-size: 14px;
    color: #2f80ed;
}

.auth-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    font-size: 14px;
    border-radius: 999px;
    border: 1px solid #2f80ed;
    background: #ffffff;
    color: #2f80ed;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-button.primary {
    background: #2f80ed;
    color: #ffffff;
}

.auth-button.secondary {
    border-color: #bdbdbd;
    color: #424242;
}

.auth-status .auth-button.secondary {
    background: #ffffff;
}

.auth-button:hover,
.auth-button:focus {
    background: #1b63c5;
    color: #ffffff;
    border-color: #1b63c5;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.auth-button.secondary:hover,
.auth-button.secondary:focus {
    background: #f2f2f2;
    color: #1f1f1f;
    border-color: #9e9e9e;
}

.auth-icon svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.auth-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2100;
    padding: 20px;
}

.auth-dialog {
    background: #ffffff;
    padding: 24px 28px;
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
    width: min(360px, 100%);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-dialog h2 {
    margin: 0;
    font-size: 22px;
    text-align: center;
}

.auth-dialog form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-dialog label {
    font-weight: 600;
    font-size: 14px;
}

.auth-dialog input {
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid #d0d0d0;
    font-size: 15px;
}

.auth-dialog input:focus {
    outline: none;
    border-color: #2f80ed;
    box-shadow: 0 0 0 2px rgba(47, 128, 237, 0.15);
}

.auth-error {
    min-height: 18px;
    color: #d32f2f;
    font-size: 13px;
    line-height: 1.4;
    margin-top: -4px;
}

.auth-submit-button {
    padding: 10px 14px;
    border: none;
    border-radius: 6px;
    background: #27ae60;
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.auth-submit-button:hover,
.auth-submit-button:focus {
    background: #1f8a4d;
}

.auth-close-button {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: #666666;
}

.auth-close-button:hover,
.auth-close-button:focus {
    color: #2f80ed;
}

.settings-container {
    width: 100%;
    padding: 10px 16px;
    background: white;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.settings-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

button.primary-action {
    padding: 8px 14px;
    border-radius: 6px;
    border: 1px solid #2f80ed;
    background: #2f80ed;
    color: #ffffff;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

button.primary-action:hover,
button.primary-action:focus {
    background: #1b63c5;
    border-color: #1b63c5;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.settings-group.online-settings button.secondary {
    padding: 8px 14px;
    border-radius: 6px;
    border: 1px solid #bdbdbd;
    background: #ffffff;
    color: #424242;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.settings-group.online-settings button.secondary:hover,
.settings-group.online-settings button.secondary:focus {
    background: #f2f2f2;
    border-color: #9e9e9e;
}

.settings-group.online-settings {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
    max-width: 360px;
    width: 100%;
}

.online-actions,
.online-friend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.online-friend input {
    flex: 1;
    min-width: 160px;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid #d0d0d0;
    font-size: 14px;
}

.online-friend input:focus {
    outline: none;
    border-color: #2f80ed;
    box-shadow: 0 0 0 2px rgba(47, 128, 237, 0.15);
}

.online-status-message {
    min-height: 18px;
    font-size: 13px;
    color: #424242;
}

#zeroPlayerControls {
    display: none;
}

.zero-player-button {
    padding: 6px 12px;
    font-size: 14px;
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
    color: #fff;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.zero-player-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.zero-player-start {
    background: #27ae60;
    border-color: #1e874b;
}

.zero-player-start:hover:not(:disabled),
.zero-player-start:focus:not(:disabled) {
    background: #1e874b;
    border-color: #16643a;
}

.zero-player-stop {
    background: #eb5757;
    border-color: #c0392b;
}

.zero-player-stop:hover:not(:disabled),
.zero-player-stop:focus:not(:disabled) {
    background: #c0392b;
    border-color: #922b21;
}

.bot-selection {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.bot-selection-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 220px;
}

.bot-selection-group label {
    font-weight: 600;
}

.bot-selection-group select {
    padding: 5px;
    font-size: 16px;
}

.settings-container label {
    margin-right: 10px;
}

.settings-container select {
    padding: 5px;
    font-size: 16px;
}

.custom-setup-button {
    padding: 6px 12px;
    font-size: 14px;
    border: 1px solid #2f80ed;
    background: #2f80ed;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.custom-setup-button:hover,
.custom-setup-button:focus {
    background: #1b63c5;
    border-color: #1b63c5;
}

#chessboard {
    display: grid;
    grid-template-columns: repeat(8, 60px);
    grid-template-rows: repeat(8, 60px);
    gap: 0;
    border: 2px solid #333;
}

.square {
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.white {
    background-color: #f0d9b5;
}

.black {
    background-color: #b58863;
}

.piece {
    width: 60px;
    height: 60px;
    transition: transform 0.3s ease;
}

.move-dot {
    width: 15px;
    height: 15px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.promotion-ui {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 250px;
    height: 100px;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    border-radius: 10px;
    z-index: 1000;
}

.promotion-options img {
    width: 50px;
    height: 50px;
    cursor: pointer;
}

.promotion-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-gap: 10px;
    width: 50%;
    height: 50%;
}

.check {
    background-color: red !important;
}

#boardArea {
    display: flex;
    align-items: flex-start;
    gap: 20px;
}

#boardArea .board-with-captures {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

#boardArea .board-with-captures {
    transition: transform 0.3s ease;
    transform-origin: center;
}

#boardArea .board-with-captures.entire-board-mode {
    will-change: transform;
}

#boardArea .board-with-captures.entire-board-flipped {
    transform: rotate(180deg);
}

#boardArea .board-with-captures.pieces-rotated .piece {
    transform: rotate(180deg);
}

.captured-pieces {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #333;
    font-size: 14px;
    justify-content: center;
}

.captured-pieces .captured-label {
    font-weight: 600;
}

.captured-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.captured-list {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 28px;
}

.captured-list img,
.captured-piece-icon {
    width: 26px;
    height: 26px;
}

.captured-advantage {
    min-width: 24px;
    font-weight: 600;
    color: #2f80ed;
    text-align: center;
}

#boardWrapper {
    display: flex;
    align-items: flex-start;
}

.engine-status-message {
    max-width: 320px;
    text-align: center;
    font-size: 13px;
    line-height: 1.4;
    color: #c0392b;
    background: rgba(192, 57, 43, 0.12);
    border-radius: 6px;
    padding: 8px 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

#evalBar {
    width: 20px;
    height: 560px;
    border: 1px solid #333;
    margin-left: 5px;
    position: relative;
    background: #000;
}

#historyColumn {
    width: 220px;
    height: 560px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 12px;
    display: flex;
    flex-direction: column;
}

.history-header {
    font-weight: 600;
    text-align: center;
    margin-bottom: 8px;
    font-size: 16px;
}

#moveHistoryList {
    flex: 1;
    overflow-y: auto;
    padding-right: 6px;
    min-height: 0;
}

.history-start {
    padding: 6px 8px;
    border-radius: 6px;
    background: #f7f7f7;
    margin-bottom: 8px;
    text-align: center;
    font-size: 13px;
    color: #555;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.history-start:hover {
    background: #e8e8e8;
}

.history-start.active {
    background: #4caf50;
    color: #fff;
}

.move-row {
    display: grid;
    grid-template-columns: 36px 1fr 1fr;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    padding: 4px 0;
    border-bottom: 1px solid #eee;
}

.move-row:last-child {
    border-bottom: none;
}

.move-number {
    text-align: right;
    color: #777;
    font-weight: 500;
}

.move {
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    white-space: nowrap;
}

.move:hover {
    background: #f0f0f0;
}

.move.active {
    background: #4caf50;
    color: #fff;
}

.move.empty {
    cursor: default;
    color: #bbb;
}

#evalFill {
    position: absolute;
    bottom: 0;
    width: 100%;
    background: #fff;
    height: 50%;
}

.file-label,
.rank-label {
    position: absolute;
    font-size: 12px;
    color: #000;
    pointer-events: none;
}
.file-label { bottom: 2px; right: 2px; }
.rank-label { top: 2px; left: 2px; }

.checkmate-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
}

.checkmate-message {
    background: #ffffff;
    padding: 20px 30px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.checkmate-message h2 {
    margin: 0 0 10px;
}

.checkmate-message button {
    margin-top: 15px;
    padding: 8px 16px;
    font-size: 16px;
    cursor: pointer;
    border: none;
    border-radius: 5px;
    background-color: #4caf50;
    color: #fff;
}

.custom-mix-container {
    margin-top: 12px;
    padding: 12px;
    background: #ffffff;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.custom-mix-description {
    margin: 0 0 8px;
    font-size: 14px;
    color: #333;
}

.custom-mix-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.custom-mix-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    border: 1px solid #ededed;
    border-radius: 6px;
    background: #fafafa;
}

.custom-mix-row-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.custom-mix-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
}

.custom-mix-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.custom-mix-controls input[type="range"] {
    flex: 1;
}

.custom-mix-number {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 72px;
}

.custom-mix-number input {
    width: 60px;
    padding: 4px;
}

.custom-mix-controls input[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
}

.custom-mix-summary {
    margin-top: 10px;
    font-size: 14px;
    font-weight: 600;
}

.custom-mix-error {
    margin-top: 4px;
    min-height: 18px;
    font-size: 13px;
    color: #c0392b;
}

.hidden {
    display: none !important;
}

.custom-setup-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.55);
    z-index: 2000;
}

.custom-setup-dialog {
    width: min(960px, 95vw);
    max-height: 90vh;
    background: #fff;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.custom-setup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
}

.custom-setup-header h2 {
    margin: 0;
    font-size: 20px;
}

.close-modal-button {
    border: none;
    background: transparent;
    font-size: 26px;
    cursor: pointer;
    color: #666;
    padding: 0;
    line-height: 1;
}

.close-modal-button:hover,
.close-modal-button:focus {
    color: #111;
}

.custom-setup-body {
    display: flex;
    gap: 20px;
    padding: 20px;
    overflow-y: auto;
}

.custom-setup-board-wrapper {
    flex: 0 0 auto;
}

.custom-setup-board {
    display: grid;
    grid-template-columns: repeat(8, 50px);
    grid-template-rows: repeat(8, 50px);
    border: 2px solid #333;
    border-radius: 6px;
    overflow: hidden;
}

.custom-setup-square {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.custom-setup-square.light {
    background: #f0d9b5;
}

.custom-setup-square.dark {
    background: #b58863;
}

.custom-setup-square img {
    width: 46px;
    height: 46px;
    pointer-events: none;
}

.custom-setup-sidebar {
    flex: 1;
    min-width: 240px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.custom-setup-section h3 {
    margin: 0 0 8px;
    font-size: 16px;
}

.custom-piece-palette {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(48px, 1fr));
    gap: 8px;
}

.piece-palette-button {
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.piece-palette-button:hover,
.piece-palette-button:focus {
    border-color: #2f80ed;
}

.piece-palette-button.selected {
    border-color: #2f80ed;
    box-shadow: 0 0 0 2px rgba(47, 128, 237, 0.2);
}

.piece-palette-button img {
    width: 38px;
    height: 38px;
    pointer-events: none;
}

.piece-palette-button.erase {
    font-size: 14px;
    font-weight: 600;
    color: #555;
}

.custom-option-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.custom-option-group span {
    font-weight: 600;
}

.castling-options label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

.custom-setup-section label {
    display: block;
    font-weight: 500;
    margin: 10px 0 4px;
}

.custom-setup-section input,
.custom-setup-section textarea {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

.custom-setup-section textarea {
    min-height: 80px;
    resize: vertical;
}

.custom-editor-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.custom-editor-buttons button,
.custom-setup-actions button,
.custom-setup-section button {
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid #2f80ed;
    background: #2f80ed;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.custom-editor-buttons button.secondary,
.custom-setup-actions button.secondary,
.custom-setup-section button.secondary {
    background: #fff;
    color: #2f80ed;
}

.custom-editor-buttons button:hover,
.custom-setup-actions button:hover,
.custom-setup-section button:hover {
    background: #1b63c5;
    border-color: #1b63c5;
}

.custom-setup-footer {
    padding: 16px 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.custom-setup-error {
    color: #d32f2f;
    font-size: 14px;
    min-height: 20px;
}

.custom-setup-actions {
    display: flex;
    gap: 10px;
}

.custom-setup-actions .primary-action {
    background: #27ae60;
    border-color: #27ae60;
}

.custom-setup-actions .primary-action:hover {
    background: #1f8a4d;
    border-color: #1f8a4d;
}

@media (max-width: 900px) {
    .custom-setup-body {
        flex-direction: column;
    }

    .custom-setup-board {
        grid-template-columns: repeat(8, 45px);
        grid-template-rows: repeat(8, 45px);
    }

    .custom-setup-square {
        width: 45px;
        height: 45px;
    }

    .custom-setup-square img {
        width: 40px;
        height: 40px;
    }
}

