/* WebGPU Entities: the shell, the engine's HUD, and each world's HUD (scoped by .fhud[data-world]) */
:root {
    --bg: #030507;
    --panel: rgba(6, 12, 16, 0.8);
    --line: rgba(110, 220, 255, 0.28);
    --accent: #6edcff;
    --ok: #62f08a;
    --warn: #ffc94a;
    --danger: #ff4a3d;
    --text: #d6e6ee;
    --muted: #7d95a3;
}
* { box-sizing: border-box; }
html, body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: 'Rajdhani', sans-serif;
    user-select: none;
}
canvas#view { display: block; width: 100vw; height: 100vh; touch-action: none; cursor: crosshair; }
canvas#view.drag { cursor: grabbing; }

.panel {
    position: fixed;
    background: var(--panel);
    border: 1px solid var(--line);
    padding: 8px 10px;
    font-family: 'Share Tech Mono', monospace;
    font-size: 12px;
    line-height: 1.35;
    pointer-events: none;
}
.panel .t, .t { color: var(--accent); letter-spacing: 0.12em; }
.panel .on, .on { color: var(--ok); }
.panel .off { color: var(--danger); }
.panel .w, .w { color: var(--warn); }
.panel .m, .m { color: var(--muted); }
.panel .d { color: var(--danger); }

/* ------------------------------------------------------------------------------------------- engine bar */
#engine-bar {
    position: fixed; top: 12px; right: 12px; z-index: 40; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    justify-content: flex-end; max-width: calc(100vw - 24px);
    font-family: 'Share Tech Mono', monospace; font-size: 12px; color: var(--muted);
}
#engine-bar .brand { color: var(--accent); letter-spacing: 0.14em; }
#engine-bar button.handheld {
    background: var(--panel); border: 1px solid var(--line); color: var(--muted); font: inherit; padding: 4px 10px; cursor: pointer;
    opacity: 0.75; transition: opacity 0.2s, border-color 0.2s;
}
#engine-bar button.handheld:hover, #engine-bar button.handheld.on { opacity: 1; border-color: var(--accent); }
#engine-bar button.handheld .key { color: var(--text); }
/* the fallback bar (the page could not start) */
#engine-bar select { background: #0a141a; color: var(--text); border: 1px solid var(--line); font: inherit; padding: 2px 6px; max-width: 300px; }
#engine-bar .gpu-pick { display: flex; align-items: center; gap: 6px; }

#engine-side { position: fixed; top: 10px; left: 10px; z-index: 20; display: flex; flex-direction: column; gap: 6px; pointer-events: none; max-height: calc(100vh - 20px); overflow: hidden; }
#engine-side .panel { position: static; white-space: pre; font-size: 11px; line-height: 1.35; max-width: 46vw; overflow: hidden; }
#engine-toast { top: 50%; left: 50%; transform: translate(-50%, -50%); color: var(--warn); font-size: 16px; display: none; text-align: center; z-index: 30; white-space: pre-wrap; }

#fallback { display: none; position: fixed; inset: 0; z-index: 35; align-items: center; justify-content: center; background: var(--bg); padding: 16px; }
#fallback.show { display: flex; }
.card { max-width: 560px; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--danger); padding: 14px 16px; }
.card .tag { font-family: 'Share Tech Mono', monospace; font-size: 11px; letter-spacing: 0.12em; color: var(--danger); }
.card h1 { margin: 4px 0 2px; font-size: 24px; letter-spacing: 0.04em; text-transform: uppercase; }
.card .desc { margin: 0 0 12px; font-size: 14px; color: var(--muted); }
#fallback pre { white-space: pre-wrap; font-family: 'Share Tech Mono', monospace; font-size: 12px; color: var(--danger); background: rgba(0,0,0,0.4); padding: 10px; margin: 10px 0 0; max-height: 40vh; overflow: auto; }

/* ------------------------------------------------------------------------------------------- feature HUDs */
/* what a world still puts on the screen: in-world labels, toasts, a crosshair (its options and readouts are on the handheld) */
.fhud.unfocused .panel { display: none !important; }
.fhud .panel:empty { display: none !important; }
.fhud canvas.labels { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; }
.fhud [data-hud=toast] { top: 50%; left: 50%; transform: translate(-50%, -50%); color: var(--warn); font-size: 16px; display: none; text-align: center; z-index: 20; white-space: pre-wrap; max-width: 80vw; }
/* while the handheld is out, the in-world labels step back */
#world-huds { transition: opacity 0.25s; }
body.handheld-up #world-huds canvas.labels { opacity: 0.35; }
/* portal: crosshair */
.fhud[data-world=portal] [data-hud=crosshair] { position: fixed; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border: 1px solid rgba(255,255,255,0.6); border-radius: 50%; pointer-events: none; }
.fhud[data-world=portal].unfocused [data-hud=crosshair] { display: none !important; }

@media (max-width: 700px) {
    #engine-bar { top: auto; bottom: 12px; }
}
