:root {
  --bg: #04070c;
  --ink: #dbe9ff;
  --cyan: #7ef0ff;
  --violet: #a78bfa;
  --pink: #ff5fae;
  --muted: #8ea0b5;
  --dim: #56687e;
  --line: rgba(126, 240, 255, 0.14);
  --line2: rgba(142, 160, 181, 0.12);
  --font: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- 背景层：网格 + 扫描线 + 噪点 ---------- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.55;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: radial-gradient(120% 90% at 50% 40%, #000 6%, transparent 74%);
  mask-image: radial-gradient(120% 90% at 50% 40%, #000 6%, transparent 74%);
}

#field { position: fixed; inset: 0; z-index: 1; display: block; }

.fx {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  mix-blend-mode: screen;
}
.fx::before {
  content: "";
  position: absolute;
  inset: -10% 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(210, 240, 255, 0.045) 0 1px,
    transparent 1px 3px
  );
  animation: scan 9s linear infinite;
}
.fx::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: jitter 0.7s steps(4) infinite;
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(120% 88% at 50% 38%, transparent 32%, rgba(4, 7, 12, 0.9) 100%);
}

.cursor-glow {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 3;
  width: 30rem;
  height: 30rem;
  margin: -15rem 0 0 -15rem;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  mix-blend-mode: screen;
  background: radial-gradient(circle, rgba(126, 240, 255, 0.14), rgba(167, 139, 250, 0.07) 46%, transparent 70%);
  transition: opacity 0.5s ease;
}
.cursor-glow.on { opacity: 1; }

.crosshair {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 3;
  width: 0;
  height: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.crosshair.on { opacity: 0.55; }
.crosshair b, .crosshair i {
  position: absolute;
  display: block;
  background: var(--cyan);
  box-shadow: 0 0 8px rgba(126, 240, 255, 0.7);
}
.crosshair b { left: -0.5px; top: -22px; width: 1px; height: 44px; }
.crosshair i { top: -0.5px; left: -22px; height: 1px; width: 44px; }

/* ---------- HUD ---------- */
.hud {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  font-family: var(--mono);
  text-transform: uppercase;
  font-size: clamp(0.55rem, 1.15vw, 0.68rem);
  letter-spacing: 0.16em;
}

.corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(126, 240, 255, 0.45);
  opacity: 0.75;
}
.c1 { top: 18px; left: 18px; border-right: 0; border-bottom: 0; }
.c2 { top: 18px; right: 18px; border-left: 0; border-bottom: 0; }
.c3 { bottom: 18px; left: 18px; border-right: 0; border-top: 0; }
.c4 { bottom: 18px; right: 18px; border-left: 0; border-top: 0; }

.panel {
  position: absolute;
  display: grid;
  grid-template-columns: auto auto;
  gap: 0.35em 1.1em;
  padding: 0.7em 0.9em;
  color: var(--dim);
  border: 1px solid var(--line2);
  border-left: 2px solid rgba(126, 240, 255, 0.5);
  background: rgba(8, 14, 22, 0.5);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  animation: hudIn 1s 2.15s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.panel .v { color: var(--muted); }
.panel .v.ok { color: #5eead4; }
.p-tl { top: 34px; left: 34px; }
.p-tr { top: 34px; right: 34px; text-align: right; }
.p-tr .k { text-align: right; }
.p-bl { bottom: 40px; left: 34px; }
.p-br { bottom: 40px; right: 34px; text-align: right; }
.p-br .k { text-align: right; }

.stream {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1.7em;
  overflow: hidden;
  white-space: nowrap;
  color: rgba(126, 240, 255, 0.22);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}
.stream span {
  display: inline-block;
  padding-left: 100vw;
  animation: stream 60s linear infinite;
}

/* ---------- 舞台 ---------- */
.stage {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: clamp(3.4rem, 8vh, 5rem) clamp(1rem, 4vw, 3rem) clamp(3rem, 7vh, 4.2rem);
  text-align: center;
  pointer-events: none;
}
.stage > * { animation: rise 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.top { animation-delay: 1.85s; }
.mid { animation-delay: 1.95s; align-self: end; }
.bottom { animation-delay: 2.1s; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(0.58rem, 1.5vw, 0.72rem);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--muted);
}

.dot {
  width: 0.5em;
  height: 0.5em;
  background: #5eead4;
  box-shadow: 0 0 12px #5eead4;
  animation: pulse 1.8s ease-in-out infinite;
}

/* 故障艺术标题 */
.title {
  position: relative;
  margin: 0;
  font-size: clamp(2.3rem, 8.6vw, 5.8rem);
  font-weight: 900;
  line-height: 1.08;
  letter-spacing: 0.08em;
  color: transparent;
  background: linear-gradient(100deg, var(--cyan), var(--violet), var(--pink), var(--cyan));
  background-size: 280% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 0 26px rgba(126, 240, 255, 0.24));
  animation: flow 9s linear infinite;
}
.title::before, .title::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  color: transparent;
  -webkit-background-clip: initial;
  background-clip: initial;
  mix-blend-mode: screen;
}
.title::before {
  color: var(--cyan);
  animation: glitchA 5.6s steps(1) infinite;
}
.title::after {
  color: var(--pink);
  animation: glitchB 5.6s steps(1) infinite;
}

.type {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  margin: 0.95em 0 0;
  min-height: 1.7em;
  font-family: var(--mono);
  font-size: clamp(0.72rem, 1.85vw, 0.98rem);
  letter-spacing: 0.08em;
  color: #9fb4cc;
}
.prompt { color: var(--cyan); }

.caret {
  display: inline-block;
  width: 0.5em;
  height: 1.05em;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
  animation: blink 1s steps(1) infinite;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem;
  margin: 1.2em 0 0;
  padding: 0;
  list-style: none;
}
.chips li {
  padding: 0.42em 0.95em;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(126, 240, 255, 0.07), rgba(8, 14, 22, 0.5));
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px);
}

.log {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--dim);
  min-height: 1.4em;
}

/* ---------- 开机自检 ---------- */
.boot {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: none;
  place-content: center;
  background: #04070c;
  transition: opacity 0.65s ease;
}
.js .boot { display: grid; }
.boot.done { opacity: 0; }
.boot-inner {
  width: min(88vw, 460px);
  font-family: var(--mono);
  font-size: clamp(0.68rem, 1.7vw, 0.82rem);
  letter-spacing: 0.06em;
  color: #9fb4cc;
}
.boot-inner pre { margin: 0 0 1.1em; min-height: 8.5em; white-space: pre-wrap; line-height: 1.75; }
.boot-inner pre .ok { color: #5eead4; }
.boot-inner pre .dim { color: var(--dim); }
.bar { height: 2px; background: rgba(142, 160, 181, 0.18); }
.bar i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  box-shadow: 0 0 12px rgba(126, 240, 255, 0.6);
  transition: width 0.35s ease;
}

@keyframes flow { to { background-position: 280% 0; } }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.7); } }
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes hudIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scan { from { transform: translateY(-10%); } to { transform: translateY(10%); } }
@keyframes jitter {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-1%, 1%); }
  50% { transform: translate(1%, -1%); }
  75% { transform: translate(-1%, -1%); }
  100% { transform: translate(1%, 1%); }
}
@keyframes stream { from { transform: translateX(0); } to { transform: translateX(-50%); } }

@keyframes glitchA {
  0%, 92%, 100% { clip-path: inset(100% 0 0 0); transform: none; }
  93% { clip-path: inset(12% 0 62% 0); transform: translate(-4px, -2px); }
  95% { clip-path: inset(58% 0 18% 0); transform: translate(3px, 1px); }
  97% { clip-path: inset(32% 0 46% 0); transform: translate(-2px, 2px); }
}
@keyframes glitchB {
  0%, 92%, 100% { clip-path: inset(0 0 100% 0); transform: none; }
  94% { clip-path: inset(70% 0 8% 0); transform: translate(4px, 2px); }
  96% { clip-path: inset(24% 0 54% 0); transform: translate(-3px, -1px); }
  98% { clip-path: inset(48% 0 30% 0); transform: translate(2px, -2px); }
}

@media (hover: none) {
  .cursor-glow, .crosshair { display: none; }
}

@media (max-width: 820px) {
  .p-tr, .p-br { display: none; }
  .c2, .c4 { display: none; }
}

@media (max-height: 660px) {
  body { overflow: auto; }
  .stage { position: relative; min-height: 100%; }
  .p-bl, .p-br { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .fx, .crosshair { display: none; }
  .js .boot { display: none; }
}
