:root {
  --ink: #0b0b10;
  --space: #070a1a;
  --panel: #172042;
  --panel-2: #1f2a55;
  --text: #f2f5ff;
  --muted: #a3acd6;
  --red: #c51111;
  --red-hi: #ec2a2f;
  --cyan: #38fedc;
  --yellow: #f5f557;
  --error: #ff9b9b;
  --bubble: #ffffff;
  --bubble-text: #141824;
  --radius: 22px;
  --font: "Nunito", "Varela Round", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  font: 600 16px/1.5 var(--font);
  color: var(--text);
  background:
    radial-gradient(60% 40% at 90% 0%, #3b1d6e66, transparent 70%),
    radial-gradient(55% 40% at 0% 100%, #0f4b6e55, transparent 70%),
    linear-gradient(180deg, #0b1030, var(--space) 60%);
  background-color: var(--space);
  background-attachment: fixed;
}

/* Slowly drifting stars */
body::before {
  content: "";
  position: fixed;
  top: -260px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.8;
  background-image:
    radial-gradient(1.5px 1.5px at 20px 30px, #fff, transparent),
    radial-gradient(1px 1px at 120px 80px, #ffffffcc, transparent),
    radial-gradient(1.5px 1.5px at 210px 150px, #ffffffaa, transparent),
    radial-gradient(1px 1px at 300px 40px, #fff, transparent),
    radial-gradient(2px 2px at 380px 200px, #ffffffdd, transparent),
    radial-gradient(1px 1px at 60px 220px, #ffffff99, transparent);
  background-size: 400px 260px;
  animation: drift 120s linear infinite;
}
@keyframes drift { to { transform: translateY(260px); } }

input, textarea, button { font: inherit; }
a { color: var(--cyan); }
h1, h2 { margin: 0; line-height: 1.15; font-weight: 900; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }

/* Layout */
.page {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 18px 16px 40px;
  display: grid;
  gap: 18px;
}
.page.wide { max-width: 680px; }
.stack { display: grid; gap: 18px; }
/* minmax(0, 1fr) stops long content (like a link) from stretching the page wider than the screen */
.page, .stack { grid-template-columns: minmax(0, 1fr); }
.center { justify-self: center; }
.scene + .btn { margin-top: 0; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.logo { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.logo img { width: 30px; height: 38px; }
.logo span { font-size: 1.45rem; font-weight: 900; letter-spacing: 0.03em; }

/* Thick outlined text, like the game's titles */
.outlined {
  color: #fff;
  text-shadow:
    -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 2px 2px 0 var(--ink),
    0 -2px 0 var(--ink), 0 2px 0 var(--ink), -2px 0 0 var(--ink), 2px 0 0 var(--ink),
    0 5px 0 var(--ink);
}

.hero { display: grid; gap: 10px; text-align: center; padding-top: 4px; }
.hero h1 { font-size: clamp(1.9rem, 7.5vw, 2.6rem); line-height: 1.1; }
.hero h1 .accent { color: var(--red-hi); }
.lead { margin: 0; font-size: 1.05rem; color: var(--muted); }

.panel {
  padding: 22px 20px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 3px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: inset 0 2px 0 #ffffff14, 0 6px 0 var(--ink), 0 18px 40px #00000099;
}
.panel h1 { font-size: 1.6rem; margin-bottom: 6px; }
.panel h2 { font-size: 1.05rem; margin: 16px 0 4px; }

/* White speech bubbles, like the in-game chat */
.bubble {
  position: relative;
  display: inline-block;
  margin: 0;
  padding: 8px 14px;
  background: var(--bubble);
  color: var(--bubble-text);
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: 0 4px 0 var(--ink);
  font-weight: 800;
}
.bubble.tail::before,
.bubble.tail::after {
  content: "";
  position: absolute;
  border-style: solid;
}
.bubble.tail::before {
  left: -14px;
  top: 10px;
  border-width: 9px 13px 9px 0;
  border-color: transparent var(--ink) transparent transparent;
}
.bubble.tail::after {
  left: -8px;
  top: 13px;
  border-width: 6px 9px 6px 0;
  border-color: transparent var(--bubble) transparent transparent;
}

/* Avatars: a crewmate in a porthole, ringed in its own color */
.avatar {
  --size: 64px;
  flex: none;
  width: var(--size);
  height: var(--size);
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 30%, #33427f, #141b3a);
  box-shadow: 0 0 0 3px var(--crew-body, #c51111), 0 5px 0 3px var(--ink);
}
.avatar.sm { --size: 44px; }
.avatar.lg { --size: 88px; }
.avatar .avatar-crew { width: 64%; height: auto; transform: translateY(10%); }

.profile { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.profile-name { margin: 0 0 8px; font-size: 1.35rem; font-weight: 900; overflow-wrap: anywhere; }

/* Inputs */
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 8px; font-weight: 800; }

.input {
  display: flex;
  align-items: center;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: 0 4px 0 var(--ink);
}
.input span { padding-left: 14px; color: #6b7189; font-weight: 900; }
.input input {
  flex: 1;
  min-width: 0;
  padding: 13px 14px 13px 4px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--bubble-text);
  font-weight: 800;
  font-size: 1.05rem;
}
.input.plain input { padding-left: 14px; }
.input:focus-within { box-shadow: 0 4px 0 var(--ink), 0 0 0 4px #38fedc66; }
.hint { margin-top: 8px; font-size: 0.85rem; color: var(--muted); }

.composer {
  padding: 12px 14px 8px;
  background: var(--bubble);
  border: 3px solid var(--ink);
  border-radius: 18px;
  box-shadow: 0 5px 0 var(--ink);
}
.composer:focus-within { box-shadow: 0 5px 0 var(--ink), 0 0 0 4px #38fedc66; }
.composer textarea {
  display: block;
  width: 100%;
  min-height: 110px;
  resize: vertical;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--bubble-text);
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.45;
}
.composer textarea::placeholder { color: #8a90a8; }
.composer-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 2px dashed #d9deea;
  font-size: 0.8rem;
  font-weight: 800;
  color: #6b7189;
}
.counter.over { color: #d11a1a; }

.error { min-height: 1.4em; margin: 12px 0 0; color: var(--error); font-weight: 800; text-align: center; }

/* Hidden field that only bots fill in */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Buttons */
.btn {
  --btn: var(--red);
  --btn-hi: var(--red-hi);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 16px;
  padding: 14px 20px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: linear-gradient(180deg, var(--btn-hi), var(--btn));
  box-shadow: inset 0 3px 0 #ffffff40, 0 6px 0 var(--ink);
  color: #fff;
  font-weight: 900;
  font-size: 1.15rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  text-shadow: 0 2px 0 var(--ink), 1px 1px 0 var(--ink), -1px 1px 0 var(--ink), 1px -1px 0 var(--ink), -1px -1px 0 var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(4px); box-shadow: inset 0 3px 0 #ffffff40, 0 2px 0 var(--ink); }
.btn:disabled {
  opacity: 0.55;
  filter: saturate(0.7);
  cursor: not-allowed;
  transform: none;
  box-shadow: inset 0 3px 0 #ffffff40, 0 6px 0 var(--ink);
}
.btn:focus-visible { outline: 4px solid var(--cyan); outline-offset: 3px; }
.btn.green { --btn: #1b9e3a; --btn-hi: #36d159; }
.btn.ghost { --btn: #202a55; --btn-hi: #2d3a72; }
.btn.sm {
  width: auto;
  margin: 0;
  padding: 7px 14px;
  font-size: 0.78rem;
  box-shadow: inset 0 2px 0 #ffffff30, 0 4px 0 var(--ink);
}
.btn.sm:active { transform: translateY(2px); box-shadow: inset 0 2px 0 #ffffff30, 0 2px 0 var(--ink); }

.copy-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 4px;
  padding: 6px 6px 6px 14px;
  background: #0e1430;
  border: 3px solid var(--ink);
  border-radius: 16px;
}
.copy-box code {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  font: 700 0.9rem ui-monospace, SFMono-Regular, Consolas, monospace;
  color: var(--cyan);
}

.notice {
  margin: 8px 0;
  padding: 12px 14px;
  background: #3a1420;
  border: 3px solid var(--ink);
  border-radius: 16px;
  color: #ffd6d6;
  font-size: 0.9rem;
}

.footnote { margin: 0; text-align: center; font-size: 0.85rem; color: var(--muted); }

/* Vent scene */
.scene {
  position: relative;
  height: 190px;
  margin-bottom: 18px;
  overflow: hidden;
  isolation: isolate;
  background: #5a6684;
  border: 3px solid var(--ink);
  border-radius: 18px;
  box-shadow: inset 0 -8px 20px #00000055, 0 5px 0 var(--ink);
}
.scene-wall {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  background:
    linear-gradient(180deg, transparent 50px, #151a2e 50px, #151a2e 56px, #0b0e1c 56px),
    repeating-linear-gradient(90deg, #2a3353 0 58px, #1f2743 58px 61px);
  border-bottom: 3px solid var(--ink);
}
.scene-light {
  position: absolute;
  top: 14px;
  left: 50%;
  width: 70px;
  height: 10px;
  margin-left: -35px;
  background: #ffe98a;
  border: 2px solid var(--ink);
  border-radius: 6px;
  box-shadow: 0 0 16px 4px #ffe98a88;
  animation: flicker 7s infinite;
}
@keyframes flicker {
  0%, 90%, 100% { opacity: 1; }
  92% { opacity: 0.35; }
  94% { opacity: 1; }
  96% { opacity: 0.6; }
}
.scene-floor {
  position: absolute;
  top: 67px;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    linear-gradient(180deg, #00000045, transparent 28px),
    repeating-linear-gradient(180deg, transparent 0 40px, #46506b 40px 43px),
    repeating-linear-gradient(90deg, transparent 0 64px, #46506b 64px 67px),
    linear-gradient(180deg, #6a7693, #5a6684);
}
.scene .vent { position: absolute; right: 22px; bottom: 30px; z-index: 1; width: 150px; height: 64px; overflow: visible; }
.vent-lid { transform-box: fill-box; transform-origin: 50% 0; }

.actor { position: absolute; left: 26px; bottom: 34px; z-index: 2; width: 70px; }
.actor .crewmate { display: block; width: 70px; height: auto; overflow: visible; transform-origin: 50% 100%; }
.actor-shadow {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: -2px;
  height: 12px;
  border-radius: 50%;
  background: #00000050;
}

.scene-status {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 3;
  translate: -50% 0;
  margin: 0;
  padding: 6px 14px;
  background: #fff;
  color: var(--bubble-text);
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--ink);
  font-weight: 900;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
}
.puff {
  position: absolute;
  z-index: 3;
  width: 16px;
  height: 16px;
  background: #dfe5f5;
  border: 2px solid #9aa4c0;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}
.sound-toggle {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  background: #fff;
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 3px 0 var(--ink);
  cursor: pointer;
}
.sound-toggle svg { width: 20px; height: 20px; }
.sound-toggle .speaker { fill: currentColor; }
.sound-toggle .waves,
.sound-toggle .cross { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.sound-toggle[aria-pressed="true"] .cross,
.sound-toggle[aria-pressed="false"] .waves { display: none; }
.sound-toggle:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }

/* Crewmate drawing */
.c-body { fill: var(--crew-body, #c51111); }
.c-shade { fill: var(--crew-shade, #7a0838); }
.ink { stroke: var(--ink); stroke-width: 5; stroke-linejoin: round; }
.no-fill { fill: none; }
.v-base { fill: #95cadc; }
.v-shade { fill: #4a7d92; }
.v-shine { fill: #fff; opacity: 0.9; }

.crewmate .leg { transform-box: fill-box; transform-origin: 50% 10%; }
.crewmate .bob,
.crewmate .flip { transform-box: view-box; transform-origin: 50% 100%; }
.crewmate .flip { transition: transform 0.15s; }
.crewmate.facing-left .flip { transform: scaleX(-1); }
.crewmate.idle .bob { animation: breathe 2.6s ease-in-out infinite; }
.crewmate.running .bob { animation: bob 0.28s ease-in-out infinite alternate; }
.crewmate.running .leg-front { animation: stride 0.28s ease-in-out infinite alternate; }
.crewmate.running .leg-back { animation: stride 0.28s ease-in-out infinite alternate-reverse; }
@keyframes breathe { 50% { transform: scale(1.015, 0.975); } }
@keyframes bob { to { transform: translateY(-4px) rotate(-2deg); } }
@keyframes stride {
  from { transform: rotate(-28deg); }
  to { transform: rotate(28deg); }
}

/* Home page steps */
.steps { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.steps li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: var(--panel);
  border: 3px solid var(--ink);
  border-radius: 18px;
  box-shadow: 0 4px 0 var(--ink);
}
.steps li::before {
  counter-increment: step;
  content: counter(step);
  flex: none;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  background: var(--yellow);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 50%;
  font-weight: 900;
}
.steps strong { display: block; }
.steps span { font-size: 0.9rem; color: var(--muted); }

/* Inbox */
.inbox-title { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.inbox-title p { margin: 4px 0 0; }
.badge {
  display: inline-block;
  padding: 2px 10px;
  background: var(--red);
  color: #fff;
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 900;
  vertical-align: middle;
}
.chat-list { display: grid; gap: 16px; margin: 0; padding: 0; list-style: none; }
.chat { display: flex; align-items: flex-start; gap: 14px; }
.chat-body { flex: 1; min-width: 0; }
.chat-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 2px 0 8px; font-size: 0.85rem; color: var(--muted); }
.chat-meta strong { color: #fff; }
.chat .bubble { display: block; font-weight: 700; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat.unread .bubble { box-shadow: 0 4px 0 var(--ink), 0 0 0 4px var(--yellow); }
.chat-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* Your reply, under the message it answers */
.reply-section { margin-top: 12px; padding-left: 14px; border-left: 3px solid var(--line, #2d3a6e); }
.reply-label { margin: 0 0 6px; font-size: 0.78rem; font-weight: 800; color: var(--muted); }
.bubble.mine { display: block; background: #d8f5e3; white-space: pre-wrap; overflow-wrap: anywhere; }
.reply-editor { margin-bottom: 10px; }
.reply-editor textarea { min-height: 70px; font-size: 1rem; }
.reply-error { min-height: 0; margin: 8px 0 0; text-align: left; }
.empty { display: grid; justify-items: center; gap: 12px; padding: 28px 16px; text-align: center; }

@media (max-width: 380px) {
  .scene { height: 176px; }
  .scene .vent { right: 14px; width: 130px; height: 55.5px; }
  .actor { left: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
