:root {
    --bg1: #020806;
    --bg2: #08150f;
    --accent: #5dff8a;
    --accent2: #ff5d3a;
    --gold: #ffe23f;
    --danger: #ff2b4d;
    --text: #eafff0;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    overflow: hidden;
    background: #000;
    font-family: 'Segoe UI', 'Trebuchet MS', sans-serif;
    color: var(--text);
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

#wrap {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

#stage {
    position: relative;
    width: min(100vw, 177.78vh);
    aspect-ratio: 960/540;
    max-height: 100vh;
    max-width: 100vw;
}

canvas {
    display: block;
    background: #000;
    width: 100%;
    height: 100%;
    box-shadow: 0 0 50px rgba(93, 255, 138, 0.12);
}

#rotateHint {
    display: none;
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    background: rgba(2, 8, 6, 0.75);
    border: 1px solid rgba(93, 255, 138, 0.4);
    border-radius: 8px;
    padding: 5px 12px;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    pointer-events: none;
    white-space: nowrap;
}

#rotateHint .icon {
    font-size: 14px;
}

#rotateHint p {
    margin: 0;
}

@media (orientation:portrait) and (max-width:900px) {
    #rotateHint {
        display: flex;
    }
}

#hud {
    position: absolute;
    top: 2%;
    left: 2%;
    right: 2%;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    font-weight: 700;
    letter-spacing: 1px;
    margin-top: auto;
    text-shadow: 0 0 8px rgba(0, 0, 0, 0.9);
    z-index: 5;
    font-size: clamp(9px, 1.6vw, 13px);
}

#hud .stat {
    background: rgba(2, 8, 6, 0.6);
    border: 1px solid rgba(93, 255, 138, 0.35);
    border-radius: 8px;
    padding: clamp(3px, 0.7vw, 6px) clamp(6px, 1.6vw, 12px);
    backdrop-filter: blur(3px);
    white-space: nowrap;
}

#hud .stat span {
    color: var(--gold);
}

#lives {
    color: var(--danger);
}

#weaponLabel {
    color: var(--accent2);
}

#progressWrap {
    position: absolute;
    top: 2%;
    left: 50%;
    transform: translateX(-50%);
    width: min(40%, 300px);
    height: 6px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(93, 255, 138, 0.3);
    z-index: 5;
}

#progressBar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--gold));
    transition: width 0.2s linear;
}

#stageLabel {
    position: absolute;
    top: 6.8%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    font-size: clamp(8px, 1.3vw, 11px);
    letter-spacing: 2px;
    margin-top: 14px;
    color: var(--gold);
    text-shadow: 0 0 8px rgba(0, 0, 0, 0.9);
    white-space: nowrap;
    pointer-events: none;
}

#bossBarWrap {
    position: absolute;
    top: 9%;
    left: 50%;
    transform: translateX(-50%);
    width: min(60%, 420px);
    display: none;
    flex-direction: column;
    align-items: center;
    z-index: 5;
}

#bossLabel {
    font-size: clamp(8px, 1.4vw, 11px);
    letter-spacing: 3px;
    color: var(--danger);
    margin-bottom: 3px;
    text-shadow: 0 0 8px rgba(255, 43, 77, 0.8);
}

#bossBarOuter {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 43, 77, 0.5);
    border-radius: 5px;
    overflow: hidden;
}

#bossBarInner {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--danger), #ff9e3a);
}

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: radial-gradient(ellipse at center, rgba(8, 21, 15, 0.95) 0%, rgba(2, 8, 6, 0.98) 100%);
    z-index: 10;
    padding: 20px;
}

.hidden {
    display: none !important;
}

.title {
    font-size: clamp(26px, 6vw, 50px);
    font-weight: 900;
    letter-spacing: 4px;
    background: linear-gradient(90deg, var(--accent), var(--gold), var(--accent2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 0 16px rgba(93, 255, 138, 0.5));
    margin-bottom: 6px;
    animation: pulseTitle 2.4s ease-in-out infinite;
}

@keyframes pulseTitle {

    0%,
    100% {
        filter: drop-shadow(0 0 16px rgba(93, 255, 138, 0.5));
    }

    50% {
        filter: drop-shadow(0 0 26px rgba(255, 93, 58, 0.65));
    }
}

.subtitle {
    font-size: clamp(12px, 2.2vw, 15px);
    opacity: 0.8;
    margin-bottom: 22px;
    max-width: 480px;
    line-height: 1.6;
}

.btn {
    background: linear-gradient(135deg, var(--accent), #2fbf62);
    border: none;
    color: #04140a;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: 1px;
    padding: 13px 34px;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 0 20px rgba(93, 255, 138, 0.4);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    margin: 6px;
}

.btn:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 0 30px rgba(255, 93, 58, 0.5);
}

.btn:active {
    transform: translateY(0) scale(0.98);
}

.btn.secondary {
    background: transparent;
    border: 1.5px solid var(--accent);
    color: var(--accent);
    box-shadow: none;
}

.bigscore {
    font-size: clamp(20px, 4vw, 30px);
    color: var(--gold);
    text-shadow: 0 0 12px rgba(255, 226, 63, 0.7);
    margin: 10px 0 18px;
    font-weight: 700;
}

.keys {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 520px;
}

.key {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.18);
    padding: 6px 11px;
    border-radius: 6px;
    font-size: 11px;
    opacity: 0.85;
}

#weaponLegend {
    display: flex;
    gap: 14px;
    margin-top: 14px;
    flex-wrap: wrap;
    justify-content: center;
    font-size: 11px;
}

.wtag {
    padding: 4px 10px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

#touchControls {
    position: absolute;
    bottom: 30%;
    left: 0;
    right: 0;
    display: none;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 14px;
    z-index: 30;
    pointer-events: none;
}

.padGroup {
    display: grid;
    grid-template-columns: repeat(3, clamp(34px, 9vh, 50px));
    grid-template-rows: repeat(3, clamp(34px, 9vh, 50px));
    gap: 3px;
    pointer-events: auto;
}

.padBtn {
    background: rgba(93, 255, 138, 0.12);
    border: 1px solid rgba(93, 255, 138, 0.4);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-size: clamp(13px, 3vh, 18px);
    -webkit-tap-highlight-color: transparent;
}

.padBtn:active {
    background: rgba(93, 255, 138, 0.35);
}

.actionGroup {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    pointer-events: auto;
}

.actionBtn {
    width: clamp(44px, 12vh, 64px);
    height: clamp(44px, 12vh, 64px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(9px, 2vh, 12px);
    font-weight: 800;
    -webkit-tap-highlight-color: transparent;
}

#jumpBtn {
    background: rgba(255, 226, 63, 0.15);
    border: 1px solid rgba(255, 226, 63, 0.55);
    color: var(--gold);
}

#fireBtn {
    background: rgba(255, 93, 58, 0.18);
    border: 1px solid rgba(255, 93, 58, 0.6);
    color: var(--accent2);
    width: clamp(52px, 14vh, 74px);
    height: clamp(52px, 14vh, 74px);
}

#pauseBtnTop {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 30;
    display: block;
    pointer-events: auto;
    background: rgba(255, 93, 58, 0.15);
    border: 1px solid rgba(255, 93, 58, 0.5);
    color: var(--accent2);
    width: clamp(28px, 6vw, 38px);
    height: clamp(28px, 6vw, 38px);
    border-radius: 50%;
    font-size: clamp(11px, 2.4vw, 15px);
}

@media (max-width:820px),
(orientation:landscape) and (max-height:500px),
(pointer:coarse) {
    #touchControls {
        display: flex;
    }

    #pauseBtnTop {
        display: block;
    }
}

.flash {
    position: absolute;
    inset: 0;
    background: #fff;
    opacity: 0;
    pointer-events: none;
    z-index: 8;
}