/* Base styles */
body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background-color: #f5f5f5;
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.9)),
        url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%239C92AC' fill-opacity='0.1'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Container */
.container {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    max-width: 95vw;
    margin: 10px auto;
    padding: 10px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    height: calc(100vh - 20px);
    box-sizing: border-box;
}

/* Mobile Responsive Layout */
@media screen and (max-width: 768px) {
    .container {
        flex-direction: column !important;
        padding: 0 !important;
        min-height: 100vh !important;
        overflow-y: auto !important;
    }

    .middle-column {
        width: 100% !important;
        order: 1 !important;
        padding: 10px !important;
        margin: 0 !important;
        touch-action: pan-y !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 10px !important;
    }

.left-column {
        width: 100% !important;
        padding: 10px !important;
        margin: 0 !important;
        order: 2 !important;
    }

    .right-column {
        width: 100% !important;
        padding: 10px !important;
        margin: 0 !important;
        order: 3 !important;
    }

    #board {
        width: 90vw !important;
        height: 90vw !important;
        max-height: 70vh !important;
        max-width: 400px !important;
        margin: 0 auto !important;
        touch-action: none !important;
    }

    .status-message {
        width: 90vw !important;
        max-width: 400px !important;
        margin: 0 auto !important;
    }

    /* Prevent touch events from scrolling the page when interacting with the board */
    .chessboard, 
    .square-55d63,
    .piece-417db,
    .white-1e1d7,
    .black-3c85d {
        touch-action: none !important;
        -webkit-touch-callout: none !important;
        -webkit-user-select: none !important;
        user-select: none !important;
        -webkit-tap-highlight-color: transparent !important;
        pointer-events: auto !important;
    }

    .button-controls {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 5px !important;
        margin: 5px 0 !important;
    }

    .button-controls button,
    #toggleEvalButton {
        padding: 6px !important;
        font-size: 12px !important;
        flex: 1 !important;
        min-width: 100px !important;
        margin: 0 !important;
    }

    .status-message {
        font-size: 13px !important;
        padding: 4px 8px !important;
        width: 100% !important;
        margin: 5px 0 !important;
        border-radius: 0 !important;
    }

    .evaluation-panel {
        font-size: 12px !important;
        padding: 8px !important;
        margin: 0 !important;
    }

    #eval-text {
        font-size: 20px !important;
    }

    .piece-option {
        padding: 8px !important;
        width: 50px !important;
    }

    .difficulty-control {
        padding: 8px !important;
        margin: 5px 0 !important;
    }

    .piece-selector {
        justify-content: center !important;
        gap: 8px !important;
        margin: 5px 0 !important;
    }

    .side-selector p {
        margin: 5px 0 !important;
        font-size: 13px !important;
    }

    .feedback-container {
        margin: 5px 0 !important;
        padding: 5px !important;
    }

    #blunder-feedback {
        font-size: 12px !important;
    }

    #undoButton {
        padding: 6px !important;
        font-size: 12px !important;
    }
}

/* Columns */
.left-column, .right-column {
    width: 20%;
    min-width: 200px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.middle-column {
    width: 50%;
    max-width: 500px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    height: 100%;
    box-sizing: border-box;
}

/* Board */
#board {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    position: relative;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    flex: 1;
    min-height: 0; /* Allow board to shrink */
}

/* Chess board arrows */
#board-arrows {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* Status message */
.status-message {
    text-align: center;
    margin: 0 auto;
    padding: 8px 15px;
    font-size: 18px;
    font-weight: bold;
    border-radius: 8px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    color: #495057;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    word-wrap: break-word;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    width: 90%;
    max-width: 350px;
}

/* Buttons */
.button-controls button,
#toggleEvalButton {
    width: 100%;
    margin: 0 0 10px 0;
    padding: 12px;
    background-color: #495057;
    color: white;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: block;
    font-size: 14px;
}

.button-controls button:hover,
#toggleEvalButton:hover {
    background-color: #343a40;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.button-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 10px 0 20px 0;
}

/* Side selector */
.side-selector {
    margin: 20px 0;
}

.piece-selector {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 10px;
}

.piece-option {
    cursor: pointer;
    padding: 15px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 80px;
    background: white;
}

.piece-option:hover {
    border-color: #495057;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.selected-side {
    border-color: #495057 !important;
    background-color: #f8f9fa !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Difficulty control */
.difficulty-control {
    margin-bottom: 20px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

#skill-slider {
    width: 100%;
    margin: 10px 0;
    -webkit-appearance: none;
    height: 4px;
    background: #e9ecef;
    border-radius: 2px;
    outline: none;
}

#skill-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: #495057;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

#skill-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    background: #343a40;
}

/* Feedback container */
.feedback-container {
    display: none;
    flex-direction: column;
    gap: 8px;
    margin: 10px auto;
    width: 90%;
    max-width: 350px;
    background-color: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 10px;
    animation: fadeIn 0.3s ease;
    box-sizing: border-box;
}

.feedback-container.visible {
    display: flex !important;
}

/* Blunder feedback */
.blunder-status {
    background-color: transparent;
    border: none;
    color: #333;
    width: 100%;
    margin: 0;
    padding: 0;
    text-align: center;
    font-weight: bold;
    transition: all 0.3s ease;
    font-size: 14px;
    line-height: 1.4;
    box-sizing: border-box;
}

.blunder-status.blunder {
    color: #d32f2f;
    background-color: #ffebee;
    border-radius: 6px;
    padding: 10px;
    margin: 0;
}

.blunder-text {
    color: #d32f2f;
    font-weight: bold;
    font-size: 16px;
    display: block;
    margin-bottom: 6px;
}

/* Undo button */
#undoButton {
    width: 100%;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.3s ease;
    margin-top: 8px;
    background-color: #f44336;
    color: white;
    font-weight: bold;
    border: 2px solid #f44336;
    cursor: pointer;
    font-size: 14px;
    box-sizing: border-box;
}

#undoButton:hover {
    background-color: #d32f2f;
    border-color: #d32f2f;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Evaluation panel */
.evaluation-panel {
    display: none;
    width: 100%;
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.evaluation-panel.visible {
    display: block;
}

.evaluation-panel h4 {
    margin: 0 0 15px 0;
    text-align: center;
    color: #495057;
    font-size: 16px;
    font-weight: 500;
}

#eval-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

#eval-table td {
    padding: 8px;
    border-bottom: 1px solid #e9ecef;
}

#eval-table td:first-child {
    font-weight: 500;
    width: 40%;
    color: #495057;
}

/* Live evaluation */
.live-eval {
    width: 100%;
    margin: 0 0 20px 0;
    text-align: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

#eval-text {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 10px;
    color: #495057;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.computer-status {
    background-color: #f8f9fa;
    border-color: #e9ecef;
    color: #333;
    margin: 10px auto;
    min-height: 40px;
    padding: 8px 15px;
    font-size: 18px;
    font-weight: bold;
    width: 90%;
    transition: all 0.3s ease;
}

.computer-status.checkmate {
    background-color: #d32f2f !important;
    color: white !important;
    border-color: #b71c1c !important;
    font-size: 20px !important;
    padding: 12px 20px !important;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

#elo-display, .elo-text {
    font-weight: bold;
    color: #495057;
}

/* Description */
.description {
    width: 100%;
    padding: 15px;
    margin-top: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.description h2 {
    color: #495057;
    margin: 0 0 12px 0;
    font-size: 20px;
    font-weight: bold;
}

.description p {
    color: #495057;
    margin: 0 0 12px 0;
    line-height: 1.4;
    font-size: 14px;
}

.description ul {
    margin: 0 0 12px 0;
    padding-left: 20px;
}

.description li {
    color: #495057;
    margin-bottom: 6px;
    line-height: 1.3;
    font-size: 14px;
}

/* Info Button */
.info-button {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    background-color: #f8f9fa !important;
    color: #495057 !important;
    border: 2px solid #e9ecef !important;
    font-size: 20px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    z-index: 100 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}

.info-button:hover {
    background-color: #e9ecef !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    border-color: #495057 !important;
}

/* Modal */
.modal {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #f8f9fa;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: slideIn 0.3s ease;
    text-align: center;
}

.close-button {
    position: absolute;
    right: 15px;
    top: 15px;
    font-size: 24px;
    font-weight: bold;
    color: #495057;
    cursor: pointer;
    transition: color 0.2s ease;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: #e9ecef;
}

.close-button:hover {
    color: #343a40;
    background-color: #dee2e6;
}

.modal-content h2 {
    color: #495057;
    margin: 0 0 20px 0;
    font-size: 24px;
    font-weight: bold;
    padding-right: 20px; /* Make room for close button */
}

.modal-content p {
    color: #495057;
    margin: 0 0 20px 0;
    line-height: 1.5;
    font-size: 16px;
}

.modal-content ul {
    margin: 0 0 20px 0;
    padding-left: 0;
    list-style-position: inside;
    text-align: left;
    display: inline-block;
}

.modal-content li {
    color: #495057;
    margin-bottom: 12px;
    line-height: 1.4;
    font-size: 16px;
    text-align: left;
}

@keyframes slideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Top Controls */
.top-controls {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
