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

body {
    background: #050516;
    font-family: 'Oxanium', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

#game-wrapper {
    position: relative;
    width: 100vw;
    height: calc(100vh - 30px);
    max-height: 100vh;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.screen {
    pointer-events: all;
    text-align: center;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px;
    border-radius: 16px;
    background: rgba(5, 5, 30, 0.85);
    border: 2px solid rgba(74, 144, 217, 0.4);
    backdrop-filter: blur(10px);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.hidden {
    display: none !important;
}

.title {
    font-size: 52px;
    font-weight: 800;
    letter-spacing: 4px;
    background: linear-gradient(180deg, #fff 0%, #4a90d9 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    filter: drop-shadow(0 2px 8px rgba(74, 144, 217, 0.5));
}

.subtitle {
    font-weight: 300;
    font-size: 16px;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 6px;
    text-transform: uppercase;
}

.gameover-title {
    font-size: 36px;
    font-weight: 800;
    color: #ff4466;
    letter-spacing: 3px;
    text-shadow: 0 0 20px rgba(255, 68, 102, 0.5);
}

.score-display {
    font-size: 28px;
    font-weight: 600;
    color: #fff;
}

.best-score-display {
    font-size: 18px;
    font-weight: 600;
    color: #ffd700;
}

.attempts-display {
    font-size: 14px;
    font-weight: 300;
    color: rgba(255, 255, 255, 0.4);
}

.game-btn {
    font-family: 'Oxanium', sans-serif;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 3px;
    padding: 14px 48px;
    border: 2px solid #4a90d9;
    background: linear-gradient(180deg, rgba(74, 144, 217, 0.3) 0%, rgba(74, 144, 217, 0.1) 100%);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
}

.game-btn:hover {
    background: linear-gradient(180deg, rgba(74, 144, 217, 0.6) 0%, rgba(74, 144, 217, 0.3) 100%);
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(74, 144, 217, 0.4);
}

.game-btn:active {
    transform: scale(0.97);
}

.game-btn.small-btn {
    font-size: 14px;
    padding: 8px 24px;
    letter-spacing: 2px;
}

.game-btn.secondary-btn {
    font-size: 16px;
    padding: 10px 28px;
    letter-spacing: 2px;
    border-color: rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.05);
}

.game-btn.secondary-btn:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.5);
}

.gameover-btns {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.controls-hint {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.3);
    letter-spacing: 2px;
    margin-top: 4px;
}

/* ===== LEVEL SELECT + SHOP SCREEN ===== */
.level-screen-wide {
    padding: 24px;
    max-width: 720px;
    width: 90vw;
    max-height: 85vh;
    overflow-y: auto;
}

.level-screen-inner {
    display: flex;
    gap: 24px;
    width: 100%;
    align-items: flex-start;
}

.levels-panel {
    flex: 1.2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.shop-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    border-left: 1px solid rgba(74, 144, 217, 0.2);
    padding-left: 24px;
    min-width: 0;
}

.panel-title {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 3px;
    color: rgba(255,255,255,0.8);
    margin-bottom: 4px;
}

.levels-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    width: 100%;
}

.level-btn {
    font-family: 'Oxanium', sans-serif;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 6px 8px;
    border-radius: 10px;
    border: 2px solid rgba(74, 144, 217, 0.3);
    background: linear-gradient(180deg, rgba(20, 30, 60, 0.9) 0%, rgba(10, 15, 40, 0.95) 100%);
    cursor: pointer;
    transition: all 0.2s;
    gap: 4px;
    min-height: 72px;
}

.level-btn:hover {
    border-color: #4a90d9;
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(74, 144, 217, 0.3);
}

.level-btn.locked {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(0.5);
}

.level-btn.locked:hover {
    transform: none;
    box-shadow: none;
    border-color: rgba(74, 144, 217, 0.3);
}

.level-num {
    font-size: 20px;
    font-weight: 800;
    color: white;
}

.level-name {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
}

.level-best {
    font-size: 9px;
    font-weight: 300;
    color: #ffd700;
}

.level-stars {
    font-size: 11px;
    letter-spacing: 1px;
}

.level-difficulty {
    position: absolute;
    bottom: 3px;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
}

.level-difficulty-fill {
    height: 100%;
    border-radius: 2px;
}

/* Shop sections */
.shop-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.shop-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2px;
    color: rgba(255,255,255,0.4);
}

.icon-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    width: 100%;
}

.icon-option {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    border: 2px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.05);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.icon-option:hover {
    border-color: rgba(90, 190, 220, 0.6);
    background: rgba(90, 190, 220, 0.1);
}

.icon-option.selected {
    border-color: #5bc0de;
    background: rgba(90, 190, 220, 0.2);
    box-shadow: 0 0 12px rgba(90, 190, 220, 0.3);
}

.icon-option canvas {
    width: 70%;
    height: 70%;
    pointer-events: none;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    width: 100%;
}

.color-option {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.2);
    cursor: pointer;
    transition: all 0.2s;
}

.color-option:hover {
    transform: scale(1.15);
}

.color-option.selected {
    border-color: white;
    box-shadow: 0 0 10px rgba(255,255,255,0.4);
    transform: scale(1.1);
}

.trail-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    width: 100%;
}

.trail-option {
    font-family: 'Oxanium', sans-serif;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 1px;
    padding: 6px 4px;
    border-radius: 6px;
    border: 2px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.05);
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.trail-option:hover {
    border-color: rgba(90, 190, 220, 0.6);
}

.trail-option.selected {
    border-color: #5bc0de;
    background: rgba(90, 190, 220, 0.2);
    color: white;
}

.shop-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.shop-preview canvas {
    border-radius: 8px;
    border: 1px solid rgba(74, 144, 217, 0.3);
    background: rgba(10, 10, 46, 0.8);
}

/* ===== HUD ===== */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 16px 24px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    pointer-events: none;
}

#score-hud {
    font-size: 32px;
    font-weight: 800;
    color: white;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5), 0 0 20px rgba(74, 144, 217, 0.3);
    letter-spacing: 2px;
}

#attempt-hud {
    position: absolute;
    top: 16px;
    right: 24px;
    font-size: 13px;
    font-weight: 300;
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 1px;
}

#level-hud {
    position: absolute;
    top: 38px;
    right: 24px;
    font-size: 11px;
    font-weight: 300;
    color: rgba(90, 190, 220, 0.5);
    letter-spacing: 1px;
}

.music-btn {
    position: absolute;
    top: 16px;
    left: 24px;
    font-family: 'Oxanium', sans-serif;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1px;
    padding: 6px 14px;
    border: 1px solid rgba(90, 190, 220, 0.4);
    background: rgba(90, 190, 220, 0.15);
    color: rgba(255, 255, 255, 0.7);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    pointer-events: all;
    z-index: 10;
}

.music-btn:hover {
    background: rgba(90, 190, 220, 0.3);
    color: white;
}

.music-btn.music-off {
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.3);
}

footer {
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

footer a {
    color: rgba(255, 255, 255, 0.25);
    text-decoration: none;
    font-family: 'Oxanium', sans-serif;
    font-size: 12px;
    letter-spacing: 1px;
    transition: color 0.2s;
}

footer a:hover {
    color: rgba(255, 255, 255, 0.6);
}

/* Scrollbar styling for level screen */
.level-screen-wide::-webkit-scrollbar {
    width: 4px;
}
.level-screen-wide::-webkit-scrollbar-track {
    background: transparent;
}
.level-screen-wide::-webkit-scrollbar-thumb {
    background: rgba(74, 144, 217, 0.3);
    border-radius: 2px;
}

@media (max-width: 600px) {
    .title { font-size: 36px; letter-spacing: 2px; }
    .screen { padding: 28px 24px; gap: 10px; }
    .gameover-title { font-size: 28px; }
    #score-hud { font-size: 24px; }

    .level-screen-wide {
        padding: 16px;
        max-height: 90vh;
    }
    .level-screen-inner {
        flex-direction: column;
        gap: 16px;
    }
    .shop-panel {
        border-left: none;
        border-top: 1px solid rgba(74, 144, 217, 0.2);
        padding-left: 0;
        padding-top: 16px;
    }
    .levels-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .color-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}