@font-face {
  font-family: "Jost";
  src: url("./assets/fonts/Jost-Variable.ttf") format("truetype-variations"),
       url("./assets/fonts/Jost-Variable.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ink-text: rgba(226, 242, 252, 0.9);
  --ink-muted: rgba(180, 210, 226, 0.58);
  --ink-faint: rgba(158, 190, 210, 0.34);
  --rail-line: rgba(180, 226, 255, 0.13);
  --rail-fill: rgba(4, 8, 15, 0.72);
  --rail-fill-strong: rgba(8, 14, 23, 0.84);
  --focus: rgba(126, 230, 255, 0.92);
  --cursor-colour: #43e6ff;
}

* {
  box-sizing: border-box;
}

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

body {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 18% 8%, rgba(22, 38, 54, 0.42), transparent 34%),
    radial-gradient(circle at 88% 96%, rgba(18, 12, 34, 0.38), transparent 38%),
    #020409;
  color: var(--ink-text);
  font-family: "Jost", "Avenir Next", Futura, "Century Gothic", "Segoe UI", system-ui, sans-serif;
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 1px solid var(--focus);
  outline-offset: 2px;
}

.icon-definitions {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

#liquid-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100vw;
  height: 100vh;
  background: #02050b;
  cursor: none;
  touch-action: none;
}

.glass-depth {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  box-shadow:
    inset 0 0 0 1px rgba(205, 238, 255, 0.17),
    inset 0 1px 0 rgba(255, 255, 255, 0.11),
    inset 0 0 34px rgba(66, 176, 255, 0.045),
    inset 0 -22px 42px rgba(0, 0, 0, 0.42),
    inset 18px 0 46px rgba(0, 0, 0, 0.2),
    inset -18px 0 46px rgba(4, 10, 18, 0.16),
    0 0 96px rgba(42, 156, 232, 0.1);
}

.glass-depth::before,
.glass-depth::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.glass-depth::before {
  background:
    linear-gradient(90deg, rgba(175, 230, 255, 0.13), transparent 1.4%, transparent 98.6%, rgba(116, 202, 255, 0.09)),
    linear-gradient(0deg, rgba(190, 235, 255, 0.1), transparent 1.2%, transparent 98.4%, rgba(130, 205, 255, 0.08));
  opacity: 0.62;
}

.glass-depth::after {
  background: radial-gradient(ellipse at 50% 118%, rgba(45, 188, 255, 0.09), transparent 52%);
  mix-blend-mode: screen;
}

.scene-label {
  position: fixed;
  z-index: 10;
  top: max(20px, env(safe-area-inset-top));
  left: max(24px, env(safe-area-inset-left));
  max-width: min(420px, calc(100vw - 160px));
  pointer-events: none;
  text-shadow: 0 1px 18px rgba(0, 0, 0, 0.78);
}

.scene-label h1 {
  margin: 0;
  color: rgba(231, 247, 255, 0.9);
  font-size: clamp(12px, 1.25vw, 17px);
  font-weight: 260;
  letter-spacing: 0.31em;
  line-height: 1.2;
  text-transform: uppercase;
}

.scene-label p {
  margin: 7px 0 0;
  color: var(--ink-muted);
  font-size: clamp(10px, 1vw, 12px);
  font-weight: 300;
  letter-spacing: 0.075em;
  transition: opacity 900ms ease, transform 900ms ease;
}

.scene-label p.is-hidden {
  opacity: 0;
  transform: translateY(-4px);
}

.intro-cue {
  position: fixed;
  z-index: 6;
  left: 0;
  top: 0;
  width: 38px;
  height: 38px;
  margin: -19px 0 0 -19px;
  pointer-events: none;
  opacity: 0;
  will-change: transform, opacity;
}

.intro-cue span {
  display: block;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(226, 250, 255, 0.66);
  border-radius: 50%;
  box-shadow:
    0 0 16px rgba(85, 224, 255, 0.38),
    inset 0 0 13px rgba(126, 232, 255, 0.2);
}

.intro-cue span::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  margin: -2px;
  border-radius: 50%;
  background: rgba(240, 253, 255, 0.86);
  box-shadow: 0 0 12px rgba(115, 231, 255, 0.9);
}

.brush-cursor {
  position: fixed;
  z-index: 30;
  left: 0;
  top: 0;
  width: var(--cursor-size, 34px);
  height: var(--cursor-size, 34px);
  border: 1px solid var(--cursor-colour);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(-100px, -100px, 0) translate(-50%, -50%);
  transition: width 150ms ease, height 150ms ease, border-color 150ms ease, opacity 180ms ease;
  mix-blend-mode: screen;
  box-shadow:
    0 0 14px color-mix(in srgb, var(--cursor-colour) 55%, transparent),
    inset 0 0 10px color-mix(in srgb, var(--cursor-colour) 26%, transparent);
}

.brush-cursor.is-visible {
  opacity: 0.82;
}

.tool-rail {
  position: fixed;
  z-index: 20;
  left: max(14px, env(safe-area-inset-left));
  top: 50%;
  width: 132px;
  max-height: calc(100vh - 32px);
  padding: 10px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  transform: translateY(-50%);
  color: rgba(222, 240, 250, 0.88);
  background: linear-gradient(180deg, var(--rail-fill-strong), var(--rail-fill));
  border: 1px solid var(--rail-line);
  border-radius: 22px;
  box-shadow:
    0 18px 60px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.055),
    inset 0 0 0 1px rgba(255, 255, 255, 0.018);
  backdrop-filter: blur(18px) saturate(126%);
  scrollbar-width: thin;
  scrollbar-color: rgba(132, 204, 238, 0.28) transparent;
}

.rail-section + .rail-section {
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid rgba(180, 226, 255, 0.09);
}

.rail-section h2 {
  margin: 0 0 6px;
  color: rgba(184, 218, 235, 0.66);
  font-size: 8.5px;
  font-weight: 390;
  letter-spacing: 0.2em;
  line-height: 1;
  text-transform: uppercase;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
}

.tool-button,
.preset-button,
.action-button,
.spin-direction button {
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.018);
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease, box-shadow 150ms ease;
}

.tool-button {
  display: flex;
  min-width: 0;
  min-height: 41px;
  padding: 5px 2px 4px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 3px;
  border-radius: 12px;
  color: rgba(210, 232, 244, 0.66);
  font-size: 9px;
  font-weight: 340;
  letter-spacing: 0.065em;
}

.tool-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.45;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool-button:hover,
.preset-button:hover,
.action-button:hover,
.spin-direction button:hover {
  color: rgba(238, 250, 255, 0.94);
  background: rgba(158, 224, 255, 0.065);
}

.tool-button.is-active,
.preset-button.is-active,
.action-button.is-active,
.spin-direction button.is-active {
  color: rgba(239, 252, 255, 0.98);
  background: rgba(93, 205, 255, 0.105);
  border-color: rgba(121, 224, 255, 0.28);
  box-shadow: inset 0 0 14px rgba(73, 192, 255, 0.05), 0 0 14px rgba(62, 186, 255, 0.055);
}

.spin-direction {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-top: 5px;
}

.spin-direction.is-visible {
  display: grid;
}

.spin-direction button {
  min-height: 21px;
  padding: 2px 3px;
  border-radius: 8px;
  color: rgba(190, 218, 233, 0.58);
  font-size: 7.5px;
  letter-spacing: 0.055em;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.swatch {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid rgba(230, 250, 255, 0.16);
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.16) 16%, var(--swatch) 43%, rgba(0, 0, 0, 0.24) 100%);
  box-shadow: 0 0 13px color-mix(in srgb, var(--swatch) 34%, transparent);
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}

.swatch:hover {
  transform: scale(1.07);
}

.swatch.is-active {
  border-color: rgba(240, 253, 255, 0.78);
  box-shadow:
    0 0 0 2px rgba(4, 10, 17, 0.8),
    0 0 0 3px color-mix(in srgb, var(--swatch) 68%, white),
    0 0 18px color-mix(in srgb, var(--swatch) 56%, transparent);
}

.colour-name {
  display: block;
  min-height: 12px;
  margin-top: 6px;
  color: rgba(203, 231, 244, 0.72);
  font-size: 8.8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.width-control {
  display: block;
  width: 100%;
}

.width-control input {
  display: block;
  width: 100%;
  height: 20px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: ew-resize;
}

.width-control input::-webkit-slider-runnable-track {
  height: 1px;
  background: linear-gradient(90deg, rgba(125, 218, 255, 0.18), rgba(207, 242, 255, 0.62));
}

.width-control input::-webkit-slider-thumb {
  width: 12px;
  height: 12px;
  margin-top: -5.5px;
  appearance: none;
  border: 1px solid rgba(240, 253, 255, 0.72);
  border-radius: 50%;
  background: #cff5ff;
  box-shadow: 0 0 10px rgba(95, 220, 255, 0.56);
}

.width-control input::-moz-range-track {
  height: 1px;
  background: linear-gradient(90deg, rgba(125, 218, 255, 0.18), rgba(207, 242, 255, 0.62));
}

.width-control input::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: 1px solid rgba(240, 253, 255, 0.72);
  border-radius: 50%;
  background: #cff5ff;
  box-shadow: 0 0 10px rgba(95, 220, 255, 0.56);
}

.width-labels {
  display: flex;
  justify-content: space-between;
  margin-top: -1px;
  color: rgba(163, 198, 216, 0.42);
  font-size: 7px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.preset-list {
  display: grid;
  gap: 4px;
}

.preset-button {
  min-height: 26px;
  padding: 4px 5px;
  border-radius: 9px;
  color: rgba(203, 226, 239, 0.63);
  font-size: 8.5px;
  font-weight: 330;
  letter-spacing: 0.08em;
  line-height: 1.1;
  text-align: left;
  text-transform: uppercase;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
}

.action-button {
  min-height: 31px;
  padding: 4px 3px;
  border-radius: 9px;
  color: rgba(205, 228, 240, 0.66);
  font-size: 8px;
  font-weight: 340;
  letter-spacing: 0.07em;
  line-height: 1.12;
  text-transform: uppercase;
}

.rail-status {
  min-height: 20px;
  margin: 9px 0 0;
  padding-top: 8px;
  border-top: 1px solid rgba(180, 226, 255, 0.09);
  color: rgba(183, 216, 232, 0.64);
  font-size: 7.8px;
  font-weight: 330;
  letter-spacing: 0.1em;
  line-height: 1.35;
  text-transform: uppercase;
}

.unsupported {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #03060b;
  color: rgba(226, 243, 252, 0.88);
  text-align: center;
}

.unsupported[hidden] {
  display: none !important;
}

.unsupported h2 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 280;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.unsupported p {
  max-width: 34rem;
  margin: 0;
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.6;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 700px) {
  .scene-label {
    top: max(14px, env(safe-area-inset-top));
    left: max(15px, env(safe-area-inset-left));
    max-width: calc(100vw - 34px);
  }

  .scene-label h1 {
    font-size: 11px;
  }

  .scene-label p {
    max-width: 250px;
    font-size: 10px;
  }

  .tool-rail {
    left: calc(10px + env(safe-area-inset-left));
    right: calc(54px + env(safe-area-inset-right));
    top: auto;
    bottom: calc(10px + env(safe-area-inset-bottom));
    width: auto;
    max-height: none;
    padding: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    transform: none;
    display: flex;
    align-items: stretch;
    border-radius: 18px;
    scrollbar-width: none;
    touch-action: pan-x;
  }

  .tool-rail::-webkit-scrollbar {
    display: none;
  }

  .rail-section {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 9px;
    border-left: 1px solid rgba(180, 226, 255, 0.09);
  }

  .rail-section + .rail-section {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }

  .rail-section:first-child {
    padding-left: 2px;
    border-left: 0;
  }

  .rail-section h2 {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }

  .tool-grid {
    display: flex;
    gap: 4px;
  }

  .tool-button {
    width: 49px;
    min-height: 48px;
    font-size: 8px;
  }

  .tool-button svg {
    width: 15px;
    height: 15px;
  }

  .spin-direction {
    margin-top: 3px;
  }

  .spin-direction button {
    min-height: 18px;
    font-size: 6.5px;
  }

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

  .swatch {
    width: 24px;
    height: 24px;
    flex: 0 0 auto;
  }

  .colour-name,
  .rail-status,
  .width-labels {
    display: none;
  }

  .width-section {
    width: 88px;
  }

  .preset-list,
  .action-grid {
    display: flex;
    gap: 4px;
  }

  .preset-button {
    width: 65px;
    min-height: 45px;
    padding: 4px;
    font-size: 7.5px;
    line-height: 1.15;
  }

  .action-button {
    width: 54px;
    min-height: 45px;
    font-size: 7px;
  }
}

@media (max-width: 420px) {
  .tool-button {
    width: 46px;
  }

  .preset-button {
    width: 61px;
  }

  .action-button {
    width: 50px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  .intro-cue {
    display: none;
  }
}
