:root {
    --sky-top: #1a3a6e;
    --sky-mid: #2d6abf;
    --sky-btm: #5fa8e8;
    --horizon: #a8d8ff;
    --accent-orange: #ff8c2a;
    --accent-orange-dark: #c45e00;
    --accent-red: #ff4560;
    --accent-red-dark: #a51833;
    --accent-green: #4ade80;
    --gold: #ffd13a;
    --gold-glow: rgba(255, 200, 30, 0.85);
    --panel-glass: rgba(255, 255, 255, 0.10);
    --panel-border-strong: rgba(255, 255, 255, 0.38);
    --shadow-soft: 0 6px 20px rgba(0, 0, 0, 0.25);
    --r-pill: 60px;
    --font-display: 'Fredoka One', cursive;
    --font-body: 'Nunito', sans-serif;
    --ease-bounce: cubic-bezier(0.175, 0.885, 0.32, 1.4);
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-body);
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 40%, var(--sky-btm) 70%, var(--horizon) 100%);
}

#canvas-container {
    position: absolute;
    inset: 0;
    z-index: 1;
}

#atmo-stars {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    background: radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.06) 0%, transparent 60%);
}

#vignette {
    position: fixed;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 50%, rgba(5, 12, 30, 0.55) 100%);
}

#hud-container {
    position: absolute;
    top: 20px;
    left: 16px;
    right: 16px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    z-index: 50;
}

#lives-layer {
    display: flex;
    gap: 8px;
    align-items: center;
    background: var(--panel-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1.5px solid var(--panel-border-strong);
    border-top-color: rgba(255, 255, 255, 0.42);
    padding: 10px 18px;
    border-radius: var(--r-pill);
    box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.heart-wrapper {
    position: relative;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.heart-svg {
    width: 28px;
    height: 28px;
    transition: all 0.35s var(--ease-bounce);
    filter: drop-shadow(0 2px 8px rgba(255, 60, 60, 0.9));
    animation: heartbeat 2.4s ease-in-out infinite;
}

.heart-svg.lost {
    filter: grayscale(1) brightness(0.3);
    transform: scale(0.6);
    opacity: 0.4;
    animation: none;
}

@keyframes heartbeat {

    0%,
    100% {
        transform: scale(1);
    }

    14% {
        transform: scale(1.28);
    }

    28% {
        transform: scale(1);
    }

    42% {
        transform: scale(1.16);
    }

    56% {
        transform: scale(1);
    }
}

#counters-layer {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.counter-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--panel-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1.5px solid var(--panel-border-strong);
    border-top-color: rgba(255, 255, 255, 0.42);
    border-radius: var(--r-pill);
    padding: 8px 18px 8px 10px;
    box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.28);
    transition: transform 0.18s var(--ease-bounce);
}

.counter-box.pop {
    transform: scale(1.15);
}

.ctr-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.ctr-icon.blocks {
    background: linear-gradient(135deg, #4ade80, #16a34a);
    box-shadow: 0 4px 14px rgba(74, 222, 128, 0.55);
}

.ctr-icon.coins {
    background: linear-gradient(135deg, #ffd13a, #ff8c2a);
    box-shadow: 0 4px 14px rgba(255, 180, 40, 0.6);
}

.ctr-val {
    font-family: var(--font-display);
    font-size: 28px;
    color: #fff;
    line-height: 1;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
    min-width: 28px;
}

.score-pop {
    position: fixed;
    pointer-events: none;
    z-index: 60;
    font-family: var(--font-display);
    font-size: 24px;
    color: var(--gold);
    text-shadow: 0 0 18px var(--gold-glow), 0 2px 6px rgba(0, 0, 0, 0.5);
    animation: popFloat 1.2s var(--ease-out) forwards;
    white-space: nowrap;
}

@keyframes popFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    40% {
        opacity: 1;
        transform: translateY(-38px) scale(1.3);
    }

    100% {
        opacity: 0;
        transform: translateY(-80px) scale(0.6);
    }
}

#charge-bar-wrap {
    position: fixed;
    bottom: 48px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 55;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

#charge-bar-wrap.visible {
    opacity: 1;
}

#charge-label {
    font-family: var(--font-display);
    font-size: 14px;
    color: rgba(255, 255, 255, 0.85);
    letter-spacing: 2px;
    text-transform: uppercase;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}

#charge-bar-bg {
    width: 180px;
    height: 14px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.15);
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

#charge-bar-fill {
    height: 100%;
    width: 0%;
    border-radius: 10px;
    background: linear-gradient(90deg, #4ade80, #ffd13a, #ff4560);
    box-shadow: 0 0 12px rgba(255, 200, 40, 0.7);
}

.screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.45s ease, visibility 0.45s ease;
}

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

#preloader-screen {
    background: linear-gradient(180deg, #0f2044 0%, #1a3a72 50%, #2d6abf 100%);
    z-index: 200;
}

.preloader-logo {
    font-family: var(--font-display);
    font-size: 52px;
    color: #fff;
    text-shadow: 0 0 40px rgba(90, 168, 255, 0.7), 0 4px 0 rgba(0, 0, 0, 0.4);
    margin-bottom: 8px;
    animation: logoPulse 1.5s ease-in-out infinite;
}

@keyframes logoPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.preloader-tagline {
    font-size: 13px;
    letter-spacing: 3px;
    color: rgba(255, 255, 255, 0.55);
    text-transform: uppercase;
    margin-bottom: 38px;
}

.loader-ring {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 5px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--accent-orange);
    animation: spin 0.85s cubic-bezier(0.6, 0.2, 0.4, 0.8) infinite;
    box-shadow: 0 0 24px rgba(255, 140, 42, 0.4);
}

.loader-hint {
    margin-top: 16px;
    font-size: 13px;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.45);
    text-transform: uppercase;
    animation: loaderPulse 1.4s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes loaderPulse {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }
}

#start-screen {
    background: linear-gradient(180deg, rgba(10, 22, 55, 0.88) 0%, rgba(15, 40, 100, 0.80) 50%, rgba(20, 60, 130, 0.72) 100%);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.start-badge {
    font-size: 11px;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--accent-orange);
    background: rgba(255, 140, 42, 0.14);
    border: 1px solid rgba(255, 140, 42, 0.4);
    padding: 5px 16px;
    border-radius: 40px;
    margin-bottom: 22px;
    font-family: var(--font-body);
    font-weight: 800;
}

.start-logo-emoji {
    font-size: 74px;
    margin-bottom: 8px;
    animation: floatEmoji 3s ease-in-out infinite;
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.4));
}

@keyframes floatEmoji {

    0%,
    100% {
        transform: translateY(0) rotate(-3deg);
    }

    50% {
        transform: translateY(-16px) rotate(3deg);
    }
}

.start-title {
    font-family: var(--font-display);
    font-size: 58px;
    color: #fff;
    letter-spacing: 2px;
    line-height: 1;
    text-shadow: 0 4px 0 rgba(20, 60, 130, 0.7), 0 8px 30px rgba(0, 0, 0, 0.4);
    margin-bottom: 6px;
}

.start-sub {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.65);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 36px;
    font-weight: 700;
}

.btn-primary {
    font-family: var(--font-display);
    font-size: 24px;
    letter-spacing: 2px;
    color: #fff;
    background: linear-gradient(180deg, var(--accent-orange) 0%, var(--accent-orange-dark) 100%);
    border: none;
    border-radius: var(--r-pill);
    padding: 17px 60px;
    cursor: pointer;
    box-shadow: 0 8px 0 #8a3e00, 0 14px 36px rgba(200, 80, 0, 0.5);
    transition: all 0.12s var(--ease-out);
    outline: none;
    position: relative;
    overflow: hidden;
}

.btn-primary::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.25) 0%, transparent 50%);
    border-radius: inherit;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 11px 0 #8a3e00, 0 18px 42px rgba(200, 80, 0, 0.6);
}

.btn-primary:active {
    transform: translateY(6px);
    box-shadow: 0 2px 0 #8a3e00, 0 6px 16px rgba(200, 80, 0, 0.4);
}

.start-tips {
    margin-top: 28px;
    background: rgba(255, 255, 255, 0.07);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 20px;
    padding: 14px 24px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.75);
    line-height: 1.7;
    text-align: center;
    font-weight: 700;
}

.tip-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tip-row+.tip-row {
    margin-top: 4px;
}

.tip-icon {
    font-size: 18px;
}

#gameover-screen {
    background: rgba(8, 4, 18, 0.87);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    z-index: 150;
}

.go-emoji {
    font-size: 64px;
    margin-bottom: 10px;
    animation: goShake 0.6s ease-out;
}

@keyframes goShake {

    0%,
    100% {
        transform: rotate(0);
    }

    15% {
        transform: rotate(-12deg);
    }

    30% {
        transform: rotate(12deg);
    }

    45% {
        transform: rotate(-8deg);
    }

    60% {
        transform: rotate(8deg);
    }

    75% {
        transform: rotate(-4deg);
    }
}

.go-title {
    font-family: var(--font-display);
    font-size: 52px;
    color: var(--accent-red);
    text-shadow: 0 0 40px rgba(255, 50, 80, 0.95), 0 4px 0 var(--accent-red-dark);
    letter-spacing: 2px;
    margin-bottom: 6px;
}

.go-divider {
    width: 120px;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(90deg, transparent, rgba(255, 80, 96, 0.9), transparent);
    margin: 14px auto;
}

.go-stats {
    display: flex;
    gap: 14px;
    margin-bottom: 30px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.07);
    border: 1.5px solid rgba(255, 255, 255, 0.14);
    border-radius: 20px;
    padding: 16px 24px;
    text-align: center;
    min-width: 100px;
}

.stat-icon {
    font-size: 26px;
    margin-bottom: 4px;
}

.stat-val {
    font-family: var(--font-display);
    font-size: 34px;
    color: #fff;
    line-height: 1;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

.stat-label {
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.45);
    font-weight: 800;
    margin-top: 2px;
}

.stat-card.blocks-card {
    border-color: rgba(74, 222, 128, 0.3);
}

.stat-card.coins-card {
    border-color: rgba(255, 180, 40, 0.3);
}

.stat-card.blocks-card .stat-val {
    color: var(--accent-green);
}

.stat-card.coins-card .stat-val {
    color: var(--gold);
}

.btn-restart {
    font-family: var(--font-display);
    font-size: 22px;
    letter-spacing: 2px;
    color: #fff;
    background: linear-gradient(180deg, var(--accent-red) 0%, var(--accent-red-dark) 100%);
    border: none;
    border-radius: var(--r-pill);
    padding: 15px 52px;
    cursor: pointer;
    box-shadow: 0 7px 0 #6b0e1e, 0 12px 28px rgba(180, 20, 40, 0.5);
    transition: all 0.12s var(--ease-out);
    outline: none;
    position: relative;
    overflow: hidden;
}

.btn-restart::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.22) 0%, transparent 50%);
    border-radius: inherit;
}

.btn-restart:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 0 #6b0e1e, 0 16px 34px rgba(180, 20, 40, 0.65);
}

.btn-restart:active {
    transform: translateY(5px);
    box-shadow: 0 2px 0 #6b0e1e, 0 5px 12px rgba(180, 20, 40, 0.4);
}

.heart-break-particle {
    position: absolute;
    pointer-events: none;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-red);
    animation: particleBurst 0.75s ease-out forwards;
    opacity: 0;
}

@keyframes particleBurst {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }

    100% {
        opacity: 0;
        transform: translate(var(--px), var(--py)) scale(0);
    }
}

@media (max-width:480px) {
    #hud-container {
        top: 12px;
        left: 10px;
        right: 10px;
    }

    .start-title {
        font-size: 42px;
    }

    .start-logo-emoji {
        font-size: 58px;
    }

    .btn-primary {
        padding: 14px 44px;
        font-size: 20px;
    }

    .go-stats {
        flex-direction: column;
        gap: 10px;
    }

    .stat-card {
        min-width: 170px;
    }
}