:root {
    --board-size: min(80vw, 560px);
    --cell-size: calc(var(--board-size) / 8);
    --piece-scale: 0.85;
    --primary-color: #0d9488;
    --primary-hover: #0f766e;
    --black-piece: #1a1a2e;
    --white-piece: #f8fafc;
    --board-green: #2d5016;
    --board-dark: #1e3a0f;
    --hint-color: rgba(13, 148, 136, 0.35);
}

.game-body {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    min-height: 100vh;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

.game-container {
    max-width: 700px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: var(--board-size);
    gap: 15px;
    flex-wrap: wrap;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.player-info.active {
    background: rgba(13, 148, 136, 0.2);
    box-shadow: 0 0 20px rgba(13, 148, 136, 0.3);
}

.player-black.active {
    border: 2px solid var(--black-piece);
}

.player-white.active {
    border: 2px solid var(--white-piece);
}

.piece-preview {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    box-shadow:
        inset -3px -3px 6px rgba(0, 0, 0, 0.5),
        inset 3px 3px 6px rgba(255, 255, 255, 0.15),
        0 4px 10px rgba(0, 0, 0, 0.4);
}

.black-piece {
    background: radial-gradient(circle at 30% 30%, #4a4a6a, var(--black-piece) 60%);
}

.white-piece {
    background: radial-gradient(circle at 30% 30%, #ffffff, var(--white-piece) 60%);
}

.score {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    min-width: 28px;
    text-align: center;
}

.turn-indicator {
    padding: 8px 20px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    font-weight: 600;
    font-size: 14px;
    animation: pulse 2s infinite;
}

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

.board-wrapper {
    perspective: 1200px;
    width: var(--board-size);
    height: var(--board-size);
}

.board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: var(--board-size);
    height: var(--board-size);
    gap: 2px;
    padding: 8px;
    background: linear-gradient(145deg, #1a1a1a, #2d2d2d);
    border-radius: 16px;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.5),
        inset 0 2px 4px rgba(255, 255, 255, 0.05),
        0 0 0 4px #333;
    transform-style: preserve-3d;
    transform: rotateX(2deg) rotateY(-1deg);
    transition: transform 0.5s ease;
}

.board:hover {
    transform: rotateX(0deg) rotateY(0deg);
}

.cell {
    aspect-ratio: 1;
    background: linear-gradient(135deg, var(--board-green), var(--board-dark));
    border-radius: 4px;
    position: relative;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cell::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 4px;
    background: transparent;
    transition: background 0.25s ease;
}

.cell:hover::before {
    background: rgba(255, 255, 255, 0.08);
}

.cell.valid-move::after {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    border-radius: 50%;
    background: var(--hint-color);
    animation: hintPulse 1.5s infinite;
}

@keyframes hintPulse {
    0%, 100% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.3); opacity: 0.4; }
}

.cell.last-move {
    box-shadow: inset 0 0 0 3px var(--primary-color);
}

.piece-container {
    width: var(--cell-size);
    height: var(--cell-size);
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: 600px;
}

.piece {
    width: calc(var(--cell-size) * var(--piece-scale));
    height: calc(var(--cell-size) * var(--piece-scale));
    border-radius: 50%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: default;
}

.piece.black {
    background: radial-gradient(circle at 30% 30%, #4a4a6a, var(--black-piece) 65%, #0a0a15);
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.6),
        inset -4px -4px 10px rgba(0, 0, 0, 0.7),
        inset 4px 4px 10px rgba(100, 100, 140, 0.2),
        0 2px 4px rgba(0, 0, 0, 0.3);
}

.piece.white {
    background: radial-gradient(circle at 30% 30%, #ffffff, var(--white-piece) 65%, #e2e8f0);
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.35),
        inset -3px -3px 8px rgba(200, 210, 220, 0.5),
        inset 3px 3px 8px rgba(255, 255, 255, 0.9),
        0 2px 4px rgba(0, 0, 0, 0.15);
}

.piece::before {
    content: '';
    position: absolute;
    top: 8%;
    left: 15%;
    width: 35%;
    height: 25%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    filter: blur(2px);
}

.piece.flipping {
    animation: flipPiece 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes flipPiece {
    0% { transform: rotateY(0deg) scale(1); }
    50% { transform: rotateY(90deg) scale(1.08); }
    100% { transform: rotateY(180deg) scale(1); }
}

.piece.placing {
    animation: placePiece 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes placePiece {
    0% { transform: translateY(-40px) scale(0.5); opacity: 0; }
    60% { transform: translateY(5px) scale(1.05); opacity: 1; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    align-items: center;
    width: var(--board-size);
}

.btn {
    padding: 10px 22px;
    border: none;
    border-radius: 10px;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.25s ease;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    box-shadow: 0 4px 15px rgba(13, 148, 136, 0.35);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(13, 148, 136, 0.5);
}

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #cbd5e1;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
}

.toggle-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.difficulty-select {
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.06);
    color: #cbd5e1;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 14px;
    cursor: pointer;
    outline: none;
    transition: all 0.25s ease;
}

.difficulty-select:focus,
.difficulty-select:hover {
    border-color: var(--primary-color);
    background: rgba(13, 148, 136, 0.1);
}

.game-status {
    padding: 14px 28px;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.95);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.game-status.show {
    opacity: 1;
    transform: scale(1);
}

.game-status.win {
    background: linear-gradient(135deg, rgba(13, 148, 136, 0.25), rgba(13, 148, 136, 0.1));
    color: #2dd4bf;
    border: 2px solid rgba(13, 148, 136, 0.4);
}

.game-status.lose {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(239, 68, 68, 0.08));
    color: #fca5a5;
    border: 2px solid rgba(239, 68, 68, 0.3);
}

.game-status.draw {
    background: linear-gradient(135deg, rgba(250, 204, 21, 0.2), rgba(250, 204, 21, 0.08));
    color: #fde047;
    border: 2px solid rgba(250, 204, 21, 0.3);
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.25s ease;
}

.modal.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: linear-gradient(145deg, #1e293b, #0f172a);
    border-radius: 20px;
    padding: 32px;
    max-width: 480px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-content h2 {
    margin-top: 0;
    color: white;
    font-size: 22px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 12px;
}

.rules-content {
    color: #cbd5e1;
    line-height: 1.75;
    font-size: 15px;
}

.rules-content p {
    margin-bottom: 12px;
}

.rules-content ul {
    padding-left: 20px;
    margin-bottom: 12px;
}

.rules-content li {
    margin-bottom: 6px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
}

.setting-item:last-of-type {
    border-bottom: none;
}

.setting-item select {
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.06);
    color: #cbd5e1;
    font-family: 'Plus Jakarta Sans', sans-serif;
    cursor: pointer;
}

.modal-close {
    margin-top: 24px;
    width: 100%;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    width: 38px;
    height: 38px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: rgba(13, 148, 136, 0.2);
    border-color: var(--primary-color);
    transform: scale(1.08);
}

@media (max-width: 640px) {
    :root {
        --board-size: 92vw;
    }

    .game-header {
        width: 100%;
        justify-content: center;
        gap: 8px;
    }

    .player-info {
        padding: 8px 12px;
        font-size: 13px;
    }

    .piece-preview {
        width: 26px;
        height: 26px;
    }

    .score {
        font-size: 20px;
    }

    .turn-indicator {
        font-size: 12px;
        padding: 6px 14px;
        order: -1;
        width: 100%;
        text-align: center;
    }

    .controls {
        width: 100%;
        gap: 8px;
    }

    .btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    .difficulty-select {
        font-size: 13px;
        padding: 6px 10px;
    }

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

@media (max-width: 400px) {
    :root {
        --board-size: 96vw;
    }

    .piece-preview {
        width: 22px;
        height: 22px;
    }

    .score {
        font-size: 18px;
    }
}
