/* GARGANTUA — HUD / overlays */

:root {
  --amber: #ffb26b;
  --line: rgba(255, 255, 255, 0.14);
  --dim: rgba(255, 255, 255, 0.55);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #eee;
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
}

#gl {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  display: block;
  cursor: grab;
}
#gl:active { cursor: grabbing; }

/* ---------- generic HUD ---------- */
.hud-block { pointer-events: none; }
.hud-block button, .hud-block select, .hud-block input,
.hud-block a, .hud-block label { pointer-events: auto; }

#ui.hidden, body.ui-hidden #ui, body.ui-hidden #panel { display: none; }

#hud-top {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 18px 22px;
  z-index: 10;
}
#brand h1 {
  font-size: 21px; letter-spacing: 0.55em; font-weight: 600;
  color: #fff; text-shadow: 0 0 18px rgba(255, 178, 107, 0.45);
}
#brand p {
  margin-top: 6px; font-size: 9.5px; letter-spacing: 0.28em; color: var(--dim);
}
#stats {
  display: flex; align-items: center; gap: 10px;
  font-size: 11px; letter-spacing: 0.08em;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px;
  backdrop-filter: blur(6px);
}
#stats .sep { color: rgba(255,255,255,0.2); }
#hud-fps { color: var(--amber); min-width: 58px; text-align: right; }
#hud-view { color: #9fc7ff; }

#stats button, #stats select {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em;
  color: #ddd; background: transparent;
  border: 1px solid var(--line); border-radius: 5px;
  padding: 3px 8px; cursor: pointer;
}
#stats button:hover, #stats select:hover { border-color: rgba(255,255,255,0.4); color: #fff; }

.badge {
  position: fixed; top: 74px; right: 22px; z-index: 10;
  font-size: 11px; letter-spacing: 0.2em; color: #ffd9a8;
  border: 1px solid rgba(255, 178, 107, 0.55); border-radius: 6px;
  padding: 5px 12px; background: rgba(40, 20, 0, 0.5);
}
.badge.hidden { display: none; }

#hud-bottom {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 16px 12px calc(14px + env(safe-area-inset-bottom));
  z-index: 10;
}
#chips {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center;
}
.chip-sep { width: 1px; height: 18px; background: var(--line); }
.chip {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.14em;
  color: #ccc; background: rgba(0, 0, 0, 0.42);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 14px; cursor: pointer;
  backdrop-filter: blur(6px);
  transition: all 0.18s;
}
.chip:hover { border-color: rgba(255,255,255,0.45); color: #fff; }
.chip.active {
  color: #0d0803; background: var(--amber); border-color: var(--amber);
  box-shadow: 0 0 16px rgba(255, 178, 107, 0.35);
}
#hint { font-size: 10px; letter-spacing: 0.12em; color: rgba(255,255,255,0.38); }
#hint b { color: rgba(255,255,255,0.66); font-weight: 500; }

/* ---------- parameter panel ---------- */
#panel {
  position: fixed; top: 64px; bottom: 86px; right: 0; width: 320px;
  z-index: 11;
  background: rgba(4, 4, 6, 0.72);
  border-left: 1px solid var(--line);
  backdrop-filter: blur(10px);
  transform: translateX(105%);
  transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex; flex-direction: column;
}
#panel.open { transform: translateX(0); }
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  font-size: 10.5px; letter-spacing: 0.22em; color: var(--amber);
}
.panel-head button {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em;
  color: #ddd; background: none; border: 1px solid var(--line);
  border-radius: 4px; padding: 3px 8px; cursor: pointer;
}
.panel-head button:hover { border-color: rgba(255,255,255,0.5); }
#param-list { flex: 1; overflow-y: auto; padding: 6px 14px 12px; scrollbar-width: thin; }
.group-head {
  margin: 12px 0 4px; font-size: 9px; letter-spacing: 0.3em;
  color: rgba(255, 255, 255, 0.4);
  border-bottom: 1px dashed rgba(255, 255, 255, 0.1); padding-bottom: 4px;
}
.prow {
  display: grid; grid-template-columns: 108px 1fr 44px;
  gap: 8px; align-items: center;
  padding: 3px 0;
}
.prow label {
  font-size: 10px; letter-spacing: 0.02em; color: #bbb;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.prow output { font-size: 10px; color: var(--amber); text-align: right; }
.prow input[type="range"] {
  width: 100%; height: 14px; appearance: none; background: transparent; cursor: ew-resize;
}
.prow input[type="range"]::-webkit-slider-runnable-track {
  height: 2px; background: rgba(255,255,255,0.22); border-radius: 1px;
}
.prow input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 10px; height: 10px; margin-top: -4px;
  border-radius: 50%; background: var(--amber); box-shadow: 0 0 6px rgba(255,178,107,0.6);
}
.prow input[type="range"]::-moz-range-track { height: 2px; background: rgba(255,255,255,0.22); }
.prow input[type="range"]::-moz-range-thumb {
  width: 10px; height: 10px; border: none; border-radius: 50%;
  background: var(--amber); box-shadow: 0 0 6px rgba(255,178,107,0.6);
}
.panel-foot {
  border-top: 1px solid var(--line); padding: 10px 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.panel-foot label {
  display: grid; grid-template-columns: 110px 52px 1fr;
  gap: 6px; align-items: center; font-size: 10px; color: #bbb;
}
.panel-foot output { color: var(--amber); text-align: right; }
.panel-foot input[type="range"] {
  appearance: none; background: transparent; height: 14px; cursor: ew-resize;
}
.panel-foot input[type="range"]::-webkit-slider-runnable-track {
  height: 2px; background: rgba(255,255,255,0.22);
}
.panel-foot input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 10px; height: 10px; margin-top: -4px;
  border-radius: 50%; background: var(--amber);
}

/* ---------- toast ---------- */
#toast {
  position: fixed; bottom: 108px; left: 50%; transform: translateX(-50%) translateY(12px);
  z-index: 30; max-width: min(84vw, 560px);
  font-size: 11.5px; letter-spacing: 0.06em; text-align: center;
  color: #ffe; background: rgba(10, 10, 12, 0.85);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 18px;
  opacity: 0; transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- loading ---------- */
#loading {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 26px;
  background: #000;
  transition: opacity 0.8s;
}
#loading.gone { opacity: 0; pointer-events: none; }
#loading .ring {
  width: 92px; height: 92px; border-radius: 50%;
  border: 2px solid rgba(255, 178, 107, 0.25);
  position: relative;
  animation: spin 2.6s linear infinite;
}
#loading .ring i {
  position: absolute; inset: -2px; border-radius: 50%;
  border: 2px solid transparent; border-top-color: var(--amber);
  filter: drop-shadow(0 0 8px rgba(255,178,107,0.8));
}
#loading .txt { font-size: 12px; letter-spacing: 0.42em; color: #fff; }
#loading .sub { font-size: 10px; letter-spacing: 0.24em; color: rgba(255,255,255,0.4); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- help ---------- */
#help {
  position: fixed; inset: 0; z-index: 60;
  display: none; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
}
#help.show { display: flex; }
#help .sheet {
  width: min(92vw, 780px); max-height: 88vh; overflow-y: auto;
  background: rgba(8, 8, 10, 0.94);
  border: 1px solid var(--line); border-radius: 14px;
  padding: 26px 30px;
}
#help h2 { font-size: 13px; letter-spacing: 0.3em; color: var(--amber); margin-bottom: 18px; }
#help .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
#help table { width: 100%; border-collapse: collapse; font-size: 11px; }
#help td { padding: 5px 4px; color: #cfcfcf; border-bottom: 1px solid rgba(255,255,255,0.06); }
#help td:first-child { color: var(--amber); white-space: nowrap; width: 42%; }
#help th {
  text-align: left; padding: 12px 4px 6px; font-size: 9.5px;
  letter-spacing: 0.26em; color: rgba(255,255,255,0.45); font-weight: 500;
}
#help .note {
  margin-top: 18px; font-size: 10px; line-height: 1.8;
  color: rgba(255,255,255,0.42);
}
#btn-help-close {
  margin-top: 18px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.15em;
  color: #ddd; background: none; border: 1px solid var(--line);
  border-radius: 6px; padding: 8px 20px; cursor: pointer;
}
#btn-help-close:hover { border-color: var(--amber); color: var(--amber); }

/* ---------- fatal error ---------- */
#fatal {
  position: fixed; inset: 0; z-index: 90;
  display: none; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(30,0,0,0.5), rgba(0,0,0,0.96));
}
#fatal.show { display: flex; }
#fatal .card {
  width: min(92vw, 560px);
  background: rgba(12, 6, 6, 0.95);
  border: 1px solid rgba(255, 90, 70, 0.45); border-radius: 14px;
  padding: 30px 34px;
}
#fatal h2 { font-size: 14px; letter-spacing: 0.28em; color: #ff7b62; margin-bottom: 14px; }
#fatal p { font-size: 12px; line-height: 1.75; color: #e8ddd8; }
#fatal pre {
  margin-top: 12px; font-size: 10px; color: rgba(255,255,255,0.4);
  white-space: pre-wrap; word-break: break-all; max-height: 120px; overflow-y: auto;
}
#fatal .row { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
#fatal button {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em;
  color: #eee; background: rgba(255,255,255,0.05);
  border: 1px solid var(--line); border-radius: 7px;
  padding: 10px 16px; cursor: pointer;
}
#fatal button:hover { border-color: #ff9a85; color: #ffb2a2; }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  #brand h1 { font-size: 15px; letter-spacing: 0.4em; }
  #brand p { font-size: 7.5px; letter-spacing: 0.18em; }
  #stats { gap: 6px; padding: 6px 8px; font-size: 10px; }
  #stats button, #stats select { font-size: 9.5px; padding: 2px 5px; }
  .chip { font-size: 9px; padding: 6px 10px; }
  #hint { display: none; }
  #panel { width: 272px; top: 56px; bottom: 76px; }
  .badge { top: 64px; right: 12px; }
  #hud-top { padding: 12px 14px; }
}
