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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow: hidden;
}

.game-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 100%;
}

.header {
    text-align: center;
    margin-bottom: 20px;
}

.header h1 {
    font-size: clamp(24px, 6vw, 32px);
    color: #667eea;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.score-board {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.score-item {
    background: linear-gradient(135deg, #667eea, #764ba2);
    padding: 10px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.3s;
}

.score-item.combo {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    animation: pulse 0.5s ease-in-out;
}

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

.score-label {
    display: block;
    color: rgba(255, 255, 255, 0.9);
    font-size: 12px;
    margin-bottom: 5px;
}

.score-value {
    display: block;
    color: white;
    font-size: 24px;
    font-weight: bold;
}

.grid-container {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 15px;
    margin-bottom: 20px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.1);
}

.grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    max-width: 400px;
    margin: 0 auto;
    aspect-ratio: 1;
}

.cell {
    background: white;
    border-radius: 6px;
    aspect-ratio: 1;
    transition: all 0.2s;
    border: 2px solid #e9ecef;
}

.cell.filled {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.cell.highlight {
    background: #ffeaa7;
    border-color: #fdcb6e;
}

.cell.invalid {
    background: #ff7675;
    border-color: #d63031;
}

.cell.clearing {
    animation: clearAnimation 0.5s ease-out;
}

.cell.hint {
    background: #a29bfe;
    border-color: #6c5ce7;
    animation: hintPulse 1s ease-in-out infinite;
}

@keyframes hintPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

.cell.power-up {
    background: linear-gradient(135deg, #ffeaa7, #fdcb6e);
    border-color: #fdcb6e;
    position: relative;
}

.cell.power-up::after {
    content: '⚡';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
}

@keyframes clearAnimation {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.5; }
    100% { transform: scale(0); opacity: 0; }
}

.blocks-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 15px;
    min-height: 120px;
    flex-wrap: wrap;
}

.block-wrapper {
    cursor: grab;
    padding: 10px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

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

.block-wrapper.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.block-wrapper.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.block-wrapper.rotated {
    animation: rotateAnimation 0.3s ease-out;
}

@keyframes rotateAnimation {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(90deg); }
}

.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.control-btn {
    background: linear-gradient(135deg, #74b9ff, #0984e3);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 3px 10px rgba(9, 132, 227, 0.3);
    transition: all 0.2s;
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(9, 132, 227, 0.4);
}

.control-btn:active {
    transform: translateY(0);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.control-btn.muted {
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
    opacity: 0.7;
}

.block-grid {
    display: grid;
    gap: 3px;
}

.block-cell {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.block-cell.filled {
    background: linear-gradient(135deg, #74b9ff, #0984e3);
    box-shadow: 0 2px 5px rgba(9, 132, 227, 0.3);
}

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

.game-over.show {
    display: flex;
}

.game-over-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateY(-100px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.game-over-content h2 {
    font-size: 32px;
    color: #667eea;
    margin-bottom: 20px;
}

.game-over-content p {
    font-size: 20px;
    color: #333;
    margin-bottom: 30px;
}

.restart-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 18px;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: transform 0.2s;
}

.restart-btn:hover {
    transform: translateY(-2px);
}

.restart-btn:active {
    transform: translateY(0);
}

/* Responsive Design for Mobile */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .game-container {
        padding: 15px;
        border-radius: 15px;
    }

    .header h1 {
        font-size: 24px;
        margin-bottom: 10px;
    }

    .score-board {
        gap: 8px;
    }

    .score-item {
        padding: 8px 15px;
    }

    .controls {
        gap: 10px;
        margin-bottom: 10px;
    }

    .control-btn {
        padding: 8px 15px;
        font-size: 12px;
    }

    .score-value {
        font-size: 20px;
    }

    .grid-container {
        padding: 10px;
    }

    .grid {
        gap: 3px;
    }

    .cell {
        border-radius: 4px;
        border-width: 1px;
    }

    .blocks-container {
        gap: 10px;
        padding: 15px;
        min-height: 100px;
    }

    .block-wrapper {
        padding: 8px;
    }

    .block-cell {
        width: 16px;
        height: 16px;
    }

    .game-over-content {
        padding: 30px 20px;
        margin: 0 10px;
    }

    .game-over-content h2 {
        font-size: 24px;
    }

    .game-over-content p {
        font-size: 18px;
    }

    .restart-btn {
        padding: 12px 30px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 20px;
    }

    .score-item {
        padding: 6px 12px;
    }

    .score-label {
        font-size: 10px;
    }

    .score-value {
        font-size: 18px;
    }

    .grid {
        gap: 2px;
    }

    .block-cell {
        width: 14px;
        height: 14px;
    }
}

/* Touch-friendly improvements for mobile */
@media (hover: none) and (pointer: coarse) {
    .block-wrapper {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .restart-btn {
        min-height: 44px;
        min-width: 120px;
    }
}
