:root {
  color-scheme: dark;
  --bg: #05080d;
  --panel: rgba(11, 18, 27, 0.9);
  --panel-solid: #0b121b;
  --line: rgba(169, 208, 218, 0.18);
  --text: #edf8f7;
  --muted: #9fb5bc;
  --accent: #56d9d0;
  --accent-2: #f1c978;
  --shadow: rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

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

body {
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 10%, rgba(86, 217, 208, 0.08), transparent 30%),
    linear-gradient(135deg, #05080d 0%, #0b1017 50%, #07090d 100%);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  width: 100vw;
  height: 100vh;
  padding: 18px;
}

.stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}

.stage-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 0 2px 12px;
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.35rem, 2.3vw, 2.35rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.stage-header p,
.hint {
  color: var(--muted);
  line-height: 1.45;
}

.brand {
  flex: 0 0 auto;
  color: #d6ecea;
  font-size: 0.84rem;
  letter-spacing: 0;
}

.canvas-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #020407;
  box-shadow: 0 24px 60px var(--shadow), inset 0 0 80px rgba(86, 217, 208, 0.04);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: none;
  touch-action: none;
}

.brush-cursor {
  position: absolute;
  left: 0;
  top: 0;
  display: none;
  width: 20px;
  height: 20px;
  pointer-events: none;
  border: 1px solid rgba(237, 248, 247, 0.86);
  border-radius: 50%;
  box-shadow: 0 0 14px rgba(86, 217, 208, 0.5);
  transform: translate(-50%, -50%);
}

.controls {
  align-self: start;
  display: grid;
  gap: 15px;
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 20px 48px var(--shadow);
  backdrop-filter: blur(16px);
}

.button-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

button,
select {
  min-height: 42px;
  border: 1px solid rgba(169, 208, 218, 0.22);
  border-radius: 7px;
  background: #101b26;
  color: var(--text);
}

button {
  cursor: pointer;
  padding: 0 10px;
}

button:hover,
select:hover {
  border-color: rgba(86, 217, 208, 0.7);
  background: #132330;
}

button:active {
  transform: translateY(1px);
}

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

.field,
.slider-block {
  display: grid;
  gap: 8px;
}

.field span,
.slider-block label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: #dceceb;
  font-size: 0.9rem;
}

select {
  width: 100%;
  padding: 0 12px;
}

output {
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  min-height: 32px;
  accent-color: var(--accent);
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    height: auto;
    padding: 12px;
  }

  .stage {
    min-height: 62vh;
  }

  .stage-header {
    align-items: start;
    padding-bottom: 10px;
  }

  .brand {
    display: none;
  }

  .controls {
    position: sticky;
    bottom: 12px;
    max-height: none;
    background: var(--panel-solid);
  }
}

@media (max-width: 520px) {
  .stage {
    min-height: 58vh;
  }
}

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