/* Grab3D web demos: shared UI. System fonts only, no external requests. */
:root {
  --ink: #0d1016;
  --panel: rgb(16 19 27 / 0.86);
  --panel-2: rgb(29 34 46 / 0.92);
  --line: rgb(255 255 255 / 0.12);
  --text: #f3f1ea;
  --muted: #b9bcc6;
  --accent: #c8f542;
  --accent-ink: #11140c;
  --hud: #45d9cf;
  --warm: #ffcf8a;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1a1d24; color: var(--text); font: 15px/1.45 var(--font); }
body { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
.g3d-canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; }
.g3d-hidden { display: none !important; }
button { font: inherit; color: inherit; }

/* full screen overlays (start, pause, end) */
.g3d-screen { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; overflow: auto;
  background: radial-gradient(ellipse at 50% 35%, rgb(255 214 160 / 0.16), rgb(10 12 18 / 0.72) 70%); }
#g3d-start { background: radial-gradient(ellipse at 50% 30%, rgb(255 205 150 / 0.22), rgb(10 12 18 / 0.55) 75%); }
.g3d-card { width: min(520px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 22px 22px 18px;
  box-shadow: 0 24px 60px -20px rgb(0 0 0 / 0.7); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.g3d-card h1, .g3d-card h2 { margin: 2px 0 6px; font-size: clamp(24px, 5vw, 34px); line-height: 1.05; letter-spacing: -0.02em; }
.g3d-card h2 { font-size: 26px; }
.g3d-tag { margin: 0 0 14px; color: var(--muted); }
.g3d-brand { display: inline-flex; align-items: center; gap: 6px; color: var(--accent); font-weight: 700; font-size: 13px; letter-spacing: 0.12em;
  text-transform: uppercase; text-decoration: none; }
.g3d-brand::before { content: ''; width: 10px; height: 10px; border-radius: 3px; background: var(--accent); }
body.g3d-embed .g3d-brand { display: none; }
.g3d-progress { height: 8px; border-radius: 99px; background: rgb(255 255 255 / 0.1); overflow: hidden; margin: 14px 0 6px; }
.g3d-progress > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--hud), var(--accent)); border-radius: 99px; transition: width 0.25s; }
.g3d-loadtxt { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.g3d-ready .g3d-progress, .g3d-ready .g3d-loadtxt { opacity: 0.5; }
.g3d-failed .g3d-loadtxt { color: #ff9b8a; }
.g3d-btn { appearance: none; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); padding: 11px 18px; border-radius: 999px;
  font-weight: 650; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; }
.g3d-btn:hover { border-color: rgb(255 255 255 / 0.3); }
.g3d-btn:focus-visible, .g3d-ibtn:focus-visible, .g3d-slot:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.g3d-btn-accent { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.g3d-btn-accent:hover { background: #d8ff62; }
.g3d-btn:disabled { opacity: 0.45; cursor: progress; }
#g3d-play { width: 100%; font-size: 18px; padding: 14px; }
.g3d-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.g3d-row .g3d-btn { flex: 1 1 140px; }
.g3d-ctl-h { margin: 14px 0 6px; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--hud); font-weight: 700; }
.g3d-keys { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font-size: 14px; }
.g3d-keys dt { font-weight: 700; color: var(--warm); white-space: nowrap; }
.g3d-keys dd { margin: 0; color: var(--muted); }
.g3d-cta { margin-top: 14px; padding: 14px; border-radius: 14px; background: rgb(200 245 66 / 0.08); border: 1px solid rgb(200 245 66 / 0.35); }
.g3d-cta-t { font-weight: 750; font-size: 16px; }
.g3d-cta-n { margin: 2px 0; }
.g3d-cta-s { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.g3d-cta .g3d-btn { width: 100%; }
.g3d-stats { font-size: 16px; margin: 8px 0; }
.g3d-stats b { color: var(--accent); }
.g3d-stats table { border-collapse: collapse; width: 100%; }
.g3d-stats td { padding: 3px 0; border-bottom: 1px solid var(--line); }
.g3d-stats td:last-child { text-align: right; font-variant-numeric: tabular-nums; }

/* in game layer */
.g3d-layer { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.g3d-layer > * { pointer-events: auto; }
.g3d-hud { position: absolute; left: max(10px, env(safe-area-inset-left)); top: max(10px, env(safe-area-inset-top)); display: flex; flex-wrap: wrap; gap: 8px; pointer-events: none; max-width: calc(100% - 180px); }
.g3d-pill { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-weight: 700; font-variant-numeric: tabular-nums;
  display: inline-flex; align-items: center; gap: 6px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); white-space: nowrap; }
.g3d-pill small { font-weight: 500; color: var(--muted); }
.g3d-hud-r { position: absolute; right: max(10px, env(safe-area-inset-right)); top: max(10px, env(safe-area-inset-top)); display: flex; gap: 8px; }
.g3d-ibtn { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 18px; display: grid; place-items: center; }
.g3d-bottom { position: absolute; left: 50%; transform: translateX(-50%); bottom: max(10px, env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: flex-end; max-width: calc(100% - 20px); }
.g3d-toast { position: absolute; left: 50%; top: 64px; transform: translate(-50%, -10px); background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 16px; font-weight: 650; opacity: 0; transition: opacity 0.2s, transform 0.2s; pointer-events: none; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; }
.g3d-toast.on { opacity: 1; transform: translate(-50%, 0); }

/* toolbar with model thumbnails */
.g3d-bar { display: flex; gap: 6px; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow-x: auto; max-width: 100%;
  scrollbar-width: thin; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); touch-action: pan-x; }
.g3d-slot { flex: 0 0 auto; width: 64px; height: 64px; border-radius: 12px; border: 2px solid transparent; background: rgb(255 255 255 / 0.06); cursor: pointer; padding: 2px;
  display: grid; place-items: center; position: relative; font-size: 24px; }
.g3d-slot img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.g3d-slot.on { border-color: var(--accent); background: rgb(200 245 66 / 0.14); }
.g3d-slot .k { position: absolute; left: 4px; top: 2px; font-size: 10px; font-weight: 800; color: var(--muted); }
.g3d-slot .c { position: absolute; right: 4px; bottom: 2px; font-size: 11px; font-weight: 800; color: var(--warm); }
.g3d-tabs { display: flex; gap: 4px; margin-bottom: 6px; justify-content: center; flex-wrap: wrap; }
.g3d-tab { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-weight: 650; font-size: 13px; min-height: 34px; }
.g3d-tab.on { background: var(--accent); color: var(--accent-ink); }
.g3d-col { display: flex; flex-direction: column; align-items: center; max-width: 100%; }

/* touch controls */
.g3d-touch-layer { position: absolute; inset: auto 0 0 0; height: 0; pointer-events: none; }
.g3d-touch-layer > * { pointer-events: auto; }
.g3d-stick { position: fixed; left: max(18px, env(safe-area-inset-left)); bottom: max(22px, env(safe-area-inset-bottom)); width: 128px; height: 128px; border-radius: 50%;
  background: rgb(255 255 255 / 0.1); border: 2px solid rgb(255 255 255 / 0.22); touch-action: none; display: none; }
.g3d-knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: rgb(255 255 255 / 0.55); }
.g3d-tbtns { position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(22px, env(safe-area-inset-bottom)); display: none; gap: 12px; align-items: flex-end; flex-direction: row-reverse; }
.g3d-tbtn { width: 64px; height: 64px; border-radius: 50%; border: 2px solid rgb(255 255 255 / 0.25); background: rgb(16 19 27 / 0.6); font-weight: 800; font-size: 15px; touch-action: none; }
.g3d-tbtn.big { width: 82px; height: 82px; font-size: 18px; }
.g3d-tbtn.on { background: var(--accent); color: var(--accent-ink); }
body.g3d-touch .g3d-stick, body.g3d-touch .g3d-tbtns { display: flex; }
body.g3d-touch .g3d-stick { display: block; }
/* floating joystick: an invisible zone over the lower left, the stick shows where the thumb lands */
.g3d-stickzone { position: fixed; left: 0; bottom: 0; width: 50%; height: 46%; touch-action: none; display: none; }
body.g3d-touch .g3d-stickzone { display: block; }
.g3d-stick.g3d-float { position: fixed; left: max(18px, env(safe-area-inset-left)); top: auto; bottom: max(22px, env(safe-area-inset-bottom)); opacity: 0.45; transition: opacity 0.15s; }
.g3d-stick.g3d-float.on { bottom: auto; opacity: 1; }
body.g3d-touch .g3d-bottom.g3d-raise { bottom: calc(max(22px, env(safe-area-inset-bottom)) + 150px); }
.g3d-bar::-webkit-scrollbar { height: 4px; }
.g3d-bar::-webkit-scrollbar-thumb { background: rgb(255 255 255 / 0.25); border-radius: 4px; }
.g3d-tip { position: fixed; z-index: 11; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 4px 10px; font-size: 13px; font-weight: 650;
  transform: translate(14px, 14px); white-space: nowrap; }

@media (max-width: 600px) {
  .g3d-card { padding: 18px 16px 14px; border-radius: 16px; }
  .g3d-slot { width: 54px; height: 54px; }
  .g3d-pill { padding: 5px 10px; font-size: 13px; }
  .g3d-ibtn { width: 38px; height: 38px; }
  .g3d-hud { max-width: calc(100% - 150px); }
  .g3d-toast { top: 27vh; font-size: 13px; }
  .g3d-pill small { font-size: 11px; }
}
