/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #2E8B57 0%, #228B22 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    overflow: hidden;
}

/* ===== GAME CONTAINER ===== */
.game-container {
    width: 100%;
    max-width: 400px;
    min-height: 100vh;
    background: linear-gradient(135deg, #2E8B57 0%, #228B22 100%);
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 10px;
    overflow: hidden;
}

/* ===== HEADER ===== */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    margin-bottom: 10px;
}

.header-left, .header-right {
    width: 50px;
}

.header-center {
    display: flex;
    gap: 15px;
}

.icon-btn {
    width: 45px;
    height: 45px;
    border: none;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.2);
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.3);
    transform: scale(1.05);
}

.crown-score, .coin-score {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    padding: 8px 15px;
    gap: 8px;
}

.crown, .coin {
    font-size: 20px;
}

.best-score, .coins {
    color: white;
    font-weight: 700;
    font-size: 16px;
}

/* ===== CURRENT SCORE ===== */
.current-score-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 25px;
    padding: 12px 20px;
    margin: 0 15px 20px 15px;
}

.medal {
    font-size: 24px;
}

.current-score {
    color: white;
    font-weight: 800;
    font-size: 24px;
}

/* ===== MAIN GAME AREA ===== */
.game-main {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 15px;
}

.canvas-container {
    position: relative;
    width: 100%;
    max-width: 350px;
    aspect-ratio: 1;
    border-radius: 15px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.1);
    border: 3px solid rgba(255, 255, 255, 0.2);
}

.game-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: pointer;
}

/* ===== OVERLAYS ===== */
.game-overlay {
    position: absolute;
    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: 100;
    border-radius: 15px;
}

.game-overlay.hidden {
    display: none;
}

.overlay-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    text-align: center;
    max-width: 280px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.overlay-content h2 {
    color: #2E8B57;
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 15px;
}

.overlay-content p {
    color: #666;
    font-size: 16px;
    margin-bottom: 20px;
}

.overlay-buttons {
    display: flex;
    gap: 10px;
    flex-direction: column;
}

/* ===== BUTTONS ===== */
.btn {
    border: none;
    border-radius: 12px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, #FF6B35, #FF8E53);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 107, 53, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #6C63FF, #8B7BFF);
    color: white;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(108, 99, 255, 0.4);
}

/* ===== BLOCK SELECTION PANEL ===== */
.block-selection-panel {
    margin: 20px 15px 0;
}

.selection-container {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.block-slot {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none; /* Preview only - no interactions */
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.block-slot.empty {
    background: rgba(255, 255, 255, 0.05);
    border-style: dashed;
}

.block-slot.next-drop {
    border-color: rgba(101, 163, 13, 0.4);
    box-shadow: 0 0 5px rgba(101, 163, 13, 0.2);
}

/* ===== BLOCK STYLING ===== */
.block {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    position: relative;
}

/* Block Colors based on value */
.block-2 { background: linear-gradient(135deg, #FF6B6B, #FF8E8E); }
.block-4 { background: linear-gradient(135deg, #4ECDC4, #6EDDD6); }
.block-8 { background: linear-gradient(135deg, #45B7D1, #6AC5E1); }
.block-16 { background: linear-gradient(135deg, #96CEB4, #A8D5C4); }
.block-32 { background: linear-gradient(135deg, #FECA57, #FFDD7A); }
.block-64 { background: linear-gradient(135deg, #FF9FF3, #FFAEF6); }
.block-128 { background: linear-gradient(135deg, #54A0FF, #6AB0FF); }
.block-256 { background: linear-gradient(135deg, #5F27CD, #7C3AED); }
.block-512 { background: linear-gradient(135deg, #00D2D3, #1DD1A1); }
.block-1k { background: linear-gradient(135deg, #FF6348, #FF7F6B); }
.block-2048 { background: linear-gradient(135deg, #FFD700, #FFE135); }

/* ===== POWER-UPS PANEL ===== */
.powerups-panel {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 20px 15px 10px;
}

.powerup-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 10px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.2);
}

.powerup-item:hover {
    transform: scale(1.05);
    background: rgba(0, 0, 0, 0.3);
}

.powerup-icon {
    font-size: 24px;
}

.powerup-cost {
    color: #FFD700;
    font-weight: 700;
    font-size: 14px;
}

/* ===== INSTRUCTIONS ===== */
.instructions {
    text-align: center;
    padding: 10px 15px;
    margin-bottom: 10px;
}

.instructions p {
    color: white;
    font-size: 14px;
    font-weight: 600;
    opacity: 0.8;
}

/* ===== MODAL ===== */
.modal {
    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: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 400px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    background: linear-gradient(135deg, #2E8B57, #228B22);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 700;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
}

.modal-body {
    padding: 25px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.setting-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.setting-item label {
    font-weight: 600;
    color: #333;
}

.setting-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* ===== LOADING SCREEN ===== */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #2E8B57 0%, #228B22 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-content {
    text-align: center;
}

.game-logo {
    font-size: 36px;
    font-weight: 800;
    color: white;
    margin-bottom: 30px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.loading-text {
    color: white;
    font-size: 16px;
    font-weight: 600;
    opacity: 0.8;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== ANIMATIONS ===== */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bounce {
    animation: bounce 0.6s ease-in-out;
}

.pulse {
    animation: pulse 0.3s ease-in-out;
}

.slide-in-up {
    animation: slideInUp 0.4s ease-out;
}

/* ===== RESPONSIVE DESIGN ===== */

/* Large phones */
@media (min-width: 414px) {
    .game-container {
        max-width: 414px;
    }
    
    .block-slot {
        width: 65px;
        height: 65px;
    }
    
    .block {
        font-size: 18px;
    }
}

/* Tablets and small desktop */
@media (min-width: 768px) {
    body {
        overflow: auto;
    }
    
    .game-container {
        max-width: 450px;
        min-height: auto;
        margin: 20px auto;
        border-radius: 25px;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    }
    
    .canvas-container {
        max-width: 380px;
    }
    
    .block-slot {
        width: 70px;
        height: 70px;
    }
    
    .block {
        font-size: 20px;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    .game-container {
        max-width: 500px;
    }
    
    .canvas-container {
        max-width: 420px;
    }
    
    .block-slot {
        width: 75px;
        height: 75px;
    }
}

/* Landscape orientation */
@media (orientation: landscape) and (max-height: 600px) {
    .game-container {
        flex-direction: row;
        max-width: 100vw;
        padding: 10px;
    }
    
    .game-main {
        flex: 0 0 auto;
    }
    
    .canvas-container {
        max-width: min(380px, 70vh);
        max-height: 70vh;
    }
    
    .game-header,
    .current-score-container,
    .block-selection-panel,
    .powerups-panel,
    .instructions {
        flex: 1;
        margin: 0 10px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .icon-btn:hover,
    .btn-primary:hover,
    .btn-secondary:hover,
    .block-slot:hover,
    .powerup-item:hover {
        transform: none;
    }
    
    .icon-btn:active,
    .btn:active,
    .block-slot:active,
    .powerup-item:active {
        transform: scale(0.95);
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .game-canvas {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .modal-content {
        background: #2a2a2a;
        color: white;
    }
    
    .setting-item {
        border-bottom-color: #444;
    }
    
    .setting-item label {
        color: #fff;
    }
}