:root {
  color-scheme: dark;
  --bg: #06111f;
  --bg-2: #08182a;
  --panel: #0d1b2e;
  --panel-2: #132742;
  --line: #29476a;
  --line-soft: #1b3352;
  --text: #f4f8ff;
  --muted: #b4c4d8;
  --dim: #7890ad;
  --accent: #60a5fa;
  --accent-2: #93c5fd;
  --warn: #ffbd73;
  --danger: #ff6b7a;
  --ink: #04111f;
  --shadow: rgba(0, 0, 0, 0.34);
  --max: 1220px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(135deg, rgba(96, 165, 250, 0.12), transparent 38%, rgba(147, 197, 253, 0.07)),
    var(--bg);
  background-size: 58px 58px, 58px 58px, auto, auto;
  font-family:
    Inter, Arial, "Helvetica Neue", Helvetica, ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.035), transparent);
  opacity: 0.58;
  transform: skewY(-8deg) translateY(-16%);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea {
  font: inherit;
}

code,
pre,
textarea,
input.mono {
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, ui-monospace, monospace;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 74px;
  width: min(100% - 32px, var(--max));
  margin: 0 auto;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(6, 17, 31, 0.88);
  backdrop-filter: blur(18px);
}

.brand,
.nav,
.hero-actions,
.fact-strip,
.score-line,
.flag-row,
.dialog-head,
.mission-band article,
.mission-tab,
.mission-points,
.status-line {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(96, 165, 250, 0.42);
  border-radius: 8px;
  background: #0b1b30;
  color: var(--accent);
}

.nav {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 22px;
  color: var(--muted);
  font-size: 0.94rem;
}

.nav a {
  transition: color 160ms ease;
}

.nav a:hover,
.nav a:focus-visible {
  color: var(--text);
}

main,
.topbar {
  width: min(100% - 32px, var(--max));
}

main {
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.94fr) minmax(320px, 0.76fr);
  gap: 54px;
  align-items: center;
  min-height: calc(88vh - 74px);
  padding: 62px 0 56px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 22px;
  font-size: clamp(3.25rem, 8vw, 7rem);
  line-height: 0.92;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 3.2vw, 2.5rem);
  line-height: 1.05;
  letter-spacing: 0;
}

p {
  line-height: 1.65;
}

.lead {
  max-width: 670px;
  margin-bottom: 30px;
  color: var(--muted);
  font-size: 1.12rem;
}

.hero-actions {
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 30px;
}

.button {
  min-height: 44px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.button:hover,
.button:focus-visible {
  transform: translateY(-1px);
  border-color: var(--accent);
  outline: none;
}

.button.primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--ink);
}

.button.ghost {
  background: rgba(13, 27, 46, 0.78);
}

.fact-strip {
  flex-wrap: wrap;
  width: fit-content;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(13, 27, 46, 0.72);
  overflow: hidden;
}

.fact-strip div {
  min-width: 142px;
  padding: 14px 16px;
  border-right: 1px solid var(--line-soft);
}

.fact-strip div:last-child {
  border-right: 0;
}

.fact-strip span {
  display: block;
  color: var(--accent-2);
  font-size: 1.35rem;
  font-weight: 900;
}

.fact-strip small {
  color: var(--dim);
  font-weight: 800;
  text-transform: uppercase;
}

.buddy-hero {
  min-width: 0;
}

.buddy-hero img {
  display: block;
  width: min(100%, 520px);
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 28px 82px var(--shadow);
}

.buddy-note {
  width: min(92%, 440px);
  margin: -54px auto 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 27, 46, 0.9);
  box-shadow: 0 20px 52px var(--shadow);
  position: relative;
}

.buddy-note p:last-child,
.buddy-panel p:last-child,
.score-meta,
.feedback {
  margin-bottom: 0;
}

.mission-band {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  padding: 6px 0 42px;
}

.mission-band article {
  align-items: flex-start;
  flex-direction: column;
  min-height: 160px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 27, 46, 0.76);
}

.mission-band span {
  color: var(--accent);
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, ui-monospace, monospace;
  font-size: 0.82rem;
  font-weight: 900;
}

.mission-band h2 {
  margin: auto 0 8px;
  font-size: 1.05rem;
}

.mission-band p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.lab-shell {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  padding: 48px 0 92px;
}

.side-panel {
  position: sticky;
  top: 94px;
  display: grid;
  gap: 14px;
}

.score-card,
.mission-list,
.buddy-panel,
.workspace,
.objective-box,
.hint-box,
.solution-box,
.browser-box,
.terminal-box,
.token-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 27, 46, 0.82);
  box-shadow: 0 20px 58px rgba(0, 0, 0, 0.22);
}

.score-card {
  padding: 18px;
}

.score-line {
  gap: 8px;
}

.score-line strong {
  color: var(--accent-2);
  font-size: 2.4rem;
  line-height: 1;
}

.score-line span,
.score-meta {
  color: var(--muted);
}

.progress-track {
  height: 10px;
  margin: 16px 0 12px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
  overflow: hidden;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--warn));
  transition: width 220ms ease;
}

.mission-list {
  display: grid;
  gap: 0;
  overflow: hidden;
}

.mission-tab {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 14px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.mission-tab:last-child {
  border-bottom: 0;
}

.mission-tab:hover,
.mission-tab:focus-visible,
.mission-tab.is-active {
  background: rgba(96, 165, 250, 0.12);
  outline: none;
}

.mission-tab span {
  color: var(--accent);
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, ui-monospace, monospace;
  font-weight: 900;
}

.mission-tab small {
  color: var(--dim);
  font-weight: 900;
  text-transform: uppercase;
}

.mission-tab small.is-done {
  color: var(--accent-2);
}

.buddy-panel {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
}

.buddy-panel img {
  width: 82px;
  height: 82px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.buddy-panel p {
  color: var(--muted);
  font-size: 0.92rem;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.mission-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: start;
  margin-bottom: 18px;
}

.mission-head p {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
}

.mission-points {
  flex-direction: column;
  justify-content: center;
  min-width: 96px;
  min-height: 78px;
  border: 1px solid rgba(147, 197, 253, 0.42);
  border-radius: 8px;
  background: rgba(147, 197, 253, 0.12);
}

.mission-points strong {
  color: var(--accent-2);
  font-size: 1.7rem;
  line-height: 1;
}

.mission-points span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.objective-box {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 14px;
  margin-bottom: 18px;
  padding: 14px;
}

.objective-box span {
  color: var(--warn);
  font-weight: 900;
  text-transform: uppercase;
}

.objective-box p {
  margin-bottom: 0;
  color: var(--muted);
}

.lab-stage {
  display: grid;
  gap: 16px;
  min-height: 390px;
  margin-bottom: 18px;
}

.browser-box,
.terminal-box,
.token-box {
  min-width: 0;
  overflow: hidden;
}

.window-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 46px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--dim);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.window-bar code {
  min-width: 0;
  color: var(--accent);
  overflow-wrap: anywhere;
  text-align: right;
  text-transform: none;
}

.box-body {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.field-grid {
  display: grid;
  gap: 8px;
}

.field-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label,
.field-label {
  color: var(--dim);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

input,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(5, 14, 27, 0.84);
  color: var(--text);
  outline: none;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

input {
  min-height: 44px;
  padding: 0 13px;
}

textarea {
  min-height: 116px;
  resize: vertical;
  padding: 12px 13px;
  line-height: 1.55;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.18);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.status-line {
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  padding: 12px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(5, 14, 27, 0.58);
  color: var(--muted);
}

.status-line code,
.found-flag code {
  color: var(--accent-2);
  overflow-wrap: anywhere;
}

.devtools-note,
.fake-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid rgba(147, 197, 253, 0.32);
  border-radius: 8px;
  background: rgba(5, 14, 27, 0.64);
}

.devtools-note strong,
.fake-card strong {
  color: var(--accent-2);
}

.devtools-note span,
.fake-card span {
  color: var(--muted);
  line-height: 1.55;
}

.devtools-note code {
  color: var(--warn);
  overflow-wrap: anywhere;
}

.found-flag {
  padding: 14px;
  border: 1px solid rgba(147, 197, 253, 0.42);
  border-radius: 8px;
  background: rgba(147, 197, 253, 0.12);
  color: var(--text);
}

.found-flag strong {
  color: var(--accent-2);
}

.preview-frame {
  width: 100%;
  min-height: 210px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #f8fafc;
}

.terminal-output {
  min-height: 148px;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #050e1b;
  color: #dbeafe;
  overflow: auto;
  white-space: pre-wrap;
}

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

.decode-grid pre {
  min-height: 124px;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #050e1b;
  color: #dbeafe;
  overflow: auto;
}

.flag-form {
  display: grid;
  gap: 8px;
  margin-top: 6px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}

.flag-row {
  gap: 10px;
}

.flag-row input {
  flex: 1;
}

.feedback {
  min-height: 26px;
  color: var(--muted);
}

.feedback.is-good {
  color: var(--accent-2);
}

.feedback.is-bad {
  color: var(--danger);
}

.hint-box {
  margin-top: 14px;
  padding: 0;
}

.hint-box summary {
  cursor: pointer;
  padding: 14px 16px;
  color: var(--accent);
  font-weight: 900;
}

.help-list {
  display: grid;
  gap: 12px;
  padding: 0 16px 16px;
}

.help-card {
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(5, 14, 27, 0.54);
}

.help-card h3 {
  margin: 0 0 8px;
  color: var(--text);
  font-size: 0.98rem;
}

.help-card p {
  margin-bottom: 8px;
  color: var(--muted);
}

.help-card .help-action {
  margin-bottom: 0;
  color: var(--accent-2);
  font-weight: 800;
}

.solution-box {
  margin: 0 16px 16px;
  background: rgba(96, 165, 250, 0.08);
  box-shadow: none;
}

.solution-box summary {
  padding: 13px 14px;
  color: var(--accent-2);
}

.hint-box ol,
.solution-box ol {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0 22px 18px 38px;
  color: var(--muted);
}

.rules-dialog {
  width: min(92vw, 560px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.5);
}

.rules-dialog::backdrop {
  background: rgba(0, 0, 0, 0.68);
}

.rules-dialog form {
  margin: 0;
  padding: 22px;
}

.dialog-head {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.dialog-head button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
  font-weight: 900;
}

@media (max-width: 1040px) {
  .hero,
  .lab-shell {
    grid-template-columns: 1fr;
  }

  .buddy-hero img {
    margin: 0 auto;
  }

  .side-panel {
    position: static;
  }

  .mission-band {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  main,
  .topbar {
    width: min(100% - 22px, var(--max));
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 0;
  }

  .nav {
    justify-content: flex-start;
    gap: 14px;
  }

  .hero {
    gap: 34px;
    padding-top: 42px;
  }

  .mission-band,
  .field-grid.two,
  .decode-grid {
    grid-template-columns: 1fr;
  }

  .mission-head,
  .objective-box {
    grid-template-columns: 1fr;
  }

  .workspace {
    padding: 16px;
  }

  .flag-row {
    align-items: stretch;
    flex-direction: column;
  }

  .flag-row .button {
    width: 100%;
  }

  .mission-tab {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .mission-tab small {
    grid-column: 2;
  }
}
