:root {
  --bg: #05060f;
  --bg-2: #0a0c1f;
  --bg-3: #11142b;
  --line: #1f2447;
  --text: #e9ecff;
  --muted: #7e88b8;
  --neon: #00ffe1;
  --neon-2: #ff3df0;
  --neon-3: #ffd23d;
  --ok: #3dff95;
  --err: #ff5e7a;
  --warn: #ffd23d;
  --shadow: 0 8px 32px rgba(0, 255, 225, 0.06);
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Space Grotesk', system-ui, sans-serif;
  background: radial-gradient(circle at 15% -10%, #1a1455 0%, #05060f 55%) fixed;
  color: var(--text);
  overflow: hidden;
}

code, pre, .terminal, .term-out, input.term { font-family: 'JetBrains Mono', ui-monospace, monospace; }

button { font-family: inherit; cursor: pointer; }

/* ───── splash ───── */
#splash {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: radial-gradient(circle at 50% 50%, #15113b 0%, #03040c 70%);
  transition: opacity .8s ease, visibility .8s;
}
#splash.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-inner { text-align: center; }
.splash-inner h1 {
  font-size: 4rem; letter-spacing: -0.04em; font-weight: 700;
  background: linear-gradient(90deg, var(--neon), var(--neon-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin: 1.5rem 0 .4rem;
}
.splash-inner p { color: var(--muted); font-size: 1.05rem; }
.splash-bar { width: 320px; height: 6px; margin: 1.6rem auto 0;
  background: rgba(255,255,255,.08); border-radius: 4px; overflow: hidden; }
.splash-bar-fill {
  width: 0%; height: 100%;
  background: linear-gradient(90deg, var(--neon), var(--neon-2));
  transition: width .35s cubic-bezier(.2,.7,.3,1);
  box-shadow: 0 0 12px rgba(0,255,225,.45);
}
.splash-status {
  display: flex; justify-content: space-between; align-items: center;
  width: 320px; margin: .6rem auto 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: .8rem; color: var(--muted);
  letter-spacing: .02em;
}
#splash-pct { color: var(--neon); font-variant-numeric: tabular-nums; }
#splash.error #splash-pct { display: none; }
#splash.error .splash-status { width: min(560px, 90vw); flex-direction: column; gap: .4rem; align-items: stretch; text-align: center; color: #ffb3c1; }
.logo { position: relative; width: 120px; height: 120px; margin: 0 auto; }
.logo .orb {
  position: absolute; inset: 30px;
  background: radial-gradient(circle at 35% 30%, #fff, var(--neon) 50%, #007a73 100%);
  border-radius: 50%;
  box-shadow: 0 0 40px var(--neon), 0 0 80px rgba(0,255,225,0.4);
  animation: pulse 2.4s ease-in-out infinite;
}
.logo .orb-ring {
  position: absolute; inset: 0;
  border: 2px dashed rgba(0,255,225,0.5);
  border-radius: 50%;
  animation: spin 6s linear infinite;
}
@keyframes pulse { 0%,100% { transform: scale(1);} 50% { transform: scale(1.06);} }
@keyframes spin { to { transform: rotate(360deg);} }

/* ───── topbar ───── */
#topbar {
  display: flex; align-items: center; gap: 1.2rem;
  padding: .8rem 1.2rem;
  background: linear-gradient(180deg, rgba(15,18,42,0.95), rgba(8,9,22,0.95));
  border-bottom: 1px solid var(--line);
  position: relative; z-index: 5;
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: .8rem; }
.brand-logo {
  width: 38px; height: 38px;
  background: radial-gradient(circle at 35% 30%, #fff, var(--neon) 45%, #00585a 100%);
  border-radius: 50%;
  position: relative;
  box-shadow: 0 0 18px var(--neon);
}
.brand-logo span {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1.5px dashed rgba(0,255,225,0.55);
  animation: spin 8s linear infinite;
}
.brand-name { font-weight: 700; letter-spacing: -0.02em; font-size: 1.25rem; }
.brand-tag { font-size: .72rem; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }

.progress-wrap { flex: 1; display: flex; justify-content: center; }
.progress {
  height: 22px; width: 60%; max-width: 460px;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--line);
  border-radius: 999px; overflow: hidden;
  position: relative;
}
#progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--neon), var(--neon-2));
  display: flex; align-items: center; justify-content: flex-end;
  padding-right: 10px;
  font-size: .7rem; font-weight: 600; color: #04101a;
  transition: width .5s ease;
  box-shadow: 0 0 18px var(--neon);
}

.actions { display: flex; gap: .5rem; }
.btn {
  padding: .55rem .95rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  font-size: .85rem;
  transition: all .18s;
}
.btn:hover { border-color: var(--neon); color: var(--neon); }
.btn.primary { border-color: var(--neon); color: var(--neon); }
.btn.primary:hover { background: rgba(0,255,225,0.12); }

/* ───── layout ───── */
#layout {
  display: grid;
  grid-template-columns: 250px 1fr 380px;
  height: calc(100vh - 64px);
  gap: 1px;
  background: var(--line);
}
@media (max-width: 1300px) {
  #layout { grid-template-columns: 220px 1fr 340px; }
}
@media (max-width: 1100px) {
  #layout { grid-template-columns: 1fr 360px; }
  #sidebar { display: none; }
}

aside, section { background: var(--bg-2); overflow: hidden; }

/* ───── sidebar / missions ───── */
#sidebar { padding: 1rem .8rem; overflow-y: auto; }
.panel-title { font-size: .75rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin-bottom: .8rem; padding: 0 .4rem; }
.mission-group { font-size: .68rem; text-transform: uppercase; letter-spacing: 0.16em;
  color: var(--neon); margin: 1rem .4rem .4rem; opacity: .8; }
.mission-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem .7rem; border-radius: 9px;
  font-size: .86rem; line-height: 1.3;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  margin-bottom: 2px;
}
.mission-item:hover { background: rgba(255,255,255,0.04); }
.mission-item.active {
  background: linear-gradient(90deg, rgba(0,255,225,0.16), rgba(255,61,240,0.04));
  border-color: rgba(0,255,225,0.4);
  box-shadow: 0 0 0 1px rgba(0,255,225,0.2);
}
.mission-item.done { color: var(--muted); }
.mission-item.done .mission-mark { color: var(--ok); }
.mission-mark { font-weight: 700; opacity: .7; }

/* ───── center / scene ───── */
#center { position: relative; display: flex; flex-direction: column; }
#scene { flex: 1; position: relative; min-height: 0; }
#scene canvas { display: block; }
.hud-bottom {
  border-top: 1px solid var(--line);
  background: rgba(8, 10, 25, 0.85);
  backdrop-filter: blur(14px);
  max-height: 130px;
  overflow-y: auto;
  padding: .7rem .9rem;
}
.files-panel { display: flex; flex-wrap: wrap; gap: .35rem; }
.file {
  font-family: 'JetBrains Mono', monospace;
  font-size: .76rem;
  padding: .25rem .55rem;
  border-radius: 6px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  display: flex; align-items: center; gap: .35rem;
}
.file.staged { border-color: var(--ok); color: var(--ok); }
.file.modified { border-color: var(--warn); color: var(--warn); }
.file.untracked { border-color: var(--err); color: var(--err); }
.file.clean { color: var(--muted); }
.badge { font-size: .58rem; padding: 0 .35rem; border-radius: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; }
.badge.stage { background: rgba(61,255,149,0.18); color: var(--ok); }
.badge.modified { background: rgba(255,210,61,0.18); color: var(--warn); }
.badge.untracked { background: rgba(255,94,122,0.18); color: var(--err); }

/* CSS2D labels */
.commit-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: #cdd5ff;
  background: rgba(8, 10, 28, 0.78);
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.08);
  white-space: nowrap;
  pointer-events: none;
  transform: translateY(-50%);
  text-shadow: 0 0 6px rgba(0,0,0,0.8);
}
.commit-label .sha { color: var(--neon); font-weight: 700; }
.commit-label .msg { color: #aab1d8; margin-left: 4px; }
.branch-pill {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  color: #fff;
  white-space: nowrap;
  pointer-events: none;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ───── right pane ───── */
#rightpane {
  display: flex; flex-direction: column;
  overflow: hidden;
}
.mission-card {
  padding: 1.1rem 1.2rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(20,23,55,0.55), rgba(10,12,30,0.4));
}
.mission-eyebrow {
  font-size: .65rem; text-transform: uppercase; letter-spacing: 0.16em;
  color: var(--neon); margin-bottom: .25rem; opacity: .85;
}
.mission-card h2 { font-size: 1.1rem; line-height: 1.25; letter-spacing: -0.01em; margin-bottom: .8rem; }
.mission-brief { font-size: .9rem; line-height: 1.5; color: #cad0f0; margin-bottom: 1rem; }
.mission-section-title {
  font-size: .65rem; text-transform: uppercase; letter-spacing: 0.18em;
  color: var(--muted); margin: .9rem 0 .5rem;
}
.mission-teach-wrap ul { list-style: none; }
.mission-teach-wrap li {
  position: relative; padding-left: 1.1rem;
  font-size: .82rem; line-height: 1.5;
  color: #b9bfe5; margin-bottom: .35rem;
}
.mission-teach-wrap li:before {
  content: '▹'; position: absolute; left: 0; top: 0;
  color: var(--neon); font-weight: 700;
}
.suggested { display: flex; flex-direction: column; gap: .3rem; }
.suggest-btn {
  background: rgba(0,255,225,0.05);
  border: 1px solid rgba(0,255,225,0.25);
  color: var(--neon);
  padding: .35rem .55rem; border-radius: 7px;
  font-family: 'JetBrains Mono', monospace; font-size: .76rem;
  text-align: left;
  transition: all .15s;
}
.suggest-btn:hover { background: rgba(0,255,225,0.15); border-color: var(--neon); }

.mission-status { margin-top: .9rem; min-height: 1.5rem; font-size: .85rem; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.mission-status .ok { color: var(--ok); font-weight: 600; }
.mission-status .hint { color: var(--warn); }
.mission-status .err { color: var(--err); }
.next-btn {
  background: linear-gradient(90deg, var(--neon), var(--neon-2));
  border: none; color: #03040c; padding: .35rem .8rem; border-radius: 8px;
  font-weight: 700; font-size: .8rem; letter-spacing: 0.02em;
  box-shadow: 0 4px 18px rgba(0,255,225,0.3);
}

.inspector {
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid var(--line);
  background: rgba(8,10,22,0.45);
  flex-shrink: 0;
  max-height: 180px;
  overflow-y: auto;
}
.commit-header { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .35rem; }
.commit-header .sha { font-family: 'JetBrains Mono', monospace; color: var(--neon); font-size: .82rem; }
.commit-header .branch-tag {
  font-size: .65rem; padding: 1px 7px; border-radius: 4px;
  border: 1px solid; letter-spacing: 0.06em; text-transform: uppercase;
}
.commit-msg { font-size: .9rem; margin-bottom: .35rem; }
.commit-files { margin-top: .55rem; font-size: .76rem; color: #aab2da; }
.commit-files div { padding: 1px 0; font-family: 'JetBrains Mono', monospace; }

.terminal-wrap { flex: 1; display: flex; flex-direction: column; padding: .9rem 1.2rem 1.2rem; min-height: 0; }
.terminal {
  flex: 1; min-height: 220px;
  background: #02030a;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .7rem .8rem;
  font-size: .8rem;
  color: #cdd5ff;
  overflow-y: auto;
  display: flex; flex-direction: column;
  box-shadow: inset 0 0 24px rgba(0,255,225,0.06);
}
.term-out { flex: 1; overflow-y: auto; }
.term-out > div { padding: 1px 0; line-height: 1.45; word-break: break-word; white-space: pre-wrap; }
.term-out pre { white-space: pre-wrap; line-height: 1.45; color: #cdd5ff; }
.term-out .ok { color: var(--ok); font-weight: 600; }
.term-out .err { color: var(--err); }
.term-out .muted { color: var(--muted); }
.term-out .prompt-echo { color: var(--neon-2); }
.term-line { display: flex; align-items: center; gap: .5rem; padding-top: .3rem; border-top: 1px dashed rgba(255,255,255,0.05); margin-top: .3rem; }
.term-line .prompt { color: var(--neon); font-weight: 600; flex-shrink: 0; }
.term-line .branch { color: var(--neon-3); }
.term-line input {
  background: transparent; border: none; outline: none; flex: 1;
  color: #fff; font-family: 'JetBrains Mono', monospace; font-size: .8rem;
  caret-color: var(--neon);
}

/* ───── modal ───── */
.modal {
  position: fixed; inset: 0;
  background: rgba(2,3,12,0.82);
  display: none; place-items: center;
  z-index: 50; backdrop-filter: blur(8px);
}
.modal.open { display: grid; }
.modal-panel {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2rem 2.2rem;
  max-width: 640px; width: calc(100% - 2rem);
  max-height: 80vh; overflow-y: auto;
  box-shadow: 0 30px 80px rgba(0,255,225,0.12);
  position: relative;
}
.modal-panel h2 { font-size: 1.4rem; margin-bottom: .8rem; letter-spacing: -0.01em; }
.modal-panel h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--neon); margin: 1.2rem 0 .5rem; }
.modal-panel p { line-height: 1.55; margin-bottom: .8rem; color: #c5cbef; font-size: .92rem; }
.modal-panel ul { padding-left: 1.2rem; }
.modal-panel li { padding: 3px 0; font-size: .88rem; color: #c5cbef; }
.modal-panel code { font-family: 'JetBrains Mono', monospace; background: rgba(0,255,225,0.08); color: var(--neon); padding: 1px 6px; border-radius: 4px; font-size: .82em; }
.modal-panel .muted { color: var(--muted); font-size: .82rem; }
.modal-panel .close {
  position: absolute; top: .8rem; right: 1rem;
  background: transparent; border: none; color: var(--muted);
  font-size: 1.6rem; line-height: 1;
}
.modal-panel .close:hover { color: var(--text); }

/* ───── celebrate (confetti) ───── */
#celebrate { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti {
  position: absolute; top: -10px; width: 9px; height: 14px;
  border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall {
  0%   { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* utility */
.muted { color: var(--muted); font-size: .85rem; }
code { font-family: 'JetBrains Mono', monospace; background: rgba(0,255,225,0.08); color: var(--neon); padding: 1px 5px; border-radius: 4px; font-size: .85em; }
b { font-weight: 700; color: #fff; }
i { font-style: italic; color: #d8def4; }
