:root {
    --primary: #00f0ff;
    --secondary: #ff0055;
    --accent: #ffd700;
    --bg: #0b0f1a;
    --glass: rgba(255, 255, 255, 0.07);
    --glass-border: rgba(255, 255, 255, 0.14);
    --glass-strong: rgba(255, 255, 255, 0.11);
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}
body {
    background: #030510;
    color: #fff;
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    touch-action: none;
    cursor: default;
}
canvas {
    display: block;
    width: 100%;
    height: 100%;
    position: absolute;
    inset: 0;
}

.ui-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    z-index: 10;
    padding: 20px;
}
.panel {
    pointer-events: auto;
    background: linear-gradient(135deg, rgba(8, 12, 28, 0.92), rgba(16, 24, 48, 0.85));
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: 28px;
    padding: 34px 42px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 0 80px rgba(0, 240, 255, 0.08);
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
    max-width: 94vw;
    max-height: 88vh;
    overflow-y: auto;
    position: relative;
}
.panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(0, 240, 255, 0.04), rgba(255, 0, 85, 0.04));
    border-radius: 28px;
    pointer-events: none;
}
.panel.active {
    transform: translateY(0);
    opacity: 1;
}
.title {
    font-size: clamp(2.2rem, 6.5vw, 3.8rem);
    font-weight: 900;
    letter-spacing: 4px;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--primary), #fff, var(--accent), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 60px rgba(0, 240, 255, 0.4);
    filter: drop-shadow(0 4px 16px rgba(0, 240, 255, 0.3));
}
.subtitle {
    font-size: clamp(0.85rem, 2.3vw, 1.1rem);
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 18px;
    line-height: 1.5;
}
.record-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.18), rgba(255, 215, 0, 0.04));
    border: 1px solid rgba(255, 215, 0, 0.35);
    padding: 10px 18px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 16px;
    color: var(--accent);
    letter-spacing: 1px;
}

.difficulty-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 20px 0;
}
.diff-btn {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
    border: 2px solid rgba(255, 255, 255, 0.12);
    color: #fff;
    padding: 16px 10px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    position: relative;
    overflow: hidden;
}
.diff-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--primary), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}
.diff-btn:hover,
.diff-btn.selected {
    border-color: var(--primary);
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 10px 28px rgba(0, 240, 255, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.diff-btn.selected::before {
    opacity: 0.14;
}
.diff-btn .diff-icon {
    font-size: 2rem;
    position: relative;
    z-index: 1;
}
.diff-btn .diff-name {
    font-weight: 800;
    font-size: 1rem;
    position: relative;
    z-index: 1;
    letter-spacing: 1px;
}
.diff-btn .diff-desc {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.55);
    position: relative;
    z-index: 1;
}

.btn {
    background: linear-gradient(135deg, var(--primary), #0098dd);
    border: none;
    color: #000;
    font-weight: 800;
    padding: 15px 38px;
    border-radius: 50px;
    font-size: clamp(1rem, 2.6vw, 1.15rem);
    cursor: pointer;
    box-shadow: 0 6px 22px rgba(0, 240, 255, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 1.5px;
    position: relative;
    overflow: hidden;
}
.btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.3), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}
.btn:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 12px 34px rgba(0, 240, 255, 0.7);
}
.btn:hover::before {
    opacity: 1;
}
.btn:active {
    transform: translateY(0) scale(0.97);
}
.btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
}
.btn-secondary {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.04));
    color: #fff;
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
.btn-secondary:hover {
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.35);
}
.btn-danger {
    background: linear-gradient(135deg, var(--secondary), #cc0044);
    box-shadow: 0 6px 20px rgba(255, 0, 85, 0.5);
}
.btn-danger:hover {
    box-shadow: 0 10px 32px rgba(255, 0, 85, 0.7);
}

#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    pointer-events: none;
    z-index: 5;
}
.hud-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent);
}
.hud-left,
.hud-right {
    display: flex;
    gap: 7px;
    align-items: center;
    flex-wrap: wrap;
}
.hud-box {
    background: var(--glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 5px 10px;
    font-size: clamp(10px, 1.8vw, 13px);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s;
}
.health-bar {
    width: clamp(55px, 14vw, 110px);
    height: 7px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
}
.health-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary), #ff6b6b);
    width: 100%;
    transition: width 0.3s;
    box-shadow: 0 0 10px rgba(255, 0, 85, 0.6);
    border-radius: 4px;
}

#stageIndicator {
    position: absolute;
    top: 48px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 6;
    text-align: center;
    transition: all 0.5s;
}
.stage-name {
    font-size: clamp(0.95rem, 2.8vw, 1.3rem);
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 24px rgba(0, 240, 255, 0.5);
    margin-bottom: 3px;
    letter-spacing: 2px;
}
.stage-progress {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.65);
}
.progress-bar {
    width: clamp(70px, 18vw, 140px);
    height: 5px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    transition: width 0.3s;
    box-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
    border-radius: 3px;
}

#bossHud {
    position: absolute;
    top: 78px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 5;
    text-align: center;
    opacity: 0;
    transition: opacity 0.5s;
    min-width: 260px;
}
#bossHud.active {
    opacity: 1;
}
.boss-name {
    font-size: clamp(1rem, 3vw, 1.3rem);
    font-weight: 900;
    color: var(--secondary);
    text-shadow: 0 0 18px var(--secondary);
    margin-bottom: 6px;
    animation: bossGlow 1.5s infinite;
    letter-spacing: 2px;
}
@keyframes bossGlow {
    0%, 100% { text-shadow: 0 0 18px var(--secondary); }
    50% { text-shadow: 0 0 30px var(--secondary), 0 0 50px var(--secondary); }
}
.boss-health-bar {
    width: clamp(180px, 45vw, 330px);
    height: 13px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 7px;
    overflow: hidden;
    border: 2px solid rgba(255, 0, 85, 0.45);
    box-shadow: 0 0 24px rgba(255, 0, 85, 0.35);
}
.boss-health-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff0055, #ff4400, #ff8800);
    width: 100%;
    transition: width 0.3s;
    box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.3);
    border-radius: 5px;
}

#backBtn {
    position: absolute;
    top: 12px;
    right: 12px;
    pointer-events: auto;
    z-index: 20;
    background: var(--glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1.1rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    color: #fff;
}
#backBtn:hover {
    background: var(--glass-strong);
    transform: scale(1.12);
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.5);
}
#backBtn:active {
    transform: scale(0.93);
}

#pauseOverlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}
#pauseOverlay.active {
    opacity: 1;
    pointer-events: auto;
}
.pause-panel {
    background: linear-gradient(135deg, rgba(8, 12, 28, 0.96), rgba(16, 24, 48, 0.92));
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 38px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85);
    transform: scale(0.88);
    transition: transform 0.3s;
    max-width: 90vw;
}
#pauseOverlay.active .pause-panel {
    transform: scale(1);
}
.pause-title {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 22px;
    color: var(--primary);
    letter-spacing: 2px;
}
.pause-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#weaponIndicator {
    position: absolute;
    bottom: 18px;
    right: 18px;
    pointer-events: none;
    z-index: 6;
    background: var(--glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 7px 13px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 5px;
    letter-spacing: 1px;
}

#mobileControls {
    position: absolute;
    bottom: 28px;
    left: 28px;
    z-index: 6;
    pointer-events: auto;
    display: none;
}
#mobileControls.show {
    display: block;
}
.joystick-base {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid rgba(255, 255, 255, 0.18);
    position: relative;
    box-shadow: 0 4px 22px rgba(0, 0, 0, 0.35);
}
.joystick-stick {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 240, 255, 0.65), rgba(0, 240, 255, 0.2));
    border: 2px solid var(--primary);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: none;
    box-shadow: 0 0 18px rgba(0, 240, 255, 0.55);
}

.stage-complete-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 30;
    pointer-events: none;
}
.stage-complete-text {
    font-size: clamp(2rem, 8vw, 4rem);
    font-weight: 900;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 60px rgba(0, 240, 255, 0.8);
    animation: stageComplete 2s ease-out;
    opacity: 0;
}
@keyframes stageComplete {
    0% { opacity: 0; transform: scale(0.4); }
    25% { opacity: 1; transform: scale(1.12); }
    60% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.3); }
}

.new-record {
    color: var(--accent);
    font-weight: 800;
    font-size: 1.3rem;
    animation: pulse 1s infinite;
    text-shadow: 0 0 22px var(--accent);
}
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.75; transform: scale(1.06); }
}

.hidden {
    display: none !important;
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}
.logo-anim {
    animation: float 4s ease-in-out infinite;
}

.weapon-upgrade {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--accent);
    text-shadow: 0 0 22px var(--accent);
    animation: weaponUpgrade 2s ease-out forwards;
    z-index: 25;
    pointer-events: none;
    letter-spacing: 2px;
}
@keyframes weaponUpgrade {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
    18% { opacity: 1; transform: translate(-50%, -50%) scale(1.25); }
    75% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -85%) scale(1); }
}

.victory-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.victory-panel {
    background: linear-gradient(135deg, rgba(8, 12, 28, 0.96), rgba(20, 30, 50, 0.9));
    border: 2px solid var(--accent);
    border-radius: 24px;
    padding: 46px;
    text-align: center;
    box-shadow: 0 0 90px rgba(255, 215, 0, 0.35);
    max-width: 90vw;
}
.victory-title {
    font-size: clamp(2rem, 8vw, 4rem);
    font-weight: 900;
    background: linear-gradient(135deg, var(--accent), #fff, var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 18px;
    animation: victoryGlow 2s infinite;
}
@keyframes victoryGlow {
    0%, 100% { filter: drop-shadow(0 0 22px var(--accent)); }
    50% { filter: drop-shadow(0 0 45px var(--accent)); }
}

@media (max-width: 600px) {
    .difficulty-grid { grid-template-columns: 1fr; }
    .diff-btn { padding: 13px; }
    .panel { padding: 22px 24px; }
    #stageIndicator { top: 42px; }
    #weaponIndicator { bottom: 10px; right: 10px; font-size: 0.7rem; padding: 5px 10px; }
    #mobileControls { bottom: 18px; left: 16px; }
    .joystick-base { width: 90px; height: 90px; }
    .joystick-stick { width: 38px; height: 38px; }
}
