:root {
  color-scheme: dark;
  --bg: #0e1217;
  --panel: #111a23;
  --line: #253241;
  --text: #ebf1f7;
  --muted: #9aa8b8;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background: #000000;
  color: var(--text);
}

.app {
  width: min(980px, 92vw);
  display: grid;
  gap: 12px;
}

h1 {
  margin: 0;
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.control-panel {
  width: 100%;
  display: grid;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(17, 26, 35, 0.7);
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
}

.control {
  display: grid;
  gap: 4px;
  padding: 0;
}

.control-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.control span,
.control output {
  font-size: 0.8rem;
}

.control output {
  color: var(--muted);
}

.control input[type="range"] {
  width: 100%;
}

.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 0.82rem;
  color: var(--muted);
}

.canvas-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #000000;
}

#sparkleCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

#sparkleCanvas:active {
  cursor: grabbing;
}

.status {
  display: inline-block;
  justify-self: start;
  margin-top: 2px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(7, 11, 16, 0.7);
  border: 1px solid rgba(85, 103, 124, 0.4);
  color: var(--muted);
  font-size: 0.8rem;
}

@media (max-width: 700px) {
  body {
    display: block;
    min-height: 100svh;
    padding: 0;
  }

  .app {
    width: 100vw;
    min-height: 100svh;
    padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
    grid-template-rows: auto auto auto 1fr;
    gap: 8px;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .canvas-shell {
    height: 100%;
    min-height: 0;
    aspect-ratio: auto;
  }
}
