:root {
  --bg: #07060b;
  --ink: #f3f1fa;
  --mute: #9b97ad;
  --violet: #7c5cff;
  --cyan: #22d3ee;
  --coral: #ff7a59;
  --grad: linear-gradient(100deg, var(--cyan), var(--violet) 50%, var(--coral));
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--ink); overflow: hidden;
  font: 400 16px/1.5 "Inter", system-ui, sans-serif; -webkit-font-smoothing: antialiased;
  cursor: crosshair; user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
#field { position: fixed; inset: 0; width: 100%; height: 100%; }
.grain {
  position: fixed; inset: -50%; pointer-events: none; opacity: .055; z-index: 5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 1s steps(6) infinite;
}
@keyframes grain { 0%,100% { transform: none; } 33% { transform: translate(-3%, 2%); } 66% { transform: translate(2%, -3%); } }

.stage {
  position: fixed; inset: 0; z-index: 2; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0 20px 6vh; text-align: center;
}
.stage::before {
  content: ""; position: absolute; width: min(900px, 120vw); height: min(560px, 80vh); z-index: -1;
  background: radial-gradient(closest-side, rgba(7, 6, 11, .9), rgba(7, 6, 11, .55) 60%, transparent);
}
.spiral {
  width: clamp(120px, 18vmin, 200px); height: clamp(120px, 18vmin, 200px);
  pointer-events: auto; cursor: pointer; border-radius: 50%; outline: none;
  opacity: 0; transform: scale(.6) rotate(-120deg); transition: opacity 1.4s var(--ease), transform 1.8s var(--ease);
}
.spiral:focus-visible { box-shadow: 0 0 0 1px rgba(255,255,255,.25); }
.word {
  font-weight: 600; letter-spacing: -0.055em; line-height: 1;
  font-size: clamp(56px, 13vw, 168px); margin-top: clamp(8px, 2vh, 24px);
  display: flex; pointer-events: auto;
}
.word span {
  display: inline-block; cursor: default; padding: 0 .005em;
  opacity: 0; transform: translateY(40%); filter: blur(12px);
  transition: opacity 1s var(--ease), transform 1.2s var(--ease), filter 1s var(--ease), color .5s;
}
.word span.hit { transform: translateY(-10%) !important; transition-duration: .08s, .15s, .1s, .08s; }
.line {
  margin-top: clamp(14px, 2.4vh, 28px); color: var(--mute); font-weight: 300;
  font-size: clamp(16px, 1.7vw, 20px); opacity: 0; transition: opacity 1.4s var(--ease) 1s;
}
.line em {
  font-family: "Instrument Serif", Georgia, serif; font-size: 1.3em; color: transparent;
  background: var(--grad); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text;
  animation: shift 6s ease-in-out infinite alternate; padding-right: .1em;
  pointer-events: auto; cursor: pointer;
}
@keyframes shift { to { background-position: 100% 0; } }

.ready .spiral { opacity: 1; transform: none; }
.ready .word span { opacity: 1; transform: none; filter: none; }
.ready .line { opacity: 1; }
.word span:nth-child(2) { transition-delay: .05s; } .word span:nth-child(3) { transition-delay: .1s; }
.word span:nth-child(4) { transition-delay: .15s; } .word span:nth-child(5) { transition-delay: .2s; }
.word span:nth-child(6) { transition-delay: .25s; } .word span:nth-child(7) { transition-delay: .3s; }
.word span:nth-child(8) { transition-delay: .35s; }

.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 18px max(20px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  font: 12px "JetBrains Mono", monospace; color: var(--mute);
}
.sound {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 16px 0 12px;
  border-radius: 999px; border: 1px solid rgba(255,255,255,.1); background: rgba(7,6,11,.5);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: var(--ink); font: inherit; cursor: pointer; transition: border-color .3s, background .3s;
}
.sound:hover { border-color: rgba(255,255,255,.25); }
.sound:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.sound svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sound svg path:first-child { fill: currentColor; }
.sound .w1, .sound .w2 { opacity: .25; transition: opacity .3s; }
.sound[aria-pressed="true"] .w1 { opacity: 1; animation: wave 1.4s ease-in-out infinite; }
.sound[aria-pressed="true"] .w2 { opacity: 1; animation: wave 1.4s ease-in-out .2s infinite; }
@keyframes wave { 50% { opacity: .3; } }
#hint { transition: opacity .4s; }
.mail { color: var(--mute); text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; transition: color .3s; }
.mail:hover { color: var(--ink); }

.toast {
  position: fixed; top: 24px; left: 50%; z-index: 7; transform: translate(-50%, -20px); opacity: 0;
  font: 12px "JetBrains Mono", monospace; color: var(--ink); letter-spacing: .04em;
  padding: 10px 16px; border-radius: 999px; background: rgba(7,6,11,.7); border: 1px solid rgba(255,255,255,.12);
  backdrop-filter: blur(10px); transition: opacity .5s, transform .6s var(--ease); pointer-events: none; white-space: nowrap;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 520px) {
  .mail { font-size: 11px; }
  .sound { padding: 0 12px 0 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .001ms !important; }
}
