body {
    margin: 0;
    padding: 0;
    background-color: #000;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    display: flex;
    flex-direction: column;
    height: 100vh;
    touch-action: none;
}

#game-viewport {
    position: relative;
    flex-grow: 1;
    overflow: hidden;
    background: radial-gradient(circle at center, #0b1026 0%, #000000 100%);
}

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

.vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, transparent 60%, rgba(0, 0, 0, 0.8) 100%);
    pointer-events: none;
    z-index: 6;
}


#ui-layer {
    position: relative;
    width: 100%;
    height: 80px;
    background-color: #050508;
    border-bottom: 2px solid #333;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 12px;
    box-sizing: border-box;
    z-index: 20;
    box-shadow: 0 0 20px rgba(0, 200, 255, 0.1);
}

/* Mobile HUD: center Score+Bonus, right-align Sector/Best/Lives */
#ui-layer>.hud-group:first-child {
    grid-column: 2;
    justify-self: center;
}

#ui-layer>.hud-group:last-child {
    grid-column: 3;
    justify-self: end;
}


/* Desktop-only HUD (new style). Hidden by default, enabled via body.desktop. */
#ui-layer-desktop {
    display: none;
}

body.desktop #ui-layer {
    display: none;
}

body.desktop #ui-layer-desktop {
    display: flex;
    position: relative;
    width: 100%;
    height: 88px;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    box-sizing: border-box;
    z-index: 20;
    background: linear-gradient(180deg, rgba(10, 18, 34, 0.98), rgba(6, 10, 18, 0.98));
    border-bottom: 2px solid rgba(0, 220, 255, 0.18);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55), 0 0 24px rgba(0, 200, 255, 0.10);
}

body.desktop #pause-btn.mobile-control {
    display: none !important;
}

body.desktop #pause-btn-desktop.hud-pause {
    width: 62px;
    height: 62px;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(120, 140, 170, 0.32), rgba(30, 40, 60, 0.42));
    border: 2px solid rgba(200, 220, 255, 0.32);
    box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.55), 0 0 18px rgba(0, 0, 0, 0.5);
    color: rgba(240, 248, 255, 0.92);
    font-weight: 900;
    font-size: 26px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.35);
}

body.desktop #pause-btn-desktop.hud-pause:active {
    transform: scale(0.96);
    background: rgba(255, 255, 255, 0.18);
}

body.desktop .hud-cluster {
    display: flex;
    align-items: center;
    gap: 16px;
}

body.desktop .hud-left {
    justify-content: flex-start;
}

body.desktop .hud-right {
    justify-content: flex-end;
}

body.desktop .hud-pill {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(18, 54, 92, 0.62), rgba(8, 26, 48, 0.78));
    border: 2px solid rgba(0, 220, 255, 0.22);
    box-shadow: inset 0 0 16px rgba(0, 0, 0, 0.55), 0 0 18px rgba(0, 200, 255, 0.12);
}

body.desktop .hud-pill.hud-best {
    border-color: rgba(255, 215, 0, 0.22);
}

body.desktop .hud-label {
    color: #3ff6ff;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    text-shadow: 0 0 8px rgba(0, 255, 255, 0.35);
    line-height: 1;
}

body.desktop .hud-main {
    color: #e9ffff;
    font-size: 24px;
    font-weight: 900;
    letter-spacing: 1px;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.25);
    line-height: 1;
}

body.desktop .hud-stack {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

body.desktop .hud-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
}

body.desktop .hud-svg {
    width: 42px;
    height: 42px;
    filter: drop-shadow(0 0 10px rgba(0, 0, 0, 0.6));
}

body.desktop .hud-bonus-value {
    color: #ffd35a;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.35);
}

body.desktop .hud-lives {
    padding: 12px 18px;
}

body.desktop .hud-hearts {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

body.desktop .hud-heart {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    color: #ff3b3b;
    text-shadow: 0 0 10px rgba(255, 0, 0, 0.35);
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.6));
}

.hud-group {
    display: flex;
    gap: 20px;
}

.hud-panel {
    display: flex;
    align-items: center;
    background: rgba(0, 20, 40, 0.8);
    border: 1px solid rgba(0, 200, 255, 0.3);
    border-radius: 12px;
    padding: 8px 20px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.hud-panel.highscore {
    border-color: rgba(255, 215, 0, 0.3);
}

.hud-text {
    color: #00ffff;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 1px;
    text-shadow: 0 0 5px rgba(0, 255, 255, 0.6);
}

.hud-value {
    color: #ffffff;
    margin-left: 10px;
    font-size: 20px;
    font-weight: 600;
}

.bonus-active {
    border-color: #ffd700 !important;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3) !important;
}

.bonus-text-active {
    color: #ffd700 !important;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.8) !important;
}

/* --- JOYSTICK STYLES --- */
#joystick-zone {
    position: absolute;
    top: 0;
    right: 0;
    width: 50%;
    height: 100%;
    z-index: 40;
    touch-action: none;
}

#joystick-base {
    width: 150px;
    height: 150px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(0, 255, 255, 0.5);
    border-radius: 50%;
    position: absolute;
    display: none;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.2);
    pointer-events: none;
    transform: translate(-50%, -50%);
}

#joystick-base::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 1px dashed rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

#joystick-stick {
    width: 60px;
    height: 60px;
    background: radial-gradient(circle at 30% 30%, #00ffff, #005577);
    border-radius: 50%;
    position: absolute;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.6);
    transform: translate(0, 0);
    pointer-events: none;
}

#shield-btn {
    position: absolute;
    bottom: 150px;
    left: 30px;
    width: 60px;
    height: 60px;
    z-index: 50;
    touch-action: none;
    background: linear-gradient(135deg, rgba(0, 200, 255, 0.3), rgba(0, 100, 200, 0.5));
    border: 2px solid rgba(0, 255, 255, 0.8);
    border-radius: 6px 6px 30px 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
    cursor: pointer;
    transition: transform 0.1s, background 0.1s, box-shadow 0.1s;
}

#shield-btn:active {
    transform: scale(0.95);
    background: rgba(0, 255, 255, 0.6);
    box-shadow: 0 0 25px rgba(0, 255, 255, 0.8);
}

#shield-count-mobile {
    font-size: 28px;
    font-weight: 900;
    color: #ffffff;
    text-shadow: 0 0 10px #00ffff;
    font-family: 'Segoe UI', monospace;
}

#pause-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    z-index: 50;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    color: #fff;
    font-weight: bold;
    font-size: 20px;
    font-family: monospace;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    touch-action: none;
    text-shadow: 0 0 5px #fff;
    transition: all 0.1s;
}

#pause-btn:active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0.95);
}

#center-screen-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 10, 15, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 80;
    pointer-events: auto;
}

#pause-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 60;
    pointer-events: auto;
}

#pause-text {
    color: #fff;
    font-size: 48px;
    font-weight: bold;
    letter-spacing: 10px;
    text-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
    margin-bottom: 40px;
}

.pause-menu-btn {
    margin: 10px;
    padding: 15px 50px;
    font-size: 24px;
    width: 280px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
    text-transform: uppercase;
    font-weight: bold;
    color: white;
}

#resume-btn {
    background: linear-gradient(45deg, #0044cc, #0088ff);
    box-shadow: 0 0 15px rgba(0, 136, 255, 0.4);
}

#quit-btn {
    background: linear-gradient(45deg, #880000, #cc0000);
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.4);
}

#dev-menu {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid #00ff00;
    padding: 20px;
    border-radius: 10px;
    display: none;
    flex-direction: column;
    align-items: center;
    z-index: 40;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

#dev-menu h3 {
    color: #00ff00;
    margin: 0 0 15px 0;
    text-transform: uppercase;
}

#dev-level-input {
    background: #111;
    border: 1px solid #00ff00;
    color: #00ff00;
    padding: 5px;
    font-size: 16px;
    width: 60px;
    text-align: center;
    margin-bottom: 10px;
}

.dev-btn {
    background: #004400;
    color: #00ff00;
    border: 1px solid #00ff00;
    padding: 5px 15px;
    cursor: pointer;
    text-transform: uppercase;
    font-weight: bold;
}

.dev-btn:hover {
    background: #006600;
}

body.desktop .mobile-control {
    display: none !important;
}

/* Desktop joystick: keep the floating joystick enabled even when other mobile controls are hidden */
body.desktop #joystick-zone.mobile-control {
    display: block !important;
}

/* Desktop: keep shield button visible */
body.desktop #shield-btn.mobile-control {
    display: flex !important;
}

h1 {
    color: #fff;
    background: -webkit-linear-gradient(#fff, #00ffff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 20px rgba(0, 255, 255, 0.4));
    font-size: 72px;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 4px;
    text-align: center;
    font-weight: 900;
}

h2 {
    color: #00ffff;
    text-shadow: 0 0 15px rgba(0, 255, 255, 0.5);
    font-size: 36px;
    margin-bottom: 20px;
    text-transform: uppercase;
    font-weight: 600;
}

p {
    color: #aaa;
    font-size: 16px;
    line-height: 1.6;
    text-align: center;
    max-width: 600px;
}

button {
    margin-top: 40px;
    padding: 18px 60px;
    font-size: 20px;
    background: linear-gradient(45deg, #0044cc, #0088ff);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s, background 0.3s;
    box-shadow: 0 0 20px rgba(0, 100, 255, 0.4);
    text-transform: uppercase;
    font-weight: bold;
    letter-spacing: 2px;
    touch-action: manipulation;
}

@media (hover: hover) {
    button:hover {
        transform: scale(1.05);
        box-shadow: 0 0 30px rgba(0, 150, 255, 0.6);
        background: linear-gradient(45deg, #0055ee, #00aaff);
    }
}

button:active {
    transform: scale(0.95);
    box-shadow: 0 0 10px rgba(0, 100, 255, 0.8);
    background: linear-gradient(45deg, #003399, #0066cc);
}

@media (max-width: 768px) {
    button {
        padding: 15px 30px;
        font-size: 18px;
        margin-top: 20px;
        width: auto;
    }

    #start-content>div {
        flex-wrap: wrap;
        justify-content: center;
    }
}

.title-perfect {
    color: #44ff44 !important;
    text-shadow: 0 0 20px rgba(0, 255, 0, 0.6);
    background: none;
    -webkit-text-fill-color: #44ff44;
}

.title-poor {
    color: #ffaa00 !important;
    text-shadow: 0 0 15px rgba(255, 170, 0, 0.5);
    background: none;
    -webkit-text-fill-color: #ffaa00;
}

.controls-info {
    margin-top: 30px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 20px 40px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.key {
    color: #00aaff;
    font-weight: bold;
}

#start-content,
#game-over-content,
#level-complete-content,
#game-complete-content {
    display: none;
    flex-direction: column;
    align-items: center;
}

/* Between-rounds: bonus multiplier feedback (uses the same medal-style icon as the BONUS HUD) */
.level-bonus-row {
    display: flex;
    justify-content: center;
    margin-top: 18px;
}

.level-bonus-pill {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(136, 255, 255, 0.22);
    box-shadow: 0 0 24px rgba(0, 255, 255, 0.18);
}

.level-bonus-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.1;
}

.level-bonus-label {
    font-size: 12px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.75);
}

.level-bonus-value {
    font-size: 28px;
    font-weight: 900;
    color: #ffd700;
    text-shadow: 0 0 18px rgba(255, 215, 0, 0.25);
    margin-top: 4px;
}

.level-bonus-note {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.68);
    margin-top: 4px;
}

@media (max-width: 768px) {
    .level-bonus-pill {
        padding: 10px 14px;
        border-radius: 14px;
    }

    .level-bonus-value {
        font-size: 24px;
    }
}

.glitch-hud {
    animation: glitch-anim 0.2s infinite;
}

@keyframes glitch-anim {
    0% {
        transform: translate(0);
        text-shadow: 2px 0 #ff0000, -2px 0 #0000ff;
    }

    25% {
        transform: translate(2px, 2px);
        text-shadow: -2px 0 #ff0000, 2px 0 #0000ff;
    }

    50% {
        transform: translate(-2px, -2px);
        text-shadow: 2px 0 #00ff00, -2px 0 #ff00ff;
    }

    75% {
        transform: translate(0);
        text-shadow: none;
    }

    100% {
        transform: translate(0);
    }
}

/* ---------- LEADERBOARD FIX ---------- */
#leaderboard-view {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 600px;
}

/* Overlay scroll mode (used for Hangar/Leaderboard so you can scroll on mobile) */
#center-screen-overlay.overlay-scroll {
    justify-content: flex-start;
    /* iOS/iPad scrolling: make the overlay a real scroll container */
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    overflow: auto;
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-top: 14px;
    padding-bottom: 14px;
    touch-action: pan-y;
}

/* Disable the mobile transform scaling for scrollable views (it breaks scrolling). */
body:not(.desktop) #center-screen-overlay.overlay-scroll>div {
    transform: none !important;
}

/* Hangar (ship selection) */
#hangar-view {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 920px;
    box-sizing: border-box;
}

/* Give the last button breathing room, especially on iPad (safe-area). */
#hangar-back-btn {
    margin-bottom: calc(24px + env(safe-area-inset-bottom));
}

/* One ship per line, scrolls vertically */
.hangar-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: stretch;
    width: 100%;
    max-width: 680px;
    padding: 6px 10px 18px;
    box-sizing: border-box;
}

.ship-card {
    width: 100%;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 0 24px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(6px);
}

.ship-card.is-active-ship {
    border-color: rgba(0, 255, 255, 0.35);
    box-shadow: 0 0 26px rgba(0, 200, 255, 0.14), 0 0 24px rgba(0, 0, 0, 0.35);
}

.ship-card.is-locked-card {
    opacity: 0.85;
}

.ship-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.ship-card-title {
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 2px;
    font-size: 16px;
    color: #e8fbff;
}

.ship-card-badge {
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 1px;
    padding: 6px 8px;
    border-radius: 999px;
    text-transform: uppercase;
    white-space: nowrap;
}

.ship-card-badge-locked {
    background: rgba(255, 80, 0, 0.18);
    border: 1px solid rgba(255, 80, 0, 0.45);
    color: rgba(255, 200, 180, 0.95);
}

.ship-card-badge-unlocked {
    background: rgba(68, 255, 68, 0.14);
    border: 1px solid rgba(68, 255, 68, 0.45);
    color: #44ff44;
}

.ship-card-imgwrap {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 140px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 12px;
    overflow: hidden;
}

.ship-card-imgwrap img {
    max-width: 100%;
    max-height: 100%;
}

.ship-card-desc {
    margin-top: 10px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.75);
    text-align: center;
    min-height: 38px;
}

.ship-card-stats {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

.ship-stat-label {
    width: 66px;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: rgba(0, 255, 255, 0.85);
    text-shadow: 0 0 8px rgba(0, 255, 255, 0.18);
}

.ship-stat-bar {
    flex: 1;
    height: 10px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    overflow: hidden;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.55);
}

.ship-stat-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(0, 200, 255, 0.85), rgba(0, 255, 213, 0.85));
    box-shadow: 0 0 16px rgba(0, 200, 255, 0.18);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.75s cubic-bezier(0.25, 0.8, 0.25, 1);
}

#hangar-view.stats-animate .ship-stat-fill {
    transform: scaleX(1);
}

.ship-stat-val {
    width: 52px;
    text-align: right;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.75);
}

.ship-traits {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.ship-trait {
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.9px;
    text-transform: uppercase;
    padding: 6px 8px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(0, 0, 0, 0.35);
    color: rgba(255, 255, 255, 0.78);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.45);
}

.ship-trait-pro {
    border-color: rgba(68, 255, 68, 0.28);
    background: rgba(68, 255, 68, 0.06);
    color: rgba(120, 255, 160, 0.95);
}

.ship-trait-con {
    border-color: rgba(255, 80, 0, 0.30);
    background: rgba(255, 80, 0, 0.06);
    color: rgba(255, 190, 160, 0.95);
}

/* Override global button spacing for card buttons */
.ship-card .ship-action-btn {
    margin-top: 14px;
    width: 100%;
    padding: 12px 0;
    font-size: 16px;
    border-radius: 10px;
}

.ship-card .ship-action-btn:disabled {
    cursor: default;
    box-shadow: none;
    opacity: 0.85;
}

.ship-card .ship-action-btn.is-active {
    background: linear-gradient(45deg, #00c8ff, #00ffd5);
    color: #001018;
}

.ship-card .ship-action-btn.is-locked {
    background: linear-gradient(45deg, #444, #777);
}

.leaderboard-container {
    background: rgba(5, 10, 20, 0.95);
    border: 2px solid #00ffff;
    border-radius: 12px;
    padding: 10px 20px;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 20px;
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.15);
    min-height: 100px;
    max-height: 60vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
}

#leaderboard-entries {
    touch-action: pan-y;
}

.score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 10px;
    border-bottom: 1px solid rgba(0, 255, 255, 0.2);
    font-family: 'Segoe UI', sans-serif;
}

.score-row:last-child {
    border-bottom: none;
}

.score-rank {
    color: #ffd700;
    width: 40px;
    font-weight: 800;
    font-size: 20px;
    text-align: left;
}

.score-name {
    flex-grow: 1;
    text-align: left;
    padding-left: 10px;
    color: #ffffff;
    font-size: 20px;
    font-weight: 600;
    text-transform: uppercase;
    text-shadow: 0 0 5px rgba(0, 255, 255, 0.8);
}

.score-value {
    color: #44ff44;
    font-weight: bold;
    font-family: monospace;
    font-size: 24px;
    text-align: right;
    text-shadow: 0 0 8px rgba(68, 255, 68, 0.5);
}

.score-row:nth-child(1) .score-name {
    color: #ffd700;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.8);
}

.score-row:nth-child(2) .score-name {
    color: #e0e0e0;
}

.score-row:nth-child(3) .score-name {
    color: #cd7f32;
}

.loading-text {
    color: #00ffff;
    margin: 20px 0;
    font-style: italic;
}

.no-scores {
    color: #888;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

#high-score-input {
    display: none;
    flex-direction: column;
    align-items: center;
    margin: 20px 0;
    animation: pulse-gold 2s infinite;
}

@keyframes pulse-gold {
    0% {
        filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.3));
    }

    50% {
        filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.8));
    }

    100% {
        filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.3));
    }
}

#player-name-input {
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #ffd700;
    color: #ffd700;
    padding: 10px 20px;
    font-size: 24px;
    text-align: center;
    text-transform: uppercase;
    border-radius: 4px;
    width: 150px;
    font-family: 'Segoe UI', sans-serif;
    font-weight: bold;
    outline: none;
    margin-bottom: 10px;
    user-select: text;
    -webkit-user-select: text;
    touch-action: manipulation;
    z-index: 90;
}

#submit-score-btn {
    background: linear-gradient(45deg, #aa8800, #ffdd00);
    color: #000;
    border: none;
    padding: 10px 30px;
    font-weight: 900;
    cursor: pointer;
    text-transform: uppercase;
    border-radius: 4px;
    font-size: 16px;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
}

@media (max-width: 768px) {
    body:not(.desktop) #ui-layer {
        height: 56px;
        padding: 0 8px;
    }

    body:not(.desktop) .hud-group {
        gap: 8px;
    }

    body:not(.desktop) .hud-panel {
        padding: 4px 8px;
        border-radius: 8px;
    }

    /* 15% smaller top HUD text on mobile (base before scaling) */
    body:not(.desktop) .hud-text {
        font-size: 9px;
        letter-spacing: 0.5px;
    }

    body:not(.desktop) .hud-value {
        font-size: 12px;
        margin-left: 6px;
    }

    /* Mobile: scale top HUD to match menus (same 0.6 as overlay) */
    body:not(.desktop) #ui-layer {
        transform: scale(0.6);
        transform-origin: top left;
        width: calc(100% / 0.6);
    }

    body:not(.desktop) #pause-overlay {
        padding: 10px;
    }

    body:not(.desktop) .pause-menu-btn {
        padding: 8px 20px;
        font-size: 14px;
        margin-top: 10px;
    }

    body:not(.desktop) #start-content h1 {
        font-size: 32px;
        letter-spacing: 1px;
        margin-bottom: 4px;
    }

    body:not(.desktop) #start-content h2 {
        font-size: 16px;
        margin-bottom: 12px;
    }

    body:not(.desktop) #start-content p {
        font-size: 13px;
        max-width: 320px;
    }

    body:not(.desktop) #start-content button {
        font-size: 14px;
        padding: 10px 22px;
        margin-top: 10px;
    }

    body:not(.desktop) #center-screen-overlay>div {
        transform: scale(0.6);
        transform-origin: center center;
    }

    body:not(.desktop) #level-complete-content,
    body:not(.desktop) #victory-content {
        transform: scale(0.6);
    }

    body:not(.desktop) #game-over-content,
    body:not(.desktop) #game-complete-content {
        transform: scale(0.6);
    }
}

/* ---------- SECTOR CLEARED: mobile compact layout ---------- */
/* The 0.6 scale transform keeps the full layout box, so tighten internal spacing. */
@media (hover: none) and (pointer: coarse) {
    body:not(.desktop) #level-complete-content h1 {
        font-size: 36px !important;
        margin-bottom: 4px !important;
    }

    body:not(.desktop) #level-complete-content h2 {
        font-size: 18px !important;
        margin-bottom: 6px !important;
    }

    body:not(.desktop) #level-complete-content p {
        font-size: 13px !important;
        margin: 4px 0 !important;
    }

    body:not(.desktop) #level-complete-content button {
        margin-top: 8px !important;
        padding: 12px 24px !important;
    }

    body:not(.desktop) #level-complete-content .level-bonus-row {
        margin-top: 8px !important;
    }

    /* Reduce the overall gap the scaled box occupies */
    body:not(.desktop) #level-complete-content {
        margin-top: -40px;
    }
}

/* ---------- SPLASH SCREEN ---------- */
#splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    flex-direction: column;
    z-index: 120;
    padding: 0;
    box-sizing: border-box;
    text-align: left;
    overflow: hidden;
    background:
        url("../assets/menubackground.png?v=4022") center center / cover no-repeat,
        #02030a;
    opacity: 1;
    transition: opacity 0.30s ease-out;
}

#splash-screen.splash-hide {
    opacity: 0;
    pointer-events: none;
}

/* Soft vignette for readability without hiding the art */
#splash-screen::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, rgba(0, 0, 0, 0.10) 0%, rgba(0, 0, 0, 0.55) 78%);
    pointer-events: none;
}

/* New splash layout (instruction panel + launch button) */
#splash-screen .splash-panel {
    position: absolute;
    top: 12%;
    right: 6%;
    width: 52vw;
    max-width: 820px;
    min-width: 340px;
    padding: 28px 34px 26px;
    box-sizing: border-box;
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.40);
    border: 1px solid rgba(0, 200, 255, 0.22);
    box-shadow: 0 0 48px rgba(0, 0, 0, 0.75), 0 0 24px rgba(0, 160, 255, 0.12);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    z-index: 1;
}

.splash-panel-title {
    font-size: 34px;
    font-weight: 900;
    letter-spacing: 4px;
    text-transform: uppercase;
    text-align: center;
    color: #ffffff;
    text-shadow: 0 0 18px rgba(0, 0, 0, 0.85);
    margin: 2px 0 18px 0;
}

.splash-panel-list {
    list-style: none;
    padding: 0;
    margin: 0 0 26px 0;
}

.splash-panel-list li {
    position: relative;
    padding-left: 20px;
    margin: 10px 0;
    color: rgba(120, 220, 255, 0.95);
    font-size: 16px;
    line-height: 1.35;
    font-weight: 700;
    text-shadow: 0 0 12px rgba(0, 0, 0, 0.85);
}

.splash-panel-list li::before {
    content: "–";
    position: absolute;
    left: 0;
    top: 0;
    color: rgba(0, 200, 255, 0.95);
}

#splash-play-btn.splash-launch-btn {
    width: 320px;
    height: 86px;
    display: block;
    margin: 0 auto;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    background:
        url("../assets/bluebutton.png?v=4022") center center / 100% 100% no-repeat,
        linear-gradient(180deg, rgba(18, 78, 120, 0.92), rgba(5, 18, 32, 0.92));
    color: #ffd34a;
    font-size: 28px;
    font-weight: 900;
    letter-spacing: 4px;
    text-transform: uppercase;
    text-shadow: 0 0 12px rgba(0, 0, 0, 0.85), 0 0 18px rgba(255, 210, 80, 0.25);
    box-shadow: 0 0 26px rgba(0, 200, 255, 0.22), inset 0 0 26px rgba(0, 0, 0, 0.55);
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

#splash-play-btn.splash-launch-btn:active {
    transform: scale(0.98);
}

#splash-play-btn.splash-launch-btn:focus-visible {
    outline: 3px solid rgba(0, 200, 255, 0.65);
    outline-offset: 4px;
}

.splash-inner {
    background: radial-gradient(circle at top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.6) 55%, transparent 100%);
    padding: 40px 30px;
    border-radius: 20px;
    border: 1px solid rgba(0, 255, 255, 0.25);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.9);
}

.splash-title {
    font-size: 40px;
    letter-spacing: 8px;
    font-weight: 900;
    text-transform: uppercase;
    background: -webkit-linear-gradient(#ffffff, #00ffff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px rgba(0, 255, 255, 0.6);
    margin-bottom: 10px;
}

.splash-subtitle {
    font-size: 18px;
    text-transform: uppercase;
    letter-spacing: 4px;
    color: #ffffff;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
    margin-bottom: 30px;
}

.splash-hint {
    font-size: 14px;
    color: #ffffff;
    opacity: 0.8;
    margin-top: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

@media (max-width: 600px) {
    .splash-inner {
        padding: 25px 18px;
    }

    .splash-title {
        font-size: 28px;
        letter-spacing: 5px;
    }

    .splash-subtitle {
        font-size: 14px;
        letter-spacing: 3px;
    }

    .splash-hint {
        font-size: 12px;
    }
}

@media (max-width: 900px) {
    #splash-screen .splash-panel {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: min(92vw, 680px);
        top: 8%;
        padding: 22px 22px 20px;
    }

    .splash-panel-title {
        font-size: 28px;
        letter-spacing: 3px;
        margin-bottom: 14px;
    }

    .splash-panel-list li {
        font-size: 14px;
        margin: 8px 0;
    }

    #splash-play-btn.splash-launch-btn {
        width: 270px;
        height: 76px;
        font-size: 24px;
        letter-spacing: 3px;
    }
}

@media (max-width: 520px) {
    #splash-screen .splash-panel {
        top: 6%;
    }

    .splash-panel-title {
        font-size: 24px;
    }

    #splash-play-btn.splash-launch-btn {
        width: 240px;
        height: 68px;
        font-size: 22px;
        letter-spacing: 2px;
    }
}

/* Small spacing tweaks */
.leaderboard-container {
    padding: 18px 22px;
}

.score-row {
    padding: 14px 10px;
}

.score-row span[style*="min-width:64px"] {
    margin-left: 12px;
    margin-right: 10px;
}

.score-value {
    min-width: 96px;
}

/* Touch devices (iPad landscape etc.): apply the same scaling as "mobile" */
@media (hover: none) and (pointer: coarse) {
    body:not(.desktop) #center-screen-overlay>div {
        transform: scale(0.6);
        transform-origin: center center;
    }

    body:not(.desktop) #ui-layer {
        transform: scale(0.6);
        transform-origin: top left;
        width: calc(100% / 0.6);
    }
}

/* --- Mobile/tablet landscape: make start menu fit, avoid cut-off buttons --- */
@media (hover: none) and (pointer: coarse) and (orientation: landscape) and (max-width: 900px) {

    /* Allow content to start higher and scroll if needed */
    body:not(.desktop) #center-screen-overlay {
        justify-content: flex-start;
        padding-top: 8px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Tighten the start menu specifically */
    body:not(.desktop) #start-content {
        margin-top: 0;
        padding-top: 6px;
    }

    body:not(.desktop) #start-content h1 {
        font-size: 22px;
        letter-spacing: 1px;
        margin: 0 0 2px 0;
    }

    body:not(.desktop) #start-content h2 {
        font-size: 12px;
        margin: 0 0 8px 0;
    }

    body:not(.desktop) #start-content .controls-info {
        margin-top: 8px;
        padding: 10px 14px;
    }

    body:not(.desktop) #start-content .controls-info p {
        font-size: 12px;
        line-height: 1.3;
        max-width: 520px;
    }

    body:not(.desktop) #start-content>div {
        gap: 10px;
    }

    body:not(.desktop) #start-content button {
        margin-top: 8px;
        padding: 8px 16px;
        font-size: 12px;
    }
}

/* Large tablets (e.g. iPad 11") landscape: don't shrink start/menu overlay */
@media (hover: none) and (pointer: coarse) and (orientation: landscape) and (min-width: 901px) {

    /* Large tablets: keep the start menu centered, but NEVER block scroll views like Hangar/Leaderboard */
    body:not(.desktop) #center-screen-overlay:not(.overlay-scroll) {
        justify-content: center !important;
        padding-top: env(safe-area-inset-top) !important;
        padding-bottom: env(safe-area-inset-bottom) !important;
        overflow-y: hidden;
    }

    body:not(.desktop) #center-screen-overlay.overlay-scroll {
        justify-content: flex-start !important;
        overflow-y: scroll !important;
        -webkit-overflow-scrolling: touch;
    }

    body:not(.desktop) #center-screen-overlay>div {
        transform: scale(0.95) !important;
        transform-origin: center center;
    }
}

/* iPhone/iPad safe-area + fix HUD black band (no transform scaling on ui-layer) */
@media (hover: none) and (pointer: coarse) {

    /* Stop using transform-scaling for the top HUD (it creates extra empty space) */
    body:not(.desktop) #ui-layer {
        transform: none !important;
        width: 100% !important;

        /* Make it small like your menus, but via real sizes (no layout gap) */
        height: calc(34px + env(safe-area-inset-top));
        padding-top: env(safe-area-inset-top);
        padding-left: calc(8px + env(safe-area-inset-left));
        padding-right: calc(8px + env(safe-area-inset-right));
        box-sizing: border-box;
    }

    body:not(.desktop) .hud-group {
        gap: 6px;
    }

    body:not(.desktop) .hud-panel {
        padding: 2px 6px;
        border-radius: 7px;
    }

    body:not(.desktop) .hud-text {
        font-size: 9px;
        letter-spacing: 0.3px;
    }

    body:not(.desktop) .hud-value {
        font-size: 12px;
        margin-left: 5px;
    }

    /* Keep the gameplay buttons out of the notch / Dynamic Island area */
    body:not(.desktop) #pause-btn {
        top: calc(10px + env(safe-area-inset-top));
        left: calc(10px + env(safe-area-inset-left));
    }

    body:not(.desktop) #shield-btn {
        left: calc(12px + env(safe-area-inset-left));
        bottom: calc(150px + env(safe-area-inset-bottom));
    }

    /* Optional: avoid joystick being too close to right notch area */
    body:not(.desktop) #joystick-zone {
        right: env(safe-area-inset-right);
    }
}

/* Shield button: force into bottom-left safe corner on iPhone/iPad touch */
@media (hover: none) and (pointer: coarse) {
    body:not(.desktop) #shield-btn {
        left: calc(10px + env(safe-area-inset-left)) !important;
        top: 50% !important;
        bottom: auto !important;
        transform: translateY(-50%) !important;
    }

    body:not(.desktop) #shield-btn:active {
        transform: translateY(-50%) scale(0.95) !important;
    }
}

/* Menu background (all menus): use the new theme image */
#center-screen-overlay.menu-bg {
    /* Use the new theme image as-is (no tint/overlay filters) */
    background: #02030a url("../assets/menubackground.png?v=4025") center center / cover no-repeat;

    /* Keep the background art sharp in menus */
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

/* Give each menu view a consistent panel so text stays readable on the themed background */
#center-screen-overlay.menu-bg>div {
    background: rgba(0, 0, 0, 0.42);
    border: 1px solid rgba(120, 220, 255, 0.20);
    border-radius: 18px;
    padding: 26px 30px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
    /* Keep the menu background crisp (the previous blur made the whole page look soft) */
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

/* Themed menu buttons (main menu, hangar, leaderboard, game over, victory, pause menu) */
#center-screen-overlay.menu-bg button,
#pause-overlay button {
    background:
        radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.00) 55%),
        url("../assets/bluebutton.png?v=4022") center center / 100% 100% no-repeat;
    color: #eaf7ff;
    border: none;
    border-radius: 14px;
    padding: 16px 58px;
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 0 18px rgba(0, 120, 255, 0.32);
    transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

@media (hover: hover) {

    #center-screen-overlay.menu-bg button:hover,
    #pause-overlay button:hover {
        transform: translateY(-1px) scale(1.03);
        box-shadow: 0 0 26px rgba(0, 160, 255, 0.45);
        filter: brightness(1.08);
    }
}

#center-screen-overlay.menu-bg button:active,
#pause-overlay button:active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 0 14px rgba(0, 120, 255, 0.28);
    filter: brightness(0.96);
}

#center-screen-overlay.menu-bg button:disabled {
    cursor: default;
    opacity: 0.65;
    box-shadow: none;
    filter: grayscale(0.2);
}

/* Card action buttons should keep their compact spacing */
#center-screen-overlay.menu-bg .ship-card .ship-action-btn {
    padding: 12px 0;
    font-size: 16px;
}

/* Tutorial overlay */
#tutorial-ui {
    position: absolute;
    inset: 0;
    display: none;
    /* Stack tutorial box + skip button together so they don't overlap other UI
	   elements that live in the top-right corner (eg. Sector 1 radio chatter button). */
    flex-direction: column;
    gap: 12px;
    align-items: center;
    justify-content: flex-end;
    pointer-events: none;
    z-index: 9000;
    padding-bottom: 140px;
}

#tutorial-box {
    pointer-events: none;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(0, 255, 255, 0.35);
    box-shadow: 0 0 26px rgba(0, 255, 255, 0.12);
    border-radius: 14px;
    padding: 18px 22px;
    min-width: 280px;
    max-width: 520px;
    text-align: center;
    backdrop-filter: blur(6px);
}

#tutorial-label {
    font-family: 'Orbitron', sans-serif;
    letter-spacing: 3px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.75);
    margin-bottom: 10px;
}

#tutorial-step-text {
    font-size: 20px;
    font-weight: 900;
    letter-spacing: 1px;
    color: #e8fbff;
    text-shadow: 0 0 12px rgba(0, 255, 255, 0.18), 0 0 10px rgba(0, 0, 0, 0.9);
    margin-bottom: 12px;
}

#tutorial-hint-row {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.tutorial-keygroup {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.9);
    font-weight: 900;
    letter-spacing: 2px;
    font-size: 12px;
}

.tutorial-keygroup.is-done {
    border-color: rgba(68, 255, 68, 0.75);
    box-shadow: 0 0 18px rgba(68, 255, 68, 0.22);
    color: #44ff44;
}


#tutorial-skip-btn {
    /* Place this right under the tutorial box (instead of top-right), so it
	   never overlaps other UI like the Sector 1 radio chatter button. */
    position: relative;
    top: auto;
    right: auto;
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: rgba(255, 255, 255, 0.85);
    border-radius: 10px;
    padding: 10px 14px;
    font-weight: 800;
    letter-spacing: 2px;
    cursor: pointer;
}

#tutorial-skip-btn:hover {
    filter: brightness(1.1);
}

/* === WORLD RECORD CELEBRATION === */

#world-record-celebration {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.78);
    z-index: 999999;
    pointer-events: none;
}

#world-record-celebration .wr-wrap {
    width: min(720px, 92vw);
    padding: 26px 22px;
    border-radius: 18px;
    background: rgba(10, 14, 22, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 16px 60px rgba(0, 0, 0, 0.55);
    text-align: center;
    transform: scale(0.96);
    opacity: 0;
    animation: wrPop 900ms ease-out forwards;
}

#world-record-celebration .wr-title {
    font-size: clamp(28px, 5.5vw, 44px);
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #ffffff;
    text-shadow: 0 0 18px rgba(255, 255, 255, 0.18), 0 0 34px rgba(0, 200, 255, 0.22);
    margin: 0 0 10px 0;
}

#world-record-celebration .wr-sub {
    font-size: clamp(14px, 2.6vw, 18px);
    color: rgba(205, 230, 255, 0.92);
    margin: 0;
}

#world-record-celebration .wr-sub b {
    color: #ffffff;
}

#world-record-celebration .wr-confetti {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: 0;
}

#world-record-celebration .wr-piece {
    position: absolute;
    top: -12vh;
    width: 10px;
    height: 18px;
    border-radius: 3px;
    opacity: 0.95;
    transform: translateY(0) rotate(0deg);
    animation: wrFall 1500ms linear forwards;
}

@keyframes wrPop {
    0% {
        transform: scale(0.92);
        opacity: 0;
    }

    35% {
        transform: scale(1.03);
        opacity: 1;
    }

    70% {
        transform: scale(0.995);
        opacity: 1;
    }

    100% {
        transform: scale(1.0);
        opacity: 1;
    }
}

@keyframes wrFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 0.95;
    }

    85% {
        opacity: 0.95;
    }

    100% {
        transform: translateY(120vh) rotate(520deg);
        opacity: 0;
    }
}

/* ========== CONTROLS TUTORIAL OVERLAY ========== */
#controls-tutorial {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    background: rgba(0, 0, 0, 0.85);
    cursor: pointer;
    touch-action: manipulation;
}

#controls-tutorial.is-visible {
    display: flex;
}

.controls-tutorial-inner {
    max-width: 600px;
    width: 90%;
    padding: 30px 40px;
    background: linear-gradient(180deg, rgba(10, 30, 50, 0.95), rgba(5, 15, 30, 0.98));
    border: 2px solid rgba(0, 200, 255, 0.35);
    border-radius: 20px;
    box-shadow: 0 0 60px rgba(0, 200, 255, 0.15), 0 0 100px rgba(0, 0, 0, 0.8);
    text-align: center;
}

.controls-tutorial-title {
    font-size: 32px;
    font-weight: 900;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: #00ffff;
    text-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
    margin-bottom: 30px;
    padding: 10px 20px;
    background: rgba(0, 200, 255, 0.1);
    border-radius: 8px;
    display: inline-block;
}

.controls-row {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 40px;
    margin-bottom: 25px;
}

.controls-row-actions {
    margin-top: 10px;
}

.controls-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.controls-or {
    color: rgba(255, 255, 255, 0.5);
    font-size: 16px;
    font-style: italic;
    align-self: center;
    margin-top: 20px;
}

.key-row {
    display: flex;
    gap: 4px;
    justify-content: center;
}

.key-cap {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #f8f8f8 0%, #d0d0d0 100%);
    border: 2px solid #999;
    border-radius: 8px;
    box-shadow:
        0 4px 0 #888,
        0 6px 10px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    color: #222;
    font-size: 18px;
    font-weight: 900;
    font-family: 'Segoe UI', system-ui, sans-serif;
    text-transform: uppercase;
}

.key-cap.arrow-key {
    font-size: 20px;
}

.key-cap.wide-key {
    width: auto;
    min-width: 100px;
    padding: 0 16px;
    font-size: 14px;
    letter-spacing: 1px;
}

.key-label {
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.85);
    margin-top: 8px;
}

/* Touch controls visuals */
.touch-joystick {
    width: 90px;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.touch-joystick-base {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(0, 255, 255, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.2);
}

.touch-joystick-stick {
    width: 36px;
    height: 36px;
    background: radial-gradient(circle at 30% 30%, #00ffff, #005577);
    border-radius: 50%;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.6);
}

.touch-button {
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    background: linear-gradient(135deg, rgba(0, 200, 255, 0.3), rgba(0, 100, 200, 0.5));
    border: 2px solid rgba(0, 255, 255, 0.8);
    border-radius: 16px;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
}

.controls-tutorial-hint {
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #ffd700;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
    margin-top: 30px;
    animation: pulse-hint 1.5s ease-in-out infinite;
}

@keyframes pulse-hint {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Image-based controls for tutorial */
.controls-image-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 15px;
}

.controls-hero-image {
    max-width: 100%;
    max-height: 320px;
    width: auto;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.6);
}

.controls-note {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #88ffff;
    text-shadow: 0 0 12px rgba(136, 255, 255, 0.4);
    margin-top: 10px;
}

.controls-joystick-image {
    width: 120px;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

/* Shield button visual for mobile tutorial (matches actual in-game button with red ring) */
.controls-shield-btn-visual {
    width: 70px;
    height: 85px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, rgba(0, 200, 255, 0.3), rgba(0, 100, 200, 0.5));
    border: 3px solid rgba(255, 80, 80, 0.9);
    border-radius: 8px 8px 35px 35px;
    box-shadow: 0 0 20px rgba(255, 80, 80, 0.5), 0 0 15px rgba(0, 255, 255, 0.3);
    position: relative;
}

.controls-shield-btn-visual::before {
    content: 'SHIELD';
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    font-weight: 900;
    letter-spacing: 1px;
    color: rgba(0, 255, 255, 0.9);
    text-shadow: 0 0 8px rgba(0, 255, 255, 0.5);
}

.shield-count-visual {
    font-size: 32px;
    font-weight: 900;
    color: #ffffff;
    text-shadow: 0 0 12px #00ffff;
    font-family: 'Segoe UI', monospace;
    margin-top: 12px;
}

/* Responsive adjustments for tutorial images */
@media (max-width: 500px) {
    .controls-hero-image {
        max-height: 220px;
    }

    .controls-joystick-image {
        width: 90px;
    }

    .controls-shield-btn-visual {
        width: 55px;
        height: 70px;
    }

    .shield-count-visual {
        font-size: 26px;
    }

    .controls-note {
        font-size: 13px;
    }
}

/* Desktop shows keyboard, hides touch */
.controls-desktop-section {
    display: block;
}

.controls-mobile-section {
    display: none;
}

/* Mobile/touch shows touch, hides keyboard */
body:not(.desktop) .controls-desktop-section {
    display: none;
}

body:not(.desktop) .controls-mobile-section {
    display: block;
}

/* Responsive adjustments */
@media (max-width: 500px) {
    .controls-tutorial-inner {
        padding: 20px 20px;
    }

    .controls-tutorial-title {
        font-size: 24px;
        letter-spacing: 2px;
        margin-bottom: 20px;
    }

    .controls-row {
        gap: 20px;
        margin-bottom: 15px;
    }

    .key-cap {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }

    .key-cap.wide-key {
        min-width: 80px;
        font-size: 12px;
    }

    .touch-joystick-base {
        width: 60px;
        height: 60px;
    }

    .touch-joystick-stick {
        width: 28px;
        height: 28px;
    }

    .touch-button {
        width: 55px;
        height: 55px;
        font-size: 28px;
    }

    .key-label {
        font-size: 12px;
    }

    .controls-tutorial-hint {
        font-size: 14px;
        letter-spacing: 2px;
    }
}

/* Green pulsing style for ship unlock progress text */
.ship-progress-pulse {
    color: #44ff44 !important;
    text-shadow: 0 0 12px rgba(68, 255, 68, 0.6), 0 0 24px rgba(68, 255, 68, 0.25);
    animation: pulse 2s ease-in-out infinite;
}

/* Pulse animation for "Tap to Start" prompt */
@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ===== Difficulty Segmented Control ===== */
.menu-difficulty-row {
    text-align: center;
}

.diff-seg {
    display: inline-flex;
    align-items: center;
    background: rgba(8, 14, 26, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    padding: 3px;
    gap: 2px;
}

.diff-seg .diff-seg-btn {
    all: unset;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 8px 22px !important;
    margin: 0 !important;
    margin-top: 0 !important;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    letter-spacing: 1.8px !important;
    text-transform: uppercase !important;
    color: rgba(255, 255, 255, 0.35) !important;
    background: transparent !important;
    border: none !important;
    border-radius: 999px !important;
    box-shadow: none !important;
    cursor: pointer !important;
    transition: color 0.18s, background 0.18s, box-shadow 0.18s !important;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    white-space: nowrap;
    box-sizing: border-box !important;
    width: auto !important;
    min-width: 0 !important;
    text-shadow: none !important;
    filter: none !important;
    transform: none !important;
}

.diff-seg .diff-seg-btn:hover {
    color: rgba(255, 255, 255, 0.6) !important;
    background: transparent !important;
    box-shadow: none !important;
    transform: none !important;
}

.diff-seg .diff-seg-btn:active {
    transform: none !important;
    box-shadow: none !important;
}

.diff-seg .diff-seg-btn.is-active {
    color: #fff !important;
}

.diff-seg .diff-seg-btn[data-diff="EASY"].is-active {
    background: rgba(40, 200, 120, 0.85) !important;
    box-shadow: 0 2px 10px rgba(40, 200, 120, 0.3) !important;
}

.diff-seg .diff-seg-btn[data-diff="NORMAL"].is-active {
    background: rgba(230, 170, 0, 0.9) !important;
    color: #1a1a1a !important;
    box-shadow: 0 2px 10px rgba(230, 170, 0, 0.3) !important;
}

.diff-seg .diff-seg-btn[data-diff="HARD"].is-active {
    background: rgba(220, 50, 50, 0.9) !important;
    box-shadow: 0 2px 10px rgba(220, 50, 50, 0.3) !important;
}

.diff-seg .diff-seg-btn.is-active:hover {
    filter: brightness(1.1) !important;
    transform: none !important;
}

@media (max-width: 480px) {
    .diff-seg .diff-seg-btn {
        padding: 7px 16px !important;
        font-size: 11px !important;
        letter-spacing: 1.2px !important;
    }
}