html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background: #150b07;
    color: #f2ece3;
    font-family: system-ui, -apple-system, sans-serif;
    overflow: hidden;
    touch-action: none;
}

/* Author `display` values override the UA's [hidden] rule — without
   this the game div can cover the page while "hidden" (the launch
   black-screen bug). The site-select landing screen was removed
   2026-07-09 — boot goes straight into the sim. */
#game-root[hidden] {
    display: none !important;
}

#game-root {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#mc-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

/* ---- HUD ---- */

#mc-hud {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.mars-hud__top {
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    left: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: none;
}

.mars-btn {
    pointer-events: auto;
    background: rgba(20, 12, 8, 0.75);
    border: 1px solid #7a4f30;
    color: #f2ece3;
    border-radius: 6px;
    padding: 10px 16px;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.mars-btn__hint {
    opacity: 0.55;
    font-size: 0.75em;
    display: none;
}

.mars-hud--desktop .mars-btn__hint {
    display: inline;
}

.mars-hud__unit {
    pointer-events: none;
    background: rgba(20, 12, 8, 0.6);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.8rem;
    letter-spacing: 0.1em;
}

.mars-hud__minimap {
    position: absolute;
    top: max(70px, calc(env(safe-area-inset-top) + 60px));
    right: 12px;
    width: 140px;
    height: 140px;
    border: 1px solid #7a4f30;
    border-radius: 8px;
    overflow: hidden;
}

.mars-minimap-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.mars-btn--menu {
    margin-left: auto;
}

/* ---- Telemetry readout ---- */

.mars-hud__telemetry {
    position: absolute;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    background: rgba(20, 12, 8, 0.75);
    border: 1px solid #7a4f30;
    border-radius: 8px;
    padding: 10px 14px;
    font-family: 'SF Mono', ui-monospace, Menlo, Consolas, monospace;
    font-size: 0.72rem;
    min-width: 180px;
    pointer-events: none;
}

.mars-tele__site {
    letter-spacing: 0.08em;
    opacity: 0.7;
    font-size: 0.62rem;
    margin-bottom: 6px;
    white-space: nowrap;
}

.mars-tele__grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 12px;
}

.mars-tele__grid span {
    opacity: 0.6;
    letter-spacing: 0.08em;
}

.mars-tele__grid b {
    font-weight: 500;
    text-align: right;
    color: #e0b95e;
}

.mars-tele__clock {
    letter-spacing: 0.06em;
    font-size: 0.66rem;
    color: #e0b95e;
    opacity: 0.9;
    margin-bottom: 6px;
}

.mars-tele__grid b.is-low {
    color: #e0885e;
}

.mars-tele__grid b.is-crit {
    color: #e05e5e;
}

/* steer arrow inside the TGT row — rotated via inline transform */
.mars-tele__arrow {
    display: inline-block;
    margin-right: 5px;
    color: #e0b95e;
    transition: transform 0.2s linear;
}

/* collapse toggle — only surfaced on phones (see the coarse media query) */
.mars-tele__toggle {
    display: none;
    position: absolute;
    top: 2px;
    right: 4px;
    background: none;
    border: none;
    color: #e0b95e;
    font-size: 0.85rem;
    padding: 4px 8px;
    pointer-events: auto;
    cursor: pointer;
}

#mc-telemetry[data-collapsed="true"] .mars-tele__clock,
#mc-telemetry[data-collapsed="true"] .mars-tele__grid {
    display: none;
}

/* On phones the joystick zones own the bottom corners and the chase cam
   frames the unit near screen center — lifting the card above the look
   zone parked it right on top of the unit. Dock it top-left under the
   top bar instead (mirroring the minimap on the right), compacted. */
@media (max-width: 899px), (pointer: coarse) {
    .mars-hud__telemetry {
        right: auto;
        bottom: auto;
        left: 12px;
        top: max(70px, calc(env(safe-area-inset-top) + 60px));
        min-width: 132px;
        max-width: 186px;
        font-size: 0.6rem;
        padding: 8px 10px;
    }

    /* the nowrap site line otherwise stretches the card across the screen */
    .mars-hud__telemetry .mars-tele__site {
        white-space: normal;
        padding-right: 22px; /* clear the collapse toggle */
    }

    .mars-tele__toggle {
        display: block;
    }

    .mars-hud__telemetry .mars-tele__grid b {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* four top-bar buttons have to fit a phone width */
    .mars-btn {
        padding: 8px 10px;
        font-size: 0.72rem;
    }

    .mars-hud__unit {
        padding: 6px 8px;
        font-size: 0.72rem;
    }

}

/* ---- In-game menu ---- */

.mars-menu {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(10, 6, 4, 0.82);
    pointer-events: auto;
    z-index: 20;
}

.mars-menu[data-open="true"] {
    display: flex;
}

.mars-menu__panel {
    background: #1d110a;
    border: 1px solid #7a4f30;
    border-radius: 12px;
    padding: 24px 28px;
    max-width: 420px;
    width: calc(100vw - 48px);
    max-height: 82vh;
    overflow-y: auto;
}

.mars-menu__panel h2 {
    margin: 0 0 14px;
    font-size: 1.1rem;
    letter-spacing: 0.12em;
}

.mars-menu__section h3 {
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    opacity: 0.6;
    margin: 16px 0 8px;
}

.mars-menu__sites {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mars-menu__site {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 14px;
    border: 1px solid #5a3a26;
    border-radius: 8px;
    color: inherit;
    text-decoration: none;
    background: rgba(90, 58, 38, 0.15);
}

.mars-menu__site:hover, .mars-menu__site:active {
    border-color: #e0b95e;
    background: rgba(224, 185, 94, 0.15);
}

.mars-menu__site.is-current {
    border-color: #e0b95e;
}

.mars-menu__site b {
    font-size: 0.9rem;
}

.mars-menu__site span {
    font-size: 0.72rem;
    opacity: 0.7;
}

.mars-menu__note {
    margin: 8px 0 0;
    font-size: 0.7rem;
    line-height: 1.5;
    opacity: 0.6;
}

.mars-menu__lab {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mars-menu__lab li {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(122, 79, 48, 0.35);
}

.mars-menu__lab li b {
    font-size: 0.85rem;
}

.mars-menu__lab li span {
    font-size: 0.72rem;
    opacity: 0.7;
}

.mars-menu__lab-empty {
    font-size: 0.78rem;
    opacity: 0.6;
}

.mars-menu__controls {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 0.8rem;
    opacity: 0.85;
}

.mars-menu__controls li {
    padding: 3px 0;
}

.mars-btn--resume {
    margin-top: 18px;
    width: 100%;
    justify-content: center;
}

.mars-hud__prompt {
    position: absolute;
    bottom: max(140px, calc(env(safe-area-inset-bottom) + 130px));
    left: 50%;
    transform: translateX(-50%);
}

/* ---- GEAR button (rover + drones; hidden for the humanoid) ---- */

.mars-hud__gear {
    position: absolute;
    right: 12px;
    bottom: 215px;
    z-index: 15;
}

.mars-hud__gear[data-visible="false"] {
    display: none;
}

@media (max-width: 899px), (pointer: coarse) {
    /* dock under the minimap, clear of telemetry (top-left) and sticks */
    .mars-hud__gear {
        bottom: auto;
        top: max(222px, calc(env(safe-area-inset-top) + 212px));
    }
}

/* ---- drone control board (visible only while a drone is active) ---- */

.mars-hud__dronectl {
    position: absolute;
    bottom: max(14px, env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    display: none;
    align-items: stretch;
    gap: 10px;
    pointer-events: none;
    z-index: 15; /* above the touch zones so the LAND button stays tappable */
}

.mars-hud__dronectl[data-visible="true"] {
    display: flex;
}

.mars-dronectl__stat {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    background: rgba(20, 12, 8, 0.75);
    border: 1px solid #7a4f30;
    border-radius: 6px;
    padding: 6px 14px;
    font-family: 'SF Mono', ui-monospace, Menlo, Consolas, monospace;
    font-size: 0.68rem;
    text-align: center;
}

.mars-dronectl__stat b {
    color: #e0b95e;
    letter-spacing: 0.1em;
    font-weight: 600;
}

.mars-dronectl__stat span {
    opacity: 0.75;
}

.mars-btn--land {
    min-width: 110px;
    justify-content: center;
}

/* phones: lift the board clear of the joystick zones (must come after
   the base rule above — same specificity, cascade order decides) */
@media (max-width: 899px), (pointer: coarse) {
    .mars-hud__dronectl {
        bottom: calc(min(45vw, 260px) + 14px);
    }
}

.mars-hud__inventory {
    position: absolute;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 12px;
    background: rgba(20, 12, 8, 0.7);
    border: 1px solid #7a4f30;
    border-radius: 8px;
    padding: 10px 14px;
    pointer-events: auto;
    max-width: 200px;
    max-height: 120px;
    overflow-y: auto;
}

.mars-hud__inventory-title {
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    opacity: 0.8;
    margin-bottom: 4px;
}

.mars-hud__inventory ul {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 0.8rem;
}

/* ---- Touch controls ---- */

.mars-touch-zone {
    position: absolute;
    bottom: 0;
    width: 45vw;
    max-width: 260px;
    height: 45vw;
    max-height: 260px;
    touch-action: none;
}

.mars-touch-zone--left {
    left: 0;
}

.mars-touch-zone--right {
    right: 0;
}

/* zones the current unit doesn't use are hidden (touch.js setHidden) */
.mars-touch-zone[data-off="true"] {
    display: none;
}

.joy-base {
    position: absolute;
    width: 100px;
    height: 100px;
    margin-left: -50px;
    margin-top: -50px;
    border-radius: 50%;
    background: rgba(224, 185, 94, 0.12);
    border: 1px solid rgba(224, 185, 94, 0.4);
    opacity: 0.3; /* resting pad stays visible; touch.js brightens it */
    transition: opacity 0.1s;
    pointer-events: none;
}

.joy-label {
    position: absolute;
    top: 6px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 0.58rem;
    letter-spacing: 0.14em;
    color: #e0b95e;
    opacity: 0.6;
    pointer-events: none;
}

.joy-nub {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 44px;
    height: 44px;
    margin-left: -22px;
    margin-top: -22px;
    border-radius: 50%;
    background: rgba(224, 185, 94, 0.55);
}

@media (min-width: 900px) and (pointer: fine) {
    .mars-touch-zone {
        display: none;
    }
}
