* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #02030a;
    color: #e8ecf5;
    font-family: 'Outfit', system-ui, sans-serif;
    font-weight: 300;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
}

#ship-canvas { pointer-events: none; }

canvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

/* ---------- HUD ---------- */
.hud {
    position: fixed;
    top: max(14px, env(safe-area-inset-top));
    left: max(16px, env(safe-area-inset-left));
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 13px;
    line-height: 1.65;
    letter-spacing: 0.02em;
    pointer-events: none;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
}

.hud-right {
    left: auto;
    right: max(16px, env(safe-area-inset-right));
    text-align: right;
}

.hud-row { display: flex; gap: 12px; justify-content: space-between; min-width: 190px; }
.hud-label { color: rgba(232, 236, 245, 0.5); text-transform: uppercase; font-size: 11px; letter-spacing: 0.12em; }

.fuel { align-items: center; }
.fuel-bar {
    width: 92px;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
}
.fuel-bar span {
    display: block;
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #ff8a3d, #ffd36b);
    border-radius: 3px;
    transition: background 0.3s;
}
.fuel-bar span.low { background: #ff4d4d; }

.ok { color: #6dffb0; }
.warn { color: #ffd36b; }
.bad { color: #ff6b6b; }

/* ---------- Messages ---------- */
.message {
    position: fixed;
    left: 50%;
    top: 38%;
    transform: translate(-50%, -50%) scale(0.96);
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.35s, transform 0.35s;
    text-shadow: 0 2px 18px rgba(0, 0, 0, 0.9);
    width: min(92vw, 560px);
}
.message.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.message h1 {
    font-weight: 200;
    font-size: clamp(34px, 7vw, 64px);
    letter-spacing: 0.08em;
    margin-bottom: 10px;
}
.message h1.win { color: #6dffb0; }
.message h1.lose { color: #ff6b6b; }
.message p { margin: 6px 0; font-size: 16px; color: rgba(232, 236, 245, 0.85); }
.message .sub { font-size: 18px; }
.message .keys { font-size: 14px; color: rgba(232, 236, 245, 0.65); }
.message .cta { margin-top: 18px; font-size: 14px; letter-spacing: 0.14em; text-transform: uppercase; animation: pulse 1.6s ease-in-out infinite; }

kbd {
    display: inline-block;
    min-width: 22px;
    padding: 1px 6px;
    border: 1px solid rgba(232, 236, 245, 0.35);
    border-radius: 5px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
}

@keyframes pulse { 50% { opacity: 0.45; } }

/* ---------- Touch controls ---------- */
.touch-controls { display: none; }

@media (pointer: coarse) {
    .touch-controls {
        display: block;
        position: fixed;
        inset: auto 0 0 0;
        height: 0;
    }
    .tc {
        position: fixed;
        bottom: max(22px, env(safe-area-inset-bottom));
        width: 68px;
        height: 68px;
        border-radius: 50%;
        border: 1px solid rgba(232, 236, 245, 0.3);
        background: rgba(255, 255, 255, 0.07);
        color: #e8ecf5;
        font-size: 28px;
        -webkit-backdrop-filter: blur(6px);
        backdrop-filter: blur(6px);
        touch-action: none;
    }
    .tc.active { background: rgba(255, 255, 255, 0.22); }
    .tc[data-act="left"] { left: max(20px, env(safe-area-inset-left)); }
    .tc[data-act="right"] { left: calc(max(20px, env(safe-area-inset-left)) + 84px); }
    .tc-thrust { right: max(20px, env(safe-area-inset-right)); width: 84px; height: 84px; }
    .hud { font-size: 11px; }
    .hud-row { min-width: 150px; }
}

@media (max-width: 600px) {
    .hud { font-size: 11px; line-height: 1.55; }
    .hud-row { min-width: 0; gap: 8px; }
    .hud-label { font-size: 9px; letter-spacing: 0.08em; }
    .fuel-bar { width: 60px; }
}
