:root {
  color-scheme: dark;
  --ink: #f5f3ff;
  --muted: #aaa6ba;
  --dim: #706b7d;
  --panel: rgba(14, 13, 26, 0.88);
  --panel-strong: #11101f;
  --line: rgba(255, 255, 255, 0.11);
  --violet: #9c7cff;
  --violet-soft: #c8b9ff;
  --amber: #f4b86a;
  --danger: #ff7a90;
  --success: #8ee7c4;
  --mono: "DM Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  --sans: "Manrope", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #070711;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -20%, rgba(95, 61, 174, 0.3), transparent 38%),
    linear-gradient(180deg, #080812 0%, #06060d 64%, #080710 100%);
  font-family: var(--sans);
}

button,
input {
  font: inherit;
}

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

.noise {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.65'/%3E%3C/svg%3E");
}

.aurora {
  position: fixed;
  z-index: -2;
  width: 460px;
  height: 460px;
  border-radius: 999px;
  filter: blur(100px);
  opacity: 0.12;
  pointer-events: none;
}

.aurora-one {
  top: 8%;
  left: -220px;
  background: #8e67ff;
}

.aurora-two {
  right: -260px;
  bottom: 6%;
  background: #f0a65b;
}

.shell,
.agent-shell {
  width: min(1120px, calc(100% - 36px));
  margin: 0 auto;
  padding: 28px 0 30px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
}

.identity {
  display: inline-flex;
  gap: 11px;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
}

.sigil {
  color: var(--violet-soft);
  font-size: 1.05rem;
}

.connection {
  display: flex;
  gap: 9px;
  align-items: center;
  color: var(--muted);
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 5px rgba(142, 231, 196, 0.08), 0 0 16px rgba(142, 231, 196, 0.7);
  animation: pulse 2.2s ease-in-out infinite;
}

.live-dot.amber {
  background: var(--amber);
  box-shadow: 0 0 0 5px rgba(244, 184, 106, 0.08), 0 0 16px rgba(244, 184, 106, 0.65);
}

@keyframes pulse {
  50% { opacity: 0.45; transform: scale(0.85); }
}

.hero {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  align-items: end;
  gap: 54px;
  padding: 92px 5% 58px;
}

.eyebrow,
.section-tag,
.micro-label,
.puzzle-meta,
.tile-label,
.candidate-name,
.small-note {
  font-family: var(--mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.eyebrow {
  grid-column: 1 / -1;
  margin-bottom: -32px;
  color: var(--violet-soft);
  font-size: 0.72rem;
}

.hero h1 {
  margin: 0;
  font-size: clamp(3.6rem, 9vw, 7.8rem);
  line-height: 0.79;
  letter-spacing: -0.075em;
  font-weight: 800;
}

.hero h1 span {
  color: transparent;
  -webkit-text-stroke: 1px rgba(200, 185, 255, 0.78);
  text-shadow: 0 0 42px rgba(156, 124, 255, 0.1);
}

.hero-copy {
  max-width: 520px;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.75;
}

.mission-card,
.agent-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(156, 124, 255, 0.055), transparent 30%),
    var(--panel);
  box-shadow: 0 38px 100px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(20px);
}

.mission-card::before,
.agent-card::before {
  position: absolute;
  top: 0;
  left: 13%;
  width: 50%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--violet), transparent);
  content: "";
}

.mission-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
}

.mission-head > div:first-child {
  display: grid;
  gap: 4px;
}

.micro-label {
  color: var(--dim);
  font-size: 0.62rem;
}

.mission-head strong,
.stage-counter {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.09em;
}

.mission-head strong {
  color: var(--success);
}

.stage-counter {
  color: var(--muted);
}

.progress {
  height: 2px;
  background: rgba(255, 255, 255, 0.05);
}

.progress-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--violet), var(--amber));
  box-shadow: 0 0 14px rgba(156, 124, 255, 0.7);
  transition: width 0.6s ease;
}

.view {
  min-height: 570px;
  padding: 64px clamp(26px, 8vw, 96px) 70px;
}

.start-view,
.candidate-view,
.final-view {
  text-align: center;
}

.lock-mark,
.success-orbit {
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  margin: 0 auto 28px;
  border: 1px solid rgba(200, 185, 255, 0.32);
  border-radius: 50%;
  color: var(--violet-soft);
  font-family: var(--mono);
  box-shadow: inset 0 0 30px rgba(156, 124, 255, 0.08), 0 0 50px rgba(156, 124, 255, 0.09);
}

.lock-mark::before,
.success-orbit::before {
  position: absolute;
  width: 116px;
  height: 116px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 50%;
  content: "";
  animation: rotate 22s linear infinite;
}

@keyframes rotate { to { transform: rotate(360deg); } }

.success-orbit span {
  font-size: 2.4rem;
}

.section-tag {
  margin: 0 0 14px;
  color: var(--violet-soft);
  font-size: 0.68rem;
}

.view h2 {
  max-width: 780px;
  margin: 0 auto 18px;
  font-size: clamp(1.9rem, 4vw, 3.5rem);
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.copy,
.puzzle-prompt {
  max-width: 720px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.8;
}

.rules {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 820px;
  margin: 42px auto;
  text-align: left;
}

.rules > div {
  min-height: 120px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.018);
}

.rules span {
  color: var(--amber);
  font-family: var(--mono);
  font-size: 0.72rem;
}

.rules p {
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.prelude-clue {
  max-width: 760px;
  margin: 34px auto;
  padding: 24px 26px;
  border: 1px solid rgba(156, 124, 255, 0.22);
  border-radius: 12px;
  background: rgba(156, 124, 255, 0.035);
  text-align: left;
}

.prelude-clue p {
  margin: 0;
  color: #c7c1d1;
  font-family: var(--mono);
  font-size: clamp(0.72rem, 1.8vw, 0.86rem);
  line-height: 1.9;
}

.prelude-clue strong {
  color: var(--violet-soft);
  font-weight: 500;
}

.gate-copy {
  margin-top: 28px;
}

.gate-cipher {
  margin-right: auto;
  margin-left: auto;
}

.start-view .gate-form {
  margin-right: auto;
  margin-left: auto;
  text-align: left;
}

.primary-button,
.copy-button {
  display: inline-flex;
  min-height: 54px;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 0 26px;
  border: 0;
  border-radius: 8px;
  color: #0b0913;
  background: linear-gradient(135deg, #cfc2ff, #a987ff);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 12px 34px rgba(118, 82, 217, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.primary-button:hover,
.copy-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 42px rgba(118, 82, 217, 0.36);
}

.primary-button:disabled,
.answer-form button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.puzzle-view {
  position: relative;
}

.puzzle-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 46px;
  color: var(--dim);
  font-size: 0.64rem;
}

.puzzle-meta span:first-child {
  color: var(--amber);
}

.puzzle-number {
  position: absolute;
  top: 88px;
  right: clamp(26px, 8vw, 96px);
  color: rgba(255, 255, 255, 0.035);
  font-size: clamp(6rem, 17vw, 13rem);
  font-weight: 800;
  line-height: 0.8;
  pointer-events: none;
}

.puzzle-view h2,
.puzzle-view .puzzle-prompt {
  position: relative;
  z-index: 1;
  margin-right: auto;
  margin-left: 0;
  text-align: left;
}

.puzzle-view h2 {
  max-width: 620px;
}

.puzzle-prompt {
  max-width: 690px;
}

.cipher-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: center;
  max-width: 820px;
  margin: 34px 0 0;
  padding: 25px;
  border: 1px solid rgba(156, 124, 255, 0.23);
  border-radius: 12px;
  color: #e3dbff;
  background: rgba(156, 124, 255, 0.045);
  font-family: var(--mono);
  font-size: clamp(0.85rem, 2.3vw, 1.15rem);
  line-height: 1.9;
  letter-spacing: 0.11em;
  text-align: left;
}

.token {
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.025);
}

.answer-form {
  max-width: 820px;
  margin: 42px 0 0;
}

.answer-form label {
  display: block;
  margin-bottom: 10px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.13em;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.025);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-row:focus-within {
  border-color: rgba(156, 124, 255, 0.75);
  box-shadow: 0 0 0 4px rgba(156, 124, 255, 0.08);
}

.input-row input {
  min-width: 0;
  min-height: 58px;
  padding: 0 18px;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-family: var(--mono);
  font-size: 0.86rem;
  letter-spacing: 0.06em;
}

.input-row input::placeholder {
  color: #595565;
}

.input-row button {
  min-width: 142px;
  border: 0;
  color: #0a0911;
  background: var(--violet-soft);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.input-row button span {
  margin-left: 16px;
}

.feedback {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
}

.feedback.error { color: var(--danger); }
.feedback.success { color: var(--success); }

.hint-button {
  margin-top: 17px;
  padding: 0;
  border: 0;
  border-bottom: 1px dotted #595565;
  color: var(--dim);
  background: transparent;
  font-family: var(--mono);
  font-size: 0.63rem;
  letter-spacing: 0.1em;
  cursor: pointer;
}

.hint {
  max-width: 650px;
  margin: 16px 0 0;
  padding: 14px 16px;
  border-left: 2px solid var(--amber);
  color: #c9c3d1;
  background: rgba(244, 184, 106, 0.04);
  font-size: 0.86rem;
  line-height: 1.6;
}

.candidate-view {
  display: grid;
  place-items: center;
  align-content: center;
}

.candidate-signal {
  margin-bottom: 22px;
  color: var(--amber);
  font-size: 4rem;
  text-shadow: 0 0 30px rgba(244, 184, 106, 0.35);
}

.candidate-code,
.agent-secret {
  margin: 32px auto 8px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: clamp(2.2rem, 8vw, 4.8rem);
  letter-spacing: 0.14em;
  text-shadow: 0 0 28px rgba(156, 124, 255, 0.22);
}

.candidate-name {
  margin-bottom: 32px;
  color: var(--dim);
  font-size: 0.64rem;
}

.final-riddle {
  max-width: 680px;
  color: #d3ccdc;
  font-style: italic;
}

.candidate-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  max-width: 820px;
  margin: 38px auto;
}

.candidate-tile {
  position: relative;
  display: grid;
  gap: 7px;
  padding: 22px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.018);
  text-align: left;
}

.tile-symbol {
  position: absolute;
  top: 8px;
  right: 16px;
  color: rgba(200, 185, 255, 0.5);
  font-size: 2rem;
}

.tile-label {
  color: var(--dim);
  font-size: 0.58rem;
}

.candidate-tile strong {
  font-family: var(--mono);
  font-size: clamp(1.1rem, 4vw, 1.65rem);
  letter-spacing: 0.11em;
}

.final-directive {
  max-width: 700px;
  margin: 0 auto 28px;
  padding: 18px 22px;
  border: 1px solid rgba(244, 184, 106, 0.22);
  border-radius: 10px;
  background: rgba(244, 184, 106, 0.035);
}

.final-directive span {
  color: var(--amber);
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.13em;
}

.final-directive p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.link-button {
  margin-top: 4px;
}

.small-note {
  margin-top: 18px;
  color: var(--dim);
  font-size: 0.58rem;
}

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 4px 0;
  color: #615c6a;
  font-family: var(--mono);
  font-size: 0.58rem;
  letter-spacing: 0.1em;
}

footer button {
  padding: 0;
  border: 0;
  border-bottom: 1px dotted #47434e;
  color: #615c6a;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* Agent channel */
.agent-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.agent-shell {
  width: min(900px, calc(100% - 36px));
}

.agent-card {
  min-height: 600px;
  margin-top: 54px;
  padding: clamp(34px, 8vw, 82px);
}

.agent-card h1 {
  margin: 0 0 18px;
  font-size: clamp(2.7rem, 8vw, 5.8rem);
  line-height: 0.96;
  letter-spacing: -0.06em;
}

.agent-card .copy,
.agent-card .answer-form {
  margin-right: 0;
  margin-left: 0;
}

.phrase-card {
  margin: 38px 0 28px;
  padding: 22px 24px;
  border: 1px solid rgba(156, 124, 255, 0.28);
  border-radius: 12px;
  background: rgba(156, 124, 255, 0.05);
}

.phrase-card span {
  color: var(--violet-soft);
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.13em;
}

.phrase-card blockquote {
  margin: 16px 0 0;
  color: var(--ink);
  font-size: clamp(1.15rem, 3vw, 1.55rem);
  line-height: 1.55;
}

.agent-secret {
  margin-left: 0;
}

.copy-button {
  min-height: 46px;
  margin-top: 10px;
}

.agent-rules {
  display: grid;
  gap: 8px;
  margin-top: 34px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.87rem;
}

.agent-rules p {
  margin: 0;
}

@media (max-width: 760px) {
  .shell,
  .agent-shell {
    width: min(100% - 22px, 680px);
    padding-top: 14px;
  }

  .topbar {
    font-size: 0.58rem;
    letter-spacing: 0.09em;
  }

  .hero {
    grid-template-columns: 1fr;
    gap: 30px;
    padding: 68px 12px 42px;
  }

  .eyebrow {
    margin-bottom: -8px;
  }

  .hero-copy {
    max-width: 580px;
  }

  .mission-card,
  .agent-card {
    border-radius: 16px;
  }

  .mission-head {
    padding: 17px 18px;
  }

  .view {
    min-height: 590px;
    padding: 48px 20px 54px;
  }

  .rules {
    grid-template-columns: 1fr;
    margin: 32px auto;
  }

  .rules > div {
    display: grid;
    min-height: 0;
    grid-template-columns: 40px 1fr;
    align-items: center;
  }

  .rules p {
    margin: 0;
  }

  .puzzle-meta {
    margin-bottom: 34px;
  }

  .puzzle-number {
    top: 98px;
    right: 15px;
    font-size: 7rem;
  }

  .cipher-panel {
    padding: 18px 14px;
    letter-spacing: 0.06em;
  }

  .answer-form {
    margin-top: 32px;
  }

  .input-row {
    grid-template-columns: 1fr;
  }

  .input-row button {
    min-height: 50px;
  }

  .candidate-grid {
    grid-template-columns: 1fr;
  }

  .candidate-code,
  .agent-secret {
    font-size: clamp(1.7rem, 10vw, 3rem);
  }

  footer {
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
  }

  .agent-card {
    min-height: 560px;
    margin-top: 28px;
    padding: 42px 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
