:root {
  color-scheme: dark;
  --bg: #000;
  --fg: #b7ffbf;
  --dim: #5f9f68;
  --line: #38d85a;
  --hot: #e7ffe9;
  --danger: #ff6b6b;
  --amber: #ffd166;
  --shadow: rgba(56, 216, 90, 0.28);
  --mono: "Cascadia Code", "Fira Code", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  background: #000;
  color: var(--fg);
  font-family: var(--mono);
  font-size: 16px;
}

button,
a {
  font: inherit;
}

#scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  opacity: 0.92;
  image-rendering: pixelated;
  filter: contrast(1.25) brightness(0.92);
}

.crt {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(183, 255, 191, 0.05) 0 1px, transparent 1px 4px),
    radial-gradient(circle at center, transparent 0, rgba(0, 0, 0, 0.55) 72%);
}

.screen {
  position: relative;
  z-index: 2;
  width: min(1120px, calc(100% - 24px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 0 28px;
}

.tui-window {
  position: relative;
  margin: 0 0 18px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.62);
  box-shadow: 0 0 0 1px rgba(56, 216, 90, 0.14), 0 0 28px var(--shadow);
}

.boot-window {
  background: rgba(0, 0, 0, 0.58);
}

.index-window,
.modal-window {
  background: rgba(0, 0, 0, 0.56);
}

.tui-window::before,
.tui-window::after {
  position: absolute;
  color: var(--line);
  background: #000;
  line-height: 1;
}

.tui-window::before {
  content: "+";
  left: -1px;
  top: -1px;
}

.tui-window::after {
  content: "+";
  right: -1px;
  bottom: -1px;
}

.tui-title {
  position: absolute;
  top: -0.72em;
  left: 18px;
  padding: 0 8px;
  background: rgba(0, 0, 0, 0.86);
  color: var(--hot);
  text-transform: uppercase;
}

.tui-content {
  padding: 22px;
}

.boot-window {
  min-height: 54vh;
}

.ascii-logo {
  max-width: 100%;
  margin: 4px 0 20px;
  overflow: hidden;
  color: var(--dim);
  font-size: clamp(0.24rem, 1.05vw, 0.72rem);
  line-height: 1.05;
  white-space: pre;
}

.command {
  margin: 0 0 14px;
  color: var(--amber);
}

.text-block {
  max-width: 78ch;
}

.text-block p,
.hint {
  margin: 0 0 8px;
  line-height: 1.55;
}

#page-title {
  margin-bottom: 18px;
  color: var(--hot);
  font-size: clamp(1.4rem, 4vw, 2.6rem);
  text-transform: uppercase;
}

.spaced {
  margin-top: 18px !important;
}

.cursor {
  display: inline-block;
  width: 0.65em;
  height: 1.12em;
  margin-left: 0.28em;
  vertical-align: -0.18em;
  background: var(--fg);
  animation: blink 1s steps(2, start) infinite;
}

h1,
h2 {
  margin: 0 0 14px;
  color: var(--hot);
  font-size: clamp(1.25rem, 3vw, 2rem);
  font-weight: 700;
}

.hint {
  color: var(--dim);
}

.status-row,
.footer-actions,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status-row {
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px dashed rgba(56, 216, 90, 0.5);
  color: var(--amber);
}

.index-window.is-locked .links-list,
.index-window.is-locked .footer-actions {
  display: none;
}

.index-window:not(.is-locked) .hint {
  display: none;
}

.tui-button,
.link-card {
  border: 0;
  color: var(--fg);
  background: transparent;
  text-decoration: none;
}

.tui-button {
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.tui-button::before {
  content: "> ";
  color: var(--line);
}

.tui-button:hover,
.tui-button:focus-visible,
.link-card:hover,
.link-card:focus-visible {
  color: #000;
  background: var(--fg);
  outline: none;
}

.tui-button:hover::before,
.tui-button:focus-visible::before {
  color: #000;
}

.tui-button.primary {
  color: var(--hot);
}

.tui-button.danger {
  color: var(--danger);
}

.tui-button.small {
  color: var(--dim);
}

.links-list {
  display: grid;
  gap: 8px;
  margin-top: 20px;
}

.link-card {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(0, 1fr) minmax(180px, 260px);
  gap: 14px;
  padding: 7px 8px;
  border-top: 1px dotted rgba(56, 216, 90, 0.36);
}

.link-name {
  color: var(--hot);
}

.link-name::before {
  content: "[DIR] ";
  color: var(--amber);
}

.link-description {
  color: var(--fg);
}

.link-url {
  overflow: hidden;
  color: var(--dim);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-card:hover .link-name,
.link-card:hover .link-description,
.link-card:hover .link-url,
.link-card:focus-visible .link-name,
.link-card:focus-visible .link-description,
.link-card:focus-visible .link-url {
  color: #000;
}

.tui-output {
  display: none;
  margin: 16px 0;
  padding: 10px 12px;
  border: 1px dashed rgba(255, 107, 107, 0.6);
  color: var(--danger);
  white-space: pre-line;
}

.tui-output:not(:empty) {
  display: block;
}

.footer-actions {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px dashed rgba(56, 216, 90, 0.5);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.72);
}

.modal-backdrop.is-visible {
  display: grid;
}

.modal-window {
  display: none;
  width: min(720px, 100%);
  margin: 0;
}

.modal-window.is-visible {
  display: block;
}

.role-menu {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.message-box {
  min-height: 150px;
  margin: 18px 0;
  padding: 14px;
  border: 1px dashed rgba(56, 216, 90, 0.62);
  background: rgba(0, 0, 0, 0.28);
  color: var(--fg);
  line-height: 1.65;
  white-space: pre-line;
}

@keyframes blink {
  50% { opacity: 0; }
}

@media (max-width: 760px) {
  body {
    font-size: 14px;
  }

  .screen {
    width: min(100% - 14px, 1120px);
    padding-top: 10px;
  }

  .tui-content {
    padding: 18px 12px;
  }

  .status-row,
  .modal-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .link-card {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
