* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    color: white;
    font-size: 3em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 20px;
}

.game-info {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 20px;
}

.turn-indicator,
.game-status,
.opening-info {
    background: rgba(255, 255, 255, 0.9);
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.opening-info {
    background: rgba(255, 235, 59, 0.9);
    color: #333;
    font-style: italic;
    font-size: 0.9em;
}

.game-board-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 30px;
    margin-bottom: 30px;
}

.chess-board {
    border: 4px solid #8B4513;
    border-radius: 8px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    background: #8B4513;
    padding: 8px;
    position: relative;
    /* Important for absolute positioning of arrows */
}

.board-row {
    display: flex;
}

.square {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2em;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    user-select: none;
}

.square.light {
    background-color: #f0d9b5;
}

.square.dark {
    background-color: #b58863;
}

.square:hover {
    opacity: 0.8;
    transform: scale(1.05);
}

.square.selected {
    background-color: #7fb069 !important;
    box-shadow: 0 0 10px rgba(127, 176, 105, 0.7);
}

.square.valid-move {
    background-color: #9bb4d1 !important;
}

.square.valid-move::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
}

.square.capture-move {
    background-color: #d19b9b !important;
    border: 2px solid #c85454;
}

.square.in-check {
    background-color: #ff6b6b !important;
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    from {
        opacity: 0.7;
    }

    to {
        opacity: 1;
    }
}

.captured-pieces {
    background: rgba(255, 255, 255, 0.9);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    width: 200px;
    min-height: 200px;
}

.captured-pieces h3 {
    margin-bottom: 10px;
    color: #333;
    font-size: 1.1em;
}

.captured-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.captured-piece {
    font-size: 1.5em;
    padding: 2px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

.game-controls {
    text-align: center;
    margin-bottom: 30px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1em;
    cursor: pointer;
    margin: 0 10px;
    transition: all 0.3s ease;
    font-weight: bold;
}

.btn-primary {
    background: #4CAF50;
    color: white;
}

.btn-primary:hover {
    background: #45a049;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #f44336;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #da190b;
    transform: translateY(-2px);
}

.btn-danger {
    background-color: #dc3545;
    color: white;
}

.btn-danger:hover {
    background-color: #c82333;
}

.btn-warning {
    background-color: #ffc107;
    color: #212529;
}

.btn-warning:hover {
    background-color: #e0a800;
}

.btn-info {
    background-color: #17a2b8;
    color: white;
}

.btn-info:hover {
    background-color: #138496;
}

.btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

.promotion-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.promotion-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.promotion-pieces {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.promotion-piece {
    width: 60px;
    height: 60px;
    border: 2px solid #333;
    background: #f0d9b5;
    font-size: 2em;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.promotion-piece:hover {
    background: #b58863;
    transform: scale(1.1);
}

.move-history {
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.move-history h3 {
    margin-bottom: 15px;
    color: #333;
}

.move-list {
    max-height: 200px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

.move-item {
    padding: 5px 10px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}

.game-options {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.9);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.game-options label {
    font-weight: bold;
}

.game-options select {
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #ccc;
}

#analysisPanel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 350px;
    max-height: 400px;
    background-color: rgba(40, 40, 50, 0.95);
    color: #f0f0f0;
    border: 1px solid #555;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow-y: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
}

#analysisPanel h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #61dafb;
    border-bottom: 1px solid #555;
    padding-bottom: 5px;
}

#analysisOutput {
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 300px;
    overflow-y: auto;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    color: #ccc;
    font-size: 1.5em;
    cursor: pointer;
    padding: 0 5px;
}

.close-btn:hover {
    color: white;
}

#aiDifficultySetting,
#showAIAssistContainer {
    display: none;
    /* Initially hidden, shown only in PvC mode */
    align-items: center;
    gap: 5px;
}

#showAIAssistContainer input[type="checkbox"] {
    margin-right: 5px;
}

.arrow {
    position: absolute;
    pointer-events: none;
    z-index: 10;
    opacity: 0.7;
}

.arrow line {
    stroke: rgba(255, 0, 0, 0.7);
    stroke-width: 4;
    marker-end: url(#arrowhead);
}

.arrow-thinking {
    position: absolute;
    pointer-events: none;
    z-index: 10;
    opacity: 0.8;
}

.arrow-thinking line {
    stroke: rgba(255, 165, 0, 0.6);
    stroke-width: 3;
    stroke-dasharray: 5, 5;
    marker-end: url(#arrowhead-thinking);
}

/* Modal styles */
.modal {
    display: none;
    /* Hidden by default */
    position: fixed;
    /* Stay in place */
    z-index: 100;
    /* Sit on top */
    left: 0;
    top: 0;
    width: 100%;
    /* Full width */
    height: 100%;
    /* Full height */
    overflow: auto;
    /* Enable scroll if needed */
    background-color: rgba(0, 0, 0, 0.4);
    /* Black w/ opacity */
}

.modal-content {
    background-color: #fefefe;
    margin: 15% auto;
    /* 15% from the top and centered */
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    /* Could be more or less, depending on screen size */
    max-width: 500px;
    border-radius: 8px;
    text-align: center;
}

/* Checkmate Modal Specific Styles */
#checkmateModal .modal-content {
    max-width: 400px;
    /* More specific width for this modal */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

#checkmateMessage {
    font-size: 1.5em;
    margin-bottom: 20px;
    color: #333;
}

#closeCheckmateModalBtn {
    background-color: #4CAF50;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
}

#closeCheckmateModalBtn:hover {
    background-color: #45a049;
}