* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background-color: #030a11;
    color: #e8f6ff;
    font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
}

body {
    display: flex;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

.shell {
    display: flex;
    flex-direction: column;
    width: 540px;
    max-width: 100vw;
    height: 100vh;
    padding: 8px;
    overflow: hidden;
}

.topline,
.controls-shell {
    border: 1px solid #23506a;
    background-color: #0b2130;
}

.topline {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    min-height: 66px;
    margin-bottom: 7px;
    padding: 8px 10px;
    border-radius: 17px;
}

.header-title {
    flex: 0 0 auto;
    width: 118px;
}

.eyebrow {
    color: #5de3ef;
    font-size: 0.56rem;
    font-weight: bold;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.topline h1 {
    margin: 5px 0 0;
    color: #e9fbff;
    font-family: Impact, "Arial Black", sans-serif;
    font-size: 1.38rem;
    line-height: 0.9;
    letter-spacing: 0.03em;
}

.topline h1 span {
    color: #ff9b42;
}

.connection-summary {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0 8px;
}

.connection-line {
    display: flex;
    align-items: center;
    min-width: 0;
}

.connection-line strong {
    overflow: hidden;
    font-size: 0.75rem;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player-glow {
    flex: 0 0 auto;
    width: 12px;
    height: 12px;
    margin-right: 7px;
    border: 2px solid #7e3c1d;
    border-radius: 50%;
    background-color: #c35b27;
}

.player-glow.online {
    border-color: #66efc6;
    background-color: #20b88b;
}

.connection-meta {
    margin-top: 5px;
    overflow: hidden;
    color: #8fabb8;
    font-size: 0.62rem;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.connection-meta b {
    color: #cbe7ef;
}

.header-actions {
    display: flex;
    flex: 0 0 90px;
    flex-direction: column;
}

.header-pill {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 25px;
    margin-top: 4px;
    padding: 0 7px;
    border: 1px solid #2c6179;
    border-radius: 999px;
    background-color: #123248;
    color: #e8f6ff;
    font: inherit;
    font-size: 0.61rem;
    font-weight: bold;
    line-height: 1;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.header-pill:first-child {
    margin-top: 0;
}

.reset-pill {
    border-color: #74401f;
    background-color: #5d2b12;
    color: #ffe6d4;
}

.header-pill:active {
    transform: scale(0.97);
}

.controls-shell {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    padding: 7px;
    overflow: hidden;
    border-radius: 19px;
}

.utility-strip {
    display: flex;
    flex: 0 0 52px;
    margin-bottom: 7px;
}

.control-deck {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}

.joystick-stage {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
}

.joystick-base {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 260px;
    overflow: hidden;
    border: 2px solid #2b6077;
    border-radius: 21px;
    background-color: #06121b;
    touch-action: none;
}

.joystick-base:focus {
    border-color: #53cbd8;
    outline: none;
}

.joystick-base.dragging {
    border-color: #5de3ef;
    background-color: #071a25;
}

.surface-axis {
    position: absolute;
    background-color: #183c4f;
    pointer-events: none;
}

.horizontal-axis {
    top: 50%;
    right: 7%;
    left: 7%;
    height: 1px;
}

.vertical-axis {
    top: 5%;
    bottom: 5%;
    left: 50%;
    width: 1px;
}

.surface-marker {
    position: absolute;
    z-index: 1;
    color: #527384;
    font-size: 0.58rem;
    font-weight: bold;
    letter-spacing: 0.12em;
    pointer-events: none;
}

.marker-up {
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
}

.marker-left {
    top: 50%;
    left: 9px;
    transform: translateY(-50%) rotate(-90deg);
}

.marker-right {
    top: 50%;
    right: 7px;
    transform: translateY(-50%) rotate(90deg);
}

.marker-down {
    bottom: 46px;
    left: 50%;
    transform: translateX(-50%);
}

.surface-guide {
    position: absolute;
    top: 13%;
    right: 12px;
    left: 12px;
    color: #6f929f;
    text-align: center;
    pointer-events: none;
}

.surface-guide strong,
.surface-guide span {
    display: block;
}

.surface-guide strong {
    color: #7fb7c2;
    font-size: 0.68rem;
    letter-spacing: 0.15em;
}

.surface-guide span {
    margin-top: 4px;
    font-size: 0.62rem;
}

.joystick-knob {
    position: absolute;
    z-index: 3;
    top: 50%;
    left: 50%;
    width: 74px;
    height: 74px;
    border: 4px solid #27748e;
    border-radius: 50%;
    background-color: #5de3ef;
    transform: translate(-50%, -50%);
    transition: transform 95ms ease-out;
    pointer-events: none;
}

.joystick-base.dragging .joystick-knob {
    border-color: #9af7fc;
    transition: none;
}

.knob-grip {
    position: absolute;
    top: 25%;
    right: 25%;
    bottom: 25%;
    left: 25%;
    border: 2px solid #167b8d;
    border-radius: 50%;
}

.pulse-banner {
    position: absolute;
    z-index: 4;
    right: 12px;
    bottom: 10px;
    left: 12px;
    min-height: 27px;
    padding: 6px 9px;
    overflow: hidden;
    border: 1px solid #23506a;
    border-radius: 999px;
    background-color: #0b2130;
    color: #9fc0cc;
    font-size: 0.68rem;
    font-weight: bold;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    pointer-events: none;
}

.pulse-banner.flash {
    border-color: #4fb8c7;
    background-color: #17455b;
    color: #e8fbff;
}

.action-button {
    min-width: 0;
    border: 2px solid #2b6077;
    border-radius: 15px;
    background-color: #123248;
    color: #e8f6ff;
    font: inherit;
    font-size: 0.72rem;
    font-weight: bold;
    text-transform: uppercase;
    touch-action: none;
}

.utility-action {
    flex: 1 1 25%;
    min-height: 52px;
}

.utility-action + .utility-action {
    margin-left: 7px;
}

.utility-action.select-action {
    border-color: #96602f;
    background-color: #633516;
}

.utility-action.menu-direction {
    border-color: #397c91;
    background-color: #17455b;
}

.button-title,
.button-subtitle {
    display: block;
}

.button-subtitle {
    margin-top: 4px;
    color: #b9d0da;
    font-size: 0.56rem;
    font-weight: normal;
    letter-spacing: 0.02em;
    line-height: 1.15;
    text-transform: none;
}

.action-button.active,
.action-button:active {
    border-color: #a9f6fb;
    background-color: #5de3ef;
    color: #041019;
    transform: scale(0.97);
}

.action-button.active .button-subtitle,
.action-button:active .button-subtitle {
    color: #15404d;
}

@media (max-width: 410px) {
    .shell {
        padding: 6px;
    }

    .topline {
        min-height: 60px;
        margin-bottom: 5px;
        padding: 6px 8px;
    }

    .header-title {
        width: 101px;
    }

    .eyebrow {
        font-size: 0.49rem;
    }

    .topline h1 {
        font-size: 1.18rem;
    }

    .connection-summary {
        padding: 0 5px;
    }

    .connection-line strong {
        font-size: 0.66rem;
    }

    .connection-meta {
        font-size: 0.56rem;
    }

    .header-actions {
        flex-basis: 78px;
    }

    .header-pill {
        min-height: 23px;
        font-size: 0.54rem;
    }

    .controls-shell {
        padding: 5px;
    }

    .utility-strip {
        flex-basis: 46px;
        margin-bottom: 5px;
    }

    .utility-action {
        min-height: 46px;
    }

    .utility-action + .utility-action {
        margin-left: 5px;
    }

    .action-button {
        font-size: 0.6rem;
    }

    .joystick-knob {
        width: 66px;
        height: 66px;
    }
}

@media (max-height: 700px) {
    .topline {
        min-height: 52px;
    }

    .eyebrow,
    .connection-meta,
    .button-subtitle {
        display: none;
    }

    .topline h1 {
        margin-top: 0;
    }

    .utility-strip {
        flex-basis: 42px;
        margin-bottom: 5px;
    }

    .utility-action {
        min-height: 42px;
    }

    .joystick-base {
        min-height: 190px;
    }

    .marker-down {
        bottom: 39px;
    }

    .pulse-banner {
        min-height: 24px;
        padding: 4px 7px;
    }
}

@media (orientation: landscape) and (max-height: 520px) {
    .shell {
        width: 100%;
        padding: 5px;
    }

    .topline {
        min-height: 46px;
        margin-bottom: 4px;
        border-radius: 13px;
    }

    .header-title {
        width: 110px;
    }

    .connection-line strong {
        font-size: 0.72rem;
    }

    .header-actions {
        flex-basis: auto;
        flex-direction: row;
    }

    .header-pill {
        min-height: 28px;
        margin: 0 0 0 5px;
        padding: 0 10px;
    }

    .controls-shell {
        padding: 4px;
        border-radius: 14px;
    }

    .utility-strip {
        flex: 0 0 39px;
        margin-bottom: 4px;
    }

    .utility-action {
        min-height: 39px;
    }

    .joystick-base {
        min-height: 160px;
        border-radius: 15px;
    }

    .surface-guide {
        top: 10%;
    }
}
