:root {
    /* Colors */
    --bg-gradient-start: #0f172a;
    --bg-gradient-end: #1e1b4b;
    --primary-color: #6366f1;
    --accent-color: #f472b6;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;

    /* Cell Colors */
    --cell-empty: rgba(255, 255, 255, 0.03);
    --cell-gap: 4px;

    /* Spacing */
    --board-padding: 10px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

body {
    font-family: 'Outfit', sans-serif;
    background: radial-gradient(circle at top left, var(--bg-gradient-end), var(--bg-gradient-start));
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-container {
    width: 100%;
    max-width: 500px;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 20px;
    position: relative;
    max-height: 900px;
}

/* Header */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.game-title {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.highlight {
    color: var(--accent-color);
}

.score-board {
    display: flex;
    gap: 12px;
}

.score-box {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 8px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 70px;
}

.current-score {
    background: rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.3);
}

.score-label {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

.score-value {
    font-size: 18px;
    font-weight: 600;
}

/* Game Area */
.game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.board-container {
    width: 100%;
    aspect-ratio: 1;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    padding: var(--board-padding);
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: var(--cell-gap);
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

/* Cells */
.cell {
    background: var(--cell-empty);
    border-radius: 4px;
    transition: background-color 0.2s, transform 0.15s;
}

.cell.filled {
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
}

.cell.ghost {
    opacity: 0.4;
}

/* Hand Area */
.hand-area {
    height: 160px;
    margin-top: 20px;
    width: 100%;
}

.hand-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 100%;
    gap: 10px;
}

.block-wrapper {
    width: 30%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* Block Styles (Miniature view in hand) */
.block {
    display: grid;
    gap: 2px;
    /* Scale will be handled by JS or transform */
    transition: transform 0.1s;
    touch-action: none;
}

.block-cell {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.2);
}

/* Dragging state */
.block.dragging {
    position: fixed;
    z-index: 100;
    pointer-events: none;
    /* Let events pass through to check underlying elements */
    opacity: 0.9;
    transform: scale(1.1) !important;
    /* Slightly larger when dragging */
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.3));
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: #1e293b;
    padding: 30px 50px;
    border-radius: 20px;
    text-align: center;
    border: 1px solid var(--glass-border);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.modal-content h2 {
    font-size: 32px;
    margin-bottom: 15px;
    color: var(--text-primary);
}

.btn-restart {
    margin-top: 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    border: none;
    padding: 12px 30px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    border-radius: 30px;
    cursor: pointer;
    transition: transform 0.1s;
}

.btn-restart:active {
    transform: scale(0.95);
}

/* Animations */
@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    80% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.leaderboard-content {
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
}

#leaderboard-list table {
    margin-top: 10px;
    font-size: 0.95rem;
}

@keyframes fadeOut {
    to {
        transform: scale(0.8);
        opacity: 0;
    }
}

.anim-pop {
    animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.anim-clear {
    animation: fadeOut 0.2s forwards;
}

@keyframes pulse {
    0% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.6;
    }
}