/* ===== GLOBAL STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

body {
    font-family: var(--font-family);
    background: var(--main-background);
    overflow: hidden;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    color: white;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

:root {
    --font-family: 'Arial', sans-serif;
    --main-background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --game-area-background: rgba(255,255,255,0.1);
    --grid-background: rgba(0,0,0,0.2);
    --primary-color: #ff6b6b;
    --secondary-color: #ee5a24;
    --accent-color: #74b9ff;
    --button-color: linear-gradient(45deg, #ff6b6b, #ee5a24);
    --restart-button-color: linear-gradient(45deg, #74b9ff, #0984e3);
    --title-font-size: 3em;
    --button-font-size: 1.5em;
    --animation-speed: 0.3s;
    --block-cell-size: 22px;
}

.container {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ===== MENU SCREEN STYLES ===== */
.menu-screen {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    z-index: 100;
    padding: 20px;
}

.menu-screen.hidden {
    display: none;
}

.title {
    font-size: var(--title-font-size);
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    animation: pulse 2s ease-in-out infinite;
}

.subtitle {
    font-size: 1.2em;
    margin-bottom: 40px;
    opacity: 0.8;
}

.play-button {
    background: var(--button-color);
    border: none;
    padding: 20px 50px;
    font-size: var(--button-font-size);
    color: white;
    border-radius: 50px;
    cursor: pointer;
    transition: all var(--animation-speed) ease;
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

.play-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(0,0,0,0.3);
}

/* Difficulty Selection */
.difficulty-selection {
    margin-top: 40px;
    text-align: center;
}

.difficulty-buttons {
    display: flex;
    gap: 25px;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
}

.difficulty-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 90px;
    height: 90px;
    padding: 10px;
    background: rgba(255,255,255,0.1);
    border: 3px solid rgba(255,255,255,0.2);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    position: relative;
}

.difficulty-btn:hover {
    border-color: rgba(255,255,255,0.4);
}


.difficulty-icon {
    font-size: 0.5em;
    line-height: 1;
    margin-bottom: 2px;
}

.difficulty-label {
    font-size: 0.75em;
    font-weight: bold;
    color: white;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* ===== GAME SCREEN - MOBILE FIRST ===== */
.game-screen {
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
}

.game-screen.active {
    display: flex;
}

/* Top Bar with Score and Controls */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.score-display {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.score-value {
    font-size: 2.5em;
    font-weight: bold;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.7);
    line-height: 0.9;
    transition: all 0.3s ease;
}

.score-value.animate {
    transform: scale(1.1);
    color: #00ff88;
}

.score-label {
    font-size: 0.8em;
    font-weight: bold;
    color: rgba(255,255,255,0.7);
    letter-spacing: 1px;
    margin-top: 2px;
}

.control-buttons {
    display: flex;
    gap: 10px;
}

.control-btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.control-btn:hover {
    transform: scale(1.05);
    background: rgba(255,255,255,0.25);
}

.control-btn:active {
    transform: scale(0.95);
}

.control-btn.muted {
    opacity: 0.5;
    background: rgba(255,0,0,0.2);
}

.control-btn.exit-btn:hover {
    background: rgba(255, 100, 100, 0.25);
    border-color: rgba(255, 150, 150, 0.5);
}

.btn-icon, #musicIcon {
    font-size: 1.2em;
    transition: all 0.3s ease;
}

/* Main Game Content */
.game-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 20px;
}

.grid-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.grid {
    width: min(85vw, 85vh);
    height: min(85vw, 85vh);
    max-width: 400px;
    max-height: 400px;
    display: grid;
    grid-template-columns: repeat(var(--grid-columns, 10), 1fr);
    grid-template-rows: repeat(var(--grid-rows, 10), 1fr);
    gap: 2px;
    background: rgba(0,0,0,0.3);
    border-radius: 15px;
    padding: 10px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
}

.cell {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.05);
}

.cell.filled {
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
    transform: scale(1.02);
}

.cell.preview {
    background: rgba(255,255,255,0.4);
    border: 2px solid rgba(255,255,255,0.8);
    box-shadow: 0 0 15px rgba(255,255,255,0.4);
    transform: scale(1.05);
}

/* ===== BLOCKS SECTION ===== */
.blocks-section {
    background: rgba(0,0,0,0.2);
    border-radius: 15px;
    padding: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
}

.blocks-container {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    min-height: 100px;
}

.block {
    display: grid;
    gap: 1px;
    padding: 10px;
    border-radius: 8px;
    cursor: grab;
    transition: all 0.3s ease;
    touch-action: none;
    align-items: center;
    justify-items: center;
}

.block:hover {
    transform: translateY(-5px);
}

.block.dragging {
    cursor: grabbing;
    pointer-events: none;
    opacity: 0.8;
}

.block-cell {
    width: var(--block-cell-size);
    height: var(--block-cell-size);
    background: linear-gradient(45deg, #ff6b6b, #ee5a24);
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.1);
}

.block-cell.empty {
    visibility: hidden;
    width: var(--block-cell-size);
    height: var(--block-cell-size);
}