:root {
  --bg: #0d1210;
  --panel: rgba(20, 26, 22, 0.92);
  --accent: #7bc97f;
  --accent-dark: #4c8f52;
  --text: #eaf1ea;
  --text-dim: #9fb3a3;
  --border: rgba(255,255,255,0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow: hidden;
}

#glcanvas {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
  outline: none;
}

.screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
}
.screen[hidden] { display: none; }

.dialog-overlay {
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(3px);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  padding: 28px 30px;
}

.menu-panel {
  width: min(720px, 92vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

h1 { margin: 0 0 18px; font-size: 24px; font-weight: 600; }
h1 .sub { display: block; font-size: 13px; font-weight: 400; color: var(--text-dim); margin-top: 4px; }
h2 { margin: 0; font-size: 18px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); margin: 18px 0 8px; }
h3:first-child { margin-top: 0; }

.menu-toolbar { display: flex; gap: 10px; margin-bottom: 16px; }

.btn {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn:hover { background: rgba(255,255,255,0.12); }
.btn.primary { background: var(--accent-dark); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent); color: #08170a; }
.btn.small { padding: 5px 12px; font-size: 12px; }
.btn-icon {
  background: transparent; border: none; color: var(--text);
  font-size: 18px; cursor: pointer; line-height: 1;
}

.scene-list {
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 8px;
  flex: 1;
  min-height: 200px;
}

.scene-item {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.scene-item:hover { background: rgba(255,255,255,0.09); border-color: rgba(123,201,127,0.4); }
.scene-item .thumb {
  width: 44px; height: 44px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(160deg, #3c5a41, #1c2a1f);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.scene-item .meta { flex: 1; min-width: 0; }
.scene-item .name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scene-item .src { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scene-item .remove-btn {
  background: none; border: none; color: var(--text-dim); font-size: 16px; cursor: pointer; padding: 4px 8px;
}
.scene-item .remove-btn:hover { color: #e88; }
.scene-item.builtin .src::before { content: "prefilled · "; }

.hint { font-size: 12px; color: var(--text-dim); margin-top: 14px; margin-bottom: 0; }

.dialog-panel { width: min(460px, 92vw); }
.dialog-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 13px; color: var(--text-dim); }
.field input[type="text"], .field input[type="number"], .field select {
  background: rgba(0,0,0,0.3); border: 1px solid var(--border); border-radius: 7px;
  color: var(--text); padding: 9px 10px; font-size: 14px;
}
.field.small input { width: 100%; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.field.row { flex-direction: row; align-items: center; justify-content: space-between; gap: 16px; }
.field.row span { flex-shrink: 0; }
.field input[type="range"] { flex: 1; accent-color: var(--accent); }
.field input[type="color"] { width: 44px; height: 28px; padding: 0; border: none; background: none; }
.field input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }

.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.load-status { font-size: 12px; color: var(--text-dim); min-height: 16px; margin: 8px 0 0; }
.load-status.error { color: #e88; }

.settings-panel-inner { width: min(480px, 92vw); max-height: 86vh; overflow-y: auto; }
.settings-grid { display: flex; flex-direction: column; }

/* ---- loading ---- */
.loading-screen { background: #0a0f0c; z-index: 40; }
.loading-inner { text-align: center; }
.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.15); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite; margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loadingText { color: var(--text-dim); font-size: 14px; }

/* ---- HUD ---- */
#hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
#crosshair {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: 6px; height: 6px;
}
#crosshair .dot { width: 100%; height: 100%; border-radius: 50%; background: rgba(255,255,255,0.75); box-shadow: 0 0 4px rgba(0,0,0,0.6); }

.hud-corner { position: absolute; display: flex; gap: 8px; align-items: center; pointer-events: auto; z-index: 2; }
.top-left { top: 16px; left: 16px; }
.top-right { top: 16px; right: 16px; }
.bottom-left { bottom: 16px; left: 16px; }

.scene-name {
  background: rgba(0,0,0,0.4); padding: 6px 12px; border-radius: 8px; font-size: 13px;
}
.fly-badge {
  background: rgba(90,60,10,0.55); padding: 6px 12px; border-radius: 8px; font-size: 12px;
  display: block;
}
.fly-badge[hidden] { display: none; }
.icon-btn {
  background: rgba(0,0,0,0.4); border: none; color: var(--text); width: 34px; height: 34px;
  border-radius: 8px; font-size: 15px; cursor: pointer;
}
.icon-btn:hover { background: rgba(0,0,0,0.6); }

.controls-hint {
  background: rgba(0,0,0,0.4); padding: 6px 12px; border-radius: 8px; font-size: 11px; color: var(--text-dim);
}

.next-scene-hint {
  position: absolute; bottom: 70px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.55); padding: 10px 16px; border-radius: 10px;
  display: flex; align-items: center; gap: 12px; font-size: 13px;
  pointer-events: auto;
  animation: fadeIn 0.4s ease;
  z-index: 2;
}
.next-scene-hint[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.click-to-look {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.25); font-size: 15px; pointer-events: auto; cursor: pointer;
  z-index: 1;
}
.click-to-look span { background: rgba(0,0,0,0.5); padding: 10px 20px; border-radius: 8px; }
.click-to-look.hidden { display: none; }

.crash-toast {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  background: rgba(0,0,0,0.7); padding: 14px 22px; border-radius: 10px; font-size: 14px; z-index: 20;
  pointer-events: none;
}

@media (max-width: 640px) {
  .hint-desktop { display: none; }
}
