:root {
  --bg: #05070c;
  --surface: rgba(13, 17, 21, 0.82);
  --surface-strong: rgba(20, 25, 31, 0.92);
  --border: rgba(214, 226, 239, 0.18);
  --text: #f4f8fb;
  --muted: #a7b2bd;
  --cyan: #5be7ff;
  --rose: #ff5d9d;
  --lime: #a7f05f;
  --amber: #f6c453;
  --shadow: 0 18px 55px rgba(0, 0, 0, 0.42);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

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

body {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 42%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.experiment {
  position: fixed;
  inset: 0;
  min-width: 320px;
  isolation: isolate;
}

canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

#trailCanvas {
  z-index: 1;
}

#sceneCanvas {
  z-index: 2;
  cursor: crosshair;
  touch-action: none;
}

.controls {
  position: fixed;
  z-index: 4;
  top: 16px;
  left: 16px;
  width: min(342px, calc(100vw - 32px));
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  text-transform: uppercase;
}

.back-link:hover {
  color: var(--lime);
}

.heading {
  display: grid;
  gap: 2px;
  margin: 4px 0 14px;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.05;
  font-weight: 780;
}

.control {
  display: grid;
  gap: 8px;
  margin-top: 13px;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 18px;
  font-size: 13px;
  font-weight: 700;
}

output {
  min-width: 58px;
  color: var(--amber);
  font-family: var(--mono);
  font-size: 12px;
  text-align: right;
}

input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: var(--rose);
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 15px;
}

button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.075);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

button:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button.primary {
  color: #071016;
  border-color: rgba(91, 231, 255, 0.72);
  background: linear-gradient(135deg, var(--cyan), var(--lime));
}

.readout {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--muted);
  box-shadow: var(--shadow);
  font-size: 12px;
  backdrop-filter: blur(14px);
}

.readout strong {
  color: var(--lime);
  font-family: var(--mono);
  font-size: 13px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(91, 231, 255, 0.35);
  outline-offset: 2px;
}

@media (max-width: 760px) {
  .controls {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: auto;
    padding: 12px 14px 14px;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 8px 8px 0 0;
  }

  .heading {
    margin-bottom: 10px;
  }

  h1 {
    font-size: 23px;
  }

  .control {
    margin-top: 10px;
  }

  .button-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  button {
    height: 36px;
    padding: 0 6px;
    font-size: 12px;
  }

  .readout {
    right: 10px;
    bottom: 304px;
  }
}

@media (max-width: 520px) {
  .button-grid {
    grid-template-columns: 1fr 1fr;
  }

  .readout {
    display: none;
  }
}

@media (max-height: 680px) and (min-width: 761px) {
  .controls {
    padding: 12px;
  }

  .control {
    margin-top: 10px;
  }

  .button-grid {
    margin-top: 12px;
  }
}
