:root {
  color-scheme: dark;
  --bg-void: #040705;
  --bg-screen: #070d08;
  --bg-panel: #0a140c;
  --phosphor: #46e868;
  --phosphor-bright: #98ffb0;
  --phosphor-dim: #338a47;
  --phosphor-faint: #194223;
  --amber: #f2b63d;
  --glow: 0 0 6px rgba(70, 232, 104, 0.32);
  --glow-strong: 0 0 10px rgba(70, 232, 104, 0.5);
  --font-mono: "Cascadia Mono", "Consolas", "SFMono-Regular", "Liberation Mono", Menlo, "Courier New", "Microsoft YaHei", "PingFang SC", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-block-size: 100%;
}

body {
  display: grid;
  place-items: center;
  min-block-size: 100vh;
  min-block-size: 100svh;
  padding: clamp(0.75rem, 3vw, 2rem);
  background:
    radial-gradient(ellipse at 50% 45%, #0d1d11 0%, var(--bg-void) 75%);
  color: var(--phosphor);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.55;
  text-shadow: var(--glow);
  -webkit-font-smoothing: antialiased;
}

/* Subtle CRT scanlines */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.18) 3px,
    rgba(0, 0, 0, 0.18) 4px
  );
}

/* Subtle CRT edge vignette */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 11;
  background: radial-gradient(
    ellipse at center,
    transparent 62%,
    rgba(0, 0, 0, 0.55) 100%
  );
}

.terminal {
  position: relative;
  width: min(100%, 40rem);
  background: var(--bg-screen);
  border: 1px solid var(--phosphor-dim);
  box-shadow:
    0 0 0 1px var(--bg-void),
    0 0 28px rgba(70, 232, 104, 0.08),
    inset 0 0 32px rgba(70, 232, 104, 0.03);
}

/* Classic TUI inverted header bar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.35rem 0.85rem;
  background: var(--phosphor);
  color: var(--bg-void);
  text-shadow: none;
  font-weight: 700;
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
}

.topbar-meta {
  font-weight: 400;
  opacity: 0.85;
}

.screen {
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
  padding: clamp(1rem, 3vw, 1.5rem);
}

/* Boot / MOTD block */
.motd {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.motd p {
  margin: 0;
}

.cmd-line {
  margin-block-end: 0.25rem;
}

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

.cmd {
  color: var(--phosphor-bright);
}

.sys-line {
  color: var(--phosphor);
  white-space: pre-wrap;
}

.badge-warn {
  color: var(--amber);
  text-shadow: 0 0 6px rgba(242, 182, 61, 0.35);
}

/* Construction viewport panel */
.panel {
  border: 1px solid var(--phosphor-faint);
  background: var(--bg-panel);
  padding: 0.85rem 1rem 1.1rem;
}

.panel-label {
  color: var(--phosphor-dim);
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  margin-block-end: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  padding-block: 0.35rem;
}

.work {
  display: grid;
  color: var(--phosphor-bright);
  text-shadow: var(--glow);
  font-size: clamp(0.95rem, 3.2vw, 1.15rem);
  line-height: 1.2;
}

.frame {
  grid-area: 1 / 1;
  margin: 0;
  font: inherit;
  visibility: hidden;
}

.frame-1 {
  visibility: visible;
  animation: frame-1 1s step-end infinite;
}

.frame-2 {
  animation: frame-2 1s step-end infinite;
}

.frame-3 {
  text-shadow: var(--glow-strong);
  animation: frame-3 1s step-end infinite;
}

.frame-4 {
  animation: frame-4 1s step-end infinite;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.875rem;
  color: var(--phosphor);
}

.spinner {
  display: inline-grid;
  color: var(--amber);
  text-shadow: 0 0 6px rgba(242, 182, 61, 0.35);
  font-weight: 700;
}

.spin-frame {
  grid-area: 1 / 1;
  visibility: hidden;
  animation: show-frame 0.6s step-end infinite;
}

.spin-frame:nth-child(1) {
  visibility: visible;
  animation-delay: 0s;
}
.spin-frame:nth-child(2) {
  animation-delay: -0.45s;
}
.spin-frame:nth-child(3) {
  animation-delay: -0.3s;
}
.spin-frame:nth-child(4) {
  animation-delay: -0.15s;
}

.progress {
  color: var(--phosphor-dim);
  letter-spacing: 0.02em;
}

/* Available links / BBS menu entry */
.routes {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.section-head {
  margin: 0;
  font-size: 0.75rem;
  color: var(--phosphor-dim);
  letter-spacing: 0.05em;
  border-bottom: 1px dashed var(--phosphor-faint);
  padding-bottom: 0.3rem;
}

.house {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--phosphor-faint);
  color: var(--phosphor);
  text-decoration: none;
  transition: background-color 80ms steps(2), color 80ms steps(2), border-color 80ms steps(2);
}

.house-art {
  margin: 0;
  font: inherit;
  font-size: 0.8125rem;
  line-height: 1.05;
  color: var(--phosphor-bright);
  flex-shrink: 0;
}

.house-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
  flex: 1;
}

.house-title {
  font-size: 0.9375rem;
  color: var(--phosphor-bright);
}

.key {
  color: var(--amber);
}

.house-url {
  font-size: 0.75rem;
  color: var(--phosphor-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.house-action {
  font-size: 0.75rem;
  color: var(--phosphor-dim);
  flex-shrink: 0;
  letter-spacing: 0.04em;
}

/* Classic terminal reverse-video highlight on hover / focus */
.house:hover,
.house:focus-visible {
  background: var(--phosphor);
  border-color: var(--phosphor);
  color: var(--bg-void);
  text-shadow: none;
  outline: none;
}

.house:hover .house-art,
.house:hover .house-title,
.house:hover .key,
.house:hover .house-url,
.house:hover .house-action,
.house:focus-visible .house-art,
.house:focus-visible .house-title,
.house:focus-visible .key,
.house:focus-visible .house-url,
.house:focus-visible .house-action {
  color: var(--bg-void);
  text-shadow: none;
}

.house:focus-visible {
  box-shadow: 0 0 0 2px var(--bg-screen), 0 0 0 3px var(--phosphor);
}

/* Bottom CLI prompt */
.prompt-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--phosphor-faint);
  font-size: 0.8125rem;
}

.prompt-line {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.cursor {
  display: inline-block;
  inline-size: 0.6em;
  block-size: 1.05em;
  background: var(--phosphor);
  box-shadow: var(--glow);
  animation: blink 1s step-end infinite;
}

.footer-meta {
  font-size: 0.75rem;
  color: var(--phosphor-dim);
}

@keyframes frame-1 {
  0% {
    visibility: visible;
  }
  32%,
  100% {
    visibility: hidden;
  }
}

@keyframes frame-2 {
  0% {
    visibility: hidden;
  }
  32% {
    visibility: visible;
  }
  46%,
  100% {
    visibility: hidden;
  }
}

@keyframes frame-3 {
  0% {
    visibility: hidden;
  }
  46% {
    visibility: visible;
  }
  76%,
  100% {
    visibility: hidden;
  }
}

@keyframes frame-4 {
  0% {
    visibility: hidden;
  }
  76% {
    visibility: visible;
  }
  100% {
    visibility: hidden;
  }
}

@keyframes show-frame {
  0% {
    visibility: visible;
  }
  25%,
  100% {
    visibility: hidden;
  }
}

@keyframes blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

@media (max-width: 480px) {
  .topbar-meta,
  .house-action {
    display: none;
  }

  .status-row {
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .frame,
  .spin-frame,
  .cursor {
    animation: none;
  }
}
