/* Clippy2027, level 5: the factory. Act 2's first look: a dark, industrial
   map with warm machines, Clippy's violet, and glass panels over the canvas.
   Everything is scoped under .fac (the ending screens under .drama.fac-d). */
.fac {
  --fac-panel: rgba(13, 15, 22, 0.86);
  --fac-line: rgba(255, 255, 255, 0.09);
  --fac-text: #e6e8f0;
  --fac-muted: #9aa2b8;
  --fac-violet: #7b5cff;
  --fac-lilac: #c9b8ff;
  --fac-amber: #ffd84a;
  position: absolute; inset: 0; overflow: hidden; color: var(--fac-text);
  font: 14px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; word-spacing: normal; letter-spacing: normal;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
.fac[hidden] { display: none; }
.fac-cv { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; background: #0b100e; }

/* Buttons: none of 98.css's bevels out here. */
.fac :where(button) {
  font: inherit; color: inherit; text-shadow: none; box-shadow: none; border: 0; border-radius: 10px;
  min-width: 0; min-height: 0; padding: 0; background: none; cursor: pointer; outline: none;
}
.fac button:not(:disabled):hover, .fac button:not(:disabled):active { box-shadow: none; text-shadow: none; }
.fac button:disabled { color: inherit; text-shadow: none; }
.fac button:focus-visible { outline: 2px solid var(--fac-lilac); outline-offset: 2px; }
.fac button:disabled { opacity: 0.45; cursor: default; }
.fac svg { display: block; }
.fac-money svg, .fac-card svg:not(.fac-ico), .fac-sheet li button svg { width: 1em; height: 1em; color: var(--fac-lilac); }

/* ---------- the HUD: paperclips, what's next, the views ---------- */
.fac-hud {
  position: absolute; left: max(10px, env(safe-area-inset-left)); top: max(8px, env(safe-area-inset-top));
  max-width: calc(100% - 160px); display: flex; flex-direction: column; align-items: flex-start; gap: 6px; pointer-events: none;
}
.fac-hud > * { pointer-events: auto; }
.fac-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fac-money {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 12px;
  background: var(--fac-panel); border: 1px solid var(--fac-line); font-size: 19px; font-variant-numeric: tabular-nums;
}
.fac-money svg { width: 18px; height: 18px; }
.fac-rate { font-size: 12px; color: #a8f0b0; font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px #000; }
.fac .fac-enough {
  padding: 5px 10px; border-radius: 999px; font-size: 12px; color: var(--fac-muted);
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--fac-line);
}
.fac .fac-enough:active { background: rgba(255, 255, 255, 0.16); }
.fac-goal {
  font-size: 12.5px; padding: 4px 9px; border-radius: 9px; background: rgba(13, 15, 22, 0.7);
  border-left: 3px solid var(--fac-amber); max-width: 100%;
}
.fac-goal[hidden] { display: none; }
.fac-views { display: flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--fac-panel); border: 1px solid var(--fac-line); }
.fac-views[hidden], .fac-views button[hidden] { display: none; }
.fac .fac-views button { padding: 7px 11px; font-size: 13px; border-radius: 9px; color: var(--fac-muted); position: relative; }
.fac .fac-views button[aria-pressed="true"] { background: var(--fac-violet); color: #fff; }
.fac .fac-views button.fac-new::after {
  content: ""; position: absolute; top: 4px; right: 4px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--fac-amber); animation: fac-blink 1s steps(1) infinite;
}
@keyframes fac-blink { 50% { opacity: 0; } }
.fac-meters { display: grid; gap: 4px; padding: 7px 9px; border-radius: 10px; background: var(--fac-panel); border: 1px solid var(--fac-line); font-size: 11.5px; min-width: 200px; }
.fac-meters[hidden] { display: none; }
.fac-meter { display: grid; grid-template-columns: 80px 1fr 46px; align-items: center; gap: 6px; }
.fac-meter i { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.fac-meter b { display: block; height: 100%; background: #c07a48; }
.fac-unrest b { background: #e2553a; }
.fac-meter em { font-style: normal; color: var(--fac-muted); text-align: right; }

/* Zoom, on the right. */
.fac-zoom { position: absolute; right: max(10px, env(safe-area-inset-right)); top: 42%; display: grid; gap: 6px; }
.fac-zoom[hidden] { display: none; }
.fac .fac-zoom button {
  width: 40px; height: 40px; font-size: 22px; line-height: 1; border-radius: 12px;
  background: var(--fac-panel); border: 1px solid var(--fac-line); display: grid; place-items: center;
}

/* ---------- the bottom: launch, the card, the chat, the dock ---------- */
.fac-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; gap: 6px;
  padding: 0 max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  pointer-events: none; max-width: 34rem; margin: 0 auto;
}
.fac-bottom > * { pointer-events: auto; }
.fac .fac-launch {
  align-self: center; padding: 12px 22px; border-radius: 999px; font-size: 16px; font-weight: 700; color: #1a1300;
  background: var(--fac-amber); box-shadow: 0 0 0 4px rgba(255, 216, 74, 0.25), 0 6px 20px rgba(0, 0, 0, 0.5);
  animation: fac-pulse 1.2s ease-in-out infinite;
}
.fac .fac-launch[hidden] { display: none; }
@keyframes fac-pulse { 50% { box-shadow: 0 0 0 9px rgba(255, 216, 74, 0.12), 0 6px 20px rgba(0, 0, 0, 0.5); } }
.fac-card, .fac-chat, .fac-dock { background: var(--fac-panel); border: 1px solid var(--fac-line); border-radius: 14px; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.fac-card { position: relative; padding: 9px 12px 10px; font-size: 13.5px; }
.fac-card[hidden] { display: none; }
.fac-card p { margin: 4px 0 0; }
.fac-card-head { display: flex; align-items: baseline; gap: 8px; padding-right: 30px; }
.fac-card-head b { font-size: 15px; }
.fac-card-head span { color: var(--fac-muted); font-size: 12px; display: inline-flex; align-items: center; gap: 3px; }
.fac .fac-x { position: absolute; top: 4px; right: 4px; width: 34px; height: 34px; font-size: 22px; color: var(--fac-muted); border-radius: 10px; }
.fac-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.fac .fac-acts button {
  min-height: 40px; padding: 0 14px; border-radius: 11px; background: rgba(123, 92, 255, 0.22); border: 1px solid rgba(201, 184, 255, 0.35);
  display: inline-flex; align-items: center; gap: 5px; font-size: 14px;
}
.fac .fac-acts button:not(:disabled):active { background: rgba(123, 92, 255, 0.45); }
.fac-ok { color: #a8f0b0; }
.fac-small { font-size: 12px; color: var(--fac-muted); }

/* Clippy's chat: the last couple of lines; tap for more. */
.fac-chat { padding: 6px 10px; font-size: 13px; cursor: pointer; }
.fac-chat:empty { display: none; }
.fac-chat.fac-open { max-height: 42vh; overflow-y: auto; }
.fac-msg { display: flex; gap: 7px; align-items: flex-start; padding: 2px 0; opacity: 0.6; }
.fac-msg.fac-last { opacity: 1; animation: fac-in 0.35s ease-out; }
.fac-open .fac-msg { opacity: 1; }
@keyframes fac-in { from { transform: translateY(6px); opacity: 0; } }
.fac-av { flex: none; width: 20px; height: 20px; border-radius: 50%; background: var(--fac-violet); display: grid; place-items: center; color: #fff; margin-top: 1px; }
.fac-av svg { width: 14px; height: 14px; }
.fac-av.fac-hum { background: #e2553a; font-weight: 800; font-size: 12px; }
.fac-av.fac-sys { background: #3a4150; font-weight: 700; font-size: 12px; font-style: italic; }
.fac-humans span { color: #ffc0a8; }
.fac-system span { color: var(--fac-muted); }

/* The dock: tools, and Research. */
.fac-dock { display: flex; gap: 4px; padding: 5px; align-items: stretch; }
.fac-tools { display: flex; gap: 3px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.fac-tools::-webkit-scrollbar { display: none; }
.fac-tools[hidden] { display: none; }
.fac-other .fac-tools { display: none; }
.fac .fac-tools button {
  flex: 1 0 40px; max-width: 60px; height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  border-radius: 11px; font-size: 10px; color: var(--fac-muted); position: relative;
}
.fac .fac-tools button[aria-pressed="true"] { background: rgba(123, 92, 255, 0.3); color: #fff; box-shadow: inset 0 0 0 1.5px var(--fac-lilac); }
.fac .fac-tools button em { font-style: normal; font-size: 9px; opacity: 0.8; }
.fac .fac-tools button.fac-poor em { color: #ff9a8a; }
.fac-ico { width: 24px; height: 24px; }
.fac .fac-res-btn {
  flex: none; width: 54px; height: 56px; border-radius: 11px; font-size: 10px; background: rgba(255, 255, 255, 0.07);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; margin-left: auto; position: relative;
}
.fac-res-btn svg { width: 22px; height: 22px; }
.fac .fac-res-btn[hidden] { display: none; }
.fac.fac-other .fac-res-btn { flex: 1; flex-direction: row; gap: 8px; font-size: 14px; height: 48px; }
.fac .fac-res-btn em { position: absolute; top: 3px; right: 5px; font-style: normal; font-size: 10px; line-height: 15px; min-width: 15px; background: rgba(255, 255, 255, 0.15); border-radius: 999px; padding: 0 3px; }
.fac.fac-other .fac-res-btn em { position: static; }
.fac .fac-res-btn.fac-can { background: rgba(255, 216, 74, 0.2); color: #ffeaa0; }
.fac .fac-res-btn.fac-can em { background: var(--fac-amber); color: #1a1300; }

/* The research sheet. */
.fac-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 72%; overflow-y: auto; z-index: 5;
  background: rgba(16, 18, 27, 0.97); border-top: 1px solid var(--fac-line); border-radius: 18px 18px 0 0;
  padding: 12px 12px max(12px, env(safe-area-inset-bottom)); max-width: 34rem; margin: 0 auto;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6); animation: fac-up 0.22s ease-out;
}
.fac-sheet[hidden] { display: none; }
@keyframes fac-up { from { transform: translateY(40px); opacity: 0; } }
.fac-sheet-head { position: relative; display: flex; align-items: baseline; gap: 8px; padding: 2px 34px 8px 2px; }
.fac-sheet-head b { font-size: 17px; }
.fac-sheet-head span { color: var(--fac-muted); font-size: 12px; }
.fac-sheet ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.fac-sheet li { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 12px; background: rgba(255, 255, 255, 0.04); }
.fac-sheet li div { flex: 1; }
.fac-sheet li p { margin: 2px 0 0; font-size: 12.5px; color: var(--fac-muted); }
.fac .fac-sheet li button {
  flex: none; min-width: 84px; min-height: 42px; padding: 0 10px; border-radius: 11px; font-weight: 600; font-variant-numeric: tabular-nums;
  background: rgba(123, 92, 255, 0.3); border: 1px solid rgba(201, 184, 255, 0.4); display: inline-flex; align-items: center; justify-content: center; gap: 4px;
}

/* Dialogs: saying enough, and the telescope's images. */
.fac-modal { position: absolute; inset: 0; z-index: 25; display: grid; place-items: center; padding: 16px; background: rgba(2, 3, 8, 0.72); outline: none; }
.fac-modal[hidden] { display: none; }
.fac-dialog {
  width: 100%; max-width: 22rem; padding: 16px; border-radius: 18px; background: #12141d; border: 1px solid var(--fac-line);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7); animation: fac-in 0.25s ease-out;
}
.fac-dialog h2 { margin: 0 0 6px; font-size: 18px; }
.fac-dialog p { margin: 0 0 6px; }
.fac-dialog .fac-acts button { flex: 1; justify-content: center; }
.fac-staples { width: 100%; height: auto; border-radius: 12px; margin: 6px 0 8px; }
.fac-staples path { opacity: 0; animation: fac-staple 0.4s ease-out forwards; }
@keyframes fac-staple { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; } }
.fac-scan { animation: fac-scan 3s linear infinite; }
@keyframes fac-scan { from { transform: translateY(-6px); } to { transform: translateY(160px); } }

/* Desktop: the same, with room to breathe. */
@media (min-width: 52rem) {
  .fac { font-size: 15px; }
  .fac-hud { left: 20px; top: 16px; }
  .fac-bottom { bottom: 10px; }
  .fac .fac-tools button { flex-basis: 56px; max-width: 72px; }
}

/* ---------- the endings' screens ---------- */
.drama.fac-d { background: #020308; color: #e6e8f0; font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; word-spacing: normal; text-align: center; }
.drama.fac-d .tap { color: #888; }
.fac-d-lines { max-width: 22rem; position: relative; z-index: 1; }
.fac-d-lines p, .drama.fac-d-liftoff .tap { opacity: 0; animation: fac-d-line 1s ease-out forwards; }
@keyframes fac-d-line { to { opacity: 1; } }
.fac-d-liftoff { background: radial-gradient(circle at 50% 120%, #0d2a40, #020308 60%); }
.fac-d-earth {
  width: 90px; height: 90px; border-radius: 50%; margin-bottom: 40px;
  background: radial-gradient(circle at 35% 30%, #6fb0ff, #1d4fa0 60%, #0a1d3c);
  box-shadow: 0 0 40px rgba(80, 150, 255, 0.4); animation: fac-d-recede 9s ease-in forwards;
}
@keyframes fac-d-recede { to { transform: scale(0.08) translateY(400px); opacity: 0.6; } }
.drama.fac-d-plenty { background: #f4f1e8; color: #3a3a3a; }
.fac-d-num { font-size: 52px; font-weight: 800; margin: 0; letter-spacing: -0.02em; color: #222; font-variant-numeric: tabular-nums; }
.fac-d-sub { font-size: 18px; margin: 4px 0 18px; }
.fac-d-small { font-size: 14px; color: #777; max-width: 20rem; margin: 0; }
.drama.fac-d-plenty .tap { color: #999; }
.fac-d-shell {
  width: 150px; height: 150px; border-radius: 50%; border: 3px solid #3a6fb0; position: relative; margin-bottom: 24px;
  box-shadow: inset 0 0 30px rgba(58, 111, 176, 0.4); animation: fac-d-crack 2.4s ease-in forwards;
}
.fac-d-shell i { position: absolute; height: 2px; background: #ff7a3c; left: 50%; top: 50%; width: 0; transform-origin: 0 50%; animation: fac-d-split 1.6s 0.8s ease-out forwards; }
.fac-d-shell i:nth-child(1) { transform: rotate(-30deg); }
.fac-d-shell i:nth-child(2) { transform: rotate(95deg); }
.fac-d-shell i:nth-child(3) { transform: rotate(200deg); }
@keyframes fac-d-split { to { width: 76px; } }
@keyframes fac-d-crack { 60% { transform: none; } 70% { transform: translate(2px, -1px); } 80% { transform: translate(-2px, 1px); } to { transform: scale(1.04); } }
.drama.fac-d-unplugged { background: #000; }
.fac-d-plug { width: 200px; height: 100px; margin-bottom: 18px; fill: #555b66; stroke: #9aa2b8; }
.fac-d-l { animation: fac-d-pull 1.4s 0.6s ease-in forwards; }
@keyframes fac-d-pull { to { transform: translateX(-28px); } }
