:root {
  --bg: #050708;
  --panel: #0b0f10;
  --panel-2: #101719;
  --text: #d9f7e6;
  --muted: #7f9f90;
  --accent: #69f0ae;
  --accent-soft: rgba(105, 240, 174, 0.14);
  --border: rgba(105, 240, 174, 0.22);
  --danger: #ff5f56;
  --warn: #ffbd2e;
  --ok: #27c93f;
  --shadow: rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 20%, rgba(105, 240, 174, 0.08), transparent 24rem),
    radial-gradient(circle at 85% 75%, rgba(105, 240, 174, 0.05), transparent 22rem),
    linear-gradient(180deg, #050708 0%, #080d0e 100%);
  color: var(--text);
  font-family: "JetBrains Mono", Consolas, Monaco, monospace;
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.025),
    rgba(255, 255, 255, 0.025) 1px,
    transparent 1px,
    transparent 4px
  );
  opacity: 0.38;
  mix-blend-mode: overlay;
}

.terminal-shell {
  width: 100%;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.terminal-window {
  width: min(1040px, 100%);
  height: min(760px, calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  background: rgba(11, 15, 16, 0.94);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 24px 90px var(--shadow), 0 0 0 1px rgba(255, 255, 255, 0.03) inset;
  overflow: hidden;
  backdrop-filter: blur(12px);
}

.terminal-header {
  min-height: 48px;
  display: grid;
  grid-template-columns: 104px 1fr 104px;
  align-items: center;
  padding: 0 16px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border-bottom: 1px solid var(--border);
}

.window-buttons {
  display: flex;
  gap: 8px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  display: inline-block;
}

.dot.red { background: var(--danger); }
.dot.yellow { background: var(--warn); }
.dot.green { background: var(--ok); }

.terminal-title {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.terminal-status {
  justify-self: end;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.08em;
}

.terminal-output {
  flex: 1;
  padding: 22px;
  overflow: auto;
  line-height: 1.45;
  font-size: 12px;
  white-space: pre;
  word-break: normal;
}

.terminal-output::-webkit-scrollbar {
  width: 10px;
}

.terminal-output::-webkit-scrollbar-thumb {
  background: rgba(105, 240, 174, 0.25);
  border-radius: 999px;
}

.line {
  margin: 0 0 3px;
}

.line.command {
  color: var(--accent);
}

.line.system {
  color: var(--muted);
}

.line.error {
  color: #ff8a80;
}


.line.neofetch {
  font-size: 8px;
  line-height: 1.02;
  letter-spacing: -0.025em;
  color: #c9f7dc;
}

.terminal-link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted rgba(105, 240, 174, 0.6);
}

.terminal-link:hover,
.terminal-link:focus {
  background: var(--accent-soft);
  outline: none;
}

.terminal-input-line {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px 22px 20px;
  border-top: 1px solid rgba(105, 240, 174, 0.12);
  background: rgba(5, 7, 8, 0.35);
}

.prompt {
  color: var(--accent);
  flex: 0 0 auto;
  font-size: 14px;
}

.terminal-input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  caret-color: var(--accent);
}

.terminal-input::selection,
.terminal-output::selection {
  background: rgba(105, 240, 174, 0.25);
}

.noscript {
  position: fixed;
  inset: 24px;
  display: grid;
  place-items: center;
  background: #0b0f10;
  color: #d9f7e6;
  font-family: Consolas, monospace;
}

@media (max-width: 720px) {
  .terminal-shell {
    padding: 10px;
  }

  .terminal-window {
    height: calc(100vh - 20px);
    border-radius: 12px;
  }

  .terminal-header {
    grid-template-columns: 74px 1fr 72px;
    padding: 0 10px;
  }

  .terminal-title,
  .terminal-status,
  .terminal-output,
  .prompt,
  .terminal-input {
    font-size: 11px;
  }

  .line.neofetch {
    font-size: 6.5px;
    line-height: 1;
  }

  .terminal-output {
    padding: 16px;
  }

  .terminal-input-line {
    padding: 12px 16px 16px;
    gap: 8px;
  }
}

/* v1.6: richer neofetch layout */
.neofetch-rich {
  display: flex;
  align-items: flex-start;
  gap: 32px;
  width: max-content;
  max-width: none;
  margin: 4px 0 10px;
  white-space: nowrap;
}

.neofetch-logo,
.neofetch-info {
  margin: 0;
  font-family: "JetBrains Mono", Consolas, Monaco, monospace;
  white-space: pre;
  background: transparent;
}

.neofetch-logo {
  flex: 0 0 auto;
  font-size: 8px;
  line-height: 1.02;
  letter-spacing: -0.035em;
  color: #c9f7dc;
}

.neofetch-info {
  flex: 0 0 auto;
  padding-top: 18px;
  font-size: 13.5px;
  line-height: 1.42;
  letter-spacing: 0;
  color: #d9f7e6;
  font-weight: 650;
}

@media (max-width: 720px) {
  .neofetch-rich {
    gap: 18px;
  }

  .neofetch-logo {
    font-size: 6.5px;
    line-height: 1;
  }

  .neofetch-info {
    padding-top: 10px;
    font-size: 10px;
    line-height: 1.35;
  }
}

/* v1.7: fake destructive-command reboot sequence */
.line.danger-log {
  color: #ff8a80;
  text-shadow: 0 0 8px rgba(255, 95, 86, 0.25);
}

.line.boot-log {
  color: #9be7ff;
  text-shadow: 0 0 8px rgba(155, 231, 255, 0.18);
}

body.rebooting .terminal-window {
  animation: terminalShake 0.11s linear infinite;
}

body.rebooting .terminal-output {
  filter: contrast(1.2) brightness(1.08);
}


/* v2.1: cinematic fake rm reboot sequence */
body.crt-collapse .terminal-window,
.terminal-window.crt-collapse-window {
  animation: crtPowerOff 1.05s cubic-bezier(.16, .84, .28, .99) forwards;
  transform-origin: center center;
}

body.clean-booting .terminal-window {
  animation: none;
}

@keyframes crtPowerOff {
  0% {
    transform: scaleX(1) scaleY(1);
    filter: brightness(1.2) contrast(1.2);
    opacity: 1;
  }
  38% {
    transform: scaleX(1.02) scaleY(0.06);
    filter: brightness(2.4) contrast(1.8);
    opacity: 0.95;
  }
  62% {
    transform: scaleX(0.34) scaleY(0.012);
    filter: brightness(3.2) contrast(2.2);
    opacity: 0.8;
  }
  100% {
    transform: scaleX(0.001) scaleY(0.001);
    filter: brightness(0) contrast(2.5);
    opacity: 0;
  }
}

.line.reconnect-log {
  color: #d7e8ff;
  text-shadow: 0 0 10px rgba(76, 145, 255, 0.24);
}

.line.boot-tip-inline {
  color: #9be7ff;
  text-shadow: 0 0 8px rgba(155, 231, 255, 0.16);
}


/* v2.2: destructive rm shakes only while deleting; powered-off state stays off until refresh */
@keyframes terminalShake {
  0% { transform: translate(0, 0) rotate(0deg); }
  20% { transform: translate(-1px, 1px) rotate(-0.12deg); }
  40% { transform: translate(1px, -1px) rotate(0.12deg); }
  60% { transform: translate(-2px, 0) rotate(-0.08deg); }
  80% { transform: translate(2px, 1px) rotate(0.08deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

body.powered-off .terminal-input-line {
  opacity: 0;
  pointer-events: none;
}

body.powered-off::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: #000;
  opacity: 0.18;
}


/* v2.5: CTF popup + Ubuntu-like desktop + interactive window controls */
.hidden {
  display: none !important;
}

.window-buttons {
  align-items: center;
}

.dot {
  border: 0;
  padding: 0;
  appearance: none;
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.22) inset;
}

.dot:hover,
.dot:focus-visible {
  transform: scale(1.12);
  outline: 1px solid rgba(255, 255, 255, 0.34);
  outline-offset: 2px;
}

body.terminal-maximized .terminal-shell {
  padding: 0;
}

body.terminal-maximized .terminal-window {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-top: 0;
}

.desktop {
  position: fixed;
  inset: 0;
  z-index: 20;
  color: #f4fff8;
  font-family: "JetBrains Mono", Consolas, Monaco, monospace;
  background:
    radial-gradient(circle at 20% 20%, rgba(105, 240, 174, 0.08), transparent 24rem),
    radial-gradient(circle at 85% 75%, rgba(105, 240, 174, 0.05), transparent 22rem),
    linear-gradient(180deg, #050708 0%, #080d0e 100%);
  overflow: hidden;
}

.desktop::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 46%, rgba(105, 240, 174, 0.045), transparent 32rem),
    repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0.025) 1px, transparent 1px, transparent 4px);
  opacity: 0.44;
}

.desktop-topbar {
  position: relative;
  z-index: 1;
  height: 34px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 14px;
  background: rgba(17, 17, 17, 0.62);
  border-bottom: 1px solid rgba(255, 255, 255, 0.11);
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.24);
  font-size: 12px;
}

.desktop-topbar span:last-child {
  justify-self: end;
  color: #9dffbf;
}

.desktop-icons {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 76px 0 0 42px;
  width: 180px;
}

.desktop-icon {
  width: 92px;
  min-height: 92px;
  display: grid;
  place-items: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  color: #f4fff8;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
}

.desktop-icon:hover,
.desktop-icon:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  outline: none;
}

.desktop-icon-glyph {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(8, 13, 14, 0.86);
  border: 1px solid rgba(105, 240, 174, 0.28);
  color: var(--accent);
  font-size: 28px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.32);
}

.desktop-hint {
  position: absolute;
  right: 28px;
  bottom: 22px;
  z-index: 1;
  color: rgba(255, 255, 255, 0.66);
  font-size: 12px;
}

.ctf-ad {
  position: fixed;
  right: 24px;
  top: 96px;
  z-index: 30;
  width: 272px;
  border: 1px solid rgba(255, 189, 46, 0.42);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(10, 14, 15, 0.96);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.42), 0 0 28px rgba(255, 189, 46, 0.09);
  color: var(--text);
  backdrop-filter: blur(10px);
  transform-origin: top right;
  will-change: transform, opacity, clip-path;
  animation: adPamphletIn 0.72s cubic-bezier(.16, .84, .28, .99) both;
}

.ctf-ad.ctf-ad-fold-out {
  pointer-events: none;
  animation: adPamphletOut 0.28s cubic-bezier(.55, .06, .68, .19) both;
}

@keyframes adPamphletIn {
  0% {
    opacity: 0;
    transform: translateX(54px) rotateY(-78deg) scaleX(0.18) scaleY(0.96);
    clip-path: inset(0 0 0 96% round 16px);
  }
  42% {
    opacity: 1;
    transform: translateX(12px) rotateY(-18deg) scaleX(0.82) scaleY(1.01);
    clip-path: inset(0 0 0 24% round 16px);
  }
  72% {
    transform: translateX(-3px) rotateY(4deg) scaleX(1.015) scaleY(1);
    clip-path: inset(0 0 0 0 round 16px);
  }
  100% {
    opacity: 1;
    transform: translateX(0) rotateY(0) scaleX(1) scaleY(1);
    clip-path: inset(0 0 0 0 round 16px);
  }
}

@keyframes adPamphletOut {
  0% {
    opacity: 1;
    transform: translateX(0) rotateY(0) scaleX(1);
    clip-path: inset(0 0 0 0 round 16px);
  }
  100% {
    opacity: 0;
    transform: translateX(42px) rotateY(-68deg) scaleX(0.22);
    clip-path: inset(0 0 0 90% round 16px);
  }
}

.ctf-ad-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.52);
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.ctf-ad-close:hover,
.ctf-ad-close:focus-visible {
  background: rgba(255, 95, 86, 0.82);
  outline: none;
}

.ctf-ad-badge {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 2;
  padding: 4px 8px;
  border-radius: 999px;
  background: #ffbd2e;
  color: #17110a;
  font-weight: 800;
  font-size: 10px;
  letter-spacing: 0.08em;
}

.ctf-ad-image {
  display: block;
  width: 100%;
  height: 150px;
  object-fit: contain;
  background: #fff;
  filter: contrast(1.08) saturate(0.95);
}

.ctf-ad-body {
  display: grid;
  gap: 5px;
  padding: 12px 14px 10px;
}

.ctf-ad-body strong {
  color: #ffbd2e;
  letter-spacing: 0.04em;
}

.ctf-ad-body span {
  color: #d9f7e6;
  font-size: 13px;
}

.ctf-ad-body small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.ctf-ad-body code {
  color: var(--accent);
}

.ctf-ad-button {
  width: calc(100% - 28px);
  margin: 0 14px 14px;
  padding: 9px 10px;
  border: 1px solid rgba(105, 240, 174, 0.42);
  border-radius: 10px;
  background: rgba(105, 240, 174, 0.12);
  color: var(--accent);
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.ctf-ad-button:hover,
.ctf-ad-button:focus-visible {
  background: rgba(105, 240, 174, 0.2);
  outline: none;
}

body.terminal-maximized .ctf-ad {
  display: none;
}

@media (max-width: 1120px) {
  .ctf-ad {
    top: auto;
    right: 14px;
    bottom: 14px;
    width: min(300px, calc(100vw - 28px));
  }

  .ctf-ad-image {
    height: 118px;
  }
}

@media (max-width: 720px) {
  .desktop-icons {
    padding: 64px 0 0 24px;
  }

  .desktop-hint {
    left: 24px;
    right: auto;
  }

  .ctf-ad {
    display: none;
  }
}


/* v2.5.0 hotfix: desktop color sync + window open/close animations */
.terminal-window.window-closing {
  animation: terminalCloseOut 0.34s cubic-bezier(.55, .06, .68, .19) forwards;
  transform-origin: top left;
}

.terminal-window.window-minimizing {
  animation: terminalMinimizeOut 0.28s cubic-bezier(.55, .06, .68, .19) forwards;
  transform-origin: top center;
}

.terminal-window.window-opening {
  animation: terminalOpenIn 0.30s cubic-bezier(.16, .84, .28, .99) both;
  transform-origin: top left;
}

@keyframes terminalCloseOut {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: brightness(1);
  }
  55% {
    opacity: 0.82;
    transform: translateY(8px) scale(0.965);
    filter: brightness(0.92);
  }
  100% {
    opacity: 0;
    transform: translateY(18px) scale(0.9);
    filter: brightness(0.62) blur(1px);
  }
}

@keyframes terminalMinimizeOut {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(48px) scale(0.78); }
}

@keyframes terminalOpenIn {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.9);
    filter: brightness(0.7) blur(1px);
  }
  72% {
    opacity: 1;
    transform: translateY(-2px) scale(1.012);
    filter: brightness(1.06) blur(0);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: brightness(1) blur(0);
  }
}


/* v2.5.0 inline prompt hotfix: input lives in the terminal scrollback like a real shell */
.terminal-output > .terminal-input-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  margin: 0 0 3px;
  padding: 0;
  border-top: 0;
  background: transparent;
  white-space: normal;
}

.terminal-output > .terminal-input-line .prompt {
  color: var(--accent);
  flex: 0 0 auto;
  font-size: inherit;
  line-height: inherit;
}

.terminal-output > .terminal-input-line .terminal-input {
  flex: 1 1 auto;
  min-width: 8ch;
  height: auto;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  line-height: inherit;
  caret-color: var(--accent);
}

.terminal-output > .terminal-input-line .terminal-input::placeholder {
  color: rgba(217, 247, 230, 0.28);
}

body.powered-off .terminal-output > .terminal-input-line {
  opacity: 0;
  pointer-events: none;
}

/* Hide the interactive prompt while the fake OS boot log is playing. */
.terminal-input-line.boot-prompt-hidden,
.terminal-output > .terminal-input-line.boot-prompt-hidden {
  display: none !important;
}
