html,
body {
    width: 100%;
    height: 100%;
}

body {
    margin: 0;
    padding: 0;
    color: rgba(255, 255, 255, 0.87);
    background-color: #000000;
    overflow: hidden;
}

#app {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    height: var(--app-height, 100dvh);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    overscroll-behavior: contain;
    touch-action: manipulation;
}

#game-container {
    position: relative;
    flex: 0 0 auto;
    width: 100%;
    height: 100%;
    overflow: hidden;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

#game-container canvas {
    display: block;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

#game-overlay {
    --safe-top: max(12px, env(safe-area-inset-top));
    --safe-right: max(16px, env(safe-area-inset-right));
    position: absolute;
    inset: 0;
    z-index: 4;
    color: #e8faff;
    font-family: Arial, sans-serif;
    pointer-events: none;
}

#game-overlay[hidden] {
    display: none;
}

#game-pause[hidden] {
    display: none;
}

.game-mode-label {
    position: absolute;
    top: var(--safe-top);
    right: var(--safe-right);
    color: #ffffff;
    font-size: 16px;
    line-height: 18px;
    text-shadow: 0 1px 4px #000;
}

#game-overlay .game-pause {
    top: calc(var(--safe-top) + 28px);
    right: var(--safe-right);
    cursor: pointer;
    pointer-events: auto;
}

#mobile-controls {
    --safe-left: max(16px, env(safe-area-inset-left));
    --safe-right: max(16px, env(safe-area-inset-right));
    --safe-bottom: max(16px, env(safe-area-inset-bottom));
    position: absolute;
    inset: 0;
    z-index: 5;
    color: #e8faff;
    font-family: Arial, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
    pointer-events: none;
}

#mobile-controls[hidden] {
    display: none;
}

.mobile-play-controls {
    position: absolute;
    inset: 0;
}

.mobile-joystick,
.mobile-action,
.mobile-utility {
    position: absolute;
    box-sizing: border-box;
    touch-action: none;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    pointer-events: auto;
}

.mobile-joystick {
    left: var(--safe-left);
    bottom: var(--safe-bottom);
    width: clamp(110px, 16vmin, 124px);
    aspect-ratio: 1;
    border: 2px solid rgba(98, 222, 255, 0.55);
    border-radius: 50%;
    background: rgba(4, 33, 59, 0.26);
    box-shadow: 0 0 16px rgba(37, 187, 255, 0.18), inset 0 0 12px rgba(37, 187, 255, 0.12);
}

.mobile-thumbstick {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 42%;
    height: 42%;
    border: 2px solid rgba(142, 236, 255, 0.8);
    border-radius: 50%;
    background: rgba(14, 108, 153, 0.42);
    box-shadow: 0 0 12px rgba(67, 210, 255, 0.3);
    transform: translate(-50%, -50%);
}

.mobile-action,
.mobile-utility {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(117, 226, 255, 0.65);
    color: #effcff;
    background: rgba(4, 39, 67, 0.4);
    box-shadow: 0 0 14px rgba(42, 190, 255, 0.18);
    font: 700 16px Arial, sans-serif;
    text-shadow: 0 1px 3px #00131f;
}

.mobile-action:active,
.mobile-action.is-pressed,
.mobile-utility:active,
.mobile-utility.is-pressed {
    border-color: #a4f1ff;
    background: rgba(15, 126, 171, 0.62);
    box-shadow: 0 0 20px rgba(88, 222, 255, 0.55);
}

.mobile-fire {
    right: var(--safe-right);
    bottom: var(--safe-bottom);
    width: clamp(82px, 14vmin, 108px);
    aspect-ratio: 1;
    border-radius: 50%;
    background: rgba(8, 77, 116, 0.44);
    font-size: clamp(14px, 2.6vmin, 18px);
}

.mobile-special {
    right: calc(var(--safe-right) + 10px);
    bottom: calc(var(--safe-bottom) + clamp(94px, 17vmin, 122px));
    width: clamp(72px, 12vmin, 88px);
    aspect-ratio: 1;
    border-radius: 50%;
    background: rgba(8, 77, 116, 0.4);
    font-size: clamp(11px, 2vmin, 14px);
}

.mobile-special small {
    margin-top: 3px;
    color: #bcefff;
    font-size: clamp(8px, 1.6vmin, 11px);
}

.mobile-action:disabled {
    border-color: rgba(104, 150, 169, 0.35);
    color: rgba(220, 241, 247, 0.52);
    background: rgba(10, 23, 33, 0.28);
    box-shadow: none;
}

.mobile-action:disabled small {
    color: rgba(220, 241, 247, 0.48);
}

.mobile-action:focus-visible,
.mobile-utility:focus-visible {
    outline: 3px solid #e8faff;
    outline-offset: 3px;
}

.mobile-utility {
    top: max(12px, env(safe-area-inset-top));
    width: 48px;
    height: 42px;
    border-radius: 12px;
    font-size: 11px;
}

.mobile-pause {
    right: var(--safe-right);
}

.mobile-fullscreen {
    left: max(var(--safe-left), var(--fullscreen-hud-left, 0px));
    top: var(--fullscreen-hud-top, max(12px, env(safe-area-inset-top)));
    width: 82px;
    height: 34px;
    border-radius: 10px;
}

.mobile-status {
    position: absolute;
    top: calc(max(12px, env(safe-area-inset-top)) + 132px);
    right: var(--safe-right);
    max-width: min(320px, 70vw);
    color: #ffdc7a;
    font-size: 12px;
    text-align: right;
    text-shadow: 0 1px 4px #000;
}

.rotate-prompt {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 6;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px;
    color: #e8faff;
    background: rgba(0, 12, 24, 0.86);
    text-align: center;
    text-shadow: 0 1px 5px #000;
    pointer-events: auto;
}

.rotate-prompt strong {
    color: #8ed8ff;
    font: 700 clamp(20px, 6vw, 30px) Arial, sans-serif;
}

.rotate-prompt span {
    font: 16px Arial, sans-serif;
}

html.mobile-immersive,
html.mobile-immersive body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

html.mobile-immersive #app {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    height: var(--app-height, 100dvh);
}

@media (orientation: portrait) {
    .mobile-play-controls {
        display: none;
    }

    .rotate-prompt {
        display: flex;
    }
}
