html, body {
    margin: 0;
    min-height: 100%;
    overflow: hidden;
    background: linear-gradient(180deg, #0e1627 0%, #182742 100%);
    font-family: Arial, sans-serif;
    touch-action: manipulation;
}
body {
    display: flex;
    align-items: center;
    justify-content: center;
}
#gameShell {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding:
        max(10px, env(safe-area-inset-top))
        max(10px, env(safe-area-inset-right))
        max(10px, env(safe-area-inset-bottom))
        max(10px, env(safe-area-inset-left));
}
@supports (padding: max(0px)) {
    #gameShell {
        padding-top: max(8px, env(safe-area-inset-top));
        padding-right: max(8px, env(safe-area-inset-right));
        padding-bottom: max(8px, env(safe-area-inset-bottom));
        padding-left: max(8px, env(safe-area-inset-left));
    }
}
#canvasWrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
#gameCanvas {
    background-color: #87CEEB;
    display: block;
    width: min(100%, 500px);
    height: auto;
    max-height: 100%;
    border-radius: 18px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
    touch-action: none;
}
#webcamVideo {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
    left: -9999px;
    top: -9999px;
}
#touchControls {
    position: absolute;
    inset: auto 0 14px 0;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 14px;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    pointer-events: none;
}
#touchControls.visible {
    display: flex;
}
.touchGroup {
    display: flex;
    gap: 12px;
    pointer-events: auto;
}
.touchBtn {
    appearance: none;
    border: 0;
    border-radius: 18px;
    min-width: clamp(68px, 17vw, 110px);
    min-height: clamp(52px, 10vw, 72px);
    padding: 0 clamp(14px, 3vw, 22px);
    background: rgba(10, 16, 28, 0.42);
    color: white;
    font: bold clamp(18px, 4vw, 24px) Arial, sans-serif;
    box-shadow:
        inset 0 0 0 2px rgba(255, 255, 255, 0.14),
        0 10px 24px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    pointer-events: auto;
}
.touchBtn:active,
.touchBtn.active {
    background: rgba(255, 215, 0, 0.3);
    transform: translateY(1px);
}
#jumpBtn {
    min-width: clamp(86px, 22vw, 140px);
}
@media (max-width: 700px), (pointer: coarse) {
    #gameShell {
        justify-content: center;
        padding-top: max(4px, env(safe-area-inset-top));
        padding-right: max(4px, env(safe-area-inset-right));
        padding-bottom: max(4px, env(safe-area-inset-bottom));
        padding-left: max(4px, env(safe-area-inset-left));
    }
    #gameCanvas {
        width: 100%;
        max-width: none;
    }
}
@media (min-width: 768px) and (pointer: coarse) {
    #gameShell {
        padding-top: max(12px, env(safe-area-inset-top));
        padding-right: max(12px, env(safe-area-inset-right));
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        padding-left: max(12px, env(safe-area-inset-left));
    }
    .touchBtn {
        min-width: clamp(86px, 12vw, 132px);
        min-height: clamp(60px, 8vw, 84px);
    }
    #jumpBtn {
        min-width: clamp(120px, 16vw, 168px);
    }
}
@media (max-width: 480px) {
    #touchControls {
        inset: auto 0 10px 0;
        padding: 0 8px;
        gap: 10px;
    }
    .touchGroup {
        gap: 8px;
    }
}
@media (max-height: 540px) and (orientation: landscape) {
    #touchControls {
        inset: auto 0 6px 0;
    }
    .touchBtn {
        min-width: clamp(58px, 12vw, 92px);
        min-height: 42px;
        border-radius: 14px;
        font-size: clamp(16px, 2.6vw, 20px);
    }
    #jumpBtn {
        min-width: clamp(82px, 16vw, 120px);
    }
}
