@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Roboto:wght@400;500;700&display=swap');

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

body {
    display: flex;
    place-items: center;
    justify-content: center;
    overflow-x: hidden;
    background: url(images/background.jpg);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    min-height: 100vh;
    font-family: 'Roboto', sans-serif;
    position: relative;
}

/* Dark overlay for better contrast */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0.6) 100%);
    pointer-events: none;
}

.container {
    display: grid;
    place-items: center;
    justify-content: center;
    padding: 25px 35px;
    background: linear-gradient(145deg, rgba(40, 40, 40, 0.95), rgba(20, 20, 20, 0.98));
    border-radius: 20px;
    position: relative;
    z-index: 1;
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.5),
        0 0 100px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin: 20px;
}

.div {
    display: flex;
}

ul {
    display: grid;
    grid-template-columns: 1fr;
    background: linear-gradient(145deg, #1a1a1a, #0d0d0d);
    padding: 12px;
    border-radius: 8px;
    box-shadow: 
        0 10px 40px rgba(0, 0, 0, 0.5),
        inset 0 2px 4px rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(139, 119, 85, 0.3);
}

li {
    list-style: none;
    display: grid;
    place-items: center;
    font-size: 0;
}

.box {
    margin: 1px;
    width: 75px;
    height: 75px;
    box-shadow: 
        inset 0 2px 4px rgba(255, 255, 255, 0.1),
        inset 0 -2px 4px rgba(0, 0, 0, 0.2),
        0 2px 4px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    border-radius: 2px;
}

.box:hover {
    transform: scale(1.02);
    z-index: 10;
}

h1 {
    margin: 15px 0 20px 0;
    font-family: 'Cinzel', serif;
    font-size: 2.8rem;
    font-weight: 700;
    text-align: center;
    color: #d4af37;
    text-shadow: 
        0 2px 10px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(212, 175, 55, 0.3);
    letter-spacing: 6px;
    padding: 15px 30px;
    border: none;
    background-color: transparent;
    border-radius: 0;
    position: relative;
}

h1::before {
    content: '♔';
    position: absolute;
    left: -35px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.8rem;
    color: #d4af37;
}

h1::after {
    content: '♚';
    position: absolute;
    right: -35px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.8rem;
    color: #d4af37;
}

#tog {
    margin: 25px 0 15px 0;
    font-family: 'Cinzel', serif;
    font-size: 1.4rem;
    font-weight: 600;
    text-align: center;
    background: linear-gradient(145deg, #fafafa, #e0e0e0);
    color: #2c2c2c;
    border: none;
    padding: 15px 40px;
    border-radius: 50px;
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    letter-spacing: 2px;
    transition: all 0.3s ease;
}

.game-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 15px;
}

#reset-btn, #draw-btn {
    font-family: 'Roboto', sans-serif;
    font-weight: 600;
    border: none;
    color: white;
    padding: 12px 28px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 14px;
    margin-top: 4px;
    cursor: pointer;
    border-radius: 50px;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

#reset-btn {
    background: linear-gradient(145deg, #5cb85c, #449d44);
}

#reset-btn:hover {
    background: linear-gradient(145deg, #6fcf6f, #5cb85c);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

#draw-btn {
    background: linear-gradient(145deg, #ff9800, #e68a00);
}

#draw-btn:hover {
    background: linear-gradient(145deg, #ffad33, #ff9800);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 152, 0, 0.4);
}

.all-img {
    width: 65px;
    position: relative;
    bottom: 5px;
    filter: drop-shadow(2px 4px 6px rgba(0, 0, 0, 0.4));
    transition: transform 0.15s ease;
}

.box:hover .all-img {
    transform: scale(1.05);
}

.all-pawn {
    transform: scale(.7);
}

.box:hover .all-pawn {
    transform: scale(.75);
}

.authcont {
    width: 100vw;
}

.author {
    float: right;
    margin-right: 50px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
}

@media (max-width: 650px) {
    .container {
        padding: 15px;
        margin: 10px;
        border-radius: 15px;
    }

    .box {
        width: 11vw;
        height: 11vw;
    }

    .all-img {
        width: 9vw;
    }

    #tog {
        margin: 20px 0;
        font-size: 1rem;
        padding: 12px 25px;
    }

    #reset-btn, #draw-btn {
        font-size: 12px;
        padding: 10px 20px;
    }

    h1 {
        font-size: 1.8rem;
        letter-spacing: 3px;
    }

    h1::before, h1::after {
        display: none;
    }

    ul {
        padding: 8px;
    }
}

@media (max-width: 400px) {
    h1 {
        font-size: 1.4rem;
        letter-spacing: 2px;
    }

    #tog {
        margin: 15px 0;
        font-size: 0.85rem;
        padding: 10px 20px;
    }

    .game-buttons {
        flex-direction: column;
        gap: 10px;
    }

    #reset-btn, #draw-btn {
        width: 100%;
    }
}

/* Promotion Dialog */
.promotion-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: linear-gradient(145deg, rgba(30, 30, 30, 0.98), rgba(15, 15, 15, 0.99));
    padding: 30px 40px;
    border-radius: 20px;
    z-index: 1000;
    display: none;
    box-shadow: 
        0 25px 60px rgba(0, 0, 0, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(212, 175, 55, 0.3);
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 90vw;
}

.promotion-dialog.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.promotion-dialog h3 {
    font-family: 'Cinzel', serif;
    color: #d4af37;
    margin-bottom: 20px;
    font-size: 1.4rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    text-align: center;
}

.promotion-options {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.promotion-option {
    width: 70px;
    height: 70px;
    cursor: pointer;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    background-size: 80%;
    background-repeat: no-repeat;
    background-position: center;
    background-color: rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
}

@media (hover: hover) {
    .promotion-option:hover {
        border-color: #d4af37;
        background-color: rgba(212, 175, 55, 0.2);
        transform: scale(1.1);
        box-shadow: 0 5px 20px rgba(212, 175, 55, 0.3);
    }
}

.promotion-option:active {
    border-color: #d4af37;
    background-color: rgba(212, 175, 55, 0.2);
}

@media (max-width: 400px) {
    .promotion-dialog {
        padding: 20px;
    }

    .promotion-dialog h3 {
        font-size: 1.1rem;
        letter-spacing: 1px;
    }

    .promotion-option {
        width: 55px;
        height: 55px;
    }

    .promotion-options {
        gap: 10px;
    }
}

.promotion-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.promotion-overlay.active {
    display: block;
    opacity: 1;
}

/* Last Move Highlighting */
.last-move {
    box-shadow: inset 0 0 12px 4px rgba(255, 215, 0, 0.5) !important;
    position: relative;
}

.last-move::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 215, 0, 0.15);
    pointer-events: none;
    border-radius: 2px;
}

/* Move Counter */
#move-counter {
    font-family: 'Roboto', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 12px;
    padding: 8px 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    letter-spacing: 1px;
}

/* Captured Pieces Display */
.captured-pieces {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 608px;
    margin: 15px auto 5px auto;
    gap: 20px;
}

.captured {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-height: 45px;
    padding: 10px;
    background: linear-gradient(145deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
    border-radius: 10px;
    flex: 1;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.captured img {
    width: 28px;
    height: 28px;
    filter: drop-shadow(1px 2px 3px rgba(0, 0, 0, 0.5));
    transition: transform 0.2s ease;
}

.captured img:hover {
    transform: scale(1.2);
}

/* King in Check Visual Indicator */
.in-check {
    background: radial-gradient(ellipse at center, #ff0000 0%, #cc0000 25%, rgba(200, 0, 0, 0.5) 60%, transparent 100%) !important;
    animation: checkPulse 1s ease-in-out infinite;
}

@keyframes checkPulse {
    0%, 100% {
        box-shadow: inset 0 0 15px 5px rgba(255, 0, 0, 0.8), 0 0 10px 3px rgba(255, 0, 0, 0.6);
    }
    50% {
        box-shadow: inset 0 0 20px 8px rgba(255, 0, 0, 1), 0 0 15px 5px rgba(255, 0, 0, 0.8);
    }
}

/* Selection highlighting improvements */
.box[style*="background-color: blue"] {
    box-shadow: 
        inset 0 0 15px 5px rgba(0, 100, 255, 0.6),
        0 0 15px 5px rgba(0, 100, 255, 0.4) !important;
}

.box[style*="background-color: greenyellow"] {
    box-shadow: 
        inset 0 0 10px 3px rgba(173, 255, 47, 0.5),
        0 0 8px 2px rgba(173, 255, 47, 0.3) !important;
}

/* ============================================
   AUDIO CONTROLS
   ============================================ */

.audio-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    padding: 12px 20px;
    background: linear-gradient(145deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.control-btn {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(145deg, #3a3a3a, #2a2a2a);
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 
        0 4px 10px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.control-btn:hover {
    background: linear-gradient(145deg, #4a4a4a, #3a3a3a);
    color: #d4af37;
    transform: scale(1.1);
    box-shadow: 
        0 6px 15px rgba(0, 0, 0, 0.4),
        0 0 15px rgba(212, 175, 55, 0.3);
}

.control-btn.active {
    background: linear-gradient(145deg, #d4af37, #b8962e);
    color: #1a1a1a;
    box-shadow: 
        0 4px 15px rgba(212, 175, 55, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.control-btn.active:hover {
    background: linear-gradient(145deg, #e5c04a, #d4af37);
    color: #1a1a1a;
}

.track-name {
    font-family: 'Roboto', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
    min-width: 120px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 10px;
}

/* ============================================
   FULLSCREEN MODE
   ============================================ */

.container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    margin: 0;
    border-radius: 0;
    z-index: 9999;
    overflow: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    /* Make container semi-transparent to show background */
    background: linear-gradient(145deg, rgba(40, 40, 40, 0.85), rgba(20, 20, 20, 0.88));
}

.container.fullscreen h1 {
    display: none;
}

.container.fullscreen .authcont {
    display: none;
}

.container.fullscreen .box {
    width: 85px;
    height: 85px;
}

.container.fullscreen .all-img {
    width: 75px;
}

.container.fullscreen .captured-pieces {
    max-width: 696px;
}

/* Mobile adjustments for audio controls */
@media (max-width: 650px) {
    .audio-controls {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 15px;
        border-radius: 20px;
    }

    .control-btn {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .track-name {
        font-size: 0.75rem;
        min-width: 100px;
        order: 5;
        width: 100%;
        margin-top: 5px;
    }

    .container.fullscreen .box {
        width: 12vw;
        height: 12vw;
    }

    .container.fullscreen .all-img {
        width: 10vw;
    }
}

@media (max-width: 400px) {
    .audio-controls {
        gap: 6px;
        padding: 8px 12px;
    }

    .control-btn {
        width: 32px;
        height: 32px;
        font-size: 0.9rem;
    }

    .track-name {
        font-size: 0.7rem;
        min-width: 80px;
    }
}
