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

html, body {
    overflow-x: hidden;
    max-width: 100vw;
}

body {
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #0f0f0f 0%, #1a1a1a 50%, #0f0f0f 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    padding: 1rem;
    position: relative;
    overflow: hidden;
}

body::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 50%, rgba(100, 100, 255, 0.03) 0%, transparent 50%),
                radial-gradient(circle at 70% 50%, rgba(255, 100, 150, 0.03) 0%, transparent 50%);
    animation: gradientShift 15s ease infinite;
    z-index: 0;
}

@keyframes gradientShift {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-50px, -50px); }
}

.container {
    width: 100%;
    max-width: 650px;
    position: relative;
    z-index: 1;
}

/* HEADER */
header {
    text-align: center;
    margin-bottom: 2.5rem;
}

header h1 {
    font-size: 1rem;
    font-weight: 200;
    letter-spacing: 12px;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #ffffff 0%, #a0a0a0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-transform: uppercase;
    text-shadow: 0 0 40px rgba(255, 255, 255, 0.1);
}

.controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    padding: 0.9rem 2rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 400;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(20px);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

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

/* GAME WRAPPER */
.game-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* ÉCHIQUIER */
.chessboard {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    max-width: 560px;
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.4),
        inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    position: relative;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* LES CASES */
.square {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.square.light {
    background: rgba(240, 240, 240, 0.993);
}

.square.dark {
    background: rgba(160, 160, 160, 0.7);
}

.square:hover {
    background: rgba(255, 255, 255, 0.15) !important;
    backdrop-filter: blur(5px);
}

.square[data-row="7"]::before {
    content: attr(data-letter);
    position: absolute;
    bottom: 3px;
    right: 5px;
    font-size: 0.65rem;
    font-weight: 600;
    opacity: 0.4;
    color: #333;
}

.square.light[data-row="7"]::before {
    color: #666;
}

.square[data-col="0"]::after {
    content: attr(data-number);
    position: absolute;
    top: 3px;
    left: 5px;
    font-size: 0.65rem;
    font-weight: 600;
    opacity: 0.4;
    color: #333;
}

.square.light[data-col="0"]::after {
    color: #666;
}

/* PIÈCES */
.piece {
    width: 75%;
    height: 75%;
    cursor: grab;
    user-select: none;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(2.5rem, 7vw, 3.5rem);
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4));
}

.piece[data-color="white"] {
    color: #fff;
    text-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.3),
        0 0 8px rgba(255, 255, 255, 0.3);
}

.piece[data-color="black"] {
    color: #1a1a1a;
    text-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.6),
        0 0 4px rgba(0, 0, 0, 0.2);
}

.piece:hover {
    transform: scale(1.15);
    filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.5));
}

.piece:active {
    cursor: grabbing;
    transform: scale(1.05);
}

.square.selected {
    background: rgba(100, 180, 255, 0.3) !important;
    box-shadow: inset 0 0 0 3px rgba(100, 180, 255, 0.6);
    backdrop-filter: blur(10px);
}

.square.possible-move {
    position: relative;
}

.square.possible-move::before {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    background: rgba(100, 255, 180, 0.4);
    border-radius: 50%;
    box-shadow: 0 0 15px rgba(100, 255, 180, 0.3);
    pointer-events: none;
    z-index: 1;
}

.square.possible-capture::before {
    width: 85%;
    height: 85%;
    background: transparent;
    border: 3px solid rgba(255, 100, 100, 0.6);
    box-shadow: 0 0 20px rgba(255, 100, 100, 0.3);
}

/* ANIMATION DE DÉPLACEMENT */
.piece.moving {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
        letter-spacing: 6px;
    }
    
    .chessboard {
        max-width: 92vw;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0.5rem;
    }
    
    header h1 {
        font-size: 1.6rem;
        letter-spacing: 4px;
        margin-bottom: 1.5rem;
    }
    
    .btn {
        padding: 0.7rem 1.5rem;
        font-size: 0.85rem;
    }
    
    .piece {
        font-size: clamp(2rem, 6vw, 2.8rem);
    }
}

/* PROMOTION DU PION */
.promotion-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(5px);
}

.promotion-dialog {
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.promotion-dialog h2 {
    font-size: 1.5rem;
    font-weight: 300;
    margin-bottom: 1.5rem;
    color: #fff;
}

.promotion-choices {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.promotion-piece {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.promotion-piece:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

.promotion-piece:active {
    transform: scale(0.95);
}

/* TIMER */
.timer-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.2rem;
}

.timer {
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.timer.active {
    background: rgba(100, 180, 255, 0.15);
    border-color: rgba(100, 180, 255, 0.5);
    box-shadow: 0 0 20px rgba(100, 180, 255, 0.3);
    transform: scale(1.05);
}

.timer-label {
    font-size: 0.55rem;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.2rem;
    font-weight: 500;
}

.timer-display {
    font-size: 1.3rem;
    font-weight: 400;
    color: #fff;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5px;
}

.timer.warning {
    border-color: rgba(255, 107, 107, 0.6);
    background: rgba(255, 107, 107, 0.1);
}

.timer.warning .timer-display {
    color: #ff6b6b;
    animation: pulse 1s infinite;
}

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

@media (max-width: 480px) {
    .timer-container {
        gap: 0.8rem;
        margin-bottom: 1rem;
    }
    
    .timer {
        width: 70px;
        height: 70px;
    }
    
    .timer-label {
        font-size: 0.45rem;
        letter-spacing: 0.5px;
        margin-bottom: 0.1rem;
    }
    
    .timer-display {
        font-size: 0.95rem;
        letter-spacing: 0px;
    }
    
    .promotion-piece {
        width: 60px;
        height: 60px;
        font-size: 2.5rem;
    }
}