:root {
  color-scheme: dark;
  --bg: #000;
  --fg: #fff;
  --text: #b8b8b8;
  --dim: #5c5c5c;
  --line: #1c1c1c;
  --accent: #ffffff;
  --accent-2: #9a9a9a;
  --ok: #ffffff;
  --err: #8a8a8a;
  --display: "Bungee Hairline", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  scrollbar-color: #333 #000;
}

:root[data-theme="green"] { --accent: #4dff9a; --accent-2: #2f9e62; --ok: #4dff9a; }
:root[data-theme="amber"] { --accent: #ffb347; --accent-2: #a8742c; --ok: #ffb347; }
:root[data-theme="red"]   { --accent: #ff4d4d; --accent-2: #a33232; --ok: #ff4d4d; }
:root[data-theme="ice"]   { --accent: #7fe3ff; --accent-2: #3f8ea3; --ok: #7fe3ff; }

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-weight: 300;
  font-size: 13.5px;
  line-height: 1.6;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection { background: #fff; color: #000; }

#fx {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ---------- HUD ---------- */

.hud {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px;
  font-size: 10.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--dim);
}
.hud b { color: var(--text); font-weight: 400; }
.hud-top { top: 0; }
.hud-bottom { bottom: 0; }
.hints { display: flex; gap: 22px; }
.hints span { display: inline-flex; align-items: baseline; gap: 7px; }
.hints b { color: var(--text); font-weight: 400; }
.hints b::after { content: ""; display: inline-block; width: 14px; height: 1px; margin-left: 7px; vertical-align: middle; background: var(--dim); }
.blink { color: #3ddc84; font-style: normal; animation: online 2.4s ease-in-out infinite; }
@keyframes online {
  0%, 100% { color: #0e2a1a; text-shadow: 0 0 0 rgba(61, 220, 132, 0); }
  50%      { color: #3ddc84; text-shadow: 0 0 8px rgba(61, 220, 132, .75); }
}
@keyframes blink { 50% { opacity: .15; } }

.vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, transparent 35%, rgba(0, 0, 0, .75) 100%);
}

/* ---------- Stage ---------- */

.stage {
  position: relative;
  z-index: 2;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  align-items: center;
  gap: clamp(32px, 6vw, 110px);
  padding: 72px clamp(16px, 6vw, 100px);
  max-width: 1400px;
  margin: 0 auto;
}

/* ---------- Mark ---------- */

.mark {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(28px, 4vh, 44px);
  user-select: none;
  pointer-events: none;
}

.logo {
  display: block;
  width: min(300px, 30vw);
  aspect-ratio: 1850 / 1610;
}
.logo svg { display: block; width: 100%; height: 100%; overflow: visible; }

.pieces { transform-box: fill-box; transform-origin: 50% 62%; }

.pc {
  fill: var(--fg);
  transform-box: fill-box;
  transform-origin: center;
  transform: translate(0, 0);
  transition: transform .55s cubic-bezier(.2, .8, .2, 1), fill .4s;
  animation: assemble 1.3s cubic-bezier(.16, 1, .3, 1) calc(.25s + var(--d)) backwards;
}
@keyframes assemble {
  from { transform: translate(calc(var(--dx) * 520px), calc(var(--dy) * 520px)); opacity: 0; }
}

.logo.burst .pc {
  transform: translate(calc(var(--dx) * 300px), calc(var(--dy) * 300px)) rotate(calc(var(--dx) * 25deg));
  transition-duration: .35s;
}

.logo.spin .pieces { animation: spin 1.1s cubic-bezier(.6, -0.25, .3, 1.3); }
@keyframes spin { to { transform: rotate(360deg); } }

.logo.party .pc { animation: party 1.6s linear infinite; animation-delay: var(--d); }
@keyframes party {
  0%, 100% { fill: #fff; }
  25% { fill: #4dff9a; }
  50% { fill: #7fe3ff; }
  75% { fill: #ffb347; }
}

.wordmark {
  display: block;
  width: min(300px, 30vw);
  height: auto;
  opacity: .9;
}
.wordmark.glitch { animation: glitch .35s steps(3) 2; }
@keyframes glitch {
  0%   { transform: translate(0); clip-path: inset(0 0 0 0); }
  33%  { transform: translate(-4px, 1px); clip-path: inset(0 0 55% 0); }
  66%  { transform: translate(4px, -1px); clip-path: inset(45% 0 0 0); }
  100% { transform: translate(0); clip-path: inset(0 0 0 0); }
}

/* ---------- Terminal ---------- */

.term {
  display: flex;
  flex-direction: column;
  height: min(540px, calc(100vh - 170px));
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, .72);
  backdrop-filter: blur(3px);
}

.term-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 10.5px;
  color: var(--dim);
  letter-spacing: .16em;
  text-transform: uppercase;
}
.term-title { color: var(--text); }

.term-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 18px 22px;
  cursor: text;
  scrollbar-width: thin;
  scrollbar-color: #222 transparent;
}

.out { white-space: pre-wrap; word-break: break-word; }
.out .line { min-height: 1.6em; }
.out .cmd-echo { color: var(--fg); }
.out .dim { color: var(--dim); }
.out .acc { color: var(--accent); font-weight: 400; }
.out .acc2 { color: var(--fg); font-weight: 400; }
.out .ok { color: var(--ok); }
.out .err { color: var(--err); font-style: italic; }
.out .ascii { color: var(--fg); line-height: 1.15; font-size: 12px; }
.out .big { font-family: var(--display); font-size: 22px; color: var(--fg); letter-spacing: .04em; }
.out a { color: var(--fg); text-decoration: underline; text-decoration-color: var(--dim); text-underline-offset: 3px; }
.out a:hover { text-decoration-color: var(--fg); }
.out .grid { display: grid; grid-template-columns: max-content 1fr; column-gap: 28px; }
.out .grid > :nth-child(odd) { color: var(--fg); font-weight: 400; }

.prompt { display: flex; gap: 8px; align-items: baseline; }
.prompt.hidden { visibility: hidden; }
.ps1 { white-space: nowrap; color: var(--dim); }
.ps1 .u { color: var(--fg); font-weight: 400; }
.ps1 .p { color: var(--accent-2); }

#cmd {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--fg);
  font: inherit;
  font-weight: 400;
  caret-color: var(--accent);
  padding: 0;
}

/* ---------- Effects ---------- */

body.shake { animation: shake .4s linear 2; }
@keyframes shake {
  25% { transform: translate(4px, -2px); }
  50% { transform: translate(-4px, 2px); }
  75% { transform: translate(2px, 3px); }
}

body.crt-off .stage,
body.crt-off .hud { animation: crt .6s ease-in forwards; }
@keyframes crt {
  60% { transform: scale(1, .004); filter: brightness(4); }
  100% { transform: scale(0, .004); opacity: 0; }
}

body.upside .stage { transform: rotate(180deg); transition: transform 1s cubic-bezier(.7, 0, .2, 1); }
body.inverted { filter: invert(1); }

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  body { overflow: auto; }
  .stage {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
    min-height: 100%;
    padding: 64px 16px 80px;
    gap: 36px;
  }
  .logo, .wordmark { width: min(220px, 60vw); }
  .term { height: 60vh; min-height: 360px; }
  .hide-sm { display: none; }
  .hud { padding: 14px 16px; }
  .out .ascii { font-size: 8.5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* ---------- Language switch ---------- */

.hud-right { display: flex; align-items: baseline; gap: 22px; }
.langs { display: flex; gap: 10px; }
.langs button { all: unset; cursor: pointer; color: var(--dim); transition: color .2s; }
.langs button:hover, .langs button:focus-visible { color: var(--fg); }
.langs button[aria-pressed="true"] { color: var(--fg); cursor: default; }
.langs button:focus-visible { outline: 1px solid var(--fg); outline-offset: 3px; }
.hints i { font-style: normal; }
