:root {
  --bg: #0D1B2B;
  --text: #F4F6F8;
  --muted: rgba(244, 246, 248, .68);
  --faint: rgba(244, 246, 248, .42);
  --line: rgba(255, 255, 255, .16);
  --line-strong: rgba(255, 255, 255, .34);
  --card: rgba(13, 27, 43, .62);
  --accent: #FF7A1A;
  --accent-soft: rgba(255, 122, 26, .14);
  --danger: #FF9272;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --pad: clamp(20px, 5vw, 72px);
  --head-h: clamp(60px, 9vh, 88px);
  --font-head: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; }

/* sem barras de rolagem em lugar nenhum */
* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { display: none; width: 0; height: 0; }

html { height: 100%; color-scheme: dark; -webkit-text-size-adjust: 100%; }
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ───────── Fundo ───────── */
.bg { position: fixed; left: 0; top: 0; width: 100%; height: 100%; z-index: 0; overflow: hidden; background: var(--bg); }
.bg__img {
  position: absolute; inset: 0;
  background: url("../assets/bg.jpg") 50% 55% / cover no-repeat;
  opacity: 0;
  transition: opacity 1.6s ease;
}
@media (max-aspect-ratio: 9/10) { .bg__img { background-position: 24% 55%; } }
#ascii { position: absolute; left: 0; top: 0; opacity: 1; transition: opacity 1.4s ease; }
.bg__shade {
  position: absolute; inset: 0; opacity: 0;
  transition: opacity 1.4s ease;
  background:
    radial-gradient(75% 85% at 50% 50%, rgba(13, 27, 43, .80) 0%, rgba(13, 27, 43, .52) 55%, rgba(13, 27, 43, .1) 100%),
    linear-gradient(180deg, rgba(13, 27, 43, .5) 0%, rgba(13, 27, 43, 0) 22%, rgba(13, 27, 43, 0) 80%, rgba(13, 27, 43, .5) 100%);
}
@media (max-aspect-ratio: 9/10) { .bg__shade { background: linear-gradient(180deg, rgba(13, 27, 43, .72), rgba(13, 27, 43, .62) 50%, rgba(13, 27, 43, .78)); } }

body.bg-img-in .bg__img { opacity: .4; }
body.is-ready #ascii { opacity: .34; }
body.is-ready .bg__img { opacity: .24; }
body.is-ready .bg__shade { opacity: 1; }


/* ───────── App ───────── */
.app {
  position: fixed; left: 0; top: 0; width: 100%;
  height: 100%; height: var(--app-h, 100dvh);
  z-index: 1;
}
.js .app { opacity: 0; transition: opacity .45s ease; }
.js body.is-ready .app { opacity: 1; }
.js body.is-intro .app { pointer-events: none; }

.progress { position: absolute; left: 0; top: 0; width: 100%; height: 2px; background: rgba(255, 255, 255, .08); z-index: 4; }
.progress i { display: block; height: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(var(--p, 0)); transition: transform .7s var(--ease); }

.top {
  position: absolute; left: 0; right: 0; top: 0; z-index: 3;
  height: var(--head-h);
  padding: 0 var(--pad);
  display: flex; align-items: center; justify-content: space-between;
}
.logo { display: block; height: clamp(26px, 3.6vw, 40px); width: auto; }

.stage { position: absolute; left: 0; right: 0; top: var(--head-h); bottom: 0; }

/* ───────── Passos ───────── */
.step {
  position: absolute; inset: 0;
  display: flex;
  padding: 0 var(--pad) clamp(16px, 4vh, 48px);
  overflow-y: auto; overflow-x: hidden;
  visibility: hidden; opacity: 0; pointer-events: none;
}
.step.is-active { visibility: visible; opacity: 1; pointer-events: auto; }
.step__inner { margin: auto 0; width: 100%; max-width: 820px; }
.step__inner--wide { max-width: 1200px; }

.step.is-entering .reveal { animation: rise .7s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms); }
.step.is-entering .choice { animation: rise .55s var(--ease) both; animation-delay: calc(180ms + var(--c, 0) * 35ms); }
.step.is-leaving { animation: out .26s cubic-bezier(.4, 0, 1, 1) forwards; }
@keyframes rise { from { opacity: 0; transform: translate3d(0, calc(var(--dir, 1) * 28px), 0); } to { opacity: 1; transform: none; } }
@keyframes out { to { opacity: 0; transform: translate3d(0, calc(var(--dir, 1) * -22px), 0); } }

/* ───────── Tipografia ───────── */
.headline {
  font: 600 clamp(26px, min(4.2vw, 7vh), 58px)/1.08 var(--font-head);
  letter-spacing: -.03em;
  text-wrap: balance;
}
.headline em { font-style: normal; color: var(--accent); white-space: nowrap; }

/* trecho decodificado com símbolos de teclado (js/scramble.js) */
.sc { display: inline-block; text-align: center; }
.sc.is-noise { font: 500 .8em/1 var(--mono); letter-spacing: 0; color: #FFB27A; opacity: .95; text-shadow: .04em 0 rgba(0, 220, 255, .55), -.04em 0 rgba(255, 40, 100, .5); }
.sc.is-pop { animation: pop .55s ease-out; }
@keyframes pop { from { color: #fff; text-shadow: 0 0 .5em rgba(255, 122, 26, .95); } to { color: var(--accent); text-shadow: 0 0 0 rgba(255, 122, 26, 0); } }
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sub {
  margin-top: clamp(14px, 2.6vh, 26px);
  max-width: min(100%, 800px);
  font: 400 clamp(16px, min(1.8vw, 2.8vh), 22px)/1.45 var(--font);
  color: var(--muted);
  text-wrap: pretty;
}
.lead {
  margin-top: clamp(12px, 2.2vh, 22px);
  max-width: min(100%, 880px);
  font-size: clamp(14px, min(1.3vw, 2.3vh), 16px);
  color: var(--faint);
  text-wrap: pretty;
}
.lead strong { color: var(--text); font-weight: 600; }

.q {
  font: 600 clamp(26px, min(4.2vw, 6.4vh), 52px)/1.1 var(--font-head);
  letter-spacing: -.025em;
  text-wrap: balance;
}
.q--long { font-size: clamp(22px, min(3.2vw, 5.2vh), 40px); }
.hint { margin-top: 12px; max-width: 58ch; color: var(--muted); font-size: clamp(15px, 1.5vw, 18px); text-wrap: pretty; }
.hint strong { color: var(--text); font-weight: 500; }
.field { margin-top: clamp(18px, 4vh, 40px); }

/* ───────── Campos de texto ───────── */
.input {
  display: block; width: 100%;
  background: transparent; border: 0; border-radius: 0;
  border-bottom: 2px solid var(--line-strong);
  padding: 10px 0 12px;
  font: 500 clamp(20px, 3vw, 32px)/1.3 var(--font-head);
  letter-spacing: -.01em;
  caret-color: var(--accent);
  outline: 0;
  transition: border-color .25s ease;
}
.input::placeholder { color: var(--faint); }
.input:focus { border-bottom-color: var(--accent); }
.input--area {
  min-height: clamp(104px, 22vh, 180px);
  padding: 16px 18px; resize: none;
  background: rgba(13, 27, 43, .5);
  border: 1px solid var(--line-strong); border-radius: 14px;
  font: 400 clamp(16px, 1.8vw, 20px)/1.5 var(--font);
  letter-spacing: 0;
  transition: border-color .25s ease, box-shadow .25s ease;
}
.input--area:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

.error { min-height: 22px; margin-top: 10px; color: var(--danger); font-size: 14px; }
.is-shake { animation: shake .4s cubic-bezier(.36, .07, .19, .97); }
@keyframes shake { 20%, 60% { transform: translate3d(-6px, 0, 0); } 40%, 80% { transform: translate3d(6px, 0, 0); } }

/* ───────── Múltipla escolha ───────── */
.choices { display: grid; gap: 12px; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); }
.choices[data-cols="1"] { --cols: 1; }
.choices[data-cols="2"] { --cols: 2; }
.choices[data-cols="3"] { --cols: 3; }
.choice {
  position: relative; display: flex; align-items: center; text-align: left;
  min-height: clamp(50px, 7.6vh, 64px);
  padding: 12px 46px 12px 18px;
  background: var(--card);
  border: 1px solid var(--line); border-radius: 12px;
  font: 500 clamp(14px, 1.3vw, 16px)/1.3 var(--font);
  transition: border-color .2s ease, background-color .2s ease, transform .2s var(--ease);
}
.choice::after {
  content: ""; position: absolute; right: 16px; top: 50%;
  width: 18px; height: 18px; margin-top: -9px; border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  transition: background-color .2s ease, border-color .2s ease;
}
@media (hover: hover) { .choice:hover { border-color: var(--line-strong); transform: translate3d(0, -1px, 0); } }
.choice:active { transform: scale(.985); }
.choice[aria-checked="true"] { border-color: var(--accent); background: rgba(255, 122, 26, .13); }
.choice[aria-checked="true"]::after {
  border-color: var(--accent);
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 12.5l4 4 8-9' fill='none' stroke='%230D1B2B' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat;
}

.other { display: grid; grid-template-rows: 0fr; opacity: 0; margin-top: 0; transition: grid-template-rows .4s var(--ease), opacity .3s ease, margin-top .4s var(--ease); }
.other.is-open { grid-template-rows: 1fr; opacity: 1; margin-top: 18px; }
.other__in { min-height: 0; overflow: hidden; }
.other .input { font-size: clamp(18px, 2.4vw, 26px); }

/* ───────── Botões ───────── */
.nav { margin-top: clamp(10px, 2.4vh, 24px); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 46px; padding: 0 22px;
  border: 1px solid transparent; border-radius: 10px;
  font: 600 15px/1 var(--font);
  transition: background-color .2s ease, border-color .2s ease, opacity .2s ease, transform .2s var(--ease);
}
.btn:active { transform: scale(.97); }
.btn--primary { background: var(--accent); color: #0D1B2B; }
.btn--primary svg { transition: transform .25s var(--ease); }
@media (hover: hover) {
  .btn--primary:hover { background: #FF8D3A; }
  .btn--primary:hover svg { transform: translate3d(3px, 0, 0); }
  .btn--ghost:hover { border-color: var(--line-strong); }
}
.btn--ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn--lg { min-height: 50px; padding: 0 26px; font-size: 16px; }
.btn[aria-disabled="true"] { opacity: .42; }
.btn.is-loading { pointer-events: none; opacity: .8; }
.btn.is-loading svg { display: none; }
.btn.is-loading::after { content: ""; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(13, 27, 43, .3); border-top-color: #0D1B2B; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.kbd-hint { font: 400 13px var(--mono); color: var(--faint); }
.kbd-hint kbd { font: inherit; padding: 2px 7px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); }
@media (hover: none), (pointer: coarse) { .kbd-hint--key { display: none; } }

/* ───────── Concluído ───────── */
.done__icon { display: block; margin-bottom: 22px; color: var(--accent); }
.done__ring { stroke-dasharray: 183; stroke-dashoffset: 183; }
.done__tick { stroke-dasharray: 50; stroke-dashoffset: 50; }
.step--done.is-active .done__ring { animation: draw .9s var(--ease) .25s forwards; }
.step--done.is-active .done__tick { animation: draw .5s var(--ease) .85s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

.noscript { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: var(--bg); padding: 24px; text-align: center; }

/* ───────── Desktop: tudo centralizado ───────── */
@media (min-width: 900px) {
  .top { padding-left: max(var(--pad), calc((100% - 1120px) / 2)); padding-right: max(var(--pad), calc((100% - 1120px) / 2)); }
  .step__inner { margin: auto; text-align: center; }
  .sub, .lead, .hint { margin-left: auto; margin-right: auto; }
  .nav { justify-content: center; }
  .input { text-align: center; }
  .input--area { text-align: left; }
  .done__icon { margin-left: auto; margin-right: auto; }
}

/* ───────── Telas pequenas ───────── */
@media (max-width: 640px) {
  .choices { gap: 8px; }
  .choices[data-m="1"] { --cols: 1; }
  .choices[data-m="2"] { --cols: 2; }
  .choice { min-height: 48px; padding: 10px 38px 10px 14px; font-size: 14px; }
  .choice::after { right: 12px; width: 16px; height: 16px; margin-top: -8px; }
}
@media (max-width: 640px) and (max-height: 700px) { .choice { min-height: 44px; } .hint { margin-top: 8px; } }
@media (max-height: 560px) { :root { --head-h: 52px; } .logo { height: 22px; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
}
