/* NARBE Space Explorer (card and button styles from NARBE Build n Ride)
   The 3D view fills the window. Menus are frosted cards over it, scaled to fit
   (fit() in ui.js) so nothing is cut off and nothing scrolls. Buttons are big
   chunky blocks with a darker lip; the highlight is colour AND a thick band. */

:root {
    --ink: #ffffff;
    --muted: #cfd8f0;
    --card: rgba(10, 16, 40, 0.82);
    --card-edge: rgba(150, 190, 255, 0.28);
    --green: #2e9e4f; --green-lip: #1d6b35;
    --red: #e2453c; --red-lip: #9c2620;
    --blue: #2f6fd0; --blue-lip: #1f4a8f;
    --plum: #7a4fc9; --plum-lip: #523390;
    --teal: #1e9c8f; --teal-lip: #126b62;
    --slate: #4a5568; --slate-lip: #2e3644;
    --help: #e0662b; --help-lip: #9c4116;
    --yellow: #ffd84a;
    --font: 'Baloo 2', 'Segoe UI Rounded', 'Arial Rounded MT Bold', 'Trebuchet MS', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; background: #02030a; }
body {
    font-family: var(--font);
    color: var(--ink);
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

#nse { position: fixed; inset: 0; }
.nse-stage { position: fixed; inset: 0; }
.nse-gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.nse-btn {
    font: inherit;
    color: inherit;
    border: 0;
    cursor: pointer;
    position: relative;
    transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease, translate 120ms ease;
}
.nse-btn[hidden] { display: none !important; }

.nse-icon { width: 30px; height: 30px; stroke: currentColor; stroke-width: 3.6; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.nse-dot, .nse-fill { fill: currentColor; stroke: none; }

/* ------------------------------------------------------------------ screens */

.nse-screen {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    background: radial-gradient(ellipse at center, rgba(2, 4, 16, 0.1), rgba(2, 4, 16, 0.55));
    overflow: hidden;
    z-index: 10;
}
.nse-screen.show { display: flex; }

.nse-card {
    position: relative;
    flex: none;
    width: min(760px, 94vw);
    padding: 20px 24px 24px;
    border-radius: 30px;
    background: var(--card);
    border: 2px solid var(--card-edge);
    box-shadow: 0 30px 80px rgba(0, 2, 12, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 0 40px rgba(80, 140, 255, 0.12);
    -webkit-backdrop-filter: blur(8px) saturate(1.2);
    backdrop-filter: blur(8px) saturate(1.2);
    transform: scale(var(--card-scale, 1));
    transform-origin: center center;
    animation: nse-card-in 300ms cubic-bezier(.2, .9, .3, 1.2);
}
.nse-card-narrow { width: min(580px, 94vw); }
@keyframes nse-card-in { from { translate: 0 16px; opacity: 0; } to { translate: 0 0; opacity: 1; } }

.nse-title {
    margin: 0 0 14px;
    font-size: clamp(30px, 4.2vw, 44px);
    font-weight: 800;
    line-height: 1.05;
    text-align: center;
    text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
}
.nse-sub {
    margin: 2px 0 16px;
    text-align: center;
    color: var(--muted);
    font-size: clamp(18px, 2.3vw, 24px);
    font-weight: 700;
}
.nse-sub[hidden] { display: none; }

.nse-scan-status { position: absolute; top: 10px; right: 14px; z-index: 3; }
.nse-hud .nse-scan-status { top: max(16px, env(safe-area-inset-top)); left: 50%; right: auto; translate: -50% 0; }

/* ------------------------------------------------------------ menu buttons */

.nse-list { display: flex; flex-direction: column; gap: 12px; }
.nse-menu-item {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    min-height: 74px;
    padding: 10px 22px 10px 12px;
    border-radius: 20px;
    background: var(--tone, var(--slate));
    box-shadow: 0 6px 0 var(--tone-lip, var(--slate-lip)), 0 10px 18px rgba(0, 0, 0, 0.3);
    font-size: clamp(22px, 2.8vw, 30px);
    font-weight: 800;
    text-align: left;
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
    margin-bottom: 6px;
}
.nse-menu-item[data-tone="green"], .nse-hud-btn[data-tone="green"] { --tone: var(--green); --tone-lip: var(--green-lip); }
.nse-menu-item[data-tone="red"], .nse-hud-btn[data-tone="red"] { --tone: var(--red); --tone-lip: var(--red-lip); }
.nse-menu-item[data-tone="blue"], .nse-hud-btn[data-tone="blue"] { --tone: var(--blue); --tone-lip: var(--blue-lip); }
.nse-menu-item[data-tone="plum"], .nse-hud-btn[data-tone="plum"] { --tone: var(--plum); --tone-lip: var(--plum-lip); }
.nse-menu-item[data-tone="teal"], .nse-hud-btn[data-tone="teal"] { --tone: var(--teal); --tone-lip: var(--teal-lip); }
.nse-menu-item[data-tone="slate"], .nse-hud-btn[data-tone="slate"] { --tone: var(--slate); --tone-lip: var(--slate-lip); }
.nse-menu-item[data-tone="help"], .nse-hud-btn[data-tone="help"] { --tone: var(--help); --tone-lip: var(--help-lip); }
.nse-menu-label { flex: 1; }
.nse-menu-note { font-size: 0.7em; font-weight: 700; opacity: 0.85; }

.nse-icon-chip {
    flex: none;
    width: 52px; height: 52px;
    border-radius: 15px;
    display: grid; place-items: center;
    background: rgba(255, 255, 255, 0.2);
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15);
}
.nse-icon-chip .nse-icon { width: 34px; height: 34px; }

/* --------------------------------------------------------------- loading */

.nse-loading { text-align: center; }
.nse-loading-orbit { position: relative; width: 110px; height: 110px; margin: 0 auto; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #8fd0ff, #2f6fd0 60%, #142c66); box-shadow: 0 0 40px rgba(90, 160, 255, 0.5); }
.nse-loading-orbit span { position: absolute; inset: -22px; border-radius: 50%; border: 3px dashed rgba(255, 216, 74, 0.7); animation: nse-spin 3s linear infinite; }
.nse-loading-orbit span::after { content: ''; position: absolute; top: -9px; left: 50%; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 12px var(--yellow); }
@keyframes nse-spin { to { rotate: 360deg; } }
.nse-loading-text { font-size: 26px; font-weight: 800; color: var(--muted); margin-top: 34px; }

/* ------------------------------------------------------------- main menu */

.nse-screen-menu { justify-content: flex-start; padding-left: max(5vw, 20px); background: linear-gradient(90deg, rgba(2, 4, 16, 0.55), rgba(2, 4, 16, 0) 60%); }
.nse-card-menu { width: min(480px, 92vw); transform-origin: left center; }
.nse-brand { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 4px; }
.nse-logo {
    width: clamp(64px, 8vw, 84px); height: clamp(64px, 8vw, 84px);
    border-radius: 22px; display: grid; place-items: center;
    color: #ff8a1f;
    background: linear-gradient(160deg, #ffffff, #dfe8ff);
    box-shadow: 0 6px 0 #8fa3d6, 0 10px 22px rgba(0, 0, 0, 0.35);
    animation: nse-float 4s ease-in-out infinite;
}
.nse-logo .nse-icon { width: 76%; height: 76%; stroke-width: 3.2; }
@keyframes nse-float { 0%, 100% { translate: 0 0; rotate: -4deg; } 50% { translate: 0 -6px; rotate: 4deg; } }
.nse-brand-words { display: flex; flex-direction: column; line-height: 0.92; }
.nse-brand-narbe { font-size: 18px; font-weight: 800; letter-spacing: 0.32em; color: var(--yellow); }
.nse-brand-title { margin: 0; font-size: clamp(38px, 5vw, 54px); font-weight: 800; text-shadow: 0 4px 0 rgba(0, 0, 0, 0.35); }
.nse-tagline { margin-bottom: 18px; }
.nse-menu-list .nse-menu-item { min-height: 82px; font-size: clamp(25px, 3.1vw, 33px); }

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

.nse-hud { position: fixed; inset: 0; pointer-events: none; display: none; z-index: 5; }
.nse-hud.show { display: block; }
.nse-hud .nse-btn { pointer-events: auto; }

.nse-info {
    position: absolute;
    top: max(16px, env(safe-area-inset-top));
    left: max(16px, env(safe-area-inset-left));
    max-width: min(46vw, 560px);
    padding: 10px 18px 12px;
    border-radius: 20px;
    background: rgba(10, 16, 40, 0.74);
    border: 2px solid rgba(150, 190, 255, 0.24);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}
.nse-info-name { font-size: 27px; font-weight: 800; line-height: 1.1; }
.nse-info-sub { font-size: 19px; font-weight: 800; color: var(--muted); }

.nse-pause-btn {
    position: absolute;
    top: max(16px, env(safe-area-inset-top));
    right: max(16px, env(safe-area-inset-right));
    width: 96px; height: 96px;
    border-radius: 50%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: #f5f2ea;
    color: #26324a;
    box-shadow: 0 6px 0 #b9b2a3, 0 10px 20px rgba(0, 0, 0, 0.35);
}
.nse-pause-icon .nse-icon { width: 38px; height: 38px; }
.nse-pause-label { font-size: 16px; font-weight: 800; line-height: 1; margin-top: 2px; }
.nse-hud[data-mode="prompt"] .nse-pause-btn, .nse-hud[data-mode="hail"] .nse-pause-btn, .nse-hud[data-mode="warp"] .nse-pause-btn { display: none; }

/* The control bars: one row along the bottom, in scan order. */
.nse-bar {
    position: absolute;
    left: 50%;
    bottom: max(18px, env(safe-area-inset-bottom));
    translate: -50% 0;
    display: none;
    gap: 12px;
    pointer-events: none;
    max-width: calc(100vw - 24px);
}
.nse-hud[data-mode="fly"] .nse-fly-bar,
.nse-hud[data-mode="orbit"] .nse-orbit-bar,
.nse-hud[data-mode="low"] .nse-low-bar,
.nse-hud[data-mode="steer"] .nse-steer-bar { display: flex; }

.nse-hud-btn {
    width: clamp(92px, 9.6vw, 150px);
    height: clamp(100px, 11vw, 140px);
    padding: 8px 6px 10px;
    border-radius: 24px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    text-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
    background: var(--tone, var(--blue));
    box-shadow: 0 8px 0 var(--tone-lip, var(--blue-lip)), 0 14px 26px rgba(0, 0, 0, 0.4);
    -webkit-touch-callout: none; touch-action: manipulation;
}
.nse-hud-icon { width: clamp(46px, 4.6vw, 64px); height: clamp(46px, 4.6vw, 64px); border-radius: 18px; display: grid; place-items: center; background: rgba(255, 255, 255, 0.2); }
.nse-hud-icon .nse-icon { width: 74%; height: 74%; }
.nse-hud-label { font-size: clamp(16px, 1.55vw, 23px); font-weight: 800; line-height: 1.02; text-align: center; }
.nse-fly-bar .nse-hud-btn, .nse-orbit-bar .nse-hud-btn, .nse-low-bar .nse-hud-btn { width: clamp(124px, 13vw, 196px); height: clamp(112px, 12vw, 152px); }
.nse-hud-btn.nse-bounce { animation: nse-bounce 420ms cubic-bezier(.2, .9, .3, 1.4); }
@keyframes nse-bounce { 0% { scale: 1; } 30% { scale: 1.12; } 60% { scale: 0.97; } 100% { scale: 1; } }

.nse-callout {
    position: absolute;
    top: 15%;
    left: 50%;
    translate: -50% 0;
    font-size: clamp(40px, 6.5vw, 76px);
    font-weight: 800;
    white-space: nowrap;
    color: #ffffff;
    -webkit-text-stroke: 3px #0a0a18;
    paint-order: stroke fill;
    text-shadow: 0 6px 0 #0a0a18, 0 12px 24px rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
}
.nse-callout[data-tone="good"] { color: #9df0ff; }
.nse-callout.show { animation: nse-callout 2.8s cubic-bezier(.2, .9, .3, 1.3) forwards; }
@keyframes nse-callout {
    0% { opacity: 0; scale: 0.4; }
    12% { opacity: 1; scale: 1.1; }
    22% { scale: 1; }
    80% { opacity: 1; scale: 1; }
    100% { opacity: 0; scale: 0.96; }
}

/* The cockpit: a light canopy (thin rim, two slim corner struts, a low console behind the
   button bar, a faint tint at the glass's edges), under the controls. */
.nse-cockpit { position: fixed; inset: 0; pointer-events: none; z-index: 4; display: none; }
.nse-cockpit.show { display: block; }
.nse-cockpit svg { width: 100%; height: 100%; display: block; }
.nse-cp-rim { fill: #121a2e; opacity: 0.92; }
.nse-cp-bow { fill: none; stroke: #121a2e; stroke-width: 15px; stroke-linecap: round; opacity: 0.9; vector-effect: non-scaling-stroke; }
.nse-cp-bow-hi { fill: none; stroke: rgba(170, 205, 255, 0.3); stroke-width: 2px; vector-effect: non-scaling-stroke; }
.nse-cp-console { opacity: 0.96; }
.nse-cp-console-edge { fill: none; stroke: rgba(130, 190, 255, 0.45); stroke-width: 2px; vector-effect: non-scaling-stroke; }
.nse-cp-lights rect { fill: #3fe08a; opacity: 0.85; }
.nse-cp-lights rect:nth-child(2) { fill: #ffd84a; }
.nse-cp-lights rect:nth-child(3) { fill: #6ac8ff; }
.nse-cp-lights rect:nth-child(4) { fill: #ff8a5a; }

/* Where Next Stop is heading, or the place you are being asked about. */
.nse-marker { position: fixed; left: 0; top: 0; z-index: 6; pointer-events: none; display: none; }
.nse-marker.show { display: block; }
.nse-marker-ring {
    position: absolute; left: -36px; top: -36px; width: 72px; height: 72px;
    border-radius: 50%;
    border: 5px solid #9df0ff;
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.55), 0 0 18px rgba(157, 240, 255, 0.6);
    animation: nse-pulse 2s ease-in-out infinite;
}
.nse-marker[data-tone="ask"] .nse-marker-ring { border-color: var(--yellow); box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.55), 0 0 22px rgba(255, 216, 74, 0.7); }
.nse-marker-label {
    position: absolute; left: 50%; top: 44px; translate: -50% 0;
    white-space: nowrap;
    font-size: 24px; font-weight: 800;
    padding: 2px 14px; border-radius: 14px;
    background: rgba(5, 10, 30, 0.82);
    border: 2px solid rgba(157, 240, 255, 0.6);
}
@keyframes nse-pulse { 0%, 100% { scale: 1; } 50% { scale: 1.12; } }

/* ------------------------------------------------------------ prompt */

/* The prompt and the new-galaxy question sit low, where the (hidden) button bar was, so the
   place being asked about stays in view above them (the view is lifted too). */
.nse-screen-prompt, .nse-screen-bottom { align-items: flex-end; padding-bottom: max(16px, env(safe-area-inset-bottom)); background: none; }
.nse-screen-prompt .nse-card, .nse-screen-bottom .nse-card { transform-origin: center bottom; }
.nse-card-prompt, .nse-card-galaxy { width: min(900px, 96vw); text-align: center; border-color: rgba(255, 216, 74, 0.55); padding: 12px 22px 18px; }
.nse-prompt-kind { font-size: clamp(19px, 2.1vw, 24px); font-weight: 800; color: var(--yellow); letter-spacing: 0.04em; }
.nse-prompt-name { font-size: clamp(36px, 4.6vw, 54px); font-weight: 800; line-height: 1; text-shadow: 0 4px 0 rgba(0, 0, 0, 0.35); }
.nse-prompt-what { font-size: clamp(18px, 2vw, 23px); font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.nse-prompt-q { margin: 4px 0 12px; font-size: clamp(26px, 3.2vw, 36px); }
.nse-prompt-list { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.nse-prompt-list .nse-menu-item { min-height: 88px; font-size: clamp(28px, 3.4vw, 38px); justify-content: center; }
/* A long label ("Find Another Galaxy") wraps inside its button instead of pushing the icon out of it. */
.nse-prompt-list .nse-menu-label { flex: 0 1 auto; min-width: 0; line-height: 1.05; }
.nse-card-galaxy .nse-prompt-list .nse-menu-item { font-size: clamp(24px, 2.8vw, 34px); padding-right: 16px; }
.nse-prompt-list .nse-menu-label { flex: none; }

/* The fade for going down into (and up out of) an atmosphere. */
.nse-fade { position: fixed; inset: 0; z-index: 8; pointer-events: none; opacity: 0; background: #0a1030; transition: opacity 700ms ease; }
.nse-fade.show { opacity: 1; }

/* ------------------------------------------------------------ scanner */

.nse-screen-scanner { background: rgba(2, 4, 16, 0.25); }
.nse-card-scanner { width: min(1060px, 96vw); border-color: rgba(120, 230, 255, 0.5); }
.nse-scan-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.nse-scan-tag { font-size: 18px; font-weight: 800; letter-spacing: 0.3em; color: #9df0ff; }
.nse-scan-count { font-size: 20px; font-weight: 800; color: var(--muted); }
.nse-scan-body { display: grid; grid-template-columns: 1.1fr 1fr; gap: 20px; align-items: center; }
.nse-viewer {
    position: relative;
    aspect-ratio: 4 / 3;
    border-radius: 20px;
    overflow: hidden;
    border: 3px solid rgba(120, 230, 255, 0.55);
    background: #0a1230;
}
/* The viewer's own 3D canvas fills the window, crisp, on top of the card. */
.nse-viewer-gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
/* Scanner corner brackets: the look of a scanner without covering what is scanned. */
.nse-viewer-grid {
    position: absolute; inset: 10px; pointer-events: none; z-index: 1;
    background:
        linear-gradient(#9df0ff, #9df0ff) top left / 30px 4px no-repeat,
        linear-gradient(#9df0ff, #9df0ff) top left / 4px 30px no-repeat,
        linear-gradient(#9df0ff, #9df0ff) top right / 30px 4px no-repeat,
        linear-gradient(#9df0ff, #9df0ff) top right / 4px 30px no-repeat,
        linear-gradient(#9df0ff, #9df0ff) bottom left / 30px 4px no-repeat,
        linear-gradient(#9df0ff, #9df0ff) bottom left / 4px 30px no-repeat,
        linear-gradient(#9df0ff, #9df0ff) bottom right / 30px 4px no-repeat,
        linear-gradient(#9df0ff, #9df0ff) bottom right / 4px 30px no-repeat;
    opacity: 0.8;
}
.nse-scan-name { font-size: clamp(38px, 4.6vw, 56px); font-weight: 800; line-height: 1; }
.nse-scan-what { font-size: clamp(19px, 2.1vw, 24px); font-weight: 700; color: #9df0ff; margin: 4px 0 10px; }
.nse-scan-facts { margin: 0; padding-left: 1.1em; font-size: clamp(18px, 2vw, 23px); font-weight: 600; line-height: 1.32; }
.nse-scan-facts li { margin-bottom: 4px; }
.nse-scan-list { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }

/* ------------------------------------------------------------ alien call */

.nse-screen-hail { background: rgba(2, 4, 16, 0.2); }
.nse-card-hail { width: min(900px, 96vw); border-color: rgba(160, 255, 160, 0.5); }
.nse-hail-tag { font-size: 18px; font-weight: 800; letter-spacing: 0.3em; color: #a8ff9a; text-align: center; margin-bottom: 10px; animation: nse-blink 1.2s steps(2) infinite; }
@keyframes nse-blink { 50% { opacity: 0.45; } }
.nse-hail-body { display: grid; grid-template-columns: auto 1fr; gap: 22px; align-items: center; }
.nse-hail-face { width: clamp(200px, 28vw, 300px); height: auto; aspect-ratio: 1; border-radius: 24px; border: 4px solid rgba(160, 255, 160, 0.55); background: #142040; }
.nse-hail-who { font-size: clamp(20px, 2.2vw, 25px); font-weight: 800; color: #a8ff9a; }
.nse-hail-alien { font-size: clamp(30px, 3.6vw, 42px); font-weight: 800; font-style: italic; line-height: 1.1; margin: 6px 0 10px; word-break: break-word; }
.nse-hail-says { font-size: clamp(21px, 2.4vw, 27px); font-weight: 700; line-height: 1.25; }
.nse-hail-list { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }

/* ------------------------------------------------------------ explore system */

/* No card over the view: the camera is up over the system, each world is a ring in the picture
   (highlighted where it is), with a title box top left and a small panel along the bottom. */
.nse-screen-survey { align-items: flex-end; padding-bottom: max(16px, env(safe-area-inset-bottom)); background: none; }
.nse-pins { position: absolute; inset: 0; pointer-events: none; }
.nse-btn.nse-pin {
    position: absolute; left: 0; top: 0;
    width: 52px; height: 52px; padding: 0;
    border-radius: 50%;
    background: transparent;
    pointer-events: auto;
    transition: none;
}
.nse-pin.off, .nse-pin-you.off { visibility: hidden; }
.nse-pin-ring { position: absolute; inset: 0; border-radius: 50%; border: 3px solid rgba(225, 238, 255, 0.6); box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.5), inset 0 0 0 2px rgba(0, 0, 0, 0.35); }
.nse-pin-name {
    position: absolute; left: 50%; top: calc(100% + 5px); translate: -50% 0;
    white-space: nowrap; pointer-events: none;
    font-size: 19px; font-weight: 800; line-height: 1.1; color: #e8f0ff;
    text-shadow: 0 2px 3px #000, 0 0 6px #000, 0 0 2px #000;
}
/* The highlight: the hub's colour-and-band ring round the world itself; the name grows into a label. */
.nse-pin.nse-focus, .nse-pin.nse-focus-full {
    translate: 0 0;
    background: transparent !important;
    outline: 8px solid var(--focus-color, #ffd700) !important;
    outline-offset: 4px;
    box-shadow: 0 0 0 14px var(--focus-ink, #1a1008), 0 0 30px 14px rgba(0, 0, 0, 0.45) !important;
    z-index: 3;
}
.nse-pin.nse-focus .nse-pin-ring, .nse-pin.nse-focus-full .nse-pin-ring { border-color: transparent; box-shadow: none; }
.nse-pin.nse-focus-full .nse-pin-ring { background: var(--focus-color, #ffd700); opacity: 0.28; }
.nse-pin.nse-focus .nse-pin-name, .nse-pin.nse-focus-full .nse-pin-name {
    top: calc(100% + 22px);
    font-size: clamp(26px, 2.8vw, 34px);
    padding: 2px 16px; border-radius: 14px;
    background: var(--focus-color, #ffd700); color: var(--focus-ink, #1a1008);
    text-shadow: none;
    box-shadow: 0 0 0 3px var(--focus-ink, #1a1008), 0 8px 18px rgba(0, 0, 0, 0.5);
}
.nse-pin[data-narbe-scan-paused] { outline-style: dotted !important; }
/* A name that would land on another ring or name waits until its world is highlighted. */
.nse-pin-quiet:not(.nse-focus):not(.nse-focus-full) .nse-pin-name { visibility: hidden; }
/* You are here (the ship is a speck from up here). */
.nse-pin-you { position: absolute; left: 0; top: 0; width: 22px; height: 22px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 0 3px #10162a, 0 0 16px 4px rgba(255, 216, 74, 0.75); }
.nse-pin-you .nse-pin-name { color: var(--yellow); font-size: 18px; top: calc(100% + 3px); }

.nse-survey-head { z-index: 1; }
.nse-card-survey .nse-scan-status { top: auto; right: auto; bottom: calc(100% + 10px); left: 50%; translate: -50% 0; }
.nse-card-survey {
    width: min(1000px, 96vw);
    display: flex; align-items: center; gap: 18px;
    padding: 12px 16px 12px 18px;
    transform-origin: center bottom;
}
.nse-card-survey .nse-menu-item { width: auto; flex: none; min-width: 190px; margin-bottom: 6px; }
.nse-survey-cap { flex: 1; min-width: 0; display: flex; align-items: center; gap: 16px; min-height: 76px; }
.nse-cap-orb { flex: none; display: grid; place-items: center; width: 64px; height: 64px; }
.nse-survey-cap[data-kind="none"] .nse-cap-orb, .nse-survey-cap[data-kind="back"] .nse-cap-orb { display: none; }
.nse-cap-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.08; }
.nse-cap-name { font-size: clamp(26px, 3vw, 38px); font-weight: 800; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nse-cap-what { font-size: clamp(17px, 1.8vw, 22px); font-weight: 700; color: #9df0ff; }
.nse-cap-tags { font-size: clamp(15px, 1.6vw, 19px); font-weight: 700; color: var(--yellow); }
.nse-cap-tags:empty { display: none; }

.nse-orb { position: relative; flex: none; width: 60px; height: 60px; border-radius: 50%; box-shadow: inset -8px -6px 14px rgba(0, 0, 0, 0.55); }
.nse-orb-star { box-shadow: 0 0 18px 4px var(--glow, #fff); }
.nse-orb-pair::after { content: ''; position: absolute; width: 24px; height: 24px; right: -10px; top: -6px; border-radius: 50%; background: radial-gradient(circle, #fff, var(--glow, #fc8) 60%); box-shadow: 0 0 10px var(--glow, #fc8); }
.nse-orb-hole { background: #000; box-shadow: 0 0 0 4px var(--glow, #fb7), 0 0 18px 6px var(--glow, #fb7); }
.nse-orb-ring { position: absolute; left: -14px; right: -14px; top: 23px; height: 14px; border-radius: 50%; border: 3px solid rgba(230, 210, 170, 0.85); transform: rotate(-14deg); }
@media (max-width: 760px) {
    .nse-card-survey { flex-wrap: wrap; }
    .nse-card-survey .nse-menu-item { width: 100%; }
}

/* ------------------------------------------------------------ galaxy map */

.nse-card-map { width: min(1040px, 96vw); }
.nse-map-body { display: grid; grid-template-columns: 1.35fr 1fr; gap: 20px; align-items: center; }
.nse-map-canvas { width: 100%; height: auto; aspect-ratio: 4 / 3; border-radius: 20px; border: 3px solid rgba(150, 190, 255, 0.4); background: #03050f; }
.nse-map-list .nse-menu-item { min-height: 92px; }

/* ------------------------------------------------------------ pause, help */

.nse-pause-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.nse-pause-list .nse-menu-item { min-height: 70px; font-size: clamp(20px, 2.4vw, 26px); }
.nse-card-pause { width: min(760px, 94vw); }

.nse-help-title {
    display: flex; align-items: center; justify-content: center; gap: 14px;
    width: 100%; margin-bottom: 12px; padding: 10px; border-radius: 20px;
    background: rgba(255, 255, 255, 0.1);
    font-size: clamp(28px, 3.6vw, 40px); font-weight: 800;
}
.nse-card-help { width: min(760px, 94vw); }
.nse-help-body { font-size: clamp(17px, 1.95vw, 22px); font-weight: 600; line-height: 1.32; margin-bottom: 14px; }
.nse-help-body p { margin: 0 0 9px; }
.nse-help-body b { color: var(--yellow); }

/* ------------------------------------------------------------ logbook */

.nse-card-log { width: min(1100px, 96vw); padding: 16px 22px 20px; }
.nse-log-head { display: flex; align-items: baseline; justify-content: center; gap: 18px; }
.nse-log-head .nse-title { margin-bottom: 4px; }
.nse-page-label { font-size: 22px; font-weight: 800; color: var(--muted); }
.nse-log-stats { margin-bottom: 12px; }
.nse-log-empty { font-size: clamp(20px, 2.4vw, 26px); margin: 18px 10px 8px; }
.nse-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.nse-grid[hidden] { display: none; }
.nse-tile {
    display: flex;
    flex-direction: column;
    padding: 8px 8px 10px;
    border-radius: 22px;
    background: #e9eefc;
    color: #141a33;
    box-shadow: 0 6px 0 #9aa8d0, 0 12px 20px rgba(0, 0, 0, 0.3);
    text-align: left;
    margin-bottom: 6px;
}
.nse-tile-empty { visibility: hidden; }
.nse-thumb {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 10;
    border-radius: 15px;
    overflow: hidden;
    background: radial-gradient(ellipse at 30% 30%, #1d2c66, #050818);
}
.nse-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nse-thumb.waiting { display: grid; place-items: center; color: #9df0ff; }
.nse-thumb.waiting .nse-icon { width: 34%; height: 34%; }
.nse-tile-cap { display: flex; flex-direction: column; padding: 6px 6px 0; }
.nse-tile-name { font-size: clamp(20px, 2.2vw, 27px); font-weight: 800; line-height: 1.1; }
.nse-tile-count { font-size: clamp(14px, 1.5vw, 18px); font-weight: 700; color: #4a5378; line-height: 1.2; }
.nse-log-foot { display: flex; gap: 16px; margin-top: 14px; }
.nse-log-foot .nse-menu-item { flex: 1; }

.nse-card-entry { width: min(1040px, 96vw); }
.nse-entry-body { display: grid; grid-template-columns: 1.1fr 1fr; gap: 20px; align-items: center; }
.nse-entry-pic { aspect-ratio: 16 / 10; }
.nse-entry-name { text-align: left; margin-bottom: 4px; }
.nse-entry-what { font-size: clamp(20px, 2.3vw, 26px); font-weight: 800; color: #9df0ff; }
.nse-entry-where { font-size: clamp(17px, 1.9vw, 21px); font-weight: 700; color: var(--muted); margin-bottom: 10px; }
.nse-entry-facts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.nse-chip { display: inline-flex; gap: 8px; align-items: baseline; padding: 5px 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.1); font-size: clamp(16px, 1.7vw, 20px); font-weight: 700; }
.nse-chip b { color: var(--yellow); }
.nse-entry-life { font-size: clamp(17px, 1.9vw, 21px); font-weight: 700; color: #a8ff9a; }
.nse-entry-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 16px; }
.nse-entry-list .nse-menu-item { min-height: 76px; font-size: clamp(19px, 2.1vw, 25px); padding-right: 12px; }

/* ------------------------------------------------------------ field guide */

.nse-card-guide { width: min(1100px, 96vw); padding: 18px 22px 20px; }
.nse-guide-stats { margin-bottom: 14px; }
.nse-guide-cats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.nse-guide-cat {
    display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
    min-height: 150px; padding: 14px 14px 16px; border-radius: 22px;
    background: var(--tone, var(--slate));
    box-shadow: 0 6px 0 var(--tone-lip, var(--slate-lip)), 0 10px 18px rgba(0, 0, 0, 0.3);
    text-align: left; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); margin-bottom: 6px;
}
.nse-guide-cat[data-tone="green"] { --tone: var(--green); --tone-lip: var(--green-lip); }
.nse-guide-cat[data-tone="blue"] { --tone: var(--blue); --tone-lip: var(--blue-lip); }
.nse-guide-cat[data-tone="plum"] { --tone: var(--plum); --tone-lip: var(--plum-lip); }
.nse-guide-cat[data-tone="teal"] { --tone: var(--teal); --tone-lip: var(--teal-lip); }
.nse-guide-cat[data-tone="help"] { --tone: var(--help); --tone-lip: var(--help-lip); }
.nse-guide-cat-text { display: flex; flex-direction: column; width: 100%; }
.nse-guide-cat-name { font-size: clamp(22px, 2.4vw, 28px); font-weight: 800; line-height: 1.05; }
.nse-guide-cat-count { font-size: clamp(16px, 1.7vw, 20px); font-weight: 800; opacity: 0.92; }
.nse-guide-bar { display: block; height: 10px; margin-top: 8px; border-radius: 6px; background: rgba(0, 0, 0, 0.3); overflow: hidden; }
.nse-guide-bar-fill { display: block; height: 100%; border-radius: 6px; background: var(--yellow); }
.nse-focus-full .nse-guide-bar-fill { background: var(--focus-ink, #1a1008); }
.nse-guide-back { margin-top: 16px; }
.nse-tile-unfound { background: #cbd2e8; }
.nse-tile-unfound .nse-tile-name { color: #36406a; }
.nse-thumb.unfound { background: radial-gradient(ellipse at 30% 30%, #18204a, #070a1c); }
.nse-thumb.portrait { background: radial-gradient(ellipse at 50% 40%, #26386f, #070b20); }
.nse-thumb.portrait img { object-fit: contain; }
.nse-thumb.waiting.unfound { color: #4a5890; }
.nse-guide-orb { width: auto; height: 62%; aspect-ratio: 1; }
.nse-orb-unknown { display: grid; place-items: center; background: radial-gradient(circle at 35% 30%, #3a4677, #1a2148 60%, #0a0e24); }
.nse-orb-neb { box-shadow: 0 0 26px 12px var(--glow, #f8a); }
.nse-orb-q { font-size: 34px; font-weight: 800; color: #8fa0d8; line-height: 1; }
.nse-thumb-q { position: absolute; right: 12px; bottom: 6px; }
.nse-guide-tag { font-size: clamp(16px, 1.7vw, 20px); font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--yellow); }
.nse-gitem-list { grid-template-columns: repeat(2, 1fr); }
.nse-guide-pic.waiting .nse-icon { width: 30%; height: 30%; }
.nse-callout[data-tone="rare"] { color: #ffe27a; }
.nse-callout[data-tone="find"] { color: #b8ffb0; }
@media (max-width: 760px) {
    .nse-guide-cats { grid-template-columns: repeat(2, 1fr); }
    .nse-guide-cat { min-height: 110px; }
}

/* -------------------------------------------------------------- settings */

.nse-card-settings { width: min(1040px, 96vw); }
.nse-settings-list { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 900px) and (min-aspect-ratio: 4/3) {
    .nse-settings-list { grid-template-columns: 1fr 1fr; grid-template-rows: repeat(var(--rows, 8), auto); grid-auto-flow: column; column-gap: 16px; }
}
.nse-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    min-height: 60px; padding: 8px 18px; border-radius: 16px;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18);
    font-size: clamp(19px, 2vw, 24px); font-weight: 800; text-align: left;
}
.nse-row-value { display: flex; align-items: center; gap: 8px; color: var(--yellow); font-size: 0.92em; text-align: right; }
.nse-row-nav { background: var(--slate); }
.nse-row-danger { background: rgba(226, 69, 60, 0.35); }
.nse-row-armed { background: rgba(226, 69, 60, 0.8); }
.nse-swatch { width: 22px; height: 22px; border-radius: 50%; border: 3px solid #fff; }

/* ------------------------------------------------------------- highlight */

.nse-focus {
    outline: 7px solid var(--focus-color, #ffd700) !important;
    outline-offset: 3px;
    box-shadow: 0 0 0 12px var(--focus-ink, #1a1008), 0 12px 28px rgba(0, 0, 0, 0.5) !important;
    translate: 0 -4px;
    z-index: 2;
}
.nse-focus-full {
    background: var(--focus-color, #ffd700) !important;
    color: var(--focus-ink, #1a1008) !important;
    outline: 7px solid var(--focus-color, #ffd700) !important;
    outline-offset: 3px;
    box-shadow: 0 0 0 12px var(--focus-ink, #1a1008), 0 12px 28px rgba(0, 0, 0, 0.5) !important;
    translate: 0 -4px;
    z-index: 2;
    text-shadow: none;
}
.nse-focus-full .nse-row-value, .nse-focus-full .nse-tile-count, .nse-focus-full .nse-pause-label { color: var(--focus-ink, #1a1008); }
.nse-focus-full .nse-icon-chip, .nse-focus-full .nse-hud-icon { background: transparent; box-shadow: inset 0 0 0 3px var(--focus-ink, #1a1008); }
.nse-tile.nse-focus, .nse-tile.nse-focus-full { scale: 1.03; }
/* Auto Scan paused by the Space brake: the same highlight, dotted. */
.nse-focus[data-narbe-scan-paused], .nse-focus-full[data-narbe-scan-paused] { outline-style: dotted !important; }
/* The help title is a button too: keep it clearly a choice. */
.nse-help-title.nse-focus-full .nse-icon-chip { box-shadow: inset 0 0 0 3px var(--focus-ink, #1a1008); }

/* ------------------------------------------------------------- smaller */

@media (max-width: 1100px) {
    .nse-bar { gap: 8px; }
    .nse-scan-body, .nse-map-body, .nse-entry-body { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
    .nse-card { padding: 14px 14px 18px; border-radius: 24px; }
    .nse-grid { gap: 10px; }
    .nse-tile { padding: 5px 5px 7px; border-radius: 16px; }
    .nse-bar { flex-wrap: wrap; justify-content: center; width: calc(100vw - 20px); }
    .nse-hud-btn { width: 86px; height: 92px; border-radius: 18px; }
    .nse-hud-label { font-size: 14px; }
    .nse-pause-list { grid-template-columns: 1fr; }
    .nse-scan-body, .nse-map-body, .nse-entry-body, .nse-hail-body { grid-template-columns: 1fr; }
    .nse-entry-list { grid-template-columns: 1fr 1fr; }
    .nse-screen-menu { justify-content: center; padding-left: 10px; }
    .nse-card-menu { transform-origin: center center; }
    .nse-info { max-width: calc(100vw - 140px); }
}
@media (max-height: 600px) {
    .nse-hud-btn { height: 88px; }
    .nse-hud-icon { width: 40px; height: 40px; }
    .nse-info { padding: 6px 10px 8px 12px; }
    .nse-info-name { font-size: 20px; }
    .nse-info-sub { font-size: 15px; }
    .nse-pause-btn { width: 76px; height: 76px; }
}

/* Calm motion, or the system's reduced-motion setting: no bounces, pulses or floats. */
#nse[data-motion="calm"] .nse-card, #nse[data-motion="calm"] .nse-logo, #nse[data-motion="calm"] .nse-marker-ring, #nse[data-motion="calm"] .nse-hail-tag { animation: none; }
#nse[data-motion="calm"] .nse-hud-btn.nse-bounce { animation: none; }
#nse[data-motion="calm"] .nse-callout.show { animation: nse-callout-calm 2.8s ease forwards; }
@keyframes nse-callout-calm { 0% { opacity: 0; } 10%, 80% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
    .nse-card, .nse-logo, .nse-marker-ring, .nse-hail-tag, .nse-loading-orbit span { animation: none; }
    .nse-callout.show { animation: nse-callout-calm 2.8s ease forwards; }
}
