:root {
  --bg0: #020409;
  --bg1: #070a10;
  --bg2: #091222;
  --fg0: rgba(246, 248, 255, 0.92);
  --fg1: rgba(232, 240, 255, 0.62);
  --fg2: rgba(232, 240, 255, 0.30);
}

html,
body {
  height: 100%;
  width: 100%;
}

html {
  margin: 0;
  padding: 0;
  background-color: var(--bg0);
  background: radial-gradient(120% 110% at 50% 20%, var(--bg2) 0%, var(--bg1) 48%, var(--bg0) 100%);
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(120% 110% at 50% 20%, var(--bg2) 0%, var(--bg1) 48%, var(--bg0) 100%);
  color: var(--fg0);
  font-family: ui-sans-serif, system-ui, -apple-system, "SF Pro Text", "SF Pro Display", "Segoe UI", Inter,
    Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
}

#bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

.fallback-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(100% 120% at 50% 30%, rgba(56, 110, 160, 0.12) 0%, rgba(10, 15, 25, 0) 62%),
    radial-gradient(160% 140% at 20% 80%, rgba(38, 70, 90, 0.08) 0%, rgba(2, 4, 9, 0) 60%),
    radial-gradient(120% 110% at 50% 20%, var(--bg2) 0%, var(--bg1) 48%, var(--bg0) 100%);
  opacity: 0;
  transition: opacity 260ms ease;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background-image: url("./assets/noise.svg");
  background-repeat: repeat;
  background-size: 260px 260px;
  opacity: 0.055;
  mix-blend-mode: overlay;
}

.center {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: grid;
  place-content: center;
  text-align: center;
  padding: 2.25rem 1.5rem;
}

.center::before {
  content: "";
  position: absolute;
  inset: -40vmin;
  background: radial-gradient(circle at 50% 50%, rgba(2, 4, 9, 0.76) 0%, rgba(2, 4, 9, 0.22) 46%,
      rgba(2, 4, 9, 0) 70%);
  filter: blur(12px);
  z-index: -1;
}

.title {
  margin: 0;
  font-size: clamp(2.25rem, 5.5vw, 4.6rem);
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  font-weight: 520;
  line-height: 1.05;
  text-rendering: geometricPrecision;
}

.subtitle {
  margin: 1.1rem 0 0;
  font-size: clamp(0.98rem, 1.4vw, 1.1rem);
  letter-spacing: 0.04em;
  color: var(--fg1);
}

.etymology {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  left: calc(1rem + env(safe-area-inset-left));
  bottom: calc(1rem + env(safe-area-inset-bottom));
  z-index: 3;
  margin: 0;
  max-width: min(70vw, 520px);
  font-size: 0.74rem;
  line-height: 1.25;
  letter-spacing: 0.06em;
  color: var(--fg2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  user-select: none;
  pointer-events: none;
}

body.no-webgl .fallback-bg {
  opacity: 1;
}

body.no-webgl #bg {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .grain {
    opacity: 0.03;
  }
}

body.dev-tools .tuner {
  position: fixed;
  left: 0.75rem;
  bottom: 0.75rem;
  bottom: calc(0.75rem + env(safe-area-inset-bottom));
  z-index: 10;
  max-width: min(380px, calc(100vw - 1.5rem));
  pointer-events: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  color: rgba(246, 248, 255, 0.92);
}

body.dev-tools .etymology {
  left: auto;
  right: 1rem;
  right: calc(1rem + env(safe-area-inset-right));
}

body.dev-tools .tuner__panel {
  background: rgba(2, 4, 9, 0.86);
  border: 1px solid rgba(246, 248, 255, 0.14);
  border-radius: 14px;
  padding: 0.6rem 0.7rem 0.75rem;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.45);
  max-height: min(72vh, 560px);
  overflow: auto;
  overscroll-behavior: contain;
}

body.dev-tools .tuner__summary {
  cursor: pointer;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: rgba(232, 240, 255, 0.76);
}

body.dev-tools .tuner__fps {
  letter-spacing: 0.02em;
  text-transform: none;
  font-variant-numeric: tabular-nums;
  color: rgba(232, 240, 255, 0.55);
}

body.dev-tools .tuner__row {
  display: grid;
  grid-template-columns: 5.6rem 1fr 3.5rem;
  gap: 0.55rem;
  align-items: center;
  margin-top: 0.55rem;
  font-size: 0.72rem;
}

body.dev-tools .tuner__label {
  color: rgba(232, 240, 255, 0.74);
}

body.dev-tools .tuner__out {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: rgba(232, 240, 255, 0.62);
}

body.dev-tools .tuner input[type="range"] {
  width: 100%;
}

body.dev-tools .tuner select {
  width: 100%;
  background: rgba(9, 18, 34, 0.55);
  border: 1px solid rgba(246, 248, 255, 0.14);
  color: rgba(246, 248, 255, 0.92);
  border-radius: 10px;
  padding: 0.2rem 0.45rem;
}

body.dev-tools .tuner__buttons {
  display: flex;
  gap: 0.55rem;
  margin-top: 0.75rem;
}

body.dev-tools .tuner__buttons button {
  flex: 1;
  background: rgba(9, 18, 34, 0.55);
  border: 1px solid rgba(246, 248, 255, 0.14);
  color: rgba(246, 248, 255, 0.86);
  border-radius: 10px;
  padding: 0.35rem 0.5rem;
  cursor: pointer;
}

body.dev-tools .tuner__buttons button:hover {
  background: rgba(9, 18, 34, 0.74);
}
