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

body {
  overflow: hidden;
  background: radial-gradient(ellipse at center, #2a2a2a 0%, #111 100%);
  font-family: sans-serif;
}

canvas {
  display: block;
  position: fixed;
  inset: 0;
}

#loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #111;
  color: #fff;
  z-index: 100;
  gap: 16px;
}

#loading.hidden {
  display: none;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#status-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 13px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 50;
  white-space: nowrap;
}

#status-bar.visible {
  opacity: 1;
}

/* ── Help button ─────────────────────────────────────────── */
#help-btn {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(0,0,0,.55);
  color: rgba(255,255,255,.75);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s, border-color .12s;
  backdrop-filter: blur(4px);
}
#help-btn:hover { background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.5); }
#help-btn.active { background: #ffd200; color: #111; border-color: #ffd200; }

/* ── Mav / GitHub link ───────────────────────────────────── */
#mav-link {
  position: fixed;
  top: 50px;
  left: 12px;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(0,0,0,.45);
  opacity: 0.6;
  transition: opacity .15s, border-color .15s, background .15s;
  backdrop-filter: blur(4px);
  text-decoration: none;
}
#mav-link svg { width: 24px; height: 16px; display: block; }
#mav-link:hover { opacity: 1; border-color: rgba(255,255,255,.35); background: rgba(0,0,0,.65); }

/* ── Help backdrop ───────────────────────────────────────── */
#help-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 299;
}
#help-backdrop.open { display: block; }

/* ── Help panel (left-side drawer) ───────────────────────── */
#help-panel {
  position: fixed;
  left: 0;
  top: 0;
  width: 340px;
  height: 100vh;
  background: #150929;
  border-right: 1px solid rgba(255,255,255,.1);
  z-index: 300;
  display: flex;
  flex-direction: column;
  transform: translateX(-105%);
  transition: transform .2s ease;
  box-shadow: 8px 0 32px rgba(0,0,0,.6);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
#help-panel.open { transform: translateX(0); }

.hp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  height: 46px;
  border-bottom: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
  color: #ffd200;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.hp-close {
  background: none;
  border: none;
  color: rgba(255,255,255,.4);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 7px;
  border-radius: 4px;
  line-height: 1;
  font-family: inherit;
}
.hp-close:hover { color: #fff; background: rgba(255,255,255,.1); }

.hp-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.2) transparent;
}
.hp-body::-webkit-scrollbar { width: 5px; }
.hp-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 3px; }

.hp-section {
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.hp-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.hp-section h3 {
  margin: 0 0 9px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(255,255,255,.35);
}

.hp-section p { margin: 0 0 7px; }
.hp-section p,
.hp-section li {
  font-size: 12px;
  color: rgba(255,255,255,.78);
  line-height: 1.55;
}
.hp-section ol,
.hp-section ul { margin: 0 0 7px; padding-left: 17px; }
.hp-section li { margin-bottom: 3px; }
.hp-section strong { color: #fff; font-weight: 600; }

.hp-section kbd {
  font-family: inherit;
  font-size: 10px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 3px;
  padding: 1px 4px;
  color: #fff;
  white-space: nowrap;
}

/* Screenshot guide — highlighted */
.hp-section--highlight {
  background: rgba(255,210,0,.04);
  border: 1px solid rgba(255,210,0,.18) !important;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 18px;
}
.hp-section--highlight.hp-section { border-bottom: none; }
.hp-section--highlight h3 { color: rgba(255,210,0,.6); }

.hp-sub {
  font-size: 10px !important;
  color: rgba(255,255,255,.4) !important;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 9px 0 5px !important;
}

.hp-tip {
  margin-top: 9px !important;
  font-size: 11px !important;
  background: rgba(255,210,0,.07);
  border-left: 2px solid rgba(255,210,0,.5);
  padding: 5px 9px;
  border-radius: 0 4px 4px 0;
  color: rgba(255,255,255,.65) !important;
}

/* OS-specific shortcut visibility */
#help-panel.os-mac .os-win { display: none; }
#help-panel.os-win .os-mac { display: none; }

#hp-os-toggle {
  display: flex;
  gap: 3px;
  margin-left: auto;
  margin-right: 10px;
}
.hp-os-btn {
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.15);
  color: rgba(255,255,255,.45);
  border-radius: 4px;
  padding: 2px 9px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  cursor: pointer;
  font-family: inherit;
  text-transform: uppercase;
  transition: background .12s, color .12s;
}
.hp-os-btn:hover { background: rgba(255,255,255,.13); color: rgba(255,255,255,.8); }
.hp-os-btn.active {
  background: rgba(255,210,0,.18);
  border-color: rgba(255,210,0,.4);
  color: #ffd200;
}

/* ── Export frame safe-area overlay ─────────────────────── */
#frame-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

#frame-mask-l,
#frame-mask-r {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.45);
  transition: width 0.1s;
}
#frame-mask-l { left: 0; }
#frame-mask-r { right: 0; }

#frame-border {
  position: absolute;
  top: 0;
  bottom: 0;
  border: 1px solid rgba(0, 204, 255, 0.6);
  box-sizing: border-box;
}

#frame-label {
  position: absolute;
  top: 8px;
  font-size: 10px;
  font-family: monospace;
  color: rgba(0, 204, 255, 0.85);
  background: rgba(0, 0, 0, 0.55);
  padding: 2px 7px;
  border-radius: 3px;
  white-space: nowrap;
  letter-spacing: .03em;
}

/* ── lil-gui theme ───────────────────────────────────────── */
.lil-gui {
  --background-color: #1c1c1c;
  --text-color: #ddd;
  --title-background-color: #111;
  --title-text-color: #fff;
  --widget-color: #2c2c2c;
  --hover-color: #383838;
  --focus-color: #444;
  --number-color: #7ec8e3;
  --string-color: #b5e488;
}
