/* Plain CSS overlay — no framework, no build step. */

:root {
  --bg: #12151a;
  --panel: rgba(20, 24, 30, 0.88);
  --line: rgba(255, 255, 255, 0.10);
  --text: #e8eaed;
  --dim: #98a0ab;
  --accent: #2f9bff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ------------------------------------------------------------- the panel */

#panel {
  position: fixed;
  top: 16px;
  left: 16px;
  width: 264px;
  max-height: calc(100% - 32px);
  overflow-y: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

#panel header { margin-bottom: 14px; }

#panel h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

#panel .sub {
  margin: 2px 0 0;
  color: var(--dim);
  font-size: 11px;
}

#panel section { margin-bottom: 14px; }

#panel h2 {
  margin: 0 0 7px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--dim);
}

/* ------------------------------------------------------------- controls */

button {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  padding: 7px 8px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

button:hover { background: rgba(255, 255, 255, 0.10); }

button.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.seg { display: flex; gap: 6px; }
.seg button { flex: 1; }

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

/* "Pool" gets its own row so the primary state reads first */
.grid button:first-child { grid-column: 1 / -1; }

.row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.row label { color: var(--dim); font-size: 11px; }
.wide { width: 100%; }

input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent);
}

output {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--dim);
  min-width: 58px;
  text-align: right;
}

/* --------------------------------------------------------------- legend */

.legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 8px;
  font-size: 11px;
  color: var(--dim);
}

.legend li { display: flex; align-items: center; gap: 6px; }

.legend i {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--c);
  box-shadow: 0 0 7px var(--c);
}

/* ---------------------------------------------------------------- text */

#caption {
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  line-height: 1.45;
}

.note, #status {
  margin: 6px 0 0;
  font-size: 10.5px;
  color: var(--dim);
}

#hint {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--dim);
  font-size: 11px;
  pointer-events: none;
  text-align: center;
  padding: 0 12px;
}

/* ---- collapsible panel -------------------------------------------------- */

#panel header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

#panelToggle {
  flex: 0 0 auto;
  padding: 5px 11px;
  font-size: 11px;
  min-height: 32px;
  border-radius: 7px;
  cursor: pointer;
}

/* Collapsed keeps the header and the caption -- the caption is the whole
   point of the thing, so hiding it with the controls would be perverse. */
#panel.collapsed > section,
#panel.collapsed > #status {
  display: none;
}

#panel.collapsed {
  max-height: none;
}

/* Narrow screens: dock the panel to the bottom so the 3D view keeps the top */
@media (max-width: 720px) {
  #panel {
    top: auto;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 46%;
    border-radius: 12px 12px 0 0;
    /* clear the iOS home indicator */
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  /* Touch targets. 32px buttons are a miss-fest on a phone. */
  #panel button,
  #panel .seg button,
  #panel .grid button {
    min-height: 42px;
    font-size: 13px;
  }

  #speed { height: 26px; }

  #hint {
    display: block;
    bottom: auto;
    top: 10px;
    font-size: 10.5px;
  }
}
