:root {
  --bg: #020402;
  --panel: #050805;
  --green: #4cff4c;
  --green-dim: #1f8f31;
  --white: #e6f4e6;
  --muted: #8ba58b;
  --line: #1b5f25;
  --danger: #ff5c5c;
  --max: 1120px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: radial-gradient(circle at 50% 0%, #071207 0, var(--bg) 45%);
  color: var(--white);
  font-family: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  line-height: 1.55;
  min-height: 100vh;
}

a { color: var(--green); text-decoration: none; }
a:hover, a:focus-visible { color: var(--white); text-shadow: 0 0 9px var(--green); }
button, input, select { font: inherit; }

.crt {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 99;
  background:
    linear-gradient(rgba(18,16,16,0) 50%, rgba(0,0,0,.18) 50%),
    linear-gradient(90deg, rgba(255,0,0,.015), rgba(0,255,0,.008), rgba(0,0,255,.015));
  background-size: 100% 4px, 5px 100%;
  mix-blend-mode: screen;
  opacity: .5;
}

.terminal {
  width: min(calc(100% - 24px), var(--max));
  margin: 18px auto 42px;
  border: 1px solid var(--line);
  box-shadow: 0 0 40px rgba(37,255,61,.08), inset 0 0 80px rgba(22,255,42,.025);
  background: rgba(1,4,1,.88);
}

.statusbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--green);
  font-size: 12px;
  letter-spacing: .05em;
}
.statusbar strong { color: var(--white); }

.panel { padding: 28px clamp(18px, 4vw, 46px); border-bottom: 1px dashed var(--line); }
.masthead { text-align: center; padding-top: 22px; padding-bottom: 22px; }
.ansi-rule { color: var(--green-dim); overflow: hidden; white-space: nowrap; }
.eyebrow { color: var(--muted); font-size: 12px; letter-spacing: .1em; }
h1 { margin: 8px 0 0; font-size: clamp(40px, 9vw, 92px); line-height: .95; letter-spacing: -.07em; color: var(--green); text-shadow: 0 0 16px rgba(76,255,76,.28); }
h1 span { color: var(--white); }
.tagline { color: var(--green); letter-spacing: .18em; font-size: clamp(11px, 1.7vw, 15px); }

.menu {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  padding-top: 12px;
  padding-bottom: 12px;
  background: #030703;
  position: sticky;
  top: 0;
  z-index: 10;
}
.menu a { color: var(--white); font-size: 14px; }
.menu b { color: var(--green); }

.hero { display: grid; grid-template-columns: minmax(240px, .75fr) 1.25fr; align-items: center; gap: clamp(26px, 5vw, 64px); }
.logo-wrap { position: relative; }
.logo-wrap::before { content: ""; position: absolute; inset: 12%; border-radius: 50%; box-shadow: 0 0 60px rgba(76,255,76,.16); }
.logo-wrap img { display: block; width: 100%; max-width: 420px; margin: auto; filter: contrast(1.08) saturate(.92); }
.hero h2 { font-size: clamp(28px, 4vw, 44px); margin: 8px 0 18px; color: var(--white); }
.hero-copy p { max-width: 700px; }
.promptline, .command { color: var(--muted); }
.prompt { color: var(--green); }
.callouts { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }

.bbs-button {
  display: inline-block;
  border: 1px solid var(--green);
  color: #001700;
  background: var(--green);
  padding: 10px 14px;
  font-weight: 800;
  letter-spacing: .03em;
  cursor: pointer;
}
.bbs-button:hover, .bbs-button:focus-visible { background: var(--white); color: #001700; box-shadow: 0 0 18px rgba(76,255,76,.22); }
.bbs-button.secondary { color: var(--green); background: transparent; }
.bbs-button.secondary:hover { color: var(--bg); background: var(--green); }

.section-title { color: var(--green); letter-spacing: .08em; margin-bottom: 24px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.section-title span { color: var(--bg); background: var(--green); padding: 2px 6px; margin-right: 8px; }
h3 { color: var(--green); margin-top: 0; }
.grid.two { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 30px; }
.dim { color: var(--muted); font-size: 13px; }

.values { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); margin-top: 26px; }
.values div { background: var(--panel); padding: 18px 10px; text-align: center; font-size: 13px; }
.values span { color: var(--green); }

.board-list { border: 1px solid var(--line); }
.board-row { width: 100%; display: grid; grid-template-columns: 1.2fr 1fr .25fr; gap: 12px; padding: 10px 12px; border: 0; border-bottom: 1px dotted var(--line); background: transparent; color: var(--white); text-align: left; cursor: pointer; }
.board-row:last-child { border-bottom: 0; }
button.board-row:hover, button.board-row:focus-visible { background: #071107; color: var(--green); outline: none; }
.board-row b, .online { color: var(--green); }
.board-head { background: var(--green); color: #001700; font-weight: 800; cursor: default; }
.message-window { margin-top: 18px; border: 1px solid var(--line); background: #020602; }
.message-head { padding: 7px 10px; color: #001700; background: var(--green); font-weight: 800; }
.message-window pre { white-space: pre-wrap; margin: 0; padding: 16px; color: var(--white); font: inherit; }

.event-card { display: grid; grid-template-columns: 120px 1fr; gap: 22px; border: 1px solid var(--line); padding: 18px; }
.datebox { border: 1px solid var(--green); display: grid; place-items: center; align-content: center; min-height: 110px; color: var(--green); }
.datebox span { font-size: 11px; color: var(--muted); }
.datebox strong { font-size: 28px; }
.ascii-map { color: var(--green); overflow-x: auto; margin-top: 18px; }
.ascii-map pre { margin: 0; }

.join-form { display: grid; gap: 14px; }
.join-form label { display: grid; gap: 5px; color: var(--green); font-size: 12px; }
.join-form input, .join-form select { width: 100%; border: 1px solid var(--line); background: #010301; color: var(--white); padding: 10px 11px; outline: none; }
.join-form input:focus, .join-form select:focus { border-color: var(--green); box-shadow: 0 0 0 2px rgba(76,255,76,.09); }
.form-status { min-height: 1.5em; margin: 0; color: var(--green); }

.footer { padding: 18px; text-align: center; color: var(--muted); font-size: 12px; }
.footer-menu { margin: 8px 0; }
.footer button { border: 0; color: var(--green); background: transparent; cursor: pointer; }
.footer button:hover { color: var(--white); }

.blink { animation: blink 1s steps(1) infinite; color: var(--green); }
@keyframes blink { 50% { opacity: 0; } }

#logoffDialog { border: 1px solid var(--green); background: #010301; color: var(--green); box-shadow: 0 0 70px rgba(76,255,76,.18); min-width: min(90vw, 480px); text-align: center; }
#logoffDialog::backdrop { background: rgba(0,0,0,.88); }

@media (max-width: 760px) {
  .terminal { width: min(calc(100% - 10px), var(--max)); margin-top: 5px; }
  .hero, .grid.two { grid-template-columns: 1fr; }
  .hero { text-align: left; }
  .logo-wrap img { max-width: 320px; }
  .values { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .board-row { grid-template-columns: 1fr; gap: 2px; }
  .board-head { display: none; }
  .event-card { grid-template-columns: 1fr; }
  .datebox { min-height: 80px; }
  .menu { position: static; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .blink { animation: none; }
}

/* Phone-first terminal refinements */
html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 64px;
}

body {
  overflow-x: hidden;
}

img,
svg,
video {
  max-width: 100%;
}

.menu a,
.board-row,
.bbs-button,
.footer button {
  -webkit-tap-highlight-color: rgba(76,255,76,.16);
  touch-action: manipulation;
}

section[id] {
  scroll-margin-top: 64px;
}

@media (max-width: 760px) {
  :root { --phone-pad: clamp(12px, 4vw, 18px); }

  body {
    background: #020402;
    font-size: 15px;
    line-height: 1.5;
  }

  .crt {
    opacity: .36;
    background-size: 100% 4px, 4px 100%;
  }

  .terminal {
    width: 100%;
    margin: 0;
    border-left: 0;
    border-right: 0;
    border-top: 0;
    box-shadow: inset 0 0 44px rgba(22,255,42,.025);
  }

  .statusbar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px 10px;
    padding: 7px var(--phone-pad);
    font-size: 10px;
    line-height: 1.35;
  }

  .statusbar span:nth-child(2) { text-align: right; }
  .statusbar span:nth-child(4) { text-align: right; }

  .panel {
    padding: 22px var(--phone-pad);
  }

  .masthead {
    padding-top: 17px;
    padding-bottom: 17px;
  }

  .ansi-rule {
    font-size: 10px;
    letter-spacing: -.08em;
  }

  .eyebrow {
    margin: 10px 0 7px;
    font-size: 10px;
    line-height: 1.45;
  }

  h1 {
    font-size: clamp(42px, 16vw, 70px);
    letter-spacing: -.085em;
    overflow-wrap: anywhere;
  }

  .tagline {
    margin: 12px auto 7px;
    max-width: 30ch;
    font-size: 10px;
    line-height: 1.7;
    letter-spacing: .11em;
  }

  .menu {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    flex-wrap: nowrap;
    gap: 0;
    padding: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 8px 18px rgba(0,0,0,.42);
  }

  .menu::-webkit-scrollbar { display: none; }

  .menu a {
    flex: 0 0 auto;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    border-right: 1px dotted var(--line);
    font-size: 12px;
    white-space: nowrap;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 15px;
    text-align: left;
  }

  .logo-wrap {
    width: min(78vw, 310px);
    margin: 0 auto;
  }

  .logo-wrap img { max-width: 100%; }

  .hero h2 {
    font-size: clamp(27px, 9vw, 38px);
    margin-bottom: 12px;
  }

  .promptline {
    font-size: 12px;
    overflow-wrap: anywhere;
  }

  .callouts {
    display: grid;
    grid-template-columns: 1fr;
    gap: 9px;
    margin-top: 20px;
  }

  .bbs-button {
    width: 100%;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 12px;
    text-align: center;
  }

  .section-title {
    margin-bottom: 18px;
    font-size: 12px;
    line-height: 1.45;
  }

  .grid.two { grid-template-columns: 1fr; gap: 18px; }

  .values {
    grid-template-columns: 1fr 1fr;
    margin-top: 20px;
  }

  .values div {
    min-height: 70px;
    display: grid;
    place-content: center;
    padding: 12px 8px;
    font-size: 11px;
  }

  .board-list { border-left: 0; border-right: 0; }

  .board-row {
    position: relative;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 3px 10px;
    min-height: 58px;
    padding: 10px 7px;
    align-items: center;
    font-size: 12px;
  }

  .board-row > span:first-child {
    grid-column: 1 / 2;
    min-width: 0;
  }

  .board-row > span:nth-child(2) {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 11px;
  }

  .board-row > span:nth-child(3) {
    grid-column: 2 / 3;
    grid-row: 1;
    align-self: center;
    justify-self: end;
    font-size: 10px;
  }

  .board-head { display: none; }

  .message-window { margin-top: 14px; }
  .message-head { font-size: 11px; line-height: 1.4; }
  .message-window pre {
    padding: 13px;
    font-size: 12px;
    line-height: 1.5;
    overflow-wrap: anywhere;
  }

  .event-card {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 13px;
  }

  .datebox {
    min-height: 68px;
    grid-template-columns: auto auto;
    gap: 10px;
    justify-content: start;
    padding: 10px 14px;
  }

  .datebox strong { font-size: 24px; }

  .ascii-map {
    width: calc(100% + (var(--phone-pad) * 2));
    margin-left: calc(var(--phone-pad) * -1);
    padding: 0 var(--phone-pad) 6px;
    font-size: 10px;
    -webkit-overflow-scrolling: touch;
  }

  .join-form input,
  .join-form select {
    min-height: 44px;
    font-size: 16px; /* prevents iOS focus zoom */
  }

  .command {
    overflow-wrap: anywhere;
  }

  .footer {
    padding: 18px var(--phone-pad) calc(18px + env(safe-area-inset-bottom));
    font-size: 10px;
  }

  .footer-menu {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 12px 0;
  }

  .footer-menu a,
  .footer-menu button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 0 10px;
    border: 1px solid var(--line);
  }

  #logoffDialog {
    width: calc(100vw - 24px);
    min-width: 0;
    max-width: 480px;
    padding: 18px 14px;
  }

  #logoffDialog pre {
    white-space: pre-wrap;
    font-size: 12px;
  }
}

@media (max-width: 390px) {
  .statusbar { font-size: 9px; }
  .menu a { padding-inline: 10px; }
  .values { grid-template-columns: 1fr; }
  h1 { font-size: clamp(38px, 15vw, 58px); }
}

@media (hover: none) and (pointer: coarse) {
  a:hover,
  button:hover {
    text-shadow: none;
  }
}

/* Logo boot / line-printer reveal */
.logo-wrap {
  overflow: hidden;
  isolation: isolate;
}

.logo-wrap.logo-printing img {
  animation:
    mae-logo-print 1.45s steps(22, end) both,
    mae-logo-flicker 1.45s linear both;
  will-change: clip-path, opacity, filter;
}

.logo-wrap.logo-printing::after {
  content: "";
  position: absolute;
  z-index: 3;
  left: 5%;
  right: 5%;
  top: 0;
  height: 3px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(230,244,230,.95) 12%, var(--green) 50%, rgba(230,244,230,.95) 88%, transparent);
  box-shadow: 0 0 8px var(--green), 0 0 22px rgba(76,255,76,.5);
  animation: mae-print-head 1.45s steps(22, end) both;
}

.logo-wrap.logo-printing::before {
  animation: mae-logo-glow 1.45s steps(8, end) both;
}

@keyframes mae-logo-print {
  0%   { clip-path: inset(0 0 100% 0); opacity: .18; filter: contrast(1.4) brightness(1.45) saturate(.7); }
  8%   { opacity: .9; }
  14%  { opacity: .38; }
  18%  { opacity: 1; }
  100% { clip-path: inset(0 0 0 0); opacity: 1; filter: contrast(1.08) saturate(.92); }
}

@keyframes mae-print-head {
  0%   { top: 0; opacity: 0; }
  3%   { opacity: 1; }
  94%  { opacity: 1; }
  100% { top: calc(100% - 3px); opacity: 0; }
}

@keyframes mae-logo-flicker {
  0%, 7%, 13%, 18%, 23%, 100% { visibility: visible; }
  8%, 14%, 22% { visibility: hidden; }
}

@keyframes mae-logo-glow {
  0%   { opacity: 0; transform: scale(.9); }
  35%  { opacity: .25; }
  100% { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .logo-wrap.logo-printing img,
  .logo-wrap.logo-printing::before,
  .logo-wrap.logo-printing::after {
    animation: none;
  }
}

/* Old-school BBS session chrome */
body.booting { overflow: hidden; }
.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: #000;
  color: var(--green);
  transition: opacity .18s steps(2, end), visibility .18s;
}
.boot-screen.is-gone { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-window {
  width: min(760px, 100%);
  min-height: min(520px, 82vh);
  border: 1px solid var(--green-dim);
  padding: clamp(18px, 4vw, 34px);
  background: #010301;
  box-shadow: 0 0 46px rgba(76,255,76,.12), inset 0 0 80px rgba(76,255,76,.025);
  position: relative;
}
.boot-lines {
  margin: 0;
  min-height: 25em;
  white-space: pre-wrap;
  color: var(--green);
  font: inherit;
  font-size: 14px;
  line-height: 1.55;
  text-shadow: 0 0 8px rgba(76,255,76,.22);
}
.boot-gate {
  color: var(--white);
  margin-top: 10px;
  letter-spacing: .06em;
}
.boot-skip {
  position: absolute;
  right: 12px;
  bottom: 10px;
  border: 0;
  background: transparent;
  color: var(--green-dim);
  cursor: pointer;
  font-size: 11px;
}
.boot-skip:hover, .boot-skip:focus-visible { color: var(--green); outline: none; }

.doorbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 12px;
  border-bottom: 1px dotted var(--line);
  color: var(--muted);
  background: #010301;
  font-size: 10px;
  letter-spacing: .04em;
}
.doorbar strong { color: var(--green); font-weight: 400; }
.menu-hint { margin-left: auto; color: var(--green-dim); font-size: 11px; white-space: nowrap; }
.bbs-id { color: var(--green-dim); font-size: 10px; letter-spacing: .07em; margin: 5px 0 0; }
.session-line { color: var(--green-dim); font-size: 11px; margin-top: -4px; }

/* Slightly rougher terminal phosphor, closer to a CRT BBS capture. */
.terminal { position: relative; }
.terminal::after {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: .055;
  background-image: repeating-linear-gradient(0deg, transparent 0 7px, rgba(76,255,76,.22) 8px);
  mix-blend-mode: screen;
}
.terminal > * { position: relative; z-index: 3; }

@media (max-width: 760px) {
  .boot-screen { padding: 0; }
  .boot-window { width: 100%; min-height: 100dvh; border: 0; padding: 22px 14px 58px; }
  .boot-lines { min-height: 0; font-size: 11px; line-height: 1.45; }
  .boot-gate { font-size: 11px; }
  .doorbar { overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
  .doorbar::-webkit-scrollbar { display: none; }
  .menu-hint { display: none; }
  .bbs-id { font-size: 9px; line-height: 1.45; }
  .session-line { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .boot-screen { transition: none; }
}

/* Classic BBS audio controls + threaded message reader */
.sound-toggle,
.status-sound,
.message-commandbar button,
.reply-actions button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--green-dim);
  font: inherit;
  cursor: pointer;
  padding: 0;
}
.sound-toggle:hover,
.sound-toggle:focus-visible,
.message-commandbar button:hover,
.message-commandbar button:focus-visible,
.reply-actions button:hover,
.reply-actions button:focus-visible {
  color: var(--green);
  outline: none;
  text-shadow: 0 0 7px rgba(76,255,76,.35);
}
.status-sound {
  font-size: 10px;
  white-space: nowrap;
}
.boot-controls {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.boot-controls .boot-skip { position: static; }
.boot-controls .sound-toggle { font-size: 11px; }

.message-window {
  border: 1px solid var(--green-dim);
  margin-top: 14px;
  background: rgba(0,8,0,.5);
}
.message-head {
  padding: 6px 9px;
  border-bottom: 1px solid var(--green-dim);
  color: var(--black);
  background: var(--green);
  font-size: 11px;
  letter-spacing: .04em;
}
.message-display { padding: 0; min-height: 250px; }
.message-placeholder { margin: 0; padding: 14px; white-space: pre-wrap; }
.message-card { min-height: 250px; }
.msg-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, .55fr);
  border-bottom: 1px dotted var(--line);
  font-size: 12px;
}
.msg-meta > div { padding: 8px 10px; }
.msg-meta > div:nth-child(odd) { border-right: 1px dotted var(--line); }
.msg-label { color: var(--green-dim); }
.msg-value { color: var(--white); }
.msg-subject {
  grid-column: 1 / -1;
  border-top: 1px dotted var(--line);
  border-right: 0 !important;
}
.msg-body {
  padding: 15px 12px 18px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.6;
  color: var(--green);
}
.quote-line { color: var(--muted); }
.quote-line::before { content: ''; }
.signature-line { color: var(--green-dim); }
.thread-marker {
  padding: 6px 10px;
  border-bottom: 1px dotted var(--line);
  color: var(--green-dim);
  font-size: 11px;
}
.message-commandbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 8px 10px;
  border-top: 1px solid var(--green-dim);
  background: #010301;
  font-size: 11px;
}
.message-commandbar[hidden] { display: none; }
.message-commandbar #messagePosition { margin-left: auto; color: var(--muted); }
.reply-editor { padding: 12px; }
.reply-meta { color: var(--green-dim); font-size: 11px; margin-bottom: 8px; }
.reply-editor textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  border: 1px solid var(--green-dim);
  background: #000;
  color: var(--green);
  font: inherit;
  line-height: 1.5;
  padding: 10px;
  outline: none;
}
.reply-editor textarea:focus { border-color: var(--green); box-shadow: 0 0 0 1px rgba(76,255,76,.14); }
.reply-actions { display: flex; gap: 18px; margin-top: 9px; font-size: 11px; }
.reply-status { color: var(--muted); margin-top: 8px; min-height: 1.5em; font-size: 11px; }
.board-row.is-active { background: rgba(76,255,76,.08); }

@media (max-width: 760px) {
  .statusbar { grid-template-columns: 1fr auto; }
  .status-sound { text-align: left; min-height: 28px; display: inline-flex; align-items: center; }
  .msg-meta { grid-template-columns: 1fr; }
  .msg-meta > div:nth-child(odd) { border-right: 0; }
  .msg-meta > div + div { border-top: 1px dotted var(--line); }
  .msg-subject { grid-column: auto; }
  .message-commandbar { position: sticky; bottom: 0; z-index: 6; }
  .message-commandbar button { min-height: 36px; }
  .message-commandbar #messagePosition { width: 100%; margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .terminal::after { opacity: .03; }
}
