:root {
    --bg-color: #0d0d15;
    --text-color: #f5f6fa;
    --accent-color: #70a1ff;
    --accent-glow: rgba(112, 161, 255, 0.4);
    --board-bg: #1e1e2f;
    --slot-bg: rgba(30, 30, 47, 0.6);
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-border: rgba(255, 255, 255, 0.08);
    --neon-green: #2ed573;
    --neon-red: #ff4757;
    --neon-yellow: #ffa502;
    --neon-blue: #1e90ff;
    --font-game: 'Comfortaa', cursive, sans-serif;
    --font-ui: 'Outfit', sans-serif;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-ui);
    background: radial-gradient(circle at center, #1b1b2f 0%, #0c0c12 100%);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    touch-action: none;
}

.game-container {
    width: 100%;
    max-width: 480px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 20px;
    position: relative;
    justify-content: space-between;
}

/* Top Control Bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 0 5px;
}

.game-title {
    font-family: var(--font-game);
    font-size: 24px;
    margin: 0;
    background: linear-gradient(135deg, #70a1ff, #a55eea);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(165, 94, 234, 0.3);
    letter-spacing: 1px;
}

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

.control-btn {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-color);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.2);
}

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

.control-btn .icon {
    font-size: 16px;
    display: inline-block;
}

/* Header & Scores */
.header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
}

.score-container, .best-score-container {
    text-align: center;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    padding: 10px 15px;
    border-radius: 16px;
    flex: 1;
    margin: 0 6px;
    backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transition: transform 0.3s ease;
    position: relative;
    overflow: hidden;
}

.score-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, #70a1ff, #a55eea);
}

.best-score-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, #ffa502, #ff7f50);
}

.score-label {
    font-size: 11px;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 2px;
    margin-bottom: 4px;
}

.score-val {
    font-family: var(--font-ui);
    font-size: 26px;
    font-weight: 800;
    background: #fff;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 2px 10px rgba(255, 255, 255, 0.1);
}

#score {
    background: linear-gradient(135deg, #ffffff, #a5b1c2);
    -webkit-background-clip: text;
}

#best-score {
    background: linear-gradient(135deg, #ffeaa7, #ffa502);
    -webkit-background-clip: text;
}

/* Board Game Area */
#board-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    margin: 10px 0;
    border-radius: 24px;
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.02);
    padding: 10px;
    min-height: 0;
    min-width: 0;
}

#board-canvas {
    max-width: 100%;
    max-height: 100%;
    filter: drop-shadow(0 15px 25px rgba(0, 0, 0, 0.5));
}

/* Combo Popup overlay */
.combo-popup {
    position: absolute;
    font-family: var(--font-game);
    font-size: 28px;
    color: var(--neon-yellow);
    font-weight: 900;
    text-shadow: 0 0 15px rgba(255, 165, 2, 0.6), 0 0 30px rgba(255, 165, 2, 0.3);
    z-index: 10;
    pointer-events: none;
    transform: scale(0.5);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.combo-popup.show {
    transform: scale(1.1) translateY(-20px);
    opacity: 1;
}

.combo-popup.hidden {
    display: none;
}

/* Blocks Container */
#blocks-container {
    height: 130px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 12px;
    backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    margin-bottom: 10px;
}

.block-slot {
    width: 30%;
    height: 106px;
    background-color: var(--slot-bg);
    border: 1px dashed rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    transition: all 0.3s ease;
    cursor: pointer;
}

.block-slot:hover {
    background-color: rgba(30, 30, 47, 0.8);
    border-color: rgba(255, 255, 255, 0.3);
}

.block-canvas {
    cursor: grab;
    transition: transform 0.15s cubic-bezier(0.2, 0, 0.2, 1);
}

.block-canvas:active {
    cursor: grabbing;
    transform: scale(0.9);
}

/* Modals and Overlays */
#help-modal, #game-over {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease;
}

.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay {
    position: absolute;
    width: 100%;
    height: 100%;
    background: rgba(5, 5, 10, 0.85);
    backdrop-filter: blur(8px);
}

.message {
    position: relative;
    background: rgba(25, 25, 38, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 30px;
    border-radius: 28px;
    width: 85%;
    max-width: 360px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 30px rgba(112, 161, 255, 0.1);
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popIn {
    from { transform: scale(0.85); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.message h2 {
    font-family: var(--font-game);
    margin: 0 0 20px 0;
    font-size: 26px;
    background: linear-gradient(135deg, #70a1ff, #a55eea);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Game Over Message Specifics */
.game-over-message h2 {
    background: linear-gradient(135deg, #ff4757, #ff6b81);
    -webkit-background-clip: text;
    text-shadow: 0 0 15px rgba(255, 71, 87, 0.2);
}

.game-over-icon {
    font-size: 48px;
    margin-bottom: 10px;
    animation: float 2s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.final-score {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 25px;
    color: rgba(255, 255, 255, 0.8);
}

.final-score span {
    color: #ffa502;
    font-family: var(--font-game);
    font-size: 26px;
}

/* Help Content Styling */
.help-content {
    text-align: left;
    margin-bottom: 25px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.help-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.help-emoji {
    font-size: 20px;
    line-height: 1.4;
}

.help-item p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.8);
}

.help-item strong {
    color: #70a1ff;
}

.help-item .highlight {
    color: #2ed573;
    font-weight: bold;
}

/* Buttons */
.action-btn {
    background: linear-gradient(135deg, #70a1ff, #5352ed);
    color: white;
    border: none;
    padding: 14px 40px;
    font-family: var(--font-ui);
    font-size: 16px;
    font-weight: 700;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 8px 20px rgba(83, 82, 237, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1);
    width: 100%;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(83, 82, 237, 0.45), 0 0 15px rgba(112, 161, 255, 0.3);
}

.action-btn:active {
    transform: translateY(1px);
}

#restart-btn {
    background: linear-gradient(135deg, #ff4757, #ff6b81);
    box-shadow: 0 8px 20px rgba(255, 71, 87, 0.3);
}

#restart-btn:hover {
    box-shadow: 0 12px 25px rgba(255, 71, 87, 0.45);
}

/* Responsiveness adjustments for smaller devices */
@media (max-height: 740px) {
    .game-container {
        padding: 10px;
    }
    .game-title {
        font-size: 20px;
    }
    .header {
        margin-bottom: 10px;
    }
    .score-container, .best-score-container {
        padding: 8px 10px;
    }
    .score-val {
        font-size: 20px;
    }
    #blocks-container {
        height: 110px;
        padding: 8px;
    }
    .block-slot {
        height: 90px;
    }
}

@media (max-width: 360px) {
    .game-title {
        font-size: 18px;
    }
    .score-val {
        font-size: 18px;
    }
    .control-btn {
        width: 32px;
        height: 32px;
    }
}

