:root {
  --bg: #000; --fg: #ededed; --mute: #7c7c7c; --line: #262626; --strong: #fff;
  --acc: #00ff5f; --warn: #ffd000; --red: #ff2020;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { color: var(--fg); font: 14px/1.5 "JetBrains Mono", ui-monospace, "DejaVu Sans Mono", monospace; overflow: hidden; }
::selection { background: var(--strong); color: #000; }
a { color: var(--strong); text-decoration: underline; text-underline-offset: 3px; }
a:hover, .chip:hover, .cmd:hover { background: var(--strong); color: #000; text-decoration: none; }
.mute { color: var(--mute); } .strong { color: var(--strong); font-weight: 700; }
.acc { color: var(--acc); } .warn { color: var(--warn); } .red { color: var(--red); }
.inv { background: var(--strong); color: #000; padding: 0 5px; font-weight: 700; }

.app { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* ---------- tiles ---------- */
.grid { flex: 1; min-height: 0; display: grid; gap: 0; padding: 0;
        grid-template-columns: minmax(0, 1fr) minmax(300px, 420px);
        grid-template-rows: minmax(0, 1.3fr) minmax(0, 1fr);
        grid-template-areas: "ocean agents" "ask log"; }
.pane { position: relative; min-height: 0; min-width: 0; border: 1px solid var(--line); margin: -1px 0 0 -1px; }
.pane.focus { border-color: var(--strong); z-index: 2; }
.pane > .ttl { position: absolute; top: 0; left: 0; z-index: 3; padding: 0 8px; font-size: 12px; line-height: 20px;
               background: var(--line); color: var(--mute); }
.pane.focus > .ttl { background: var(--strong); color: #000; font-weight: 700; }
.p-ocean { grid-area: ocean; cursor: crosshair; overflow: hidden; }
.p-ask { grid-area: ask; } .p-agents { grid-area: agents; } .p-log { grid-area: log; }

/* ocean */
#sea { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero { position: absolute; left: 36px; top: 44px; z-index: 2; pointer-events: none; }
.logo { margin: 0; color: var(--strong); font: 800 clamp(10px, 1.45vw, 21px)/1.02 "JetBrains Mono", monospace; white-space: pre; }
.tag { margin-top: 20px; font-size: clamp(15px, 1.35vw, 19px); line-height: 1.4; max-width: 34ch; }
.tag .now { display: block; margin-top: 10px; font-size: 13px; color: var(--mute); }
.tag a { pointer-events: auto; }
.hint { position: absolute; right: 10px; bottom: 6px; z-index: 2; font-size: 11px; color: var(--mute); pointer-events: none; }

/* ask */
#screen { position: absolute; inset: 0; overflow-y: auto; padding: 32px 18px 14px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.line { white-space: pre-wrap; word-break: break-word; }
.ghost { margin: 8px 0 2px; }
.ghost .who { background: var(--strong); color: #000; font-weight: 700; padding: 0 5px; margin-right: 10px; }
.tool { color: var(--mute); }
.tool::before { content: "→ "; color: var(--acc); }
.think { color: var(--mute); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 6px; }
.chip, .cmd { cursor: pointer; }
.chip { border: 1px solid var(--mute); padding: 1px 9px; font-size: 12px; }
.cmd { text-decoration: underline; text-underline-offset: 3px; }
.prompt-row { display: flex; gap: .6ch; margin-top: 4px; }
.ps1 { white-space: nowrap; }
.ps1 b { color: var(--acc); }
#input-wrap { position: relative; flex: 1; min-width: 0; }
#typed { white-space: pre-wrap; word-break: break-all; }
.cursor { display: inline-block; width: .62em; height: 1.15em; vertical-align: text-bottom; background: var(--strong); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
#cmd { position: absolute; inset: 0; opacity: 0; width: 100%; font-size: 16px; border: 0; background: none; color: transparent; }

/* agents + log */
#top { position: absolute; inset: 0; margin: 0; padding: 32px 16px 10px; font: inherit; font-size: 12px; white-space: pre; overflow: hidden; }
#log { position: absolute; inset: 0; padding: 32px 16px 10px; clip-path: inset(26px 0 0 0); font-size: 12px; overflow: hidden;
       display: flex; flex-direction: column; justify-content: flex-end; }
#log div { flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* tmux-like status line */
.status { display: flex; align-items: stretch; font-size: 12px; line-height: 22px; background: var(--line); white-space: nowrap; }
.status .sess { background: var(--acc); color: #000; font-weight: 700; padding: 0 10px; }
.status .wins { flex: 1; display: flex; overflow: hidden; }
.status .wins span { padding: 0 10px; color: var(--mute); cursor: pointer; }
.status .wins span.on { color: var(--strong); font-weight: 700; }
.status .wins span.on::after { content: "*"; }
.status .right { display: flex; }
.status .right > span { padding: 0 10px; border-left: 1px solid #000; color: var(--mute); }
.status .right > span.hi { color: var(--strong); }

/* boot */
#boot { position: fixed; inset: 0; z-index: 40; background: #000; padding: 28px 32px; white-space: pre-wrap; overflow: hidden; }
@media (max-width: 560px) { #boot { padding: 18px 14px; font-size: 12px; } }

/* the virus */
#virus { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; pointer-events: none; }
#virus .box { pointer-events: auto; background: #000; border: 2px solid var(--red); color: var(--red);
              width: min(720px, calc(100vw - 24px)); padding: 0 0 16px; font-size: 13px; }
#virus .box.ok { border-color: var(--strong); color: var(--fg); }
#virus .head { background: var(--red); color: #000; font-weight: 800; padding: 4px 14px; letter-spacing: .08em; }
#virus .box.ok .head { background: var(--strong); }
#virus .body { padding: 12px 16px 0; white-space: pre-wrap; }
#virus .big { font-size: clamp(18px, 3vw, 28px); font-weight: 800; line-height: 1.2; margin: 4px 0 12px; color: var(--strong); }
#virus .box:not(.ok) .big { animation: shake .12s steps(2) infinite; color: var(--red); }
@keyframes shake { 50% { transform: translateX(2px); } }
#fall { position: fixed; inset: 0; z-index: 65; pointer-events: none; }
body.infected .app { visibility: hidden; }
body.alarm .app { animation: alarm .5s steps(1) infinite; }
@keyframes alarm { 50% { filter: invert(1); } }

.fab { display: none; }

@media (max-width: 860px) {
  body { overflow-x: hidden; overflow-y: auto; }
  .app { position: relative; min-height: 100svh; }
  .grid { display: flex; flex-direction: column; }
  .p-ocean { height: 66svh; min-height: 400px; }
  .p-ask #screen, #top { position: static; overflow: visible; }
  .p-ask #screen { min-height: 260px; }
  .p-log { height: 200px; }
  .hero { left: 16px; top: 40px; right: 16px; }
  .logo { font-size: min(15px, calc((100vw - 40px) / 25.6)); }
  .tag { font-size: 18px; }
  .chips { gap: 8px; }
  .chip { padding: 5px 10px; font-size: 13px; }
  .status { position: sticky; bottom: 0; padding-bottom: env(safe-area-inset-bottom); }
  #prompt { scroll-margin-bottom: calc(30px + env(safe-area-inset-bottom)); } /* keep it above the sticky status line */
  .status .wins, .status .right .opt { display: none; }
  .status .right { flex: 1; justify-content: flex-end; }
  .fab { position: fixed; right: 12px; bottom: calc(34px + env(safe-area-inset-bottom)); z-index: 30;
         display: block; font: inherit; font-size: 14px; font-weight: 700; color: #000; background: var(--strong); border: 0;
         padding: 10px 14px; cursor: pointer; transition: opacity .2s, transform .2s; }
  .fab.away { opacity: 0; transform: translateY(12px); pointer-events: none; }
}
@media (prefers-reduced-motion: reduce) {
  .cursor, body.alarm .app, #virus .box .big { animation: none !important; }
}

/* ---------- root (CTF solved) and god mode (konami) ---------- */
body.root .ps1 b { color: var(--red); }
body.root .status .sess { background: var(--red); }
body.god .app { background: #000; filter: invert(1); }

/* ---------- rm -rf / ---------- */
.pane, .status { transition: opacity .35s, transform .35s; }
.gone { opacity: 0 !important; transform: scaleY(.02); }
#panic { position: fixed; inset: 0; z-index: 80; background: #000; color: var(--fg); padding: 24px; font-size: 13px; overflow: hidden; }
#panic pre { margin: 0; white-space: pre-wrap; font: inherit; }

/* ---------- hack ---------- */
#hack { position: fixed; inset: 0; z-index: 80; background: #000; display: flex; flex-direction: column; }
#hack .bar { background: var(--line); padding: 2px 12px; font-size: 12px; white-space: nowrap; overflow: hidden; }
#hack .bar .prog { color: var(--acc); }
#hack .code { flex: 1; margin: 0; padding: 16px; overflow: hidden; color: var(--acc); font: 13px/1.45 "JetBrains Mono", monospace; white-space: pre-wrap; }
#hack .granted { position: absolute; inset: 0; margin: auto; width: fit-content; height: fit-content; max-width: 92vw;
                 background: var(--acc); color: #000; font-weight: 800; font-size: clamp(28px, 6vw, 72px); padding: 16px 32px;
                 text-align: center; white-space: pre-wrap; animation: blink 1s steps(1) infinite; }
#hack .granted small { display: block; font-size: 14px; font-weight: 400; margin-top: 10px; }

/* ---------- tmux splits ---------- */
.split-a, .split-b { position: absolute; inset: 0; overflow: hidden; }
.pane.split-v > .split-a { right: 50%; }
.pane.split-v > .split-b { left: 50%; border-left: 1px solid var(--strong); }
.pane.split-h > .split-a { bottom: 50%; }
.pane.split-h > .split-b { top: 50%; border-top: 1px solid var(--strong); }
.split-b .ttl { position: absolute; top: 0; left: 0; z-index: 3; padding: 0 8px; font-size: 12px; line-height: 20px; background: var(--line); color: var(--mute); }
.split-b pre { position: absolute; inset: 0; margin: 0; padding: 28px 12px 8px; clip-path: inset(22px 0 0 0); overflow: hidden; font: 12px/1.35 "JetBrains Mono", monospace; color: var(--fg); white-space: pre; }
