* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary-color: #ff6b6b;
    --secondary-color: #4ecdc4;
    --accent-color: #ffe66d;
    --dark-color: #2c3e50;
    --light-color: #ecf0f1;
    --pixel-size: 4px;
    --game-bg: #1a1a2e;
    --board-bg: #16213e;
    --tile-bg: #0f3460;
    --tile-border: #533483;
    --path-color: #4ecdc4;
}

body {
    font-family: 'Courier New', monospace;
    background: linear-gradient(135deg, var(--game-bg) 0%, var(--dark-color) 100%);
    color: var(--light-color);
    overflow: hidden;
    touch-action: none;
    user-select: none;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Header */
#game-header {
    width: 100%;
    max-width: 600px;
    padding: 10px;
}

#score-panel {
    display: flex;
    justify-content: space-around;
    background: var(--board-bg);
    border-radius: 10px;
    padding: 10px;
    border: 3px solid var(--tile-border);
    box-shadow: 0 4px 0 var(--dark-color);
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat .label {
    font-size: 10px;
    color: #888;
    text-transform: uppercase;
}

.stat .value {
    font-size: 20px;
    font-weight: bold;
    color: var(--accent-color);
    text-shadow: 2px 2px 0 var(--dark-color);
}

#combo-panel {
    text-align: center;
    margin-top: 10px;
    height: 25px;
}

#combo-text {
    display: inline-block;
    font-size: 16px;
    font-weight: bold;
    color: var(--primary-color);
    animation: none;
}

#combo-text.show {
    animation: comboPopup 0.5s ease-out;
}

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

/* Canvas */
#gameCanvas {
    background: var(--board-bg);
    border: 4px solid var(--tile-border);
    border-radius: 10px;
    box-shadow: 0 6px 0 var(--dark-color);
    max-width: 95vw;
    max-height: 55vh;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* Power-ups */
#powerups {
    display: flex;
    gap: 15px;
    margin-top: 15px;
}

.powerup-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: var(--tile-bg);
    border: 3px solid var(--tile-border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.1s;
    box-shadow: 0 4px 0 var(--dark-color);
    position: relative;
}

.powerup-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 var(--dark-color);
}

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

.powerup-btn .icon {
    font-size: 24px;
}

.powerup-btn .count {
    font-size: 10px;
    margin-top: 5px;
    color: var(--accent-color);
}

.powerup-btn.hint-active {
    border-color: var(--accent-color);
    animation: pulse 0.5s ease-in-out infinite alternate;
}

@keyframes pulse {
    from { box-shadow: 0 4px 0 var(--dark-color), 0 0 10px var(--accent-color); }
    to { box-shadow: 0 4px 0 var(--dark-color), 0 0 20px var(--accent-color); }
}

/* 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;
    transition: opacity 0.3s;
}

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

.modal-content {
    background: var(--board-bg);
    border: 4px solid var(--tile-border);
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    max-width: 90%;
    box-shadow: 0 10px 0 var(--dark-color);
    animation: modalIn 0.3s ease-out;
}

@keyframes modalIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-content h1 {
    color: var(--accent-color);
    font-size: 28px;
    margin-bottom: 15px;
    text-shadow: 3px 3px 0 var(--dark-color);
}

.modal-content p {
    margin-bottom: 20px;
    line-height: 1.6;
}

#modal-stats {
    margin: 15px 0;
    padding: 15px;
    background: var(--tile-bg);
    border-radius: 10px;
    text-align: left;
}

#modal-stats p {
    margin: 5px 0;
}

.primary-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 18px;
    font-family: inherit;
    font-weight: bold;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 4px 0 #c0392b;
    transition: all 0.1s;
}

.primary-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #c0392b;
}

/* Settings */
#settings-btn {
    position: fixed;
    top: 10px;
    right: 10px;
    font-size: 24px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

#settings-btn:hover {
    opacity: 1;
}

#settings-panel {
    position: fixed;
    top: 50px;
    right: 10px;
    background: var(--board-bg);
    border: 3px solid var(--tile-border);
    border-radius: 10px;
    padding: 15px;
    z-index: 100;
    min-width: 200px;
}

#settings-panel.hidden {
    display: none;
}

#settings-panel h3 {
    margin-bottom: 15px;
    color: var(--accent-color);
}

#settings-panel label {
    display: block;
    margin: 10px 0;
    cursor: pointer;
}

#settings-panel select {
    background: var(--tile-bg);
    color: var(--light-color);
    border: 2px solid var(--tile-border);
    padding: 5px 10px;
    border-radius: 5px;
    font-family: inherit;
    cursor: pointer;
}

/* Responsive */
@media (max-width: 480px) {
    #score-panel {
        padding: 8px;
    }

    .stat .value {
        font-size: 16px;
    }

    #powerups {
        gap: 10px;
    }

    .powerup-btn {
        width: 50px;
        height: 50px;
    }

    .powerup-btn .icon {
        font-size: 20px;
    }

    .modal-content {
        padding: 20px;
    }

    .modal-content h1 {
        font-size: 24px;
    }

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

/* Animations */
@keyframes tileSelect {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes tileMatch {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.5); opacity: 0; }
}

@keyframes scoreFloat {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-50px); opacity: 0; }
}
