:root {
  --bg: #050507;
  --fg: #ecebf4;
  --dim: rgba(236, 235, 244, 0.42);
  --faint: rgba(236, 235, 244, 0.16);
  --pad: clamp(16px, 2.6vw, 32px);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Malgun Gothic", monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font: 500 10.5px/1.55 var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#gl {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#type {
  position: fixed;
  left: 50%;
  bottom: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  border: 0;
  font-size: 16px;
  pointer-events: none;
}

/* ---------------------------------------------------------------- HUD */

.hud,
.frame {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.4s ease 0.3s;
}

body.ready .hud,
body.ready .frame {
  opacity: 1;
}

.c {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 5px;
  white-space: nowrap;
}

.tl { top: var(--pad); left: var(--pad); }
.tr { top: var(--pad); right: var(--pad); align-items: flex-end; text-align: right; }
.bl { bottom: var(--pad); left: var(--pad); }
.br { bottom: var(--pad); right: var(--pad); align-items: flex-end; text-align: right; }

.mark {
  font-weight: 500;
  letter-spacing: 0.42em;
}

.dim {
  color: var(--dim);
}

.hb {
  pointer-events: auto;
  appearance: none;
  border: 0;
  background: none;
  color: var(--dim);
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  padding: 2px 0;
  cursor: pointer;
  transition: color 0.2s;
}

.hb b {
  font-weight: 500;
  color: var(--fg);
  margin-left: 0.6em;
}

.hb:hover,
.hb:focus-visible {
  color: var(--fg);
  outline: none;
}

.hb:hover b {
  text-shadow: 0 0 12px rgba(160, 200, 255, 0.8);
}

.hint,
.toast {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  letter-spacing: 0.42em;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.8s ease;
}

.hint {
  bottom: 17%;
  color: var(--dim);
}

.hint.on {
  opacity: 1;
  animation: breathe 2.6s ease-in-out infinite;
}

.toast {
  bottom: calc(17% + 26px);
  color: var(--fg);
  text-shadow: 0 0 14px rgba(150, 190, 255, 0.55);
  transition: opacity 0.35s ease;
}

.toast.on {
  opacity: 1;
}

@keyframes breathe {
  50% { opacity: 0.35; }
}

/* viewfinder corners */
.frame i {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 0 solid var(--faint);
}
.frame i:nth-child(1) { top: 10px; left: 10px; border-top-width: 1px; border-left-width: 1px; }
.frame i:nth-child(2) { top: 10px; right: 10px; border-top-width: 1px; border-right-width: 1px; }
.frame i:nth-child(3) { bottom: 10px; left: 10px; border-bottom-width: 1px; border-left-width: 1px; }
.frame i:nth-child(4) { bottom: 10px; right: 10px; border-bottom-width: 1px; border-right-width: 1px; }

/* ---------------------------------------------------------------- help */

.help {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 5, 7, 0.55);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  animation: fade 0.35s ease;
  z-index: 5;
}

.help[hidden] {
  display: none;
}

.card {
  width: min(460px, calc(100vw - 32px));
  padding: 28px 28px 22px;
  border: 1px solid var(--faint);
  background: rgba(14, 14, 20, 0.72);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}

.card h2 {
  font: inherit;
  letter-spacing: 0.42em;
  margin-bottom: 18px;
}

.card dl {
  display: grid;
  grid-template-columns: 76px 1fr;
  row-gap: 9px;
  column-gap: 14px;
}

.card dt {
  color: var(--fg);
}

.card dd,
.card p {
  color: var(--dim);
  text-transform: none;
  letter-spacing: 0.02em;
  font-size: 12px;
}

.card p {
  margin-top: 18px;
  color: rgba(255, 170, 220, 0.75);
}

@keyframes fade {
  from { opacity: 0; }
}

/* -------------------------------------------------------------- cursor */

.cur {
  position: fixed;
  left: 0;
  top: 0;
  pointer-events: none;
  border-radius: 50%;
  mix-blend-mode: difference;
  opacity: 0;
  z-index: 10;
  will-change: transform;
}

.cur-ring {
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  transition: border-color 0.3s, opacity 0.4s;
}

.cur-dot {
  width: 4px;
  height: 4px;
  margin: -2px 0 0 -2px;
  background: #fff;
}

body.charging .cur-ring {
  border-color: #ff9a55;
  border-style: dashed;
  mix-blend-mode: normal;
}

@media (pointer: fine) {
  body,
  .hb {
    cursor: none;
  }
  body.ready .cur {
    opacity: 1;
  }
}

/* ---------------------------------------------------------- responsive */

.touch-only {
  display: none;
}

body.touch .touch-only {
  display: initial;
}

body.touch .fine-only {
  display: none;
}

body.touch .hb {
  padding: 5px 0;
}

@media (max-width: 640px) {
  body {
    font-size: 9.5px;
    letter-spacing: 0.1em;
  }
  .hide-sm {
    display: none;
  }
  .hint,
  .toast {
    letter-spacing: 0.24em;
  }
  .hint {
    bottom: auto;
    top: 19%;
  }
  .toast {
    bottom: auto;
    top: calc(19% + 24px);
  }
}

/* ------------------------------------------------------------ fallback */

.fallback {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

body.nogl #gl,
body.nogl .cur {
  display: none;
}

body.nogl .fallback {
  position: fixed;
  inset: 0;
  width: auto;
  height: auto;
  clip-path: none;
  display: grid;
  place-items: center;
  font: 900 clamp(44px, 13vw, 200px)/1 "Unbounded", "Arial Black", sans-serif;
  letter-spacing: 0;
  background: linear-gradient(100deg, #8f9bff, #f6f6ff 30%, #ff8bd8 55%, #7ef2ff 80%, #8f9bff);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: sheen 8s linear infinite;
}

@keyframes sheen {
  to { background-position: 300% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .hint.on,
  body.nogl .fallback {
    animation: none;
  }
}
