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

html {
    overflow-x: hidden;
    width: 100%;
}

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: 10px;
    overflow-x: hidden;
}

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

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

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

.game-info {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.status {
    font-size: 1.2em;
    font-weight: bold;
    color: #555;
    padding: 10px 20px;
    background: #f0f0f0;
    border-radius: 10px;
}

.reset-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 1em;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-weight: bold;
}

.reset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

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

main {
    display: flex;
    gap: 30px;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
    width: 100%;
    max-width: 100%;
}

.chess-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: min(calc(100vw - 60px), 640px);
    height: min(calc(100vw - 60px), 640px);
    max-width: 640px;
    max-height: 640px;
    border: 3px solid #333;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    margin: 0 auto;
}

.square {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3.5em;
    cursor: pointer;
    transition: background-color 0.2s;
    position: relative;
}

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

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

.square.selected {
    background-color: #aacc44 !important;
}

.square.possible-move {
    background-color: #8bc34a !important;
    opacity: 0.7;
}

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

.square.possible-capture {
    background-color: #ff6b6b !important;
}

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.piece {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    transition: transform 0.2s;
}

.piece:hover {
    transform: scale(1.1);
}

.captured-pieces {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 200px;
}

.captured-section {
    background: #f8f8f8;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.captured-section h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1em;
    text-align: center;
}

.captured-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-height: 30px;
    font-size: 1.5em;
}

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

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.3s ease-out;
}

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

.modal-content h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 2em;
}

@media (max-width: 768px) {
    body {
        padding: 5px;
    }
    
    .container {
        padding: 10px;
        border-radius: 15px;
    }
    
    header {
        margin-bottom: 15px;
    }
    
    h1 {
        font-size: 1.8em;
        margin-bottom: 10px;
    }
    
    .game-info {
        gap: 10px;
        flex-direction: column;
    }
    
    .status {
        font-size: 1em;
        padding: 8px 16px;
    }
    
    .reset-btn {
        padding: 10px 20px;
        font-size: 0.9em;
    }
    
    .chess-board {
        width: min(calc(100vw - 30px), calc(100vh - 250px), 500px);
        height: min(calc(100vw - 30px), calc(100vh - 250px), 500px);
        border: 2px solid #333;
    }
    
    .square {
        font-size: 2em;
    }
    
    main {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }
    
    .captured-pieces {
        width: 100%;
        flex-direction: row;
        justify-content: space-around;
        gap: 10px;
    }
    
    .captured-section {
        padding: 10px;
        flex: 1;
    }
    
    .captured-section h3 {
        font-size: 0.85em;
        margin-bottom: 5px;
    }
    
    .captured-list {
        font-size: 1.2em;
        min-height: 25px;
    }
    
    .modal-content {
        padding: 25px;
        margin: 20px;
        max-width: calc(100vw - 40px);
    }
    
    .modal-content h2 {
        font-size: 1.5em;
    }
}

@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    
    .container {
        padding: 8px;
        border-radius: 10px;
    }
    
    h1 {
        font-size: 1.5em;
        margin-bottom: 8px;
    }
    
    .chess-board {
        width: min(calc(100vw - 20px), calc(100vh - 220px));
        height: min(calc(100vw - 20px), calc(100vh - 220px));
        border: 2px solid #333;
    }
    
    .square {
        font-size: 1.6em;
    }
    
    .captured-section {
        padding: 8px;
    }
    
    .captured-section h3 {
        font-size: 0.75em;
    }
    
    .captured-list {
        font-size: 1em;
    }
    
    .modal-content {
        padding: 20px;
        margin: 15px;
        max-width: calc(100vw - 30px);
    }
    
    .modal-content h2 {
        font-size: 1.2em;
    }
}