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

:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #334155;
    --border-color: #475569;
    --text-primary: #ffffff;
    --text-secondary: #cbd5e1;
    --accent-color: #f97316;
    --success-color: #22c55e;
    --warning-color: #eab308;
    --secondary-color: #0ea5e9;
    --border-radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    user-select: none;
}

#game-container {
    width: 100%;
    height: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: clamp(0.5rem, 2vw, 1rem);
    gap: clamp(0.5rem, 1.5vw, 1rem);
    box-sizing: border-box;
}

#game-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.3;
    z-index: -1;
}

#mute-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: clamp(0.4rem, 1.5vw, 0.5rem) clamp(0.5rem, 2vw, 0.75rem);
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    cursor: pointer;
    transition: background-color 0.2s;
    color: var(--text-primary);
}

#mute-btn:hover {
    background: var(--accent-color);
}

#mute-btn.muted {
    background: var(--warning-color);
}

#score-display {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: clamp(0.4rem, 1.5vw, 0.5rem) clamp(0.75rem, 2vw, 1rem);
    border-radius: var(--border-radius);
    min-width: clamp(80px, 20vw, 100px);
    text-align: center;
    font-size: clamp(0.75rem, 2vw, 0.9rem);
}

#game-board {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: clamp(0.5rem, 1.5vw, 1rem);
    min-height: 0;
}

#columns-container {
    display: flex;
    gap: clamp(0.25rem, 1vw, 0.5rem);
    background: transparent;
    padding: clamp(0.5rem, 2vw, 1rem);
    width: 100%;
    max-width: min(95vw, 700px);
    height: auto;
    aspect-ratio: 5/4;
    max-height: 70vh;
    margin: 0 auto;
    justify-content: center;
    align-items: center;
}

.column {
    flex: 1;
    min-width: 0;
    height: 100%;
    background: transparent;
    overflow: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.column-symbols {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    transition: transform 0.1s ease-out;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.symbol {
    width: 100%;
    height: calc(100% / 4);
    display: flex;
    justify-content: center;
    align-items: center;
}

.symbol img {
    max-width: 75%;
    max-height: 75%;
    object-fit: contain;
}

#match-lines-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.match-line {
    position: absolute;
    background: rgba(255, 215, 0, 0.8);
    height: 3px;
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.match-line.active {
    opacity: 1;
    animation: match-glow 1s ease-in-out infinite alternate;
}

@keyframes match-glow {
    0% { box-shadow: 0 0 5px rgba(255, 215, 0, 0.8); }
    100% { box-shadow: 0 0 15px rgba(255, 215, 0, 1); }
}

#game-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: clamp(0.75rem, 2vw, 1rem) clamp(1rem, 3vw, 1.5rem);
    min-height: 60px;
}

#level-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#level-minus, #level-plus {
    width: clamp(32px, 8vw, 36px);
    height: clamp(32px, 8vw, 36px);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#level-minus:hover, #level-plus:hover {
    background: var(--accent-color);
}

#level-display {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: clamp(0.4rem, 1.5vw, 0.5rem) clamp(0.75rem, 2vw, 1rem);
    border-radius: var(--border-radius);
    min-width: clamp(80px, 20vw, 100px);
    text-align: center;
    font-size: clamp(0.8rem, 2vw, 0.9rem);
}

#play-controls {
    display: flex;
    justify-content: center;
    align-items: center;
}

.control-btn {
    padding: clamp(0.4rem, 1.5vw, 0.5rem) clamp(0.75rem, 2.5vw, 1rem);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: clamp(0.75rem, 2vw, 0.9rem);
    cursor: pointer;
    transition: background-color 0.2s;
    background: var(--bg-card);
    color: var(--text-primary);
    white-space: nowrap;
}

.play-btn {
    background: var(--accent-color);
    color: white;
    padding: clamp(1rem, 3vw, 1.5rem) clamp(3rem, 8vw, 5rem);
    font-weight: 700;
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    letter-spacing: 0.1em;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.play-btn:hover {
    background: #3a8ae6;
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.play-btn:disabled {
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: not-allowed;
    transform: scale(1);
    box-shadow: none;
}

.control-btn:hover {
    background: var(--accent-color);
    color: white;
}

#auto-play-btn.active {
    background: var(--success-color);
    color: white;
}

#game-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#points-display, #matches-info {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: clamp(0.4rem, 1.5vw, 0.5rem) clamp(0.75rem, 2vw, 1rem);
    border-radius: var(--border-radius);
    min-width: clamp(80px, 20vw, 100px);
    text-align: center;
    font-size: clamp(0.75rem, 2vw, 0.9rem);
}

#success-animation {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    text-align: center;
    background: var(--bg-secondary);
    border: 2px solid var(--success-color);
    border-radius: var(--border-radius);
    padding: clamp(1.5rem, 4vw, 2rem) clamp(2rem, 6vw, 3rem);
    max-width: 90vw;
    max-height: 90vh;
}

#success-animation.hidden {
    display: none;
}

#points-amount {
    font-size: clamp(2rem, 8vw, 3rem);
    font-weight: 700;
    color: var(--success-color);
    margin-bottom: 0.5rem;
}

#success-text {
    font-size: clamp(1rem, 4vw, 1.5rem);
    font-weight: 600;
    color: var(--text-primary);
}

.spinning .column-symbols {
    animation: spin-column 0.1s linear infinite;
}

@keyframes spin-column {
    0% { transform: translate(-50%, -50%); }
    100% { transform: translate(-50%, -75%); }
}

/* Responsive Design */
@media (max-width: 768px) {
    #columns-container {
        max-height: 60vh;
        aspect-ratio: 5/3.5;
    }
    
    #game-controls {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    #play-controls {
        order: -1;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }
    
    #level-controls, #game-info {
        justify-content: center;
    }
    
    #game-info {
        flex-direction: row;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    #columns-container {
        max-height: 55vh;
        aspect-ratio: 5/3.2;
    }
    
    #play-controls {
        gap: 0.4rem;
    }
    
    .control-btn {
        font-size: clamp(0.7rem, 3vw, 0.8rem);
        padding: clamp(0.3rem, 1.2vw, 0.4rem) clamp(0.6rem, 2vw, 0.8rem);
    }
}
