* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    outline: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}
html, body {
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    position: fixed;
    margin: 0; padding: 0;
    width: 100%; height: 100%;
    overflow: hidden;
    background: #05070d;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
#game { display: block; width: 100%; height: 100%; }

.hud-panel {
    position: fixed; top: 16px; right: 24px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 10; pointer-events: none;
    align-items: flex-end;
}
.hud-row {
    display: flex; align-items: center; gap: 10px;
    background: rgba(5,10,15,0.5);
    border: 1px solid rgba(107,255,184,0.2);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 11px; letter-spacing: 2px; text-transform: uppercase;
    color: rgba(107,255,184,0.75);
    backdrop-filter: blur(4px);
    min-width: 210px;
}
.hud-row b { color: #b6ffe0; font-weight: 600; margin-left: auto; }

/* Строка соперника — светло-белая */
.hud-row.opponent {
    border-color: rgba(232,238,242,0.45);
    color: rgba(232,238,242,0.9);
}
.hud-row.opponent b { color: #ffffff; }
.hud-row.opponent.local-mode {
    display: none !important;
}    

.zoom-row {
    display: flex; align-items: center; gap: 10px;
    background: rgba(5,10,15,0.5);
    border: 1px solid rgba(107,255,184,0.2);
    border-radius: 8px;
    padding: 6px 12px;
    backdrop-filter: blur(4px);
    min-width: 210px;
    pointer-events: auto;
}
.zoom-row input[type=range] {
    -webkit-appearance: none; appearance: none;
    flex: 1 1 auto; min-width: 0;
    height: 4px;
    background: rgba(107,255,184,0.2); border-radius: 4px; outline: none;
    margin: 0;
}
.zoom-row input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; width: 14px; height: 14px;
    background: #6bffb8; border-radius: 50%;
    box-shadow: 0 0 10px #6bffb8, 0 0 20px rgba(107,255,184,0.5);
    cursor: pointer;
}
.zoom-row input[type=range]::-moz-range-thumb {
    width: 14px; height: 14px; background: #6bffb8; border-radius: 50%;
    border: none; box-shadow: 0 0 10px #6bffb8, 0 0 20px rgba(107,255,184,0.5);
    cursor: pointer;
}

.time-btn {
    cursor: pointer;
    padding: 4px 8px;
    font-size: 10px; letter-spacing: 1px; text-transform: uppercase;
    color: #6bffb8;
    border: 1px solid rgba(107,255,184,0.3);
    border-radius: 6px;
    background: rgba(5,10,15,0.35);
    backdrop-filter: blur(4px);
    white-space: nowrap;
    flex: 0 0 auto;
}
.time-btn:hover { background: rgba(107,255,184,0.12); }

.ping-label {
    flex: 1 1 auto;
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(107,255,184,0.75);
    white-space: nowrap;
}
.ping-label b {
    color: #b6ffe0;
    font-weight: 600;
}

.timer-panel {
    position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
    z-index: 10; pointer-events: none;
    display: flex; gap: 10px; align-items: center;
}
.timer-panel .time {
    background: rgba(5,10,15,0.6);
    border: 1px solid rgba(107,255,184,0.3);
    border-radius: 8px;
    padding: 8px 18px;
    font-size: 18px; letter-spacing: 3px;
    color: #b6ffe0;
    text-shadow: 0 0 12px rgba(107,255,184,0.6);
    font-variant-numeric: tabular-nums;
    backdrop-filter: blur(4px);
}
.timer-panel .time.low {
    color: #ff8a5a;
    border-color: rgba(255,138,90,0.5);
    text-shadow: 0 0 12px rgba(255,138,90,0.7);
}
.timer-panel .home-btn-narrow {
    display: none;
    cursor: pointer;
    pointer-events: auto;
    background: rgba(5,10,15,0.6);
    border: 1px solid rgba(107,255,184,0.3);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 9px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #6bffb8;
    text-align: center;
    backdrop-filter: blur(4px);
}    

#loading { display: none; }

#error {
    position: fixed; inset: 0; display: none;
    align-items: center; justify-content: center;
    background: #1a0505; color: #ff8080;
    font-family: monospace; font-size: 13px;
    padding: 40px; white-space: pre-wrap; z-index: 200;
}

/* Стартовое меню */
#startMenu {
    position: fixed; inset: 0;
    background: #05070d;
    z-index: 400; color: #b6ffe0;
    text-align: center;
    overflow: hidden;
}
#startMenu.hide { display: none; }

.splash-stage {
    position: absolute; inset: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 26px;
}

/* ---------- ПИКО ---------- */
.piko {
    width: 64px; height: 64px; position: relative;
    transform: translateX(-160vw);
    animation: runIn 1.1s .1s cubic-bezier(.2,.8,.2,1) forwards;
}
@keyframes runIn {
    to { transform: translateX(0); }
}
.piko .b, .piko .h, .piko .e1, .piko .e2, .piko .f1, .piko .f2 {
    position: absolute; background: #6bffb8; border-radius: 4px;
    box-shadow: 0 0 8px rgba(107,255,184,.5);
}
.piko .b  { left: 8px;  top: 26px; width: 48px; height: 24px; }
.piko .h  { left: 6px;  top: 6px;  width: 52px; height: 22px; background: #a0ffd0; }
.piko .e1 { left: 16px; top: 12px; width: 8px;  height: 8px;  background: #0a1a12; box-shadow: none; border-radius: 2px; }
.piko .e2 { left: 40px; top: 12px; width: 8px;  height: 8px;  background: #0a1a12; box-shadow: none; border-radius: 2px; }
.piko .f1 { left: 12px; top: 50px; width: 14px; height: 8px; animation: leg .25s infinite alternate; }
.piko .f2 { left: 38px; top: 50px; width: 14px; height: 8px; animation: leg .25s infinite alternate-reverse; }
@keyframes leg {
    from { transform: translateY(0); }
    to   { transform: translateY(-4px); }
}

/* ---------- ЛОГОТИП ---------- */
.logo {
    display: flex; gap: 6px;
    font-size: 44px; font-weight: 800;
    letter-spacing: 6px; color: #6bffb8;
    animation: stabilize 1.2s 2.30s ease-out forwards;
}
.logo span {
    display: inline-block;
    opacity: 0;
    transform: translateY(-14px);
    animation: drop .45s cubic-bezier(.2,.9,.3,1.4) forwards;
}
@keyframes drop {
    to { opacity: 1; transform: translateY(0); }
}
.logo span:nth-child(1) { animation-delay: 1.15s; }
.logo span:nth-child(2) { animation-delay: 1.25s; }
.logo span:nth-child(3) { animation-delay: 1.35s; }
.logo span:nth-child(4) { animation-delay: 1.45s; }
.logo span:nth-child(5) { animation-delay: 1.55s; }
.logo span:nth-child(6) { animation-delay: 1.65s; }
.logo span:nth-child(7) { animation-delay: 1.75s; }

/* PIKO — зелёный */
.logo span:nth-child(1),
.logo span:nth-child(2),
.logo span:nth-child(3),
.logo span:nth-child(4) {
    color: #6bffb8;
}
/* RUN — оранжевый с обводкой */
.logo span:nth-child(5),
.logo span:nth-child(6),
.logo span:nth-child(7) {
    color: #ff9f4a;
    -webkit-text-stroke: 1px rgba(255,159,74,.5);
}

/* ---------- ДВУХЦВЕТНАЯ ТОЧКА-РАЗДЕЛИТЕЛЬ ---------- */
.logo span:nth-child(4)::after {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-left: 8px;
    margin-right: 4px;
    border-radius: 50%;

    /* резкая граница по центру: левая половина оранжевая, правая зелёная */
    background: linear-gradient(90deg,
        #ff9f4a 0%,
        #ff9f4a 50%,
        #6bffb8 50%,
        #6bffb8 100%);

    box-shadow:
        0 0 10px rgba(255,159,74,.7),
        0 0 10px rgba(107,255,184,.7);

    /* появление в момент остановки */
    opacity: 0;
    transform: scale(.4);
    animation: dotIn .5s 2.30s cubic-bezier(.2,.9,.3,1.4) forwards;
}

@keyframes dotIn {
    to { opacity: 1; transform: scale(1); }
}

@keyframes stabilize {
    0% {
        text-shadow: 3px 0 #ff4a6b, -3px 0 #4a9cff, 0 0 22px rgba(107,255,184,.7);
        transform: translateX(2px);
    }
    30% {
        text-shadow: -3px 0 #ff4a6b, 3px 0 #4a9cff, 0 0 22px rgba(107,255,184,.7);
        transform: translateX(-2px);
    }
    60% {
        text-shadow: 2px 0 #ff4a6b, -2px 0 #4a9cff, 0 0 22px rgba(107,255,184,.7);
        transform: translateX(1px);
    }
    100% {
        text-shadow: 0 0 22px rgba(107,255,184,.7);
        transform: translateX(0);
    }
}

/* ---------- МЕНЮ КНОПОК ---------- */
.splash-menu {
    display: flex; flex-direction: column;
    gap: 14px; align-items: center;
    margin-top: 18px;
    opacity: 0;
    transform: translateY(14px);
    animation: menuIn .6s 2.80s cubic-bezier(.2,.9,.3,1.2) forwards;
}
@keyframes menuIn {
    to { opacity: 1; transform: translateY(0); }
}
.menu-btn {
    padding: 14px 40px;
    min-width: 260px;
    font-size: 13px; letter-spacing: 4px; text-transform: uppercase;
    color: #05070d;
    background: #6bffb8;
    border: none; border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 0 20px rgba(107,255,184,0.5);
    font-weight: 600;
}
.menu-btn:hover { background: #b6ffe0; }
.menu-btn.secondary {
    background: transparent;
    color: #6bffb8;
    border: 1px solid rgba(107,255,184,0.5);
    box-shadow: none;
}
.menu-btn.secondary:hover { background: rgba(107,255,184,0.12); }

/* Заставка ожидания */
#waitOverlay {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    flex-direction: column; gap: 18px;
    background: #05070d;
    z-index: 300; color: #b6ffe0;
    text-align: center;
    transition: opacity 0.4s;
}
#waitOverlay.hide { opacity: 0; pointer-events: none; }
#waitOverlay h1 {
    font-size: 18px; letter-spacing: 8px; text-transform: uppercase;
    margin: 0; text-shadow: 0 0 22px rgba(107,255,184,0.7);
    font-weight: 600;
}
#waitOverlay p {
    font-size: 11px; letter-spacing: 5px;
    color: rgba(107,255,184,0.55); margin: 0; text-transform: uppercase;
}
.spinner {
    width: 46px; height: 46px;
    border: 2px solid rgba(107,255,184,0.18);
    border-top-color: #6bffb8;
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    box-shadow: 0 0 18px rgba(107,255,184,0.25);
}
@keyframes spin { to { transform: rotate(360deg); } }

#minimap {
    position: fixed;
    top: 16px;
    left: 16px;
    width: 160px;
    height: 160px;
    border: 1px solid rgba(107,255,184,0.3);
    border-radius: 10px;
    background: rgba(5,10,15,0.6);
    backdrop-filter: blur(4px);
    z-index: 10;
    box-shadow: 0 0 16px rgba(0,0,0,0.4);
    overflow: hidden;
}
#minimap canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}
.hud-panel,
.timer-panel,
#minimap {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0s 0.3s;
}
.hud-panel.visible,
.timer-panel.visible,
#minimap.visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s, visibility 0s 0s;
}       
.game-over {
    position: fixed; inset: 0;
    display: none; align-items: center; justify-content: center;
    flex-direction: column; gap: 20px;
    background: rgba(5,7,13,0.92);
    z-index: 150; color: #b6ffe0;
    text-align: center;
}
.game-over.show { display: flex; }
.game-over h1 {
    font-size: 28px; letter-spacing: 8px; text-transform: uppercase;
    margin: 0; text-shadow: 0 0 20px rgba(107,255,184,0.8);
}
.game-over p {
    font-size: 14px; letter-spacing: 4px;
    color: rgba(107,255,184,0.7); margin: 0;
}
.game-over button {
    margin-top: 10px;
    padding: 12px 32px;
    font-size: 13px; letter-spacing: 4px; text-transform: uppercase;
    color: #05070d;
    background: #6bffb8;
    border: none; border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 0 20px rgba(107,255,184,0.5);
}
.game-over button:hover { background: #b6ffe0; }

.game-over .home-btn {
    margin-top: 0;
    background: transparent;
    color: #6bffb8;
    border: 1px solid rgba(107,255,184,0.5);
    box-shadow: none;
}
.game-over .home-btn:hover {
    background: rgba(107,255,184,0.12);
}

.mobile-controls { display: none; }
body.mobile .mobile-controls { display: block; }

.dpad {
    position: fixed;
    right: 20px;
    bottom: calc(20px + 2vh);
    width: 220px;
    height: 80px;
    border-radius: 40px;
    background: rgba(5, 10, 15, 0.45);
    border: 1.5px solid rgba(107, 255, 184, 0.4);
    box-shadow:
        inset 0 0 14px rgba(107, 255, 184, 0.05),
        inset 0 1px 4px rgba(0, 0, 0, 0.5),
        0 0 14px rgba(107, 255, 184, 0.1);
    backdrop-filter: blur(8px);
    z-index: 20;
    touch-action: none;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 70px;
    padding: 0 5px;
}
.dpad::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    height: 2px;
    border-radius: 2px;
    background: linear-gradient(
        90deg,
        rgba(107, 255, 184, 0.05),
        rgba(107, 255, 184, 0.5),
        rgba(107, 255, 184, 0.05)
    );
    pointer-events: none;
    z-index: 1;
}
.dpad::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(107, 255, 184, 0.8);
    box-shadow: 0 0 8px rgba(107, 255, 184, 0.9);
    pointer-events: none;
    z-index: 1;
}
.dbtn {
    position: relative;
    display: flex; align-items: center; justify-content: center;
    color: #b6ffe0;
    line-height: 1;
    user-select: none;
    touch-action: none;
    cursor: pointer;
    background: rgba(5, 10, 15, 0.5);
    border: 1.5px solid rgba(107, 255, 184, 0.55);
    border-radius: 50%;
    box-shadow: 0 0 14px rgba(107, 255, 184, 0.2);
    transition: background 0.25s ease, box-shadow 0.25s ease, transform 0.05s;
    z-index: 2;
}
.dbtn:active,
.dbtn.pressed {
    background: rgba(107, 255, 184, 0.45) !important;
    box-shadow: 0 0 24px rgba(107, 255, 184, 0.5);
    transform: scale(0.95);
}

.dbtn.sticky-on {
    background: rgba(107, 255, 184, 0.22) !important;
    box-shadow:
        inset 0 0 12px rgba(107, 255, 184, 0.75),
        inset 0 0 22px rgba(107, 255, 184, 0.35),
        0 0 14px rgba(107, 255, 184, 0.35);
    color: #e8fff4;
}
.dbtn.sticky-on.sticky-running {
    background: rgba(107, 255, 184, 0.42) !important;
    box-shadow:
        inset 0 0 18px rgba(107, 255, 184, 1),
        inset 0 0 32px rgba(107, 255, 184, 0.6),
        0 0 26px rgba(107, 255, 184, 0.7);
    color: #ffffff;
}
.dpad .dbtn.left  { width: 70px; height: 70px; margin-left: 0;  font-size: 28px; border-radius: 50% 33% 33% 50%; }
.dpad .dbtn.right { width: 70px; height: 70px; margin-right: 0; font-size: 28px; border-radius: 33% 50% 50% 33%; }
.dpad .dbtn.center-up {
    position: absolute;
    top: -74px;
    left: 50%;
    transform: translateX(-50%);
    width: 58px;
    height: 58px;
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-weight: 600;
    border-radius: 50%;
}
.dbtn.up,
.dbtn.down {
    width: 58px; height: 58px; font-size: 16px;
}
.dbtn.up   { border-radius: 50% 50% 30% 30%; }
.dbtn.down { border-radius: 30% 30% 50% 50%; }

.action-buttons {
    position: fixed;
    left: calc(20px + 5vw);
    bottom: calc(20px + 2vh);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    z-index: 20;
    touch-action: none;
    user-select: none;
}
.abtn {
    width: 72px; height: 72px;
    border-radius: 50%;
    background: rgba(5,10,15,0.4);
    border: 1px solid rgba(107,255,184,0.35);
    color: #b6ffe0;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
    backdrop-filter: blur(6px);
    user-select: none;
    touch-action: none;
    cursor: pointer;
    font-weight: 600;
}
.abtn:active,
.abtn.pressed {
    background: rgba(107,255,184,0.25);
}
.abtn.jump {
    width: 80px; height: 80px;
    align-self: flex-end;
}
#siteFooter {
    position: fixed;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 450;
    font-size: 10px;
    letter-spacing: 1.5px;
    color: rgba(107,255,184,0.45);
    text-align: center;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    white-space: pre;   /* сохраняем пробелы перед версией */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0s 0.3s;
}
#siteFooter.visible {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s, visibility 0s 0s;
}
html, body {
    touch-action: manipulation;
}
* {
    touch-action: manipulation;
}
#game, .dpad, .mobile-controls, .action-buttons {
    touch-action: none;
}
@media (max-width: 700px) {

    .zoom-row {
        display: none !important;
    }

    .timer-panel {
        top: 16px;
        right: 16px;
        left: auto;
        transform: none;
        flex-direction: column;
        align-items: stretch;
        gap: 3px;
        width: 90px;
        pointer-events: none;
    }

    .timer-panel .time {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 3px 4px;
        font-size: 14px;
        letter-spacing: 2px;
        text-align: center;
        line-height: 1;
        min-height: 26px;
        width: 100%;
    }

    .timer-panel .home-btn-narrow {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 3px 4px;
        font-size: 11px;
        letter-spacing: 2px;
        line-height: 1;
        min-height: 26px;
        width: 100%;
        text-align: center;
        pointer-events: auto;
    }

    .hud-panel {
        top: calc(16px + 26px + 3px + 26px + 3px);
        right: 16px;
        left: auto;
        gap: 3px;
        width: 90px;
        align-items: stretch;
        pointer-events: none;
    }

    .hud-row {
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 0;
        width: 100%;
        padding: 3px 4px;
        font-size: 11px;
        letter-spacing: 2px;
        gap: 0;
        line-height: 1;
        min-height: 26px;
        text-align: center;
    }

    .hud-row .row-label {
        display: none;
    }

    .hud-row b {
        margin-left: 0;
        font-size: 9px;
        letter-spacing: 2px;
        font-variant-numeric: tabular-nums;
        line-height: 1;
        display: inline;
    }
}