:root {
    --bg-primary: #0a0e27;
    --bg-secondary: #1a1f3a;
    --bg-tertiary: #2d3250;
    --accent-primary: #6366f1;
    --accent-glow: #8b5cf6;
    --text-primary: #e0e7ff;
    --text-secondary: #94a3b8;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --font-main: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

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

/* Loading Screen */
#loading-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    z-index: 1000;
}

.loading-content {
    text-align: center;
}

.loading-title {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 2rem;
}

.loading-bar {
    width: 200px;
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    margin: 0 auto 1rem;
    overflow: hidden;
}

.loading-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-glow));
    border-radius: 2px;
    transition: width 0.3s ease;
}

.loading-text {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Canvas */
.canvas-container {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

#game-canvas {
    display: block;
    background: transparent;
    touch-action: none;
}

/* Game Header */
.game-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--bg-tertiary);
    z-index: 10;
}

.game-level-info {
    text-align: center;
    flex: 1;
}

.level-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.game-header-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-skip svg {
    display: block;
}

.skip-content {
    padding: 1.5rem 2rem;
}

.skip-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1.2rem;
    line-height: 1.4;
}

.btn-play-ad {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-glow));
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-play-ad:active {
    transform: scale(0.9);
}

.btn-play-ad svg {
    margin-left: 3px;
}

.btn-small {
    font-size: 0.8rem;
    padding: 8px 20px;
}

.btn-pause {
    gap: 3px;
}

.pause-bar {
    display: block;
    width: 3px;
    height: 14px;
    background: var(--text-primary);
    border-radius: 1.5px;
}

/* Game Footer */
.game-footer {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--bg-tertiary);
}

.game-stat {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.stat-value {
    color: var(--text-primary);
    font-weight: 600;
}

.stat-separator {
    margin: 0 2px;
}

/* Compact height */
@media (max-height: 550px) {
    .game-header {
        padding: 4px 8px;
        padding-left: max(8px, env(safe-area-inset-left));
        padding-right: max(8px, env(safe-area-inset-right));
    }

    .game-footer {
        padding: 4px 8px;
        padding-left: max(8px, env(safe-area-inset-left));
        padding-right: max(8px, env(safe-area-inset-right));
    }

    .level-name {
        font-size: 0.75rem;
    }

    .game-stat {
        font-size: 0.75rem;
    }

    .btn-icon {
        width: 34px;
        height: 34px;
        border-radius: 8px;
    }

    .pause-bar {
        height: 12px;
    }

    .btn-skip svg {
        width: 16px;
        height: 16px;
    }

    .canvas-container {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}
