:root {
  --ink: #ffffff;
  --glow: rgba(255, 230, 255, 0.55);
  --bg: #07020d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Pixelify Sans", ui-monospace, monospace;
  cursor: default;
  -webkit-font-smoothing: none;
}

body.idle-mouse { cursor: none; }

#view {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
}

/* The real input is invisible but stays focused to capture keys (also on mobile). */
#typer {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 1px;
  height: 1px;
  opacity: 0;
  border: 0;
  padding: 0;
  font-size: 16px; /* stops iOS zooming on focus */
  pointer-events: none;
}

#stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  mix-blend-mode: difference;
}

#prompt, #ghost {
  grid-area: 1 / 1;
  max-width: min(84vw, 1100px);
  text-align: center;
  font-size: clamp(26px, 5.6vw, 84px);
  line-height: 1.12;
  letter-spacing: 0.04em;
  font-weight: 400;
  word-break: break-word;
}

#prompt {
  transition: opacity 0.6s ease;
  text-shadow:
    0 0 6px var(--glow),
    0 0 22px rgba(255, 255, 255, 0.25);
}

#prompt.idle {
  opacity: 0.22;
  animation: breathe 6s ease-in-out infinite;
}

#prompt .ch {
  display: inline-block;
  white-space: pre;
  animation: wobble 3.2s ease-in-out infinite;
  animation-delay: calc(var(--i) * -0.17s);
}

#prompt .ch.new {
  animation: appear 0.35s ease-out, wobble 3.2s ease-in-out 0.35s infinite;
}

#prompt .caret {
  display: inline-block;
  margin-left: 0.06em;
  animation: caret 1.4s ease-in-out infinite;
}

#prompt.idle .caret { display: none; }

/* letters released on Enter */
#ghost .ch {
  display: inline-block;
  white-space: pre;
  transition:
    transform 1.6s cubic-bezier(0.2, 0.7, 0.2, 1),
    opacity 1.6s ease-in,
    filter 1.6s ease-in;
}

#ghost.go .ch {
  transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(var(--s));
  opacity: 0;
  filter: blur(14px);
}

#hint {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 14vh;
  text-align: center;
  font-size: clamp(14px, 1.6vw, 20px);
  letter-spacing: 0.3em;
  opacity: 0;
  transition: opacity 2s ease;
  pointer-events: none;
  mix-blend-mode: difference;
}
#hint.show { opacity: 0.45; }

#status {
  position: fixed;
  right: 16px;
  bottom: 12px;
  font-size: 13px;
  letter-spacing: 0.15em;
  opacity: 0.4;
  mix-blend-mode: difference;
  transition: opacity 1.2s ease;
  cursor: pointer;
  user-select: none;
}
body.idle-mouse #status { opacity: 0; }

#debug {
  position: fixed;
  left: 16px;
  top: 12px;
  margin: 0;
  font: 12px/1.5 ui-monospace, monospace;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  padding: 8px 10px;
  pointer-events: none;
}

@keyframes breathe {
  0%, 100% { opacity: 0.14; filter: blur(1.5px); }
  50% { opacity: 0.3; filter: blur(0px); }
}

@keyframes wobble {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-0.04em) rotate(-1.2deg); }
  75% { transform: translateY(0.04em) rotate(1.2deg); }
}

@keyframes appear {
  from { opacity: 0; filter: blur(10px); transform: scale(1.6); }
  to { opacity: 1; filter: blur(0); transform: scale(1); }
}

@keyframes caret {
  0%, 100% { opacity: 0.15; }
  50% { opacity: 0.9; }
}

@media (prefers-reduced-motion: reduce) {
  #prompt .ch, #prompt.idle { animation: none; }
}

/* hidden while submitted letters fly off */
#prompt.hush { animation: none; opacity: 0 !important; }

#prompt .w, #ghost .w { display: inline-block; white-space: nowrap; }

/* ---------- options panel ---------- */
#panel {
  --p-bg: rgba(12, 6, 22, 0.82);
  --p-line: rgba(255, 255, 255, 0.12);
  --p-dim: rgba(255, 255, 255, 0.55);
  --p-accent: #ff6ad5;
  position: fixed;
  top: 12px;
  right: 12px;
  width: min(300px, calc(100vw - 32px));
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  padding: 10px 14px 14px;
  background: var(--p-bg);
  border: 1px solid var(--p-line);
  border-radius: 10px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  font: 12px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace;
  -webkit-font-smoothing: auto;
  z-index: 10;
  scrollbar-width: thin;
}
#panel[hidden] { display: none; }
@media (max-width: 480px) { #panel { right: 16px; left: 16px; width: auto; } }

.p-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: "Pixelify Sans", monospace;
  font-size: 16px;
  letter-spacing: 0.15em;
  margin-bottom: 6px;
}
.p-x {
  background: none;
  border: 0;
  color: var(--p-dim);
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
}
.p-x:hover { color: #fff; }

.p-stats {
  margin: 0 0 8px;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 6px;
  white-space: pre-wrap;
  word-break: break-word;
  font: inherit;
  color: var(--p-dim);
}

.p-actions { display: flex; gap: 6px; margin-bottom: 4px; }
.p-actions button {
  flex: 1;
  padding: 5px 0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--p-line);
  border-radius: 6px;
  color: #fff;
  font: inherit;
  cursor: pointer;
}
.p-actions button:hover { border-color: var(--p-accent); }
.p-actions button:active { transform: translateY(1px); }

#panel .p-foot { margin-top: 14px; font-size: 11px; line-height: 1.4; opacity: 0.7; }
#panel .p-foot a { color: var(--p-accent); }
#panel h3 {
  margin: 12px 0 4px;
  font: 13px "Pixelify Sans", monospace;
  letter-spacing: 0.2em;
  color: var(--p-accent);
  text-transform: lowercase;
}

.p-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 8px;
  padding: 3px 0;
  cursor: pointer;
}
.p-name { color: var(--p-dim); }
.p-row:hover .p-name { color: #fff; }
.p-val { text-align: right; font-variant-numeric: tabular-nums; }

.p-range input {
  grid-column: 1 / -1;
  width: 100%;
  margin: 0;
  accent-color: var(--p-accent);
  height: 16px;
}

.p-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.p-sw {
  width: 30px;
  height: 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  position: relative;
  transition: background 0.2s;
}
.p-sw::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}
.p-toggle input:checked + .p-sw { background: var(--p-accent); }
.p-toggle input:checked + .p-sw::after { transform: translateX(14px); }
.p-toggle input:focus-visible + .p-sw { outline: 2px solid #fff; outline-offset: 2px; }

.p-text input {
  grid-column: 1 / -1;
  width: 100%;
  padding: 4px 6px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--p-line);
  border-radius: 5px;
  color: #fff;
  font: inherit;
}
.p-select select {
  padding: 2px 4px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--p-line);
  border-radius: 5px;
  color: #fff;
  font: inherit;
}
.p-select select:focus { outline: none; border-color: var(--p-accent); }
.p-text input:focus { outline: none; border-color: var(--p-accent); }
#stage[hidden] { display: none; }
