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

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.title {
    font-size: 3rem;
    font-weight: 800;
    color: white;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.game-area {
    display: flex;
    align-items: center;
    gap: 60px;
}

/* Piece tray */
.piece-tray {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    min-height: 320px;
}

.tray-label {
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0.8;
}

.piece-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.draggable-piece {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    font-weight: 800;
    border-radius: 16px;
    cursor: grab;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.draggable-piece:hover {
    transform: scale(1.05);
}

.draggable-piece:active {
    cursor: grabbing;
}

.draggable-piece.dragging {
    opacity: 0.4;
}

.piece-x {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
}

.piece-o {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
}

/* Game board */
.board-container {
    position: relative;
}

.board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.cell {
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

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

.cell.drag-over {
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

.cell .draggable-piece {
    width: 90px;
    height: 90px;
    font-size: 54px;
}

.cell .draggable-piece.just-placed {
    animation: placepiece 0.3s ease;
}

@keyframes placepiece {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(10deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Win line overlay */
.win-line {
    position: absolute;
    background: linear-gradient(135deg, #f1c40f, #f39c12);
    border-radius: 10px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10;
    box-shadow: 0 0 30px rgba(241, 196, 15, 0.8);
}

.win-line.show {
    opacity: 1;
    animation: winPulse 1s ease-in-out infinite;
}

@keyframes winPulse {
    0%, 100% {
        box-shadow: 0 0 30px rgba(241, 196, 15, 0.8);
    }
    50% {
        box-shadow: 0 0 50px rgba(241, 196, 15, 1);
    }
}

/* Controls */
.controls {
    display: flex;
    gap: 20px;
}

.reset-btn {
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: 700;
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(46, 204, 113, 0.4);
}

.reset-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(46, 204, 113, 0.5);
}

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

/* Status message */
.status {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    text-align: center;
    min-height: 40px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.status.winner {
    animation: celebrate 0.5s ease;
    color: #f1c40f;
}

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

/* Drag ghost */
.drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 10000;
    opacity: 0.9;
    transform: scale(1.1);
}

/* Confetti */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    top: -20px;
}

/* Responsive */
@media (max-width: 900px) {
    .game-area {
        flex-direction: column;
        gap: 30px;
    }

    .piece-tray {
        flex-direction: row;
        gap: 30px;
        min-height: auto;
    }

    .piece-container {
        flex-direction: row;
    }

    .cell {
        width: 90px;
        height: 90px;
    }

    .cell .draggable-piece {
        width: 70px;
        height: 70px;
        font-size: 42px;
    }

    .draggable-piece {
        width: 60px;
        height: 60px;
        font-size: 36px;
    }

    .title {
        font-size: 2rem;
    }
}

@media (max-width: 400px) {
    .cell {
        width: 70px;
        height: 70px;
    }

    .cell .draggable-piece {
        width: 55px;
        height: 55px;
        font-size: 32px;
    }

    .draggable-piece {
        width: 50px;
        height: 50px;
        font-size: 28px;
    }

    .board {
        gap: 6px;
        padding: 12px;
    }
}

@keyframes fall {
    0% {
        transform: translateY(-20px) translateX(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) translateX(var(--drift)) rotate(var(--rotation));
        opacity: 0;
    }
}
