/* ZORIX — Game Design & Stylesheet (Portrait 3D edition) */

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Outfit:wght@300;400;600;700&display=swap');

:root {
    --bg-dark: #05060f;
    --glass-bg: rgba(20, 24, 44, 0.55);
    --neon-cyan: #00e5ff;
    --neon-cyan-glow: rgba(0, 229, 255, 0.6);
    --neon-magenta: #ff2d7e;
    --neon-magenta-glow: rgba(255, 45, 126, 0.6);
    --neon-gold: #ffb020;
    --neon-gold-glow: rgba(255, 176, 32, 0.6);
    --text-primary: #f0f2ff;
    --text-secondary: #8f96bf;
    --font-sci: 'Orbitron', sans-serif;
    --font-body: 'Outfit', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

html, body {
    background: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-body);
    overflow: hidden;
    width: 100%;
    height: 100%;
}

/* Desktop backdrop behind the portrait device */
.app-wrapper {
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* mobile browsers: exclude collapsing toolbars */
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 30% 20%, rgba(0, 229, 255, 0.10), transparent 45%),
        radial-gradient(circle at 70% 80%, rgba(255, 45, 126, 0.10), transparent 45%),
        radial-gradient(circle at center, #0c1030 0%, #04050c 100%);
}

/* The portrait "phone" frame — centered on desktop */
.device-frame {
    position: relative;
    height: min(94vh, 940px);
    aspect-ratio: 10 / 19;
    border-radius: 28px;
    overflow: hidden;
    background: #04050c;
    border: 2px solid rgba(120, 160, 255, 0.18);
    box-shadow:
        0 0 0 6px rgba(10, 14, 30, 0.9),
        0 30px 80px rgba(0, 0, 0, 0.7),
        0 0 60px rgba(0, 229, 255, 0.15);
}

#game-canvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
}

/* Subtle cinematic vignette over the 3D view (below the HUD) */
.device-frame::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 4;
    border-radius: inherit;
    box-shadow: inset 0 0 90px 24px rgba(0, 0, 0, 0.55);
}

/* Cinematic landing: letterbox bars slide in, white-out flash overlay */
.cinema-bar {
    position: absolute;
    left: 0;
    width: 100%;
    height: 0;
    background: #000;
    z-index: 6;
    pointer-events: none;
    transition: height 1.4s ease;
}
.cinema-bar.top { top: 0; }
.cinema-bar.bottom { bottom: 0; }
.device-frame.cinema .cinema-bar { height: 9%; }

#land-flash {
    position: absolute;
    inset: 0;
    background: #eef2ff;
    opacity: 0;
    pointer-events: none;
    z-index: 7;
}

/* ---- Screen Overlays -------------------------------------------- */
.screen-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 34px 28px;
    z-index: 10;
    transition: opacity 0.35s ease;
    background: linear-gradient(180deg, rgba(6, 8, 18, 0.72), rgba(4, 5, 12, 0.86));
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    overflow-y: auto;
}
.screen-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

/* ---- Logo -------------------------------------------------------- */
.game-logo {
    margin-bottom: 34px;
    text-align: center;
}
/* Badge logo (replaces the text wordmark on login + main menu) */
.game-logo .logo-img {
    display: block;
    width: min(64vw, 250px);
    height: auto;
    margin: 0 auto;
    filter: drop-shadow(0 0 22px rgba(0, 229, 255, 0.35))
            drop-shadow(0 10px 30px rgba(0, 0, 0, 0.7));
    animation: logoFloat 5s ease-in-out infinite alternate;
}
@keyframes logoFloat {
    from { transform: translateY(0); }
    to { transform: translateY(-7px); }
}
.game-logo h1 {
    font-family: var(--font-sci);
    font-weight: 900;
    font-size: 3.6rem;
    letter-spacing: 8px;
    background: linear-gradient(180deg, #ffffff 25%, #a6d8ff 60%, #00e5ff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 18px rgba(0, 229, 255, 0.7));
    animation: titleGlow 4s infinite alternate;
}
.game-logo .sub-logo {
    font-family: var(--font-sci);
    font-size: 0.85rem;
    color: var(--neon-magenta);
    text-shadow: 0 0 6px var(--neon-magenta-glow);
    letter-spacing: 6px;
    margin-top: -6px;
    text-transform: uppercase;
}
.logo-destroyed {
    font-family: var(--font-sci);
    font-weight: 900;
    font-size: 2.8rem;
    letter-spacing: 4px;
    background: linear-gradient(180deg, #ffd0d0, var(--neon-magenta));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 12px var(--neon-magenta-glow));
}
@keyframes titleGlow {
    0% { filter: drop-shadow(0 0 10px rgba(0, 229, 255, 0.5)); }
    100% { filter: drop-shadow(0 0 22px rgba(0, 229, 255, 0.9)) drop-shadow(0 0 30px rgba(255, 45, 126, 0.4)); }
}

/* ---- Buttons ----------------------------------------------------- */
.btn-sci {
    background: var(--glass-bg);
    border: 1px solid var(--neon-cyan);
    color: var(--text-primary);
    font-family: var(--font-sci);
    font-size: 1.1rem;
    font-weight: 700;
    padding: 14px 40px;
    margin: 8px 0;
    border-radius: 10px;
    cursor: pointer;
    width: 260px;
    max-width: 80vw;
    letter-spacing: 2px;
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
    transition: all 0.25s;
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.12);
}
.btn-sci::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.12), transparent);
    transition: 0.5s;
}
.btn-sci:hover {
    background: rgba(0, 229, 255, 0.15);
    box-shadow: 0 0 22px var(--neon-cyan-glow), inset 0 0 10px var(--neon-cyan-glow);
    border-color: #ffffff;
}
.btn-sci:hover::before { left: 100%; }
.btn-sci.secondary { border-color: var(--neon-magenta); }
.btn-sci.secondary:hover {
    background: rgba(255, 45, 126, 0.15);
    box-shadow: 0 0 22px var(--neon-magenta-glow), inset 0 0 10px var(--neon-magenta-glow);
}
.btn-sci.ghost {
    border-color: rgba(150, 170, 220, 0.3);
    background: rgba(20, 24, 44, 0.4);
    font-size: 0.95rem;
    color: var(--text-secondary);
}
.btn-sci.ghost:hover { color: #fff; border-color: var(--neon-cyan); box-shadow: 0 0 12px var(--neon-cyan-glow); }
.btn-sci.small { padding: 9px 30px; font-size: 0.8rem; width: 200px; }

/* ---- Login / Register ------------------------------------------- */
.auth-tabs {
    display: flex;
    gap: 8px;
    width: 280px;
    max-width: 82vw;
    margin-bottom: 22px;
}
.auth-tab {
    flex: 1;
    text-align: center;
    padding: 10px;
    font-family: var(--font-sci);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    cursor: pointer;
    transition: all 0.2s;
}
.auth-tab.active {
    color: var(--neon-cyan);
    border-color: var(--neon-cyan);
    background: rgba(0, 229, 255, 0.08);
    box-shadow: inset 0 0 10px rgba(0, 229, 255, 0.2);
}
.auth-form {
    display: flex;
    flex-direction: column;
    width: 280px;
    max-width: 82vw;
}
.auth-label {
    font-family: var(--font-sci);
    font-size: 0.72rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin: 12px 0 6px;
}
.auth-input {
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(150, 170, 220, 0.25);
    padding: 13px 16px;
    color: #fff;
    border-radius: 10px;
    font-family: var(--font-body);
    font-size: 1rem;
    outline: none;
    transition: all 0.2s;
}
.auth-input:focus {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 10px var(--neon-cyan-glow);
}
.pin-input {
    letter-spacing: 12px;
    text-align: center;
    font-family: var(--font-sci);
    font-size: 1.4rem;
}
.auth-error {
    color: var(--neon-magenta);
    font-size: 0.82rem;
    min-height: 20px;
    margin: 12px 0 4px;
    text-align: center;
    text-shadow: 0 0 6px var(--neon-magenta-glow);
}
.auth-form .btn-sci { width: 100%; margin-top: 6px; }
.auth-hint {
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 14px;
    line-height: 1.4;
}

/* ---- Menu -------------------------------------------------------- */
.menu-pilot {
    font-family: var(--font-sci);
    font-size: 0.9rem;
    margin-bottom: 26px;
    color: var(--neon-cyan);
    text-shadow: 0 0 6px var(--neon-cyan-glow);
}
.crystal-balance {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-sci);
    font-size: 1.05rem;
    color: var(--neon-cyan);
    margin-bottom: 12px;
    text-shadow: 0 0 5px var(--neon-cyan-glow);
}
.crystal-icon {
    width: 16px;
    height: 16px;
    background: #00e5ff;
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    box-shadow: 0 0 8px var(--neon-cyan);
    display: inline-block;
}

/* ---- Shop -------------------------------------------------------- */
.shop-panel { width: 100%; height: 100%; display: flex; flex-direction: column; }
.shop-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 14px;
    margin-bottom: 14px;
}
.shop-title {
    font-family: var(--font-sci);
    color: var(--neon-cyan);
    font-size: 1.4rem;
    text-shadow: 0 0 10px var(--neon-cyan-glow);
    text-transform: uppercase;
}
.shop-tabs { display: flex; gap: 10px; margin-bottom: 14px; }
.shop-tab {
    flex: 1;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-sci);
    font-size: 0.85rem;
    font-weight: 700;
    text-align: center;
    transition: all 0.2s;
}
.shop-tab.active {
    background: rgba(0, 229, 255, 0.1);
    border-color: var(--neon-cyan);
    color: var(--neon-cyan);
    box-shadow: inset 0 0 8px rgba(0, 229, 255, 0.2);
}
.shop-items-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 4px;
    margin-bottom: 14px;
}
.shop-item-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.shop-item-card.equipped { border-color: rgba(0, 229, 255, 0.4); background: rgba(0, 229, 255, 0.03); }
.shop-item-info { flex: 1; }
.shop-item-name {
    font-family: var(--font-sci);
    font-size: 0.98rem;
    font-weight: 700;
    margin-bottom: 3px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.lvl-tag { font-size: 0.75rem; color: var(--text-secondary); font-family: var(--font-body); }
.skin-preview-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.shop-item-desc { font-size: 0.78rem; color: var(--text-secondary); }
.upgrade-pips { display: flex; gap: 4px; margin-top: 6px; }
.upgrade-pip { width: 14px; height: 6px; background: rgba(255, 255, 255, 0.12); border-radius: 2px; }
.upgrade-pip.filled { background: var(--neon-cyan); box-shadow: 0 0 6px var(--neon-cyan-glow); }
.btn-buy {
    background: var(--glass-bg);
    border: 1px solid var(--neon-cyan);
    color: var(--text-primary);
    font-family: var(--font-sci);
    font-size: 0.82rem;
    font-weight: 700;
    padding: 9px 14px;
    border-radius: 8px;
    cursor: pointer;
    min-width: 88px;
    text-align: center;
    transition: all 0.2s;
}
.btn-buy:hover:not(:disabled) { background: var(--neon-cyan); color: #000; box-shadow: 0 0 10px var(--neon-cyan-glow); }
.btn-buy:disabled { border-color: rgba(255, 255, 255, 0.12); color: var(--text-secondary); cursor: not-allowed; opacity: 0.7; }
.btn-buy.equipped-btn { border-color: var(--neon-magenta); color: var(--neon-magenta); }
.btn-close-shop { width: 100%; }

/* ---- Leaderboard ------------------------------------------------- */
.leaderboard-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    max-height: 55vh;
    margin-bottom: 18px;
    padding-right: 4px;
}
.leaderboard-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    font-family: var(--font-sci);
    font-size: 0.88rem;
}
.leaderboard-item.top-1 { background: rgba(255, 176, 32, 0.06); border-color: rgba(255, 176, 32, 0.35); }
.leaderboard-item.top-1 .rank-num { color: var(--neon-gold); }
.leaderboard-item.top-2 { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.2); }
.leaderboard-item.top-3 { background: rgba(0, 229, 255, 0.05); border-color: rgba(0, 229, 255, 0.2); }
.leaderboard-item.self { border-color: var(--neon-cyan); background: rgba(0, 229, 255, 0.08); }
.rank-num { font-weight: 900; width: 34px; color: var(--text-secondary); }
.player-name { flex: 1; margin-left: 8px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-score { font-weight: 700; color: var(--neon-cyan); }
.lb-empty { text-align: center; color: var(--text-secondary); padding: 40px 0; }
.rank-summary { font-family: var(--font-sci); font-size: 0.85rem; color: var(--neon-cyan); margin-bottom: 18px; text-align: center; }

/* ---- HUD --------------------------------------------------------- */
.hud-overlay.hidden { display: none; }
.hud-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
    padding: 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.hud-top { display: flex; justify-content: space-between; width: 100%; }
.hud-powerups { display: flex; flex-direction: column; gap: 8px; }
.hud-powerup-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.6);
    border-left: 3px solid var(--neon-cyan);
    padding: 4px 10px;
    border-radius: 0 6px 6px 0;
    font-family: var(--font-sci);
    font-size: 0.72rem;
    color: #fff;
    animation: slideInHUD 0.2s forwards;
}
.hud-powerup-item.shield { border-color: #3dffa8; }
.hud-powerup-item.speedboost { border-color: var(--neon-gold); }
@keyframes slideInHUD {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
.hud-distance-container {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    font-family: var(--font-sci);
}
.hud-distance {
    font-size: 1.9rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 12px rgba(0, 229, 255, 0.6);
}
.hud-best { font-size: 0.72rem; color: var(--text-secondary); margin-top: 4px; }
.hud-goal-label { font-size: 0.58rem; letter-spacing: 1px; color: var(--text-secondary); text-transform: uppercase; margin-top: 1px; }
.hud-progress {
    width: 150px; max-width: 42vw; height: 5px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px; margin: 5px auto 0; overflow: hidden;
}
.hud-progress-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--neon-cyan), #ffffff);
    box-shadow: 0 0 8px var(--neon-cyan-glow);
    transition: width 0.2s linear;
}
.hud-points {
    font-family: var(--font-sci); font-size: 1.2rem; font-weight: 700;
    color: var(--neon-gold); text-shadow: 0 0 8px var(--neon-gold-glow);
    margin-top: 5px;
}
.hud-points.bump { animation: ptsBump 0.3s ease-out; }
@keyframes ptsBump {
    30% { transform: scale(1.22); color: #fff; }
    100% { transform: scale(1); }
}
.logo-win {
    font-family: var(--font-sci); font-weight: 900;
    font-size: 2rem; letter-spacing: 2px;
    background: linear-gradient(180deg, #ffffff, var(--neon-cyan));
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 14px var(--neon-cyan-glow));
}
.win-medal {
    font-family: var(--font-sci); font-weight: 700;
    font-size: 1.2rem; letter-spacing: 2px; margin-bottom: 14px;
    text-shadow: 0 0 10px currentColor;
}
.hud-crystals {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(0, 229, 255, 0.25);
    padding: 6px 12px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-sci);
    font-size: 0.9rem;
    color: #fff;
    height: 32px;
}
/* Toasts sit in a slim strip right below the HUD header — small and quick,
   so they never cover the flight path in the screen center. */
.hud-alerts {
    position: absolute;
    top: 12.5%;
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    pointer-events: none;
}
.hud-alert-msg {
    font-family: var(--font-sci);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 3px 12px;
    border-radius: 5px;
    color: #fff;
    animation: alertPulse 1s forwards;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid transparent;
}
.hud-alert-msg.near-miss { color: #ffea00; border-color: rgba(255, 234, 0, 0.4); box-shadow: 0 0 10px rgba(255, 234, 0, 0.2); }
.hud-alert-msg.magnet { color: var(--neon-cyan); border-color: var(--neon-cyan); }
.hud-alert-msg.speedboost, .hud-alert-msg.boost { color: var(--neon-gold); border-color: rgba(255, 176, 32, 0.4); box-shadow: 0 0 10px var(--neon-gold-glow); }
.hud-alert-msg.shield, .hud-alert-msg.shield-break { color: #3dffa8; border-color: rgba(61, 255, 168, 0.4); box-shadow: 0 0 10px rgba(61, 255, 168, 0.25); }
.hud-alert-msg.overheat { color: #ff4b3a; border-color: rgba(255, 75, 58, 0.5); box-shadow: 0 0 12px rgba(255, 75, 58, 0.3); }
.hud-alert-msg.warning { color: #ff9a30; border-color: rgba(255, 154, 48, 0.5); box-shadow: 0 0 12px rgba(255, 154, 48, 0.3); }
@keyframes alertPulse {
    0% { transform: scale(0.9) translateY(8px); opacity: 0; }
    15% { transform: scale(1.03) translateY(0); opacity: 0.95; }
    85% { transform: scale(1) translateY(0); opacity: 0.95; }
    100% { transform: scale(0.96) translateY(-8px); opacity: 0; }
}

/* Directional side-comet warning: red glow pulsing on the incoming edge */
.side-flash {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 24%;
    opacity: 0;
    pointer-events: none;
    z-index: 14;
}
.side-flash.left { left: 0; background: linear-gradient(90deg, rgba(255, 80, 30, 0.45), transparent); }
.side-flash.right { right: 0; background: linear-gradient(-90deg, rgba(255, 80, 30, 0.45), transparent); }
.side-flash.on { animation: sideFlash 0.9s ease-out 2; }
@keyframes sideFlash {
    0% { opacity: 0; }
    25% { opacity: 1; }
    100% { opacity: 0; }
}
.hud-bottom-mobile {
    display: none;
    width: 100%;
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-shadow: 0 1px 2px #000;
    margin-bottom: 10px;
}
.mobile-fire-btn { display: none; }
.joystick { display: none; }

/* ---- View toggle button ------------------------------------------ */
.hud-view-btn {
    position: absolute;
    top: 64px;
    right: 18px;
    padding: 6px 12px;
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(0, 229, 255, 0.35);
    font-family: var(--font-sci);
    font-size: 0.62rem;
    letter-spacing: 1px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    pointer-events: auto;
    user-select: none;
    transition: background 0.15s, border-color 0.15s;
}
.hud-view-btn:hover {
    background: rgba(0, 229, 255, 0.18);
    border-color: var(--neon-cyan);
}
.hud-view-btn .ico {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke: var(--neon-cyan);
    fill: none;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 0 3px rgba(0, 229, 255, 0.5));
}

/* ---- Shop: live skin preview -------------------------------------- */
.skin-preview-wrap {
    position: relative;
    height: 168px;
    flex-shrink: 0;
    margin-bottom: 12px;
    border-radius: 12px;
    border: 1px solid rgba(0, 229, 255, 0.22);
    background: radial-gradient(ellipse at 50% 42%, rgba(30, 50, 90, 0.5), rgba(3, 6, 14, 0.92));
    overflow: hidden;
}
.skin-preview-wrap.hidden { display: none; }
#skin-preview-canvas { width: 100%; height: 100%; display: block; }
.skin-preview-label {
    position: absolute;
    bottom: 8px;
    width: 100%;
    text-align: center;
    font-family: var(--font-sci);
    font-size: 0.68rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-secondary);
    pointer-events: none;
    text-shadow: 0 1px 3px #000;
}

/* ---- Stored powerup buttons (tap to activate) --------------------- */
.hud-item-btn {
    position: absolute;
    right: 24px;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: rgba(0, 0, 0, 0.55);
    border: 2px solid rgba(255, 255, 255, 0.25);
    cursor: pointer;
    pointer-events: auto;
    user-select: none;
    z-index: 25;
    animation: itemPop 0.25s ease-out;
}
.hud-item-btn.hidden { display: none; }
#btn-item-shield {
    bottom: 92px;
    border-color: rgba(61, 255, 168, 0.75);
    box-shadow: 0 0 14px rgba(61, 255, 168, 0.4);
}
#btn-item-boost {
    bottom: 24px;
    border-color: rgba(255, 176, 32, 0.75);
    box-shadow: 0 0 14px rgba(255, 176, 32, 0.4);
}
@keyframes itemPop {
    from { transform: scale(0.3); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ---- Admin test mode toggles -------------------------------------- */
.hud-admin {
    position: absolute;
    left: 16px;
    top: 42%;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 25;
}
.hud-admin.hidden { display: none; }
.admin-label {
    font-family: var(--font-sci);
    font-size: 0.55rem;
    letter-spacing: 2px;
    color: #ff4b3a;
    text-shadow: 0 1px 2px #000;
}
.admin-toggle {
    padding: 7px 12px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 75, 58, 0.45);
    font-family: var(--font-sci);
    font-size: 0.62rem;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    pointer-events: auto;
    user-select: none;
}
.admin-toggle.on {
    color: #fff;
    background: rgba(255, 75, 58, 0.3);
    border-color: #ff4b3a;
    box-shadow: 0 0 12px rgba(255, 75, 58, 0.4);
}

/* ---- Boss health bar (projected above the enemy ship) ------------- */
.boss-bar {
    position: absolute;
    transform: translate(-50%, -100%);
    width: min(240px, 55vw);
    pointer-events: none;
    z-index: 18;
    text-align: center;
}
.boss-bar.hidden { display: none; }
.boss-bar-label {
    font-family: var(--font-sci);
    font-size: 0.62rem;
    letter-spacing: 2.5px;
    color: #ff4b3a;
    text-shadow: 0 1px 3px #000;
    margin-bottom: 4px;
}
.boss-bar-track {
    height: 9px;
    background: rgba(0, 0, 0, 0.65);
    border: 1px solid rgba(255, 75, 58, 0.6);
    border-radius: 5px;
    overflow: hidden;
}
.boss-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #ff4b3a, #ff8a3a);
    box-shadow: 0 0 10px rgba(255, 75, 58, 0.5);
    transition: width 0.15s linear;
}

/* ---- Weapon heat gauge ------------------------------------------- */
.hud-weapon {
    position: absolute;
    left: 16px;
    bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-family: var(--font-sci);
    font-size: 0.6rem;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.75);
    text-shadow: 0 1px 2px #000;
    pointer-events: none;
}
.hud-heat {
    width: 130px;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 4px;
    overflow: hidden;
}
.hud-heat-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #3dffa8, #ffb020 60%, #ff4b3a);
    transition: width 0.08s linear;
}
.hud-weapon.overheat .hud-weapon-label { color: #ff4b3a; }
.hud-weapon.overheat .hud-heat-fill {
    background: #ff4b3a;
    animation: heatBlink 0.5s steps(2, start) infinite;
}
@keyframes heatBlink { 50% { opacity: 0.35; } }

/* ---- Game Over --------------------------------------------------- */
.gameover-stats {
    width: 100%;
    max-width: 320px;
    margin: 22px 0;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.stat-row { display: flex; justify-content: space-between; font-size: 1rem; color: var(--text-secondary); }
.stat-row.highlight { color: #fff; font-weight: 700; }
.stat-row.record-alert {
    color: var(--neon-gold);
    font-family: var(--font-sci);
    font-size: 0.9rem;
    justify-content: center;
    text-shadow: 0 0 6px var(--neon-gold-glow);
    animation: flashText 1s infinite alternate;
}
.stat-row.hidden { display: none; }
@keyframes flashText { 0% { opacity: 0.4; } 100% { opacity: 1; } }

/* ---- Landscape lock (mobile) ------------------------------------ */
.landscape-lock-screen {
    position: fixed;
    inset: 0;
    background: #04050c;
    z-index: 100;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
}
.lock-phone-icon {
    width: 60px;
    height: 100px;
    border: 4px solid var(--neon-cyan);
    border-radius: 10px;
    margin-bottom: 30px;
    position: relative;
    animation: rotatePhone 2.5s infinite ease-in-out;
}
.lock-phone-icon::after {
    content: '';
    position: absolute;
    bottom: 5px; left: 50%;
    transform: translateX(-50%);
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--neon-cyan);
}
@keyframes rotatePhone {
    0% { transform: rotate(90deg); }
    35%, 65% { transform: rotate(0deg); }
    100% { transform: rotate(90deg); }
}
.landscape-lock-screen h3 { font-family: var(--font-sci); color: var(--neon-cyan); margin-bottom: 10px; text-shadow: 0 0 10px var(--neon-cyan-glow); }
.landscape-lock-screen p { color: var(--text-secondary); }

/* ---- Mobile: fullscreen portrait + touch fire button ------------ */
@media (max-width: 991px) {
    .device-frame {
        width: 100vw;
        height: 100vh;
        height: 100dvh; /* iOS Safari: real visible height, toolbar excluded */
        aspect-ratio: auto;
        border-radius: 0;
        border: none;
        box-shadow: none;
    }
    .hud-bottom-mobile { display: block; padding-bottom: env(safe-area-inset-bottom, 0px); }
    /* Virtual joystick: left edge, level with the FEUER button — low enough
       to keep the play area clear, thumb rests in one place */
    .joystick {
        display: block;
        position: absolute;
        left: 14px;
        bottom: calc(28px + env(safe-area-inset-bottom, 0px));
        width: 124px;
        height: 124px;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.05);
        border: 1.5px solid rgba(0, 229, 255, 0.35);
        box-shadow: inset 0 0 18px rgba(0, 229, 255, 0.08);
        pointer-events: auto;
        touch-action: none;
        z-index: 25;
    }
    .joystick-knob {
        position: absolute;
        left: 50%;
        top: 50%;
        width: 54px;
        height: 54px;
        margin: -27px 0 0 -27px;
        border-radius: 50%;
        background: radial-gradient(circle at 35% 30%, rgba(0, 229, 255, 0.55), rgba(0, 90, 120, 0.75));
        border: 1px solid rgba(0, 229, 255, 0.7);
        box-shadow: 0 0 14px rgba(0, 229, 255, 0.35);
        will-change: transform;
    }
    /* Admin panel out of the joystick's way on mobile */
    .hud-admin { top: 20%; }
    /* Mobile: the heat gauge lives ON the FEUER button (ring + countdown) */
    .hud-weapon { display: none; }
    /* View toggle: compact circle top-right BELOW the crystal counter —
       deliberately away from the fire/boost/shield action column so it can
       never be mis-tapped in combat (every function gets its own spot). */
    .hud-view-btn {
        top: calc(60px + env(safe-area-inset-top, 0px));
        right: 14px;
        left: auto;
        bottom: auto;
        width: 54px;
        height: 54px;
        padding: 0;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.3rem;
    }
    .hud-view-btn .txt { display: none; }
    .hud-view-btn .ico { width: 24px; height: 24px; }
    /* Stored powerups stack right above the FEUER button (right thumb) */
    #btn-item-boost { bottom: calc(146px + env(safe-area-inset-bottom, 0px)); right: 49px; }
    #btn-item-shield { bottom: calc(214px + env(safe-area-inset-bottom, 0px)); right: 49px; }
    /* Heat ring: fills clockwise with weapon heat, green→red via --heat-col;
       on overheat the button blinks red and shows the cooldown countdown */
    .mobile-fire-btn::after {
        content: "";
        position: absolute;
        inset: -8px;
        border-radius: 50%;
        background: conic-gradient(var(--heat-col, #3dffa8) calc(var(--heat, 0) * 360deg), rgba(255, 255, 255, 0.08) 0);
        -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5px));
        mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5px));
        pointer-events: none;
    }
    .mobile-fire-btn.overheat {
        background: rgba(255, 75, 58, 0.35);
        border-color: #ff4b3a;
        box-shadow: 0 0 18px rgba(255, 75, 58, 0.5);
        animation: heatBlink 0.5s steps(2, start) infinite;
    }
    .mobile-fire-btn {
        display: flex;
        position: absolute;
        bottom: calc(46px + env(safe-area-inset-bottom, 0px));
        right: 34px;
        width: 84px;
        height: 84px;
        border-radius: 50%;
        background: rgba(255, 45, 126, 0.25);
        border: 2px solid var(--neon-magenta);
        box-shadow: 0 0 15px var(--neon-magenta-glow);
        z-index: 25;
        align-items: center;
        justify-content: center;
        font-family: var(--font-sci);
        font-weight: bold;
        font-size: 0.9rem;
        color: #fff;
        text-shadow: 0 0 5px var(--neon-magenta-glow);
        pointer-events: auto;
        animation: pulseFireBtn 2s infinite alternate;
    }
}
@keyframes pulseFireBtn {
    0% { transform: scale(1); box-shadow: 0 0 15px var(--neon-magenta-glow); }
    100% { transform: scale(1.08); box-shadow: 0 0 25px var(--neon-magenta-glow), inset 0 0 10px var(--neon-magenta-glow); }
}
