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

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

#app {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
}

#game-container canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    touch-action: none;
}

.mobile-touch-controls {
    position: absolute;
    inset: 0;
    z-index: 120;
    display: none;
    overflow: hidden;
    pointer-events: none;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.mobile-touch-controls.is-enabled {
    display: block;
}

.mobile-touch-controls__stick {
    position: absolute;
    bottom: calc(18px + env(safe-area-inset-bottom));
    border-radius: 50%;
    pointer-events: auto;
    touch-action: none;
}

.mobile-touch-controls__stick--move {
    left: calc(20px + env(safe-area-inset-left));
    width: var(--touch-move-stick-size, 140px);
    height: var(--touch-move-stick-size, 140px);
}

.mobile-touch-controls__stick--aim {
    right: calc(20px + env(safe-area-inset-right));
    width: var(--touch-aim-stick-size, 140px);
    height: var(--touch-aim-stick-size, 140px);
}

.mobile-touch-controls.is-left-handed .mobile-touch-controls__stick--move {
    right: calc(20px + env(safe-area-inset-right));
    left: auto;
}

.mobile-touch-controls.is-left-handed .mobile-touch-controls__stick--aim {
    right: auto;
    left: calc(20px + env(safe-area-inset-left));
}

.mobile-touch-controls__stick-ring {
    position: absolute;
    inset: 0;
    border: 2px solid rgba(193, 224, 255, 0.6);
    border-radius: 50%;
    background: rgba(6, 18, 28, 0.42);
    box-shadow: inset 0 0 24px rgba(85, 175, 255, 0.12), 0 2px 10px rgba(0, 0, 0, 0.4);
}

.mobile-touch-controls__stick-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 43%;
    height: 43%;
    transform: translate(-50%, -50%);
    border: 2px solid rgba(226, 241, 255, 0.86);
    border-radius: 50%;
    background: rgba(72, 151, 210, 0.64);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

.mobile-touch-controls__stick-label {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: rgba(240, 248, 255, 0.78);
    font: 800 10px/1 Arial, sans-serif;
    letter-spacing: 0.08em;
    text-shadow: 0 1px 3px #000;
    pointer-events: none;
}

.mobile-touch-controls__actions {
    position: absolute;
    right: calc(20px + env(safe-area-inset-right));
    bottom: calc(30px + env(safe-area-inset-bottom) + var(--touch-aim-stick-size, 140px));
    width: max(var(--touch-aim-stick-size, 140px), 110px);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    pointer-events: none;
}

.mobile-touch-controls.is-left-handed .mobile-touch-controls__actions {
    right: auto;
    left: calc(20px + env(safe-area-inset-left));
}

.mobile-touch-controls button {
    box-sizing: border-box;
    min-width: 52px;
    min-height: 48px;
    margin: 0;
    padding: 7px 6px;
    border: 1px solid rgba(198, 225, 255, 0.72);
    border-radius: 12px;
    color: #eff8ff;
    background: rgba(10, 27, 40, 0.72);
    box-shadow: inset 0 0 12px rgba(95, 183, 255, 0.1), 0 2px 8px rgba(0, 0, 0, 0.42);
    font: 800 9px/1 Arial, sans-serif;
    letter-spacing: 0.04em;
    text-shadow: 0 1px 3px #000;
    pointer-events: auto;
    touch-action: none;
}

.mobile-touch-controls button:active {
    border-color: #ffffff;
    background: rgba(75, 155, 214, 0.84);
    transform: scale(0.96);
}

.mobile-touch-controls__action--primary {
    color: #fff6e0 !important;
    border-color: rgba(255, 205, 115, 0.86) !important;
    background: rgba(110, 61, 21, 0.78) !important;
}

.mobile-touch-controls__action {
    opacity: 0.62;
}

.mobile-touch-controls__action:active {
    opacity: 0.9;
}

.mobile-touch-controls__action--compact {
    font-size: 8px !important;
}

.mobile-touch-controls__action--contextual:not(.is-available) {
    visibility: hidden;
    pointer-events: none;
}

.mobile-touch-controls__weapons {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.mobile-touch-controls__weapon {
    position: absolute;
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    opacity: 0;
}

.mobile-touch-controls__rotate-hint {
    display: none;
}

@media (orientation: portrait) {
    .mobile-touch-controls__rotate-hint {
        position: absolute;
        inset: 0;
        z-index: 10;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #ffffff;
        background: rgba(4, 10, 16, 0.9);
        font: 900 16px/1.3 Arial, sans-serif;
        letter-spacing: 0.08em;
        text-align: center;
        pointer-events: auto;
        touch-action: none;
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    .mobile-touch-controls__stick {
        bottom: calc(12px + env(safe-area-inset-bottom));
    }

    .mobile-touch-controls__actions {
        bottom: calc(22px + env(safe-area-inset-bottom) + var(--touch-aim-stick-size, 140px));
        gap: 5px;
    }

    .mobile-touch-controls button {
        min-width: 46px;
        min-height: 42px;
        padding: 5px 4px;
    }
}

body.is-gameplay-active,
body.is-gameplay-active #app,
body.is-gameplay-active #game-container {
    touch-action: none;
    overscroll-behavior: none;
}

.orb-wave-command-console {
    position: absolute;
    right: 14px;
    bottom: 14px;
    width: min(560px, calc(100% - 28px));
    z-index: 50;
    font-family: Arial, sans-serif;
    pointer-events: none;
    color: #f5f8ff;
}

.orb-wave-command-console[hidden] {
    display: none !important;
}

.orb-wave-command-guide {
    display: none;
    max-height: min(360px, 50vh);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    touch-action: pan-y;
    pointer-events: auto;
    margin-bottom: 6px;
    padding: 9px 11px;
    border: 1px solid rgba(132, 161, 211, 0.8);
    border-radius: 7px;
    background: rgba(6, 10, 18, 0.94);
    font: 12px/1.45 monospace;
    box-shadow: 0 5px 18px rgba(0, 0, 0, 0.45);
}

.orb-wave-command-guide.visible {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2px;
}

.orb-wave-command-guide-heading {
    position: sticky;
    top: -9px;
    z-index: 1;
    margin: -9px -11px 5px;
    padding: 8px 11px;
    color: #dceaff;
    background: rgba(10, 17, 30, 0.98);
    border-bottom: 1px solid rgba(132, 161, 211, 0.42);
    font-weight: bold;
    letter-spacing: 0.05em;
}

.orb-wave-command-guide-group {
    margin-top: 6px;
    color: #82b8ff;
    font-weight: bold;
    text-transform: uppercase;
}

.orb-wave-command-guide-item {
    padding: 5px 7px;
    border-left: 2px solid rgba(110, 175, 255, 0.48);
    background: rgba(24, 34, 53, 0.56);
}

.orb-wave-command-guide-syntax {
    color: #ffffff;
    font-weight: bold;
    overflow-wrap: anywhere;
}

.orb-wave-command-guide-description {
    margin-top: 2px;
    color: #bdc9da;
    white-space: normal;
}

.orb-wave-command-guide-example {
    margin-top: 2px;
    color: #7ee59b;
    white-space: normal;
}

.orb-wave-command-output {
    max-height: 116px;
    overflow: hidden;
    margin-bottom: 5px;
    font: 12px/1.35 monospace;
    text-shadow: 0 1px 3px #000;
}

.orb-wave-chat-history {
    display: flex;
    min-height: 0;
    max-height: 112px;
    flex-direction: column;
    justify-content: flex-end;
    gap: 3px;
    overflow: hidden;
    margin-bottom: 5px;
    font: 13px/1.35 Arial, sans-serif;
    text-shadow: 0 1px 3px #000;
}

.orb-wave-chat-line {
    align-self: flex-end;
    max-width: 100%;
    padding: 3px 7px;
    border-radius: 5px;
    overflow-wrap: anywhere;
    background: rgba(4, 7, 13, 0.66);
    opacity: 1;
    transition: opacity 0.9s ease, transform 0.9s ease;
}

.orb-wave-chat-line:nth-last-child(2) {
    opacity: 0.82;
}

.orb-wave-chat-line:nth-last-child(n + 3) {
    opacity: 0.62;
}

.orb-wave-chat-line.is-fading {
    opacity: 0;
    transform: translateY(-8px);
}

.orb-wave-chat-line strong {
    color: #86bcff;
}

.orb-wave-command-line {
    padding: 1px 5px;
    background: rgba(4, 7, 13, 0.62);
}

.orb-wave-command-line.success {
    color: #7ee59b;
}

.orb-wave-command-line.error {
    color: #ff858f;
}

.orb-wave-command-form {
    pointer-events: auto;
}

.orb-wave-command-input {
    box-sizing: border-box;
    width: 100%;
    height: 34px;
    padding: 7px 10px;
    border: 1px solid rgba(120, 153, 211, 0.82);
    border-radius: 7px;
    outline: none;
    color: #ffffff;
    background: rgba(7, 11, 20, 0.9);
    font: 13px monospace;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.36);
}

.orb-wave-command-input:focus {
    border-color: #6eafff;
    box-shadow: 0 0 0 2px rgba(82, 151, 255, 0.25);
}

@media (any-pointer: coarse) and (max-width: 900px),
       (any-pointer: coarse) and (max-height: 500px) {
    .orb-wave-command-console {
        right: max(8px, env(safe-area-inset-right));
        bottom: max(8px, env(safe-area-inset-bottom));
        width: min(330px, calc(100% - 16px));
    }

    .orb-wave-command-guide {
        max-height: 38vh;
        padding: 7px 8px;
        font-size: 10px;
    }

    .orb-wave-command-output {
        max-height: 72px;
        font-size: 10px;
    }

    .orb-wave-chat-history {
        max-height: 70px;
        font-size: 11px;
    }

    .orb-wave-command-input {
        height: 30px;
        padding: 5px 8px;
        font-size: 11px;
    }
}
