:root {
  --bg: #070b16;
  --ink: #e6ebf5;
  --dim: #7d8aa6;
  --accent: #6ee7c8;
  --blue: #3b6cff;
  --violet: #7a4dff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Manrope", system-ui, sans-serif;
  overflow: hidden;
}

/* Ambient background */
.glow {
  position: fixed;
  width: 46vmax;
  height: 46vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .55;
  pointer-events: none;
}
.glow-a { background: var(--blue); top: -18vmax; left: -12vmax; }
.glow-b { background: var(--violet); bottom: -22vmax; right: -14vmax; opacity: .4; }

.grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at center, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(circle at center, #000 20%, transparent 75%);
  pointer-events: none;
}

/* Intro */
.intro {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  transition: opacity .5s ease, transform .5s ease;
}
.intro.leaving { opacity: 0; transform: scale(1.06); pointer-events: none; }

.glass-btn {
  position: relative;
  overflow: hidden;
  padding: 20px 52px;
  font: 600 17px/1 "Manrope", sans-serif;
  letter-spacing: .04em;
  color: var(--ink);
  cursor: pointer;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.22);
  background: linear-gradient(135deg, rgba(255,255,255,.16), rgba(255,255,255,.04));
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.35),
    inset 0 -1px 0 rgba(255,255,255,.05),
    0 10px 40px rgba(0,0,0,.45),
    0 0 60px rgba(59,108,255,.25);
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.glass-btn span { position: relative; z-index: 1; }
.glass-btn::before {
  content: "";
  position: absolute;
  top: 0; left: -80%;
  width: 60%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.35), transparent);
  transform: skewX(-20deg);
  transition: left .7s ease;
}
.glass-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(255,255,255,.4);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.5),
    0 14px 50px rgba(0,0,0,.5),
    0 0 80px rgba(110,231,200,.28);
}
.glass-btn:hover::before { left: 130%; }
.glass-btn:active { transform: translateY(0) scale(.98); }
.glass-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

/* Terminal — positioning/opacity layer only. Tilt is applied on .tilt via JS
   every frame, kept off this element so the pop-in transition below never
   fights with the continuous rotate updates. */
.terminal {
  position: fixed;
  top: 50%; left: 50%;
  width: min(820px, 92vw);
  height: min(480px, 70vh);
  perspective: 1300px;
  opacity: 0;
  transform: translate(-50%, -50%) scale(.96);
  pointer-events: none;
  transition: opacity .45s ease .15s, transform .45s cubic-bezier(.2,.9,.3,1.2) .15s;
}
.terminal.open {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

/* Tilt — purely visual box, rotated by inline style from script.js, never
   by a CSS transition, so it tracks the mouse with no lag. */
.tilt {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(10,14,26,.72);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  box-shadow: 0 30px 80px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.12);
  overflow: hidden;
  transform-style: preserve-3d;
  will-change: transform;
}

.titlebar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  font: 500 12.5px "JetBrains Mono", monospace;
  color: var(--dim);
  flex: none;
}
.dots { display: flex; gap: 7px; }
.dots i { width: 11px; height: 11px; border-radius: 50%; background: #ff5f57; }
.dots i:nth-child(2) { background: #febc2e; }
.dots i:nth-child(3) { background: #28c840; }
.title { flex: 1; }
.titlebar.center .title { text-align: center; margin-right: 50px; }
.panel-close {
  margin-left: auto;
  background: none;
  border: 0;
  color: var(--dim);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
  flex: none;
}
.panel-close:hover { color: var(--ink); }

.screen {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  padding: 18px 20px;
  font: 400 15px/1.6 "JetBrains Mono", monospace;
}
.screen::-webkit-scrollbar { width: 8px; }
.screen::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 4px; }

.line { display: flex; gap: 10px; align-items: center; white-space: pre-wrap; word-break: break-word; }
.line.output { color: var(--ink); }
.line .ok { color: var(--accent); }
.prompt { color: var(--accent); white-space: nowrap; flex: none; }
.prompt.msf { color: #ff6b81; }

/* A single pre-formatted "text picture" — banners, ASCII art. Printed once,
   never animated line-by-line. */
.ascii-block {
  white-space: pre;
  font: inherit;
  line-height: 1.3;
  margin: 4px 0;
}

/* Live input line: an invisible real <input> sits over a visible "mirror"
   span so the caret/selection behaves like a real text field, while what
   you actually see is our own blinking block cursor. */
.field { position: relative; flex: 1; min-width: 0; }
.mirror { white-space: pre; }
.hidden-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font: inherit;
  letter-spacing: inherit;
  outline: none;
  padding: 0;
}

.cursor-block {
  display: inline-block;
  min-width: .55em;
  background: var(--accent);
  color: var(--bg);
  animation: blink 1s steps(1) infinite;
}
.cursor-block.idle {
  background: transparent;
  outline: 1px solid var(--accent);
  color: var(--ink);
  animation: none;
}
@keyframes blink { 50% { opacity: 0; } }

@media (max-width: 520px) {
  .screen { font-size: 13px; }
  .glass-btn { padding: 18px 40px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; }
  .cursor-block { animation: none; }
}
