:root {
  color-scheme: dark;
  --bg: #080a0b;
  --panel: rgba(13, 16, 17, 0.92);
  --ink: #e8e6df;
  --muted: #81888a;
  --dim: #353a3b;
  --signal: #d6ff42;
  --signal-soft: rgba(214, 255, 66, 0.14);
  --fault: #ff5e48;
  --line: rgba(232, 230, 223, 0.18);
  --mono: "SFMono-Regular", "Cascadia Code", "Liberation Mono", Menlo, monospace;
  --sans: Inter, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 78% 12%, rgba(214, 255, 66, 0.07), transparent 24rem),
    radial-gradient(circle at 18% 82%, rgba(115, 140, 124, 0.08), transparent 26rem),
    var(--bg);
  font-family: var(--mono);
}

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

.noise,
.scanline {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.noise {
  opacity: 0.15;
  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='.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.25'/%3E%3C/svg%3E");
  animation: grain 0.18s steps(2) infinite;
}

.scanline {
  opacity: 0.08;
  background: linear-gradient(transparent 50%, #000 50%);
  background-size: 100% 4px;
}

.shell {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: min(1120px, calc(100% - 48px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0 22px;
}

.topbar,
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topbar {
  padding: 0 0 18px;
  border-bottom: 1px solid var(--line);
}

.identity,
.topbar__status {
  display: flex;
  align-items: center;
  gap: 14px;
}

.counter {
  min-width: 58px;
  color: var(--ink);
  text-align: right;
}

.sound-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  border: 1px solid transparent;
  color: var(--muted);
  background: transparent;
  font: 10px/1 var(--mono);
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}

.sound-toggle:hover,
.sound-toggle:focus-visible {
  border-color: rgba(214, 255, 66, 0.45);
  outline: none;
  color: var(--signal);
  background: var(--signal-soft);
}

.sound-toggle__bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  width: 12px;
  height: 10px;
}

.sound-toggle__bars i {
  display: block;
  width: 2px;
  height: 4px;
  background: currentColor;
  transform-origin: bottom;
}

.sound-toggle__bars i:nth-child(2) {
  height: 8px;
}

.sound-toggle__bars i:nth-child(3) {
  height: 6px;
}

.sound-toggle[data-playing="true"] .sound-toggle__bars i {
  animation: sound-bars 0.72s ease-in-out infinite alternate;
}

.sound-toggle[data-playing="true"] .sound-toggle__bars i:nth-child(2) {
  animation-delay: -0.38s;
}

.sound-toggle[data-playing="true"] .sound-toggle__bars i:nth-child(3) {
  animation-delay: -0.17s;
}

.vibe-toggle {
  min-width: 54px;
  justify-content: center;
  border-color: var(--line);
  color: var(--ink);
}

.vibe-toggle[aria-pressed="false"] {
  color: var(--muted);
}

.pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 15px rgba(214, 255, 66, 0.8);
  animation: pulse 1.6s ease-in-out infinite;
}

.terminal {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: min(720px, calc(100vh - 144px));
  margin: 24px 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.018), transparent 42%),
    var(--panel);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.28);
}

.terminal::before,
.terminal::after {
  position: absolute;
  width: 32px;
  height: 32px;
  content: "";
  pointer-events: none;
}

.terminal::before {
  top: 9px;
  left: 9px;
  border-top: 1px solid var(--signal);
  border-left: 1px solid var(--signal);
}

.terminal::after {
  right: 9px;
  bottom: 9px;
  border-right: 1px solid var(--dim);
  border-bottom: 1px solid var(--dim);
}

.terminal__meta {
  display: flex;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.16em;
}

.terminal__meta b {
  color: var(--ink);
  font-weight: 500;
}

.screen {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  width: min(790px, calc(100% - 72px));
  margin: 0 auto;
  padding: 72px 0;
}

.screen[hidden] {
  display: none;
}

.eyebrow,
.question-index {
  margin: 0 0 28px;
  color: var(--signal);
  font-size: 11px;
  line-height: 1.5;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-family: var(--sans);
  font-weight: 750;
  letter-spacing: -0.045em;
}

h1 {
  max-width: 780px;
  font-size: clamp(48px, 8vw, 106px);
  line-height: 0.88;
  text-transform: uppercase;
}

.prompt--large {
  margin: 38px 0 44px;
  color: var(--muted);
  font-size: clamp(18px, 2.5vw, 28px);
}

.command,
.download {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: min(100%, 560px);
  min-height: 62px;
  padding: 0 20px;
  border: 1px solid var(--signal);
  color: var(--bg);
  background: var(--signal);
  font: 600 14px/1 var(--mono);
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.command:hover,
.command:focus-visible,
.download:hover,
.download:focus-visible {
  transform: translateY(-2px);
  outline: none;
  box-shadow: 0 0 0 4px var(--signal-soft), 0 12px 40px rgba(214, 255, 66, 0.1);
}

.command__mark {
  font-size: 22px;
}

.command__key {
  padding: 5px 7px;
  border: 1px solid rgba(8, 10, 11, 0.4);
  font-size: 9px;
  letter-spacing: 0.1em;
}

.screen--quiz {
  justify-content: flex-start;
  padding-top: clamp(68px, 12vh, 140px);
}

.question {
  min-height: 2.2em;
  max-width: 760px;
  font-size: clamp(30px, 5vw, 64px);
  line-height: 1.04;
}

.answers {
  display: grid;
  gap: 10px;
  width: 100%;
  margin-top: 52px;
}

.answer {
  position: relative;
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 58px;
  padding: 12px 18px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.015);
  font: 14px/1.45 var(--mono);
  text-align: left;
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.answer:hover,
.answer:focus-visible {
  border-color: rgba(214, 255, 66, 0.65);
  outline: none;
  background: var(--signal-soft);
  transform: translateX(4px);
}

.answer__number {
  color: var(--muted);
  font-size: 10px;
}

.answer__arrow {
  color: var(--signal);
  opacity: 0;
  transition: opacity 140ms ease;
}

.answer:hover .answer__arrow,
.answer:focus-visible .answer__arrow {
  opacity: 1;
}

.answer--wrong {
  border-color: var(--fault);
  color: var(--fault);
  animation: shake 220ms linear;
}

.answer--correct {
  border-color: var(--signal);
  color: var(--signal);
  background: var(--signal-soft);
}

.answer:disabled {
  cursor: default;
}

.feedback {
  min-height: 20px;
  margin: 22px 0 0;
  color: var(--fault);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.screen--pause {
  align-items: center;
  text-align: center;
}

.pause-line {
  margin: 0 0 32px;
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
}

.screen--pause h2,
.screen--gift h2 {
  font-size: clamp(48px, 8vw, 96px);
  line-height: 0.96;
}

.analysis-line {
  width: min(460px, 80%);
  height: 2px;
  margin-top: 60px;
  overflow: hidden;
  background: var(--dim);
}

.analysis-line span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--signal);
  transform: translateX(-100%);
  animation: analyze 2.4s ease-in-out forwards;
}

.analysis-copy {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.17em;
}

.screen--gift {
  position: relative;
  justify-content: flex-start;
  padding-top: 84px;
  padding-bottom: 84px;
}

.screen--gift .eyebrow {
  max-width: calc(100% - 120px);
}

.success-mark {
  position: absolute;
  top: 72px;
  right: 0;
  display: grid;
  width: 78px;
  height: 78px;
  place-items: center;
  border: 1px solid var(--signal);
  border-radius: 50%;
  color: var(--signal);
  font-size: 11px;
  letter-spacing: 0.12em;
  transform: rotate(8deg);
}

.letter {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 30px 54px;
  width: 100%;
  margin: 54px 0 58px;
  padding: 36px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.letter p {
  margin: 0;
  font-family: var(--sans);
  font-size: clamp(16px, 1.9vw, 21px);
  line-height: 1.48;
}

.gift-card {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  width: 100%;
  margin-bottom: 18px;
  padding: 26px 28px;
  border: 1px solid var(--line);
  background: linear-gradient(125deg, rgba(214, 255, 66, 0.12), rgba(255, 255, 255, 0.02));
}

.gift-card__code {
  display: grid;
  gap: 10px;
}

.gift-card__code span,
.validity {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.14em;
}

.gift-card__code strong {
  font-family: var(--sans);
  font-size: clamp(22px, 4vw, 38px);
  letter-spacing: 0.02em;
}

.gift-card__amount {
  color: var(--signal);
  font-family: var(--sans);
  font-size: clamp(36px, 7vw, 70px);
  font-weight: 800;
  line-height: 0.8;
  letter-spacing: -0.06em;
}

.download {
  width: 100%;
  margin-top: 8px;
  text-decoration: none;
}

.download span:last-child {
  font-size: 24px;
}

.validity {
  margin: 17px 0 0;
}

.footer {
  padding-top: 2px;
}

.glitch {
  animation: glitch 180ms linear 2;
}

.particle {
  position: fixed;
  top: -20px;
  z-index: 20;
  width: 5px;
  height: 18px;
  pointer-events: none;
  background: var(--signal);
  animation: fall var(--duration) linear forwards;
  animation-delay: var(--delay);
}

@keyframes pulse {
  0%, 100% { opacity: 0.45; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.1); }
}

@keyframes sound-bars {
  from { transform: scaleY(0.35); }
  to { transform: scaleY(1); }
}

@keyframes grain {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2%, 2%); }
  50% { transform: translate(2%, -1%); }
  75% { transform: translate(1%, 2%); }
  100% { transform: translate(-1%, -2%); }
}

@keyframes shake {
  25% { transform: translateX(-7px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
}

@keyframes glitch {
  0%, 100% { transform: translate(0); filter: none; }
  33% { transform: translate(-3px, 1px); filter: hue-rotate(35deg); }
  66% { transform: translate(4px, -1px); filter: contrast(1.8); }
}

@keyframes analyze {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(-15%); }
  100% { transform: translateX(0); }
}

@keyframes fall {
  to { transform: translate3d(var(--drift), 110vh, 0) rotate(520deg); opacity: 0; }
}

@media (max-width: 700px) {
  .shell {
    width: calc(100% - 24px);
    padding: 14px 0;
  }

  .topbar {
    padding-bottom: 13px;
  }

  .identity span:last-child,
  #progressLabel,
  .footer span:first-child {
    display: none;
  }

  .topbar__status {
    gap: 7px;
  }

  .sound-toggle {
    padding-inline: 5px;
  }

  .vibe-toggle {
    min-width: 46px;
  }

  .terminal {
    min-height: calc(100vh - 92px);
    margin: 12px 0;
  }

  .terminal__meta {
    padding: 15px 17px;
  }

  .screen {
    width: calc(100% - 38px);
    padding: 54px 0;
  }

  h1 {
    font-size: clamp(48px, 16vw, 74px);
  }

  .screen--quiz {
    padding-top: 64px;
  }

  .question {
    font-size: clamp(29px, 9.5vw, 46px);
  }

  .answers {
    margin-top: 38px;
  }

  .answer {
    grid-template-columns: 26px 1fr 12px;
    gap: 8px;
    padding: 13px 12px;
    font-size: 13px;
  }

  .screen--gift {
    padding-top: 64px;
  }

  .screen--gift h2 {
    max-width: 100%;
    font-size: clamp(38px, 12vw, 48px);
    overflow-wrap: anywhere;
  }

  .screen--gift .eyebrow {
    max-width: calc(100% - 78px);
  }

  .success-mark {
    top: 50px;
    width: 62px;
    height: 62px;
    font-size: 9px;
  }

  .letter {
    grid-template-columns: 1fr;
    gap: 24px;
    margin: 38px 0;
    padding: 28px 0;
  }

  .letter p {
    overflow-wrap: break-word;
  }

  .gift-card {
    align-items: flex-start;
    flex-direction: column;
    padding: 22px;
  }

  .gift-card__amount {
    align-self: flex-end;
  }
}

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