:root {
  --deep: #0f1f2e;
  --ink: #0a1520;
  --mist: #8fa8b8;
  --foam: #fcf4e7;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background-color: var(--deep);
  overflow: hidden;
}

.fx-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

/* --- Fallback (no WebGL, or the mark could not be rasterised) --- */
.fx-fallback {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.75rem;
  padding: 2rem;
  pointer-events: none;
}

.fx-fallback[hidden] {
  display: none;
}

.fx-fallback__logo {
  width: min(46vw, 320px);
  height: auto;
}

.fx-fallback__note {
  margin: 0;
  max-width: 30rem;
  font-family: "Instrument Serif", Times, serif;
  font-style: italic;
  font-size: 0.95rem;
  line-height: 1.6;
  text-align: center;
  color: var(--mist);
  opacity: 0.65;
}

.fx-fallback__note code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-style: normal;
  font-size: 0.82em;
  letter-spacing: 0.02em;
}

/* --- Fixed chrome (playground only) --- */
.fx-hint {
  position: fixed;
  z-index: 4;
  bottom: max(1.4rem, calc(env(safe-area-inset-bottom, 0px) + 0.9rem));
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  white-space: nowrap;
  pointer-events: none;
  font-family: "Montserrat", sans-serif;
  font-weight: 600;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mist);
  opacity: 0.4;
  transition: opacity 0.4s ease;
}

.fx-hint.is-faded {
  opacity: 0;
}

.fx-hint kbd {
  font-family: inherit;
  font-size: inherit;
  border: 1px solid rgba(143, 168, 184, 0.4);
  border-radius: 3px;
  padding: 0.1em 0.35em;
}

/* --- Control panel --- */
.fx-panel {
  position: fixed;
  z-index: 5;
  top: max(1.25rem, calc(env(safe-area-inset-top, 0px) + 0.9rem));
  right: max(1.25rem, calc(env(safe-area-inset-right, 0px) + 0.9rem));
  width: 17.5rem;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1.15rem 1.25rem 1.25rem;
  border: 1px solid rgba(143, 168, 184, 0.16);
  border-radius: 10px;
  background: rgba(10, 21, 32, 0.58);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  box-shadow: 0 18px 50px rgba(4, 10, 16, 0.45);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.fx-panel.is-hidden {
  opacity: 0;
  transform: translateX(0.75rem);
  pointer-events: none;
}

.fx-panel__head {
  margin-bottom: 1.15rem;
}

.fx-panel__title {
  margin: 0;
  font-family: "Instrument Serif", Times, serif;
  font-weight: 400;
  font-size: 1.35rem;
  line-height: 1.1;
  color: var(--foam);
  opacity: 0.9;
}

.fx-panel__sub {
  margin: 0.2rem 0 0;
  font-family: "Instrument Serif", Times, serif;
  font-style: italic;
  font-size: 0.85rem;
  color: var(--mist);
  opacity: 0.6;
}

.fx-panel-toggle {
  position: fixed;
  z-index: 6;
  top: max(1.25rem, calc(env(safe-area-inset-top, 0px) + 0.9rem));
  right: max(1.25rem, calc(env(safe-area-inset-right, 0px) + 0.9rem));
  padding: 0.45rem 0.8rem;
  border: 1px solid rgba(143, 168, 184, 0.22);
  border-radius: 999px;
  background: rgba(10, 21, 32, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-family: "Montserrat", sans-serif;
  font-weight: 600;
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mist);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, color 0.3s ease;
}

.fx-panel-toggle.is-visible {
  opacity: 0.75;
  pointer-events: auto;
}

.fx-panel-toggle:hover {
  color: var(--foam);
}

.fx-field {
  margin-bottom: 1rem;
}

.fx-field__label,
.fx-slider__label {
  display: block;
  font-family: "Montserrat", sans-serif;
  font-weight: 600;
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mist);
  opacity: 0.55;
}

.fx-field__label {
  margin-bottom: 0.45rem;
}

/* Sliders */
.fx-sliders {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  margin-bottom: 1.1rem;
}

.fx-slider__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.fx-slider__value {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.62rem;
  color: var(--foam);
  opacity: 0.55;
  font-variant-numeric: tabular-nums;
}

.fx-slider__input {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 1rem;
  margin: 0;
  background: transparent;
  cursor: ew-resize;
}

.fx-slider__input::-webkit-slider-runnable-track {
  height: 2px;
  border-radius: 2px;
  background: rgba(143, 168, 184, 0.25);
}

.fx-slider__input::-moz-range-track {
  height: 2px;
  border-radius: 2px;
  background: rgba(143, 168, 184, 0.25);
}

.fx-slider__input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 10px;
  height: 10px;
  margin-top: -4px;
  border: none;
  border-radius: 50%;
  background: var(--foam);
  opacity: 0.8;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.fx-slider__input::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border: none;
  border-radius: 50%;
  background: var(--foam);
  opacity: 0.8;
}

.fx-slider__input:hover::-webkit-slider-thumb,
.fx-slider__input:focus-visible::-webkit-slider-thumb {
  opacity: 1;
  transform: scale(1.2);
}

.fx-slider__input:focus-visible {
  outline: none;
}

/* Buttons */
.fx-modes,
.fx-presets,
.fx-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.fx-actions {
  margin-top: 1.15rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(143, 168, 184, 0.14);
}

.fx-btn {
  flex: 1 1 auto;
  padding: 0.4rem 0.6rem;
  border: 1px solid rgba(143, 168, 184, 0.2);
  border-radius: 5px;
  background: transparent;
  font-family: "Montserrat", sans-serif;
  font-weight: 600;
  font-size: 0.57rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--mist);
  cursor: pointer;
  transition: color 0.25s ease, border-color 0.25s ease, background-color 0.25s ease;
}

.fx-btn:hover {
  color: var(--foam);
  border-color: rgba(252, 244, 231, 0.35);
}

.fx-btn.is-active,
.fx-btn[aria-pressed="true"] {
  color: var(--ink);
  background: rgba(252, 244, 231, 0.85);
  border-color: rgba(252, 244, 231, 0.85);
}

@media (max-width: 720px) {
  .fx-panel {
    top: auto;
    right: max(0.75rem, calc(env(safe-area-inset-right, 0px) + 0.5rem));
    left: max(0.75rem, calc(env(safe-area-inset-left, 0px) + 0.5rem));
    bottom: max(0.75rem, calc(env(safe-area-inset-bottom, 0px) + 0.5rem));
    width: auto;
    max-height: 52vh;
  }

  .fx-panel.is-hidden {
    transform: translateY(0.75rem);
  }

  .fx-hint {
    display: none;
  }
}
