:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #05070b;
  color: #eef2f7;
}

* { box-sizing: border-box; }

html, body, #viewport {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background:
    radial-gradient(circle at 50% 18%, rgba(48, 65, 91, 0.18), transparent 42%),
    #05070b;
}

canvas { display: block; }

/* ---------- barra superior ---------- */

.topbar {
  position: fixed;
  z-index: 10;
  top: 18px;
  left: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.brand, .status, .action {
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(11, 15, 23, .78);
  box-shadow: 0 16px 36px rgba(0,0,0,.32);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  border-radius: 13px;
}

.brand-mark {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffb45e;
  box-shadow: 0 0 16px rgba(255,180,94,.85);
}

.brand-copy { line-height: 1.05; }
.brand-copy strong { display: block; font-size: 12px; letter-spacing: .04em; }
.brand-copy span { color: #8792a4; font-size: 10px; }

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(360px, 38vw);
  padding: 10px 13px;
  border-radius: 13px;
  color: #aab4c3;
  font-size: 11px;
}

.status-dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f5bd4f;
  box-shadow: 0 0 10px rgba(245,189,79,.6);
}

.status.ready .status-dot { background: #5bd69e; box-shadow: 0 0 10px rgba(91,214,158,.6); }
.status.error .status-dot { background: #ff6d78; box-shadow: 0 0 10px rgba(255,109,120,.6); }
#status-text { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.action {
  pointer-events: auto;
  cursor: pointer;
  border-radius: 13px;
  padding: 10px 13px;
  color: #dbe8ff;
  font: inherit;
  font-size: 11px;
  appearance: none;
  outline: none;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}

.action:hover { border-color: rgba(255,180,94,.45); background: rgba(38,30,22,.9); transform: translateY(-1px); }
.action input { display: none; }

/* ---------- loader ---------- */

.loading {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(4,6,10,.74);
  backdrop-filter: blur(10px);
  transition: opacity .4s ease, visibility .4s ease;
}

.loading.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.loader-card {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 300px;
  padding: 18px 20px;
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 18px;
  background: rgba(13,18,28,.9);
  box-shadow: 0 28px 80px rgba(0,0,0,.52);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 2px solid rgba(255,180,94,.18);
  border-top-color: #ffb45e;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.loader-card strong { display: block; font-size: 13px; }
.loader-card span { display: block; margin-top: 4px; color: #8792a4; font-size: 10px; }

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

/* ---------- overlays ---------- */

.hint {
  position: fixed;
  z-index: 8;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 999px;
  background: rgba(8,11,17,.62);
  color: #788397;
  font-size: 10px;
  pointer-events: none;
  backdrop-filter: blur(12px);
}

.stats {
  position: fixed;
  z-index: 8;
  left: 18px;
  bottom: 18px;
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  background: rgba(8,11,17,.72);
  color: #7f8b9e;
  font: 10px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre;
  pointer-events: none;
  backdrop-filter: blur(12px);
}

.lil-gui.root {
  --background-color: rgba(10, 14, 22, .84);
  --widget-color: #263246;
  --hover-color: #34435a;
  --focus-color: #a6733a;
  --text-color: #d8e0ec;
  --number-color: #ffc98c;
  --string-color: #f5d6ac;
  top: 18px;
  right: 18px;
  width: min(320px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px;
  overflow: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,.38);
  backdrop-filter: blur(18px);
}

@media (max-width: 720px) {
  .topbar { right: 18px; flex-wrap: wrap; }
  .status { order: 3; max-width: calc(100vw - 36px); }
  .brand-copy span { display: none; }
  .lil-gui.root { top: auto; bottom: 54px; max-height: 48vh; }
  .hint, .stats { display: none; }
}
