* {
    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;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 700px;
    width: 100%;
}

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

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

h1 {
    color: #333;
    font-size: 2.5em;
    margin: 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.locale-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.locale-selector label {
    font-size: 1.5em;
    cursor: pointer;
}

.locale-select {
    padding: 8px 12px;
    border: 2px solid #667eea;
    border-radius: 8px;
    background: white;
    color: #333;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.locale-select:hover {
    background: #f5f5f5;
    border-color: #764ba2;
}

.locale-select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

.game-mode-selector {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.mode-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #f5f5f5;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    color: #333;
}

.mode-label:hover {
    background: #e0e0e0;
    transform: translateY(-2px);
}

.mode-label input[type="radio"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
    accent-color: #667eea;
}

.mode-label input[type="radio"]:checked + span {
    color: #667eea;
    font-weight: bold;
}

.game-info {
    margin-bottom: 20px;
}

.player-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.player {
    flex: 1;
    padding: 15px;
    border-radius: 10px;
    background: #f5f5f5;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.player.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.player-name {
    font-weight: bold;
    font-size: 1.1em;
}

.piece-count {
    font-size: 1.5em;
    font-weight: bold;
}

.turn-indicator {
    padding: 10px 20px;
    background: #333;
    color: white;
    border-radius: 25px;
    font-weight: bold;
    font-size: 0.9em;
    white-space: nowrap;
}

.board-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 20px 0;
    width: 100%;
}

.board-wrapper {
    display: flex;
    align-items: center;
    gap: 0;
    width: 100%;
    max-width: 600px;
    justify-content: center;
}

.board-labels-top,
.board-labels-bottom {
    display: grid;
    grid-template-columns: 30px repeat(8, 1fr) 30px;
    width: 100%;
    max-width: 600px;
    margin-bottom: 2px;
}

.board-labels-bottom {
    margin-bottom: 0;
    margin-top: 2px;
}

.board-labels-left,
.board-labels-right {
    display: flex;
    flex-direction: column;
    width: 30px;
    flex-shrink: 0;
    height: 100%;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 0;
    border: 4px solid #333;
    border-radius: 10px;
    overflow: hidden;
    background: #deb887;
    width: 540px;
    height: 540px;
    flex-shrink: 0;
    transition: opacity 0.3s ease;
}

/* Rules Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
}

.modal-content {
    background-color: white;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 700px;
    width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 2px solid #e0e0e0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 15px 15px 0 0;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.8em;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 2em;
    font-weight: bold;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    line-height: 1;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.modal-body {
    padding: 30px;
    overflow-y: auto;
    flex: 1;
    color: #333;
    line-height: 1.6;
}

.modal-body h1 {
    color: #667eea;
    font-size: 1.8em;
    margin-top: 0;
    margin-bottom: 20px;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.modal-body h2 {
    color: #764ba2;
    font-size: 1.4em;
    margin-top: 25px;
    margin-bottom: 15px;
}

.modal-body h3 {
    color: #495057;
    font-size: 1.2em;
    margin-top: 20px;
    margin-bottom: 10px;
}

.modal-body p {
    margin: 10px 0;
}

.modal-body ul {
    margin: 15px 0;
    padding-left: 30px;
}

.modal-body li {
    margin: 8px 0;
}

.modal-body strong {
    color: #667eea;
    font-weight: 600;
}

.modal-body hr {
    border: none;
    border-top: 2px solid #e0e0e0;
    margin: 30px 0;
}

@media (max-width: 600px) {
    .game-board {
        width: calc(100vw - 100px);
        height: calc(100vw - 100px);
        max-width: 540px;
        max-height: 540px;
    }
    
    .board-labels-top,
    .board-labels-bottom {
        max-width: calc(100vw - 60px);
    }

    .modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .modal-header {
        padding: 15px 20px;
    }

    .modal-header h2 {
        font-size: 1.4em;
    }

    .modal-body {
        padding: 20px;
    }
}

.file-label,
.rank-label {
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    color: #333;
    font-size: 0.9em;
    user-select: none;
}

.file-label {
    height: 25px;
}

.rank-label {
    height: calc(540px / 8);
    min-height: 25px;
}

@media (max-width: 600px) {
    .rank-label {
        height: calc((100vw - 100px) / 8);
    }
}

.label-spacer {
    width: 30px;
}

.cell {
    aspect-ratio: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cell.light {
    background: #f0d9b5;
}

.cell.dark {
    background: #b58863;
}

.cell.valid-move {
    background: rgba(102, 126, 234, 0.3);
    cursor: pointer;
}

.cell.valid-move::before {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    background: rgba(102, 126, 234, 0.6);
    border-radius: 50%;
}

.cell.selected {
    background: rgba(255, 215, 0, 0.5);
    box-shadow: inset 0 0 20px rgba(255, 215, 0, 0.8);
}

.piece {
    width: 80%;
    height: 80%;
    border-radius: 50%;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.piece:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.piece.red {
    background: radial-gradient(circle at 30% 30%, #ff6b6b, #c92a2a);
    border: 3px solid #a61e1e;
}

.piece.black {
    background: radial-gradient(circle at 30% 30%, #495057, #212529);
    border: 3px solid #000;
}

.piece.king::after {
    content: '♔';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5em;
    color: gold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.piece.red.king::after {
    color: #ffd700;
}

.piece.black.king::after {
    color: #ffd700;
}

.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.btn:active {
    transform: translateY(0);
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.4);
}

.btn-secondary:hover {
    box-shadow: 0 6px 20px rgba(108, 117, 125, 0.6);
}

.game-status {
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
    min-height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-status.winner {
    color: #28a745;
    animation: pulse 1s infinite;
}

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

@media (max-width: 600px) {
    .container {
        padding: 15px;
    }

    h1 {
        font-size: 2em;
    }

    .player-info {
        flex-direction: column;
        gap: 10px;
    }

    .turn-indicator {
        order: -1;
    }

    .game-board {
        margin: 10px 0;
    }
}

