:root {
  --bg: #070603;
  --surface: #100e08;
  --surface-soft: rgba(255, 255, 255, 0.035);
  --text: #f4f1e9;
  --muted: #928b7d;
  --gold: #d8aa34;
  --gold-bright: #f0cf72;
  --gold-dark: #8f6916;
  --line: rgba(232, 194, 94, 0.18);
  color-scheme: dark;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }

body {
  margin: 0;
  background: #020201;
  color: var(--text);
  font-family: "Manrope", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }
button { touch-action: manipulation; }
[hidden] { display: none !important; }

.app-shell {
  position: relative;
  width: min(100%, 30rem);
  min-height: var(--tg-viewport-stable-height, 100svh);
  margin: 0 auto;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 30%, rgba(195, 139, 18, 0.105), transparent 20rem),
    linear-gradient(158deg, #111008 0%, #080704 52%, #0d0a05 100%);
}

.app-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.035;
  pointer-events: none;
  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='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E");
}

.screen {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: var(--tg-viewport-stable-height, 100svh);
  padding:
    max(1.25rem, var(--tg-content-safe-area-inset-top, env(safe-area-inset-top)))
    max(1.25rem, var(--tg-content-safe-area-inset-right, env(safe-area-inset-right)))
    max(1.25rem, var(--tg-content-safe-area-inset-bottom, env(safe-area-inset-bottom)))
    max(1.25rem, var(--tg-content-safe-area-inset-left, env(safe-area-inset-left)));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  animation: enter 320ms cubic-bezier(.2,.72,.2,1) both;
}

.brand-row, .topbar {
  display: grid;
  align-items: center;
  min-height: 2.75rem;
}

.brand-row {
  justify-items: center;
  gap: .42rem;
  padding-top: clamp(1.2rem, 4vh, 2.3rem);
}

.brand-mark { width: 4rem; height: 4rem; object-fit: contain; }

.brand-name, .topbar__title, .topbar__count {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.brand-name { color: #c9b574; letter-spacing: .24em; }

.topbar {
  grid-template-columns: 2.75rem 1fr 2.75rem;
  gap: .75rem;
  padding-bottom: .85rem;
  border-bottom: 1px solid var(--line);
}

.topbar__title { color: #cec4aa; }
.topbar__count { color: #776f61; text-align: right; }

.icon-button {
  display: grid;
  width: 2.5rem;
  height: 2.5rem;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: .9rem;
  background: rgba(255,255,255,.025);
  color: var(--text);
  cursor: pointer;
}

.welcome-stage, .lesson-overview, .video-stage, .task-stage, .decision-stage, .golden-stage, .application-stage {
  align-self: center;
  min-width: 0;
  padding: 2.1rem 0;
}

.welcome-stage { text-align: center; }

.kicker, .step-label, .question-count {
  margin: 0 0 .9rem;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .13em;
  line-height: 1.45;
  text-transform: uppercase;
}

.kicker--gold, .step-label { color: var(--gold); }

h1, h2 {
  margin: 0;
  font-family: inherit;
  font-weight: 700;
  letter-spacing: -.052em;
  line-height: 1.04;
}

h1:focus, h2:focus { outline: none; }
.lesson-overview h1, .task-stage h1, .application-stage h1, .decision-stage h1, .golden-stage h1 {
  max-width: 12ch;
  font-size: clamp(2.2rem, 10vw, 3.2rem);
}

.task-stage h1, .application-stage h1 {
  font-size: clamp(1.9rem, 8.2vw, 2.65rem);
}

.amount, .business { display: block; }
.amount {
  color: var(--gold);
  font-size: clamp(4.5rem, 21vw, 6.45rem);
  font-weight: 800;
  font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: -.055em;
  line-height: .9;
}

.business {
  position: relative;
  margin-top: 2rem;
  color: var(--text);
  font-size: clamp(1.05rem, 4.8vw, 1.35rem);
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.business::before {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  top: -1.05rem;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(220,175,60,.62), transparent);
}

.course-progress { margin-bottom: clamp(2rem, 6vh, 3.8rem); }
.course-progress__meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: .65rem;
  color: #817969;
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .15em;
  text-transform: uppercase;
}

.course-progress__track {
  height: 2px;
  overflow: hidden;
  background: rgba(255,255,255,.07);
}

.course-progress__track span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold-bright));
}

.action-area { align-self: end; padding-top: 1rem; }
.action-stack { display: grid; gap: .35rem; }
.action-stack--equal { gap: .75rem; }

.primary-action {
  width: 100%;
  min-height: 3.9rem;
  padding: 0 1.35rem;
  border: 1px solid rgba(244,216,131,.24);
  border-radius: 1.15rem;
  background: linear-gradient(105deg, #b87911 0%, #e8aa2f 48%, #c98616 100%);
  color: #100d05;
  cursor: pointer;
  box-shadow: 0 1rem 3.2rem rgba(156,105,7,.18), inset 0 1px rgba(255,234,164,.2);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-align: center;
  text-transform: uppercase;
  transition: transform 160ms ease, filter 160ms ease;
}

.primary-action:hover { filter: brightness(1.08); }
.primary-action:active { transform: scale(.985); }
.primary-action:focus-visible, .icon-button:focus-visible, .text-action:focus-visible, .add-action:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}

.primary-action--secondary {
  border-color: rgba(216,170,52,.38);
  background: rgba(216,170,52,.065);
  color: var(--gold-bright);
  box-shadow: none;
}

.text-action, .add-action {
  min-height: 2.8rem;
  border: 0;
  background: transparent;
  color: #a59b88;
  cursor: pointer;
  font-size: .8rem;
  font-weight: 600;
}

.add-action {
  margin-top: .6rem;
  padding: .6rem 0;
  color: var(--gold-bright);
  text-align: left;
}

.add-action:disabled { color: #665f53; cursor: default; }

.video-stage h1 {
  margin-bottom: 1.35rem;
  font-size: clamp(1.75rem, 7.6vw, 2.45rem);
}

.screen--video .course-progress { margin-bottom: 1.8rem; }

.video-frame {
  position: relative;
  overflow: hidden;
  width: 100%;
  border: 1px solid rgba(216,170,52,.23);
  border-radius: 1.15rem;
  background: #050403;
  box-shadow: 0 1.5rem 4rem rgba(0,0,0,.42);
}

.video-frame iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16/9;
  border: 0;
  background: #050403;
}

.video-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #b9ad98;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.field-label {
  display: flex;
  justify-content: space-between;
  margin: 1.6rem 0 .65rem;
  color: #aaa293;
  font-size: .78rem;
  font-weight: 600;
  line-height: 1.4;
}

.field-label:empty { display: none; }
.field-label span { color: #70695e; font-weight: 500; }

.task-stage > h1 + .field-label + input,
.task-stage > h1 + .field-label + textarea,
.application-stage > h1 + .field-label + input,
.application-stage > h1 + .field-label + textarea,
.context-card + h1 + .field-label + textarea,
.repeatable-fields {
  margin-top: 2.15rem;
}

input, textarea {
  width: 100%;
  border: 1px solid rgba(216,170,52,.22);
  border-radius: 1rem;
  outline: none;
  background: var(--surface-soft);
  color: var(--text);
  font: 500 1rem/1.5 "Manrope", Arial, sans-serif;
}

input { min-height: 3.65rem; padding: 0 1rem; }
textarea { min-height: 8.25rem; padding: 1rem; resize: vertical; }
input:focus, textarea:focus { border-color: rgba(216,170,52,.7); box-shadow: 0 0 0 3px rgba(216,170,52,.08); }
input::placeholder, textarea::placeholder { color: #666056; }

.repeatable-fields [data-second-reaction] { margin-top: 1rem; }

.context-card {
  margin: 0 0 1.4rem;
  padding: 1rem 1.05rem;
  border-left: 2px solid var(--gold);
  background: rgba(216,170,52,.055);
  color: #d7cfbf;
  font-size: .95rem;
  line-height: 1.55;
}

.context-card span {
  display: block;
  margin-bottom: .35rem;
  color: #807768;
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.form-status {
  min-height: 1.15rem;
  margin: .65rem 0 0;
  color: #d39b66;
  font-size: .74rem;
  line-height: 1.45;
}

.decision-stage, .golden-stage { text-align: center; }
.decision-stage h1, .golden-stage h1 { margin-inline: auto; }

.golden-mark {
  width: 8.5rem;
  height: 8.5rem;
  margin: 2.5rem auto 0;
  display: grid;
  place-items: center;
  border: 1px solid rgba(216,170,52,.18);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(216,170,52,.12), transparent 68%);
}

.golden-mark img { width: 5.25rem; height: 5.25rem; object-fit: contain; }

@media (min-width: 38rem) {
  body { padding: 2rem; }
  .app-shell {
    min-height: min(52rem, calc(100svh - 4rem));
    border: 1px solid rgba(229,193,97,.12);
    border-radius: 2rem;
    box-shadow: 0 2.5rem 8rem rgba(0,0,0,.7);
  }
  .screen { min-height: min(52rem, calc(100svh - 4rem)); padding: 1.75rem; }
}

@media (max-height: 46rem) {
  .welcome-stage, .lesson-overview, .video-stage, .task-stage, .decision-stage, .golden-stage, .application-stage {
    align-self: start;
    padding: 1.35rem 0;
  }
  .course-progress { margin-bottom: 1.7rem; }
  .screen { overflow-y: auto; }
}

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

@keyframes enter {
  from { opacity: 0; transform: translateY(.35rem); }
  to { opacity: 1; transform: translateY(0); }
}
