:root {
    --ink: #f7fbff;
    --muted: #a8b8c9;
    --panel: rgba(6, 10, 16, 0.78);
    --line: rgba(255, 255, 255, 0.16);
    --accent: #45d9ff;
    --gold: #ffd166;
    --sand: #d7aa67;
    --copper: #ff8f3d;
}

* {
    box-sizing: border-box;
}

html,
body,
#game {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
}

body {
    color: var(--ink);
    background: #050810;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    touch-action: none;
}

button,
a {
    font: inherit;
}

#world {
    position: fixed;
    inset: 0;
    display: block;
    width: 100vw;
    height: 100vh;
    outline: none;
    touch-action: none;
}

.intro {
    position: fixed;
    inset: 0;
    z-index: 8;
    display: grid;
    place-items: center;
    padding: 26px;
    background:
        linear-gradient(90deg, rgba(5, 8, 16, 0.95) 0%, rgba(5, 8, 16, 0.58) 46%, rgba(5, 8, 16, 0.2) 100%),
        radial-gradient(circle at 72% 30%, rgba(84, 214, 255, 0.2), transparent 26rem);
}

.intro.is-hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 260ms ease;
}

.intro-copy {
    width: min(760px, 100%);
    transform: translateX(-12vw);
}

.kicker {
    margin: 0 0 14px;
    color: var(--gold);
    font-family: "JetBrains Mono", monospace;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.intro h1 {
    max-width: 760px;
    margin: 0 0 16px;
    font-size: clamp(3rem, 9vw, 8.5rem);
    line-height: 0.88;
    letter-spacing: 0;
}

.intro p:not(.kicker) {
    max-width: 620px;
    margin: 0 0 30px;
    color: #d7e6f8;
    font-size: clamp(1rem, 2vw, 1.35rem);
    line-height: 1.55;
}

#start-game {
    min-width: 220px;
    min-height: 54px;
    border: 1px solid rgba(255, 209, 102, 0.72);
    border-radius: 8px;
    color: #171005;
    cursor: pointer;
    font-weight: 900;
    background: linear-gradient(135deg, #ffd166, #ff8f3d);
    box-shadow: 0 18px 50px rgba(255, 143, 61, 0.22);
}

.hud {
    position: fixed;
    top: 18px;
    left: 18px;
    right: 18px;
    z-index: 5;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    pointer-events: none;
}

.brand,
.objective,
.quick-links,
.info-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.26);
    backdrop-filter: blur(14px);
}

.pause-menu {
    position: fixed;
    inset: 0;
    z-index: 9;
    display: none;
    place-items: center;
    padding: 24px;
    background: rgba(4, 6, 10, 0.58);
    backdrop-filter: blur(10px);
}

.pause-menu.is-open {
    display: grid;
}

.pause-menu > div {
    width: min(460px, 100%);
    padding: 26px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(7, 11, 18, 0.88);
    box-shadow: 0 30px 100px rgba(0, 0, 0, 0.44);
}

.pause-menu h2 {
    margin: 0 0 10px;
    font-size: clamp(2rem, 5vw, 4rem);
    line-height: 0.95;
}

.pause-menu p:not(.kicker) {
    margin: 0 0 20px;
    color: var(--muted);
    line-height: 1.6;
}

.pause-menu button {
    display: block;
    width: 100%;
    min-height: 48px;
    margin-top: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    cursor: pointer;
    font-weight: 900;
    background: rgba(255, 255, 255, 0.08);
}

.pause-menu button:first-of-type {
    color: #171005;
    border-color: rgba(255, 209, 102, 0.72);
    background: linear-gradient(135deg, var(--gold), var(--copper));
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
}

.brand-avatar {
    display: block;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    border: 2px solid rgba(69, 217, 255, 0.72);
    object-fit: cover;
    object-position: 50% 18%;
    box-shadow: 0 0 18px rgba(69, 217, 255, 0.28);
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    color: var(--muted);
}

.objective {
    min-width: min(430px, 46vw);
    padding: 12px 14px;
    text-align: right;
}

.objective span,
.objective strong {
    display: block;
}

.objective span {
    color: var(--ink);
    font-weight: 800;
}

.objective strong {
    margin-top: 5px;
    color: var(--muted);
    font-size: 0.88rem;
}

.quick-links {
    position: fixed;
    left: 18px;
    bottom: 18px;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-width: min(640px, calc(100vw - 36px));
    padding: 10px;
}

.quick-links a {
    display: inline-grid;
    place-items: center;
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    text-decoration: none;
    background: rgba(255, 255, 255, 0.08);
}

.audio-controls {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.26);
    backdrop-filter: blur(14px);
}

.audio-controls button {
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    cursor: pointer;
    font-weight: 800;
    background: rgba(255, 255, 255, 0.08);
}

.audio-controls label {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 800;
}

.audio-controls input {
    width: 112px;
}

.vehicle-hint {
    position: fixed;
    left: 50%;
    bottom: 96px;
    z-index: 6;
    min-width: 156px;
    padding: 12px 18px;
    border: 1px solid rgba(69, 217, 255, 0.64);
    border-radius: 8px;
    color: #06101a;
    text-align: center;
    font-family: "JetBrains Mono", monospace;
    font-weight: 900;
    letter-spacing: 0;
    background: linear-gradient(135deg, var(--accent), #ffd166);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.34), 0 0 28px rgba(69, 217, 255, 0.28);
    transform: translateX(-50%);
}

.info-panel {
    --panel-accent: var(--accent);
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 7;
    width: min(620px, calc(100vw - 36px));
    max-height: min(650px, calc(100vh - 36px));
    overflow: auto;
    padding: 0;
    border-color: color-mix(in srgb, var(--panel-accent) 48%, rgba(255, 255, 255, 0.18));
    background:
        linear-gradient(135deg, color-mix(in srgb, var(--panel-accent) 18%, transparent), transparent 42%),
        linear-gradient(180deg, rgba(9, 16, 26, 0.96), rgba(5, 8, 14, 0.9));
    box-shadow:
        0 34px 110px rgba(0, 0, 0, 0.48),
        0 0 38px color-mix(in srgb, var(--panel-accent) 24%, transparent);
    transform: translateY(24px) scale(0.98);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 220ms ease, transform 220ms ease;
}

.info-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg, transparent 0 48%, color-mix(in srgb, var(--panel-accent) 18%, transparent) 50%, transparent 52%),
        repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 6px);
    opacity: 0.28;
}

.info-panel::after {
    content: "";
    position: absolute;
    left: 28px;
    right: 28px;
    top: 24px;
    height: 2px;
    background: linear-gradient(90deg, var(--panel-accent), transparent 52%);
    opacity: 0.65;
    pointer-events: none;
}

.info-panel.is-open {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.panel-orbit {
    position: absolute;
    top: 22px;
    right: 58px;
    width: 86px;
    height: 86px;
    border: 1px solid color-mix(in srgb, var(--panel-accent) 58%, transparent);
    border-radius: 50%;
    box-shadow: inset 0 0 26px color-mix(in srgb, var(--panel-accent) 24%, transparent);
    pointer-events: none;
}

.panel-orbit::before,
.panel-orbit::after {
    content: "";
    position: absolute;
    inset: 16px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 50%;
}

.panel-orbit::after {
    inset: 36px;
    background: var(--panel-accent);
    box-shadow: 0 0 18px var(--panel-accent);
}

.panel-header {
    position: relative;
    padding: 34px 82px 22px 34px;
    border-bottom: 1px solid color-mix(in srgb, var(--panel-accent) 34%, rgba(255, 255, 255, 0.12));
}

#close-panel {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1;
    width: 36px;
    height: 36px;
    border: 1px solid color-mix(in srgb, var(--panel-accent) 38%, var(--line));
    border-radius: 8px;
    color: var(--ink);
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    font-size: 1.4rem;
    line-height: 1;
}

.info-panel h2 {
    margin: 0 0 10px;
    max-width: 430px;
    font-size: clamp(1.65rem, 4vw, 2.7rem);
    line-height: 0.96;
    letter-spacing: 0;
    text-shadow: 0 0 18px color-mix(in srgb, var(--panel-accent) 34%, transparent);
}

.info-panel p:not(.kicker) {
    max-width: 440px;
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.info-panel ul {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 20px 24px 24px;
    list-style: none;
}

.info-panel li {
    position: relative;
    display: grid;
    grid-template-columns: 42px 1fr;
    gap: 12px;
    align-items: center;
    min-height: 64px;
    padding: 13px 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-left: 3px solid var(--panel-accent);
    border-radius: 8px;
    color: #edf6ff;
    background:
        linear-gradient(90deg, color-mix(in srgb, var(--panel-accent) 16%, transparent), rgba(255, 255, 255, 0.055));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    line-height: 1.45;
}

.info-panel li span {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 1px solid color-mix(in srgb, var(--panel-accent) 46%, rgba(255, 255, 255, 0.16));
    border-radius: 50%;
    color: var(--panel-accent);
    background: rgba(0, 0, 0, 0.18);
    font-family: "JetBrains Mono", monospace;
    font-size: 0.9rem;
    text-shadow: 0 0 12px var(--panel-accent);
}

.info-panel li strong {
    color: #f7fbff;
    font-weight: 700;
}

.assistant-chat {
    position: relative;
    display: grid;
    gap: 14px;
    padding: 18px 24px 24px;
}

.assistant-messages {
    display: grid;
    gap: 12px;
    max-height: 300px;
    overflow: auto;
    padding-right: 4px;
}

.assistant-message {
    display: grid;
    gap: 6px;
    max-width: 88%;
    padding: 12px 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.07);
}

.assistant-message.user {
    justify-self: end;
    border-color: color-mix(in srgb, var(--panel-accent) 42%, rgba(255, 255, 255, 0.14));
    background: color-mix(in srgb, var(--panel-accent) 18%, rgba(255, 255, 255, 0.06));
}

.assistant-message span {
    color: var(--panel-accent);
    font-family: "JetBrains Mono", monospace;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.assistant-message p {
    margin: 0;
    color: #f7fbff;
    line-height: 1.45;
}

.assistant-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
}

.assistant-form input,
.assistant-form button {
    min-height: 44px;
    border: 1px solid color-mix(in srgb, var(--panel-accent) 38%, var(--line));
    border-radius: 8px;
    color: var(--ink);
    background: rgba(0, 0, 0, 0.22);
}

.assistant-form input {
    width: 100%;
    padding: 0 13px;
    outline: none;
}

.assistant-form button {
    padding: 0 18px;
    cursor: pointer;
    font-weight: 900;
    background: color-mix(in srgb, var(--panel-accent) 32%, rgba(255, 255, 255, 0.08));
}

#crosshair {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 4;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.68);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.mobile-controls {
    display: none;
}

.mobile-controls.is-active {
    display: flex;
}

@media (hover: none), (pointer: coarse), (max-width: 820px) {
    .quick-links,
    .audio-controls {
        display: none;
    }

    #close-panel {
        display: none;
    }

    .mobile-controls {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 8;
        display: none;
        align-items: flex-end;
        justify-content: space-between;
        padding: 0 14px max(14px, env(safe-area-inset-bottom));
        pointer-events: none;
    }

    .mobile-controls.is-active {
        display: flex;
    }

    .touch-joystick {
        position: relative;
        width: 132px;
        height: 132px;
        border: 1px solid rgba(69, 217, 255, 0.5);
        border-radius: 50%;
        background: rgba(5, 9, 15, 0.48);
        box-shadow: inset 0 0 28px rgba(69, 217, 255, 0.16), 0 18px 48px rgba(0, 0, 0, 0.28);
        pointer-events: auto;
        touch-action: none;
    }

    .touch-stick {
        position: absolute;
        left: 50%;
        top: 50%;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: linear-gradient(135deg, var(--accent), var(--gold));
        transform: translate(-50%, -50%);
        box-shadow: 0 0 20px rgba(69, 217, 255, 0.34);
    }

    .touch-actions {
        display: grid;
        grid-template-columns: 68px;
        gap: 8px;
        pointer-events: auto;
        padding-bottom: 4px;
    }

    .touch-actions button {
        min-width: 68px;
        min-height: 54px;
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 8px;
        color: var(--ink);
        background: rgba(5, 9, 15, 0.68);
        box-shadow: 0 16px 42px rgba(0, 0, 0, 0.3);
        font-weight: 900;
        touch-action: manipulation;
    }

    #touch-interact {
        color: #06101a;
        background: linear-gradient(135deg, var(--accent), #80ed99);
    }

    #touch-jump {
        min-width: 86px;
        transform: translateX(-18px);
    }

    #touch-close {
        display: none;
    }

    #touch-close.is-visible {
        display: block;
    }
}

@media (max-width: 760px) {
    .intro {
        place-items: end start;
    }

    .intro-copy {
        transform: none;
    }

    .hud {
        display: grid;
    }

    .objective {
        min-width: 0;
        width: min(100%, 420px);
        text-align: left;
    }

    .info-panel {
        left: 12px;
        right: 12px;
        bottom: calc(150px + env(safe-area-inset-bottom));
        width: auto;
        max-height: min(430px, calc(100vh - 290px));
    }

    .panel-header {
        padding: 32px 62px 18px 24px;
    }

    .panel-orbit {
        width: 62px;
        height: 62px;
        right: 50px;
    }

    .info-panel ul {
        padding: 14px;
    }

    .info-panel li {
        grid-template-columns: 34px 1fr;
        gap: 10px;
    }

    .info-panel li span {
        width: 32px;
        height: 32px;
    }

    .assistant-chat {
        padding: 14px;
    }

    .assistant-form {
        grid-template-columns: 1fr;
    }
}
