:root {
  color-scheme: dark;
  --ink: #f7f2ff;
  --muted: #b8aacd;
  --faint: #867a99;
  --void: #100b16;
  --panel: #191121;
  --panel-strong: #21152d;
  --line: #3f2b52;
  --cyan: #34d7ff;
  --green: #74f7a1;
  --pink: #ff5da8;
  --amber: #ffbf4d;
  --violet: #a779ff;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 12%, rgba(255, 93, 168, 0.14), transparent 28rem),
    radial-gradient(circle at 86% 8%, rgba(52, 215, 255, 0.12), transparent 26rem),
    var(--void);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: default;
  opacity: 0.72;
}

.site-header {
  position: fixed;
  z-index: 20;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px max(18px, calc((100vw - 1180px) / 2));
  background: rgba(16, 11, 22, 0.78);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-family: "Pixelify Sans", Inter, sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 2px solid var(--cyan);
  border-radius: 6px;
  background: #151023;
  color: var(--green);
  box-shadow: 4px 4px 0 rgba(52, 215, 255, 0.28);
}

.compact .brand-mark {
  border-color: var(--pink);
  color: var(--amber);
}

.header-actions,
.hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.solid-button,
.ghost-button,
.outline-button,
.text-button,
.tab {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.solid-button {
  padding: 0 18px;
  background: linear-gradient(135deg, var(--green), var(--cyan));
  color: #120c18;
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.24);
}

.ghost-button,
.outline-button {
  padding: 0 16px;
  background: rgba(25, 17, 33, 0.72);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.outline-button {
  background: transparent;
  border-color: var(--cyan);
  color: var(--cyan);
}

.text-button {
  background: transparent;
  color: var(--muted);
}

.large {
  min-height: 50px;
  padding: 0 22px;
}

.full-width {
  width: 100%;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hero-scene {
  position: relative;
  display: grid;
  min-height: 86svh;
  align-items: end;
  overflow: hidden;
  padding: 118px max(18px, calc((100vw - 1180px) / 2)) 42px;
  background-image:
    linear-gradient(90deg, rgba(16, 11, 22, 0.94), rgba(16, 11, 22, 0.72) 48%, rgba(16, 11, 22, 0.25)),
    linear-gradient(0deg, rgba(16, 11, 22, 0.92), transparent 42%),
    url("assets/keylab-pixel-skyline.jpg");
  background-position: center;
  background-size: cover;
  image-rendering: auto;
}

.scene-noise {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 18px 18px;
  mask-image: linear-gradient(180deg, transparent, #000 18%, #000);
}

.hero-content {
  position: relative;
  max-width: 650px;
  padding-bottom: 82px;
}

.eyebrow,
.card-kicker {
  margin: 0 0 12px;
  color: var(--green);
  font-family: "Pixelify Sans", Inter, sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.hero h1,
.hero-scene h1,
.auth-copy h1,
.dashboard-header h1 {
  margin-bottom: 18px;
  font-family: "Pixelify Sans", Inter, sans-serif;
  font-size: 5.9rem;
  line-height: 0.9;
  letter-spacing: 0;
  text-shadow: 0 8px 0 rgba(0, 0, 0, 0.3);
}

.auth-copy h1,
.dashboard-header h1 {
  font-size: 3.7rem;
}

.tutorial-prompt h2,
.stack-card h2 {
  font-family: "Pixelify Sans", Inter, sans-serif;
  letter-spacing: 0;
}

.hero-text,
.auth-copy p,
.tutorial-prompt p,
.stack-card p,
.quest-strip p,
.lab-panel pre {
  color: var(--muted);
  line-height: 1.65;
}

.hero-text {
  max-width: 620px;
  font-size: 1.16rem;
}

.quest-console {
  position: absolute;
  right: max(18px, calc((100vw - 1180px) / 2));
  bottom: 42px;
  width: min(390px, calc(100vw - 36px));
  padding: 16px;
  border: 1px solid rgba(52, 215, 255, 0.52);
  border-radius: 8px;
  background: rgba(18, 12, 24, 0.88);
  box-shadow: var(--shadow), 6px 6px 0 rgba(255, 93, 168, 0.25);
}

.console-topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--amber);
  font-family: "Pixelify Sans", Inter, sans-serif;
  font-size: 0.95rem;
}

pre {
  margin: 0;
  overflow-x: auto;
  white-space: pre-wrap;
}

code {
  font-family: "SFMono-Regular", Consolas, monospace;
}

.quest-console pre,
.lab-panel pre {
  padding: 14px;
  border-radius: 8px;
  background: #0b0710;
  color: #d9ffe5;
  font-size: 0.9rem;
}

.hero-badges {
  position: absolute;
  left: max(18px, calc((100vw - 1180px) / 2));
  right: max(18px, calc((100vw - 1180px) / 2));
  bottom: 18px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-badges span,
.path-node {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: rgba(16, 11, 22, 0.74);
  color: var(--ink);
  font-weight: 800;
}

.quest-strip,
.auth-shell,
.dashboard-main {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
}

.quest-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  transform: translateY(-18px);
}

.quest-strip article,
.auth-card,
.tutorial-prompt,
.lab-panel,
.coding-workbench,
.stack-card,
.xp-panel {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(33, 21, 45, 0.94), rgba(20, 13, 28, 0.96));
  box-shadow: var(--shadow);
}

.quest-strip article {
  min-height: 188px;
  padding: 22px;
}

.step-marker {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  margin-bottom: 16px;
  border: 2px solid var(--green);
  border-radius: 6px;
  color: var(--green);
  font-family: "Pixelify Sans", Inter, sans-serif;
  font-weight: 700;
}

.quest-strip h2 {
  margin-bottom: 8px;
  font-size: 1.08rem;
}

.auth-view {
  min-height: 100vh;
  padding: 112px 0 48px;
  background-image:
    linear-gradient(90deg, rgba(16, 11, 22, 0.96), rgba(16, 11, 22, 0.62)),
    url("assets/keylab-city-street.jpg");
  background-position: center;
  background-size: cover;
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(300px, 460px);
  gap: 54px;
  align-items: center;
  min-height: calc(100vh - 160px);
}

.auth-copy {
  max-width: 620px;
}

.auth-card {
  display: grid;
  gap: 16px;
  padding: 24px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 6px;
  border-radius: 8px;
  background: rgba(11, 7, 16, 0.8);
}

.tab {
  background: transparent;
  color: var(--muted);
}

.tab.active {
  background: var(--panel-strong);
  color: var(--green);
  box-shadow: inset 0 0 0 1px rgba(116, 247, 161, 0.28);
}

label {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 800;
}

input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: #0f0a15;
  color: var(--ink);
}

input:focus {
  border-color: var(--cyan);
  outline: 3px solid rgba(52, 215, 255, 0.16);
}

.dashboard-view.active {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  min-height: 100vh;
  background:
    linear-gradient(rgba(16, 11, 22, 0.9), rgba(16, 11, 22, 0.96)),
    url("assets/keylab-city-skyline.jpg");
  background-attachment: fixed;
  background-position: center;
  background-size: cover;
}

body.dashboard-open .site-header {
  display: none;
}

.sidebar {
  display: flex;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-direction: column;
  gap: 30px;
  padding: 24px;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(13, 8, 18, 0.92);
  backdrop-filter: blur(16px);
}

.sidebar nav {
  display: grid;
  gap: 8px;
}

.sidebar a {
  padding: 12px 14px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
  text-decoration: none;
}

.sidebar a.active {
  background: rgba(116, 247, 161, 0.12);
  color: var(--green);
}

.sidebar .ghost-button {
  margin-top: auto;
}

.dashboard-main {
  padding-top: 34px;
  padding-bottom: 44px;
}

.dashboard-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 18px;
  align-items: end;
  margin-bottom: 22px;
}

.dashboard-header h1 {
  margin-bottom: 0;
}

.xp-panel {
  padding: 18px;
}

.xp-panel span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.xp-panel strong {
  display: block;
  margin: 8px 0 12px;
  color: var(--amber);
  font-family: "Pixelify Sans", Inter, sans-serif;
  font-size: 1.5rem;
}

.xp-meter {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #0b0710;
}

.xp-meter span {
  width: 16%;
  height: 100%;
  background: linear-gradient(90deg, var(--pink), var(--amber));
}

.adventure-board {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(310px, 0.85fr);
  gap: 18px;
  margin-bottom: 18px;
}

.tutorial-prompt,
.lab-panel {
  padding: 24px;
}

.tutorial-prompt h2 {
  margin-bottom: 10px;
  font-size: 2.35rem;
}

.selection-status {
  margin-top: 14px;
  color: var(--green);
  font-weight: 800;
}

.mission-path {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 22px;
}

.path-node.active {
  border-color: var(--green);
  color: var(--green);
}

.lab-panel {
  display: grid;
  align-content: start;
  gap: 16px;
}

.coding-workbench {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
  padding: 24px;
}

.workbench-toolbar,
.workbench-actions {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
}

.workbench-toolbar h2 {
  margin-bottom: 0;
  font-family: "Pixelify Sans", Inter, sans-serif;
  font-size: 2.25rem;
}

.board-picker {
  width: min(240px, 100%);
}

select,
.code-editor {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: #0f0a15;
  color: var(--ink);
}

select {
  min-height: 46px;
  padding: 0 12px;
  font-weight: 800;
}

.code-editor {
  min-height: 310px;
  resize: vertical;
  padding: 16px;
  color: #d9ffe5;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.92rem;
  line-height: 1.55;
}

.status-pill {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  margin-left: auto;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(11, 7, 16, 0.72);
  color: var(--muted);
  font-weight: 800;
}

.serial-output {
  min-height: 118px;
  max-height: 220px;
  overflow: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: #0b0710;
  color: var(--green);
  font-size: 0.86rem;
}

.stack-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.stack-card {
  min-height: 225px;
  padding: 24px;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.stack-card:hover,
.stack-card:focus,
.stack-card:focus-within {
  transform: translateY(-3px);
  border-color: rgba(52, 215, 255, 0.5);
  box-shadow: var(--shadow), 0 0 0 3px rgba(52, 215, 255, 0.14);
  outline: 0;
}

.stack-card.selected {
  border-color: var(--green);
  box-shadow: var(--shadow), 0 0 0 3px rgba(116, 247, 161, 0.16);
}

.stack-card h2 {
  margin-bottom: 12px;
  font-size: 2rem;
}

.stack-card p:last-child {
  margin-bottom: 0;
}

.stack-card.cloudflare {
  border-top: 6px solid var(--amber);
}

.stack-card.database {
  border-top: 6px solid var(--green);
}

.stack-card.server {
  border-top: 6px solid var(--pink);
}

.stack-card.browser {
  border-top: 6px solid var(--cyan);
}

@media (max-width: 980px) {
  .hero-scene h1 {
    font-size: 4.6rem;
  }

  .quest-console {
    position: relative;
    right: auto;
    bottom: auto;
    margin-top: 24px;
  }

  .hero-content {
    padding-bottom: 56px;
  }

  .quest-strip,
  .auth-shell,
  .dashboard-view.active,
  .adventure-board,
  .workbench-toolbar,
  .workbench-actions,
  .stack-grid,
  .dashboard-header {
    grid-template-columns: 1fr;
  }

  .workbench-toolbar,
  .workbench-actions {
    display: grid;
    align-items: stretch;
  }

  .status-pill {
    margin-left: 0;
  }

  .dashboard-view.active {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }

  .sidebar nav {
    display: flex;
    min-width: max-content;
  }

  .sidebar .ghost-button {
    min-width: max-content;
    margin-top: 0;
    margin-left: auto;
  }
}

@media (max-width: 640px) {
  .site-header {
    padding: 14px 16px;
  }

  .header-actions .ghost-button {
    display: none;
  }

  .hero-scene {
    min-height: 88svh;
    padding-top: 96px;
  }

  .hero-scene h1,
  .auth-copy h1,
  .dashboard-header h1 {
    font-size: 3.45rem;
  }

  .tutorial-prompt h2 {
    font-size: 2.1rem;
  }

  .hero-actions,
  .dashboard-header {
    align-items: stretch;
  }

  .hero-actions {
    flex-direction: column;
  }

  .hero-actions button,
  .tutorial-prompt button,
  .lab-panel button,
  .workbench-actions button {
    width: 100%;
  }

  .quest-console {
    width: 100%;
  }

  .sidebar {
    padding: 16px;
  }

  .dashboard-main {
    width: calc(100% - 32px);
    padding-top: 24px;
  }
}
