:root {
  --fg: #e9eef7;
  --dim: rgba(233, 238, 247, .54);
  --faint: rgba(233, 238, 247, .3);
  --line: rgba(255, 255, 255, .09);
  --acc: #9dbcff;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --pad: 28px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: #000;
  color: var(--fg);
  overflow: hidden;
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

::selection { background: rgba(157, 188, 255, .3); }

#gl {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 2.6s ease;
  touch-action: none;
  user-select: none;
}
body.ready #gl { opacity: 1; }

/* The word lives in the canvas; this copy is for screen readers and the no-WebGL fallback. */
#word {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.nogl #word {
  position: fixed;
  inset: 0;
  width: auto; height: auto;
  margin: 0;
  clip-path: none;
  display: grid;
  place-items: center;
  font: 500 clamp(36px, 10vw, 130px) var(--mono);
  letter-spacing: .22em;
  padding-left: .22em;
  text-shadow: 0 0 60px rgba(157, 188, 255, .45);
}

/* ---------- telemetry ---------- */
.hud {
  position: fixed; z-index: 1;
  font-size: 9.5px; line-height: 1.9; letter-spacing: .18em; text-transform: uppercase;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.6s ease;
}
body.ui .hud { opacity: 1; }
.hud b { display: inline-block; width: 46px; font-weight: 400; color: var(--faint); }
#hud { left: var(--pad); top: var(--pad); }
#clock { right: var(--pad); top: var(--pad); text-align: right; }
#clock b { width: auto; margin-right: 12px; }
#snd {
  pointer-events: auto; cursor: pointer;
  background: none; border: 0; padding: 0;
  font: inherit; letter-spacing: inherit; text-transform: inherit; color: var(--acc);
}
#snd:hover, #snd:focus-visible { color: var(--fg); outline: none; }
#hint { left: var(--pad); bottom: var(--pad); color: var(--faint); }
body.held #hint { opacity: 0; }

/* ---------- shared panel ---------- */
.panel {
  position: fixed;
  z-index: 2;
  background: rgba(6, 8, 12, .6);
  border: 1px solid var(--line);
  border-radius: 14px;
  -webkit-backdrop-filter: blur(18px) saturate(120%);
  backdrop-filter: blur(18px) saturate(120%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .05), 0 24px 70px rgba(0, 0, 0, .65);
}

/* ---------- discord presence ---------- */
#presence {
  right: calc(var(--pad) / 1.25);   /* zoom scales these too; divide so the gap stays one pad */
  bottom: calc(var(--pad) / 1.25);
  width: 316px;
  padding: 16px;
  zoom: 1.25;   /* whole card scaled up together; 316px reads as 395px */
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 1.2s ease, transform 1.2s cubic-bezier(.2, .7, .2, 1);
  pointer-events: none;
}
body.ui #presence.on { opacity: 1; transform: none; pointer-events: auto; }

.p-head { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.p-avw { position: relative; width: 44px; height: 44px; }
.p-av { width: 44px; height: 44px; border-radius: 50%; display: block; object-fit: cover; background: #10131a; }
.p-dot {
  position: absolute; right: -2px; bottom: -2px;
  width: 13px; height: 13px; border-radius: 50%;
  border: 3px solid #080a0f;
  background: #5b6270;
}
[data-s="online"] .p-dot { background: #57e39a; box-shadow: 0 0 12px rgba(87, 227, 154, .75); }
[data-s="idle"] .p-dot { background: #f6c356; box-shadow: 0 0 12px rgba(246, 195, 86, .6); }
[data-s="dnd"] .p-dot { background: #f2686d; box-shadow: 0 0 12px rgba(242, 104, 109, .6); }
.p-name { font-size: 14px; font-weight: 500; letter-spacing: .02em; }
.p-user { font-size: 11px; color: var(--dim); margin-top: 2px; }
.p-name, .p-user, .p-t1, .p-t2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-state { font-size: 9.5px; letter-spacing: .24em; text-transform: uppercase; color: var(--dim); align-self: start; padding-top: 4px; }
.p-custom { margin-top: 12px; font-size: 12px; line-height: 1.55; color: var(--dim); overflow-wrap: anywhere; }

.p-row {
  display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 10px 12px; align-items: center;
  margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--line);
}
.p-row > img, .p-ph { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: #10131a; }
.p-ph { display: grid; place-items: center; font-size: 16px; color: var(--dim); border: 1px solid var(--line); }
.p-lbl { display: flex; justify-content: space-between; gap: 8px; font-size: 9px; letter-spacing: .24em; text-transform: uppercase; color: var(--acc); }
.p-lbl .p-tm { color: var(--faint); letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.p-t1 { display: block; margin-top: 4px; font-size: 12.5px; color: var(--fg); text-decoration: none; }
a.p-t1:hover { color: var(--acc); }
.p-t2 { margin-top: 2px; font-size: 11px; color: var(--dim); }
.p-bar { grid-column: 1 / -1; height: 2px; border-radius: 2px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.p-bar i { display: block; height: 100%; width: 0; background: var(--fg); }
.p-times { grid-column: 1 / -1; display: flex; justify-content: space-between; margin-top: -4px; font-size: 9.5px; color: var(--faint); font-variant-numeric: tabular-nums; }

.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 9px; margin-left: 7px; vertical-align: -1px; }
.eq b { width: 2px; background: var(--acc); animation: eq 1s ease-in-out infinite; }
.eq b:nth-child(2) { animation-delay: -.35s; }
.eq b:nth-child(3) { animation-delay: -.7s; }
@keyframes eq { 0%, 100% { height: 2px; } 50% { height: 9px; } }

/* ---------- terminal: a command line that is always there ---------- */
#term {
  left: 50%; bottom: var(--pad);
  width: min(470px, calc(100vw - 2 * var(--pad)));
  transform: translateX(-50%);
  display: flex; flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transition: opacity 1s ease, border-color .3s ease;
}
body.ready #term { opacity: 1; }
#term:focus-within { border-color: rgba(157, 188, 255, .3); }
#termOut {
  max-height: 0;
  padding: 0 14px;
  overflow-y: auto;
  font-size: 12.5px; line-height: 1.7;
  white-space: pre-wrap; overflow-wrap: anywhere;
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .15) transparent;
  transition: max-height .35s cubic-bezier(.2, .7, .2, 1), padding .35s cubic-bezier(.2, .7, .2, 1);
}
body.term #termOut { max-height: 250px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
#termOut .c { color: var(--acc); }
#termOut .d { color: var(--dim); }
#termOut .e { color: #f2868a; }
.t-in { display: flex; gap: 9px; align-items: center; padding: 11px 14px; font-size: 12.5px; cursor: text; }
.t-in label { color: var(--acc); white-space: nowrap; }
.t-in input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; padding: 0; color: var(--fg); font: inherit; caret-color: var(--acc); }
.t-in input::placeholder { color: var(--faint); }

/* ---------- settings: opens above the prompt on "help" ---------- */
#settings {
  left: 50%; bottom: calc(var(--pad) + 56px);
  width: min(470px, calc(100vw - 2 * var(--pad)));
  padding: 4px 14px 12px;
  transform: translate(-50%, 8px);
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s cubic-bezier(.2, .7, .2, 1);
}
#settings.open { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.s-head, .s-row > span { font-size: 9.5px; letter-spacing: .24em; text-transform: uppercase; color: var(--dim); }
.s-head { display: flex; justify-content: space-between; padding: 8px 0 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.s-row { display: grid; grid-template-columns: 78px minmax(0, 1fr); align-items: center; gap: 10px; min-height: 34px; }
.s-ctl { display: flex; flex-wrap: wrap; gap: 4px; }
#settings button {
  background: none; border: 1px solid transparent; border-radius: 6px; padding: 3px 8px;
  font: 11.5px var(--mono); color: var(--dim); cursor: pointer;
}
.s-head button { padding: 0; font-size: inherit; letter-spacing: inherit; text-transform: inherit; color: var(--faint); }
#settings button:hover { color: var(--fg); }
#settings .s-ctl button.on { color: var(--fg); border-color: rgba(157, 188, 255, .45); }
#settings input[type="range"] { width: 100%; height: 14px; margin: 0; accent-color: var(--acc); background: none; cursor: pointer; }

/* ---------- cursor: the black hole drawn in the canvas ---------- */
@media (hover: hover) and (pointer: fine) { #gl { cursor: none; } }

/* ---------- narrower screens ---------- */
@media (max-width: 1180px) {
  #term { left: var(--pad); transform: none; width: min(470px, calc(100vw - 395px - 3 * var(--pad))); }
  #settings, #settings.open { left: var(--pad); transform: none; width: min(470px, calc(100vw - 395px - 3 * var(--pad))); }
  #hint { display: none; }
}
@media (max-width: 720px) {
  :root { --pad: 14px; }
  #presence { zoom: 1; width: auto; left: var(--pad); right: var(--pad); bottom: calc(var(--pad) + env(safe-area-inset-bottom)); }
  #term { top: calc(var(--pad) + env(safe-area-inset-top)); bottom: auto; width: auto; right: var(--pad); flex-direction: column-reverse; }
  body.term #termOut { border-bottom: 0; border-top: 1px solid var(--line); max-height: 220px; }
  .t-in input { font-size: 16px; } /* below 16px iOS zooms the page on focus */
  #settings, #settings.open { top: calc(var(--pad) + env(safe-area-inset-top) + 54px); bottom: auto; width: auto; right: var(--pad); }
  #hud, #clock { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .eq b { animation: none; }
}
