@font-face {
  font-family: "Science Gothic";
  src: url("../fonts/science-gothic-var.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 50% 200%;
  font-style: normal;
  font-display: block;
}

/* ------------------------------------------------------------------ tokens */

:root {
  color-scheme: dark;

  --night: #05060b;
  --a: #5ef2e6;
  --b: #a78bff;
  --c: #ff8fcf;

  --pad: max(16px, 3.2vmin);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);

  --dock-size: clamp(11px, 0.78vmin + 5px, 22px);
  --torque: cubic-bezier(0.12, 0.9, 0.18, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

html {
  background: var(--night);
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--night);
  color: #fff;
  font-family: "Science Gothic", ui-sans-serif, system-ui, sans-serif;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: geometricPrecision;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ------------------------------------------------------------------- stage */

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
}

.stage__bg,
.count__irid,
.sparks {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.stage__bg {
  background:
    radial-gradient(120% 80% at 50% 45%, #141028 0%, transparent 70%),
    var(--night);
}

/* Weisse Ziffern auf Schwarz, multipliziert mit dem irisierenden Material,
   danach per "screen" als reines Licht über die Szene gelegt. */
.count {
  position: absolute;
  inset: 0;
  background: #000;
  mix-blend-mode: screen;
  pointer-events: none;
}

.count__groups {
  position: absolute;
  inset: 0;
  transform-origin: 50% 50%;
}

.count__irid {
  mix-blend-mode: multiply;
  background: linear-gradient(115deg, var(--a), var(--b) 45%, var(--c));
}

.grp {
  position: absolute;
  left: 0;
  top: 0;
  --wdth: 100;
  --wght: 300;
  --wdth-fx: 0;
  --wght-fx: 0;
  --ctrs: 40;
  --slnt: 0;
}

.cell {
  position: absolute;
  top: 0;
  --dw: 0;
  --dp: 0;
}

.win {
  position: absolute;
  inset: 0;
}

.glyph {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 0.73em;
  line-height: 0.74em;
  text-align: center;
  white-space: pre;
  color: #fff;
  font-feature-settings: "tnum" 1;
  font-variant-numeric: tabular-nums;
  /* --tw, --ts, --tl: Gewicht, Breite und Neigung, die ein Ziffernwechsel kurzzeitig beisteuert. */
  --tw: 0;
  --ts: 0;
  --tl: 0;
  font-stretch: calc((var(--wdth) + var(--wdth-fx) + var(--ts)) * 1%);
  font-weight: calc(var(--wght) + var(--wght-fx) + var(--dw) + var(--dp) + var(--tw));
  font-variation-settings: "CTRS" var(--ctrs), "slnt" calc(var(--slnt) + var(--tl));
}

.glyph--next {
  visibility: hidden;
}

.cell .glyph {
  transition: color 0.9s var(--torque);
}

.cell.is-lead .glyph {
  color: rgb(255 255 255 / 0.17);
}

.scan {
  position: absolute;
  left: -18%;
  right: -18%;
  top: 0;
  height: max(10px, 0.08em);
  margin-top: min(-5px, -0.04em);
  /* Scharfer Kern plus elliptischer Schein, beides im Hintergrund: keine dunklen Kanten wie bei box-shadow. */
  background:
    linear-gradient(90deg, transparent, #fff 18%, #fff 82%, transparent) center / 100% max(2px, 0.013em) no-repeat,
    radial-gradient(closest-side, rgb(255 255 255 / 0.5), rgb(255 255 255 / 0.12) 60%, transparent) center / 100% 100% no-repeat;
  visibility: hidden;
}

.grp__label {
  position: absolute;
  left: 0;
  top: 0;
  text-align: left;
  white-space: nowrap;
  line-height: 1;
  font-stretch: 118%;
  font-weight: 430;
  letter-spacing: 0.02em;
  font-variation-settings: "CTRS" 0, "slnt" 0;
  color: rgb(255 255 255 / 0.66);
}

.grp__label {
  transition: opacity 0.9s var(--torque);
}

.grp.is-spent .grp__label {
  opacity: 0.4;
}

.grp__stem,
.grp__suffix {
  display: inline-block;
  vertical-align: top;
}

.grp__suffix {
  overflow: hidden;
}

/* ------------------------------------------------------------- light layers */

.flares,
.fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  mix-blend-mode: screen;
}

.flare {
  position: absolute;
  left: 0;
  top: 0;
  width: 100px;
  height: 100px;
  margin: -50px 0 0 -50px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgb(255 255 255 / 0.95), rgb(255 255 255 / 0.35) 32%, transparent 100%);
  opacity: 0;
  will-change: transform, opacity;
}

.flare--tint {
  background: radial-gradient(closest-side, color-mix(in srgb, var(--flare) 55%, white), color-mix(in srgb, var(--flare) 45%, transparent) 34%, transparent 100%);
}

.flare--core {
  background: radial-gradient(closest-side, #fff 0%, rgb(255 255 255 / 0.8) 18%, rgb(255 255 255 / 0.12) 55%, transparent 100%);
}

.grain {
  position: absolute;
  inset: -64px;
  pointer-events: none;
  opacity: 0.075;
  background-size: 256px 256px;
  mix-blend-mode: overlay;
}

/* -------------------------------------------------------------------- dock */

.dock {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-b) + var(--pad) * 0.35);
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.15em;
  translate: -50% 0;
  font-size: var(--dock-size);
}

.dock button {
  position: relative;
  min-height: 44px;
  margin: 0;
  padding: 0.9em clamp(0.3em, 1.5vw, 0.95em);
  border: 0;
  border-radius: 0.35em;
  background: none;
  color: rgb(255 255 255 / 0.5);
  font: inherit;
  font-stretch: 112%;
  font-weight: 420;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: color 0.5s var(--torque);
  -webkit-user-select: none;
  user-select: none;
}

.dock button:hover {
  color: rgb(255 255 255 / 0.78);
}

.dock button[aria-pressed="true"] {
  color: rgb(255 255 255 / 0.96);
}

.dock button:focus-visible {
  outline: 1px solid var(--a);
  outline-offset: -0.35em;
}

.dock__mark {
  position: absolute;
  left: 0;
  bottom: 0.5em;
  width: 1.7em;
  height: 0.2em;
  clip-path: polygon(0 100%, 14% 0, 100% 0, 86% 100%);
  background: linear-gradient(90deg, var(--a), var(--b) 50%, var(--c));
  pointer-events: none;
}

.dock.is-quiet button:not([aria-pressed="true"]) {
  color: rgb(255 255 255 / 0.12);
}

.dock.is-touch.is-quiet button:not([aria-pressed="true"]) {
  color: rgb(255 255 255 / 0.3);
}

@media (pointer: fine) {
  body.is-idle,
  body.is-idle .stage {
    cursor: none;
  }
}

/* ------------------------------------------------------ states & fallbacks */

.is-lite .grain {
  display: none;
}

@media (forced-colors: active) {
  .stage__bg,
  .count__irid,
  .flares,
  .fx,
  .sparks,
  .grain {
    display: none;
  }

  .count {
    mix-blend-mode: normal;
    background: Canvas;
  }

  .glyph,
  .grp__label {
    color: CanvasText;
  }

  .cell.is-lead .glyph {
    color: GrayText;
  }
}

.js .count,
.js .flares,
.js .fx,
.js .dock,
.js .grain {
  visibility: hidden;
}

.fallback {
  display: none;
}

.no-js .fallback {
  position: absolute;
  inset: 0;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 4vmin 8vmin;
  padding: var(--pad);
}

.no-js .dock {
  display: none;
}

.fallback__group {
  display: grid;
  justify-items: center;
  gap: 1vmin;
}

.fallback__value {
  font-size: clamp(56px, min(18vw, 24vh), 50vh);
  font-stretch: 120%;
  font-weight: 220;
  line-height: 0.8;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(115deg, var(--a), var(--b) 50%, var(--c));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.fallback__label {
  font-size: clamp(12px, 1.6vmin, 28px);
  font-stretch: 118%;
  color: rgb(255 255 255 / 0.6);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
