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

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

/* Body styling */
body {
    margin: 0;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    font-family: 'Arial', sans-serif;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: start;
    min-height: 100vh;
    color: white;
    overflow-x: hidden; /* Hindari scroll horizontal */
}

.block-preview, .rotate-btn, .score-value {
    user-select: none;
}

/* Container utama untuk game + leaderboard */
.container {
    display: flex;
    gap: 40px;
    flex-wrap: wrap;
    max-width: 1100px;
    width: 100%;
    justify-content: center;
}

/* Game container */
.game-container {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: 440px;
    text-align: center;
}

/* Judul game */
.game-title {
    font-size: 2.5em;
    font-weight: bold;
    margin: 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    background: linear-gradient(45deg, #fff, #f0f0f0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Skor */
.score-container {
    display: flex;
    justify-content: space-between;
    margin: 20px 0;
    gap: 20px;
    flex-wrap: wrap;
}

.score-item {
    background: rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    border-radius: 15px;
    text-align: center;
    backdrop-filter: blur(5px);
    flex: 1;
    min-width: 100px;
}

.score-label {
    font-size: 0.9em;
    opacity: 0.8;
    margin-bottom: 5px;
}

.score-value {
    font-size: 1.5em;
    font-weight: bold;
}

/* Canvas game */
canvas#gameCanvas {
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    background: #2c3e50;
    margin-bottom: 20px;
    display: block;
    max-width: 100%;
    height: auto;
}

/* Preview blok */
.next-blocks {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.block-preview {
    width: 80px;
    height: 80px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.block-preview:hover {
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.4);
}

.block-preview.selected {
    border-color: #ffd700;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.block-preview.dragging {
    opacity: 0.5;
    transform: scale(0.8);
}

/* Tombol rotasi */
.rotate-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(45deg, #ff6b6b, #ee5a24);
    border: none;
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.rotate-btn:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.rotate-btn:active {
    transform: scale(0.95) rotate(180deg);
}

/* Drag ghost preview */
.drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.8;
    transform-origin: center;
    transition: none;
}

.grid-cell-highlight {
    position: fixed; /* Pastikan elemen tetap di posisi yang benar */
    border: 3px solid #ffd700;
    border-radius: 5px;
    pointer-events: none;
    z-index: 100;
    background: rgba(255, 215, 0, 0.2);
    transition: all 0.1s ease;
}

.grid-cell-invalid {
    border-color: #e74c3c;
    background: rgba(231, 76, 60, 0.2);
}

/* Leaderboard Section */
.leaderboard {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: 250px;
    min-height: 400px;
    color: white;
}

.leaderboard h2 {
    font-size: 1.5em;
    margin-bottom: 15px;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

#leaderboardList {
    list-style: none;
    padding-left: 0;
    counter-reset: rank;
}

#leaderboardList li {
    background: rgba(255, 255, 255, 0.15);
    padding: 10px 15px;
    margin-bottom: 10px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1em;
}

#leaderboardList li::before {
    content: counter(rank);
    counter-increment: rank;
    background: #ffd700;
    color: #000;
    padding: 5px 10px;
    border-radius: 50%;
    font-weight: bold;
    margin-right: 10px;
}

/* Modal game over */
.game-over {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.game-over-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.restart-btn {
    background: linear-gradient(45deg, #ff6b6b, #ee5a24);
    border: none;
    padding: 15px 30px;
    border-radius: 25px;
    color: white;
    font-size: 1.2em;
    cursor: pointer;
    margin-top: 20px;
    transition: all 0.3s ease;
}

.restart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    body {
        padding: 10px;
        flex-direction: column;
        align-items: center;
    }

    .container {
        flex-direction: column;
        align-items: center;
    }

    .game-container {
        width: 100%;
        max-width: 440px;
    }

    .next-blocks {
        flex-wrap: wrap;
        gap: 15px;
    }

    .block-preview {
        width: 70px;
        height: 70px;
    }

    .rotate-btn {
        width: 50px;
        height: 50px;
        font-size: 1.2em;
    }

    .leaderboard {
        width: 100%;
        max-width: 440px;
        margin-top: 20px;
    }
}
