:root {
  --bg:        #0e0a1a;
  --bg-2:      #16102a;
  --accent:    #ffce00;
  --accent-2:  #ffd84d;
  --text:      #f4f2fb;
  --muted:     #8b86a3;
  --dim:       #4a4363;
  --future:    #5a4a26;   /* контур будущих узлов */
  --future-ln: #3b3120;   /* будущие линии */
  --frame:     #2d7dff;   /* синяя рамка выделения */
  --attention: #ff7a3c;
  --radius:    16px;
  --stage-pad: clamp(16px, 4vw, 48px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100%;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(120% 80% at 50% -10%, #1a1230 0%, var(--bg) 60%);
}

.stage {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--stage-pad) + env(safe-area-inset-top))
           var(--stage-pad)
           calc(var(--stage-pad) + env(safe-area-inset-bottom));
}

.view {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

[hidden] { display: none !important; }

/* ---------- ЭКРАН ЗАКАЗА ---------- */
.order-head { margin-bottom: clamp(14px, 2vw, 26px); }

.order-title {
  margin: 0;
  font-weight: 800;
  color: var(--accent);
  font-size: clamp(28px, 5vw, 52px);
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.order-code {
  margin-top: 4px;
  font-weight: 600;
  color: var(--dim);
  font-size: clamp(18px, 3.4vw, 34px);
  letter-spacing: 0.06em;
}

/* Картинка персонажа на прозрачном фоне — без рамки, встроена в фон */
.art-media {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: clamp(230px, 42vh, 400px);
  margin: clamp(6px, 1.4vw, 14px) 0 clamp(20px, 3vw, 32px);
}

.art-media picture { display: contents; }

.art-img {
  height: 100%;
  width: auto;
  max-width: 92vw;
  object-fit: contain;
  filter: drop-shadow(0 18px 28px rgba(0,0,0,0.5));
  opacity: 1;
  transition: opacity .35s ease;
}
.art-media.is-loading .art-img { opacity: 0; }

/* ---------- СТЕППЕР ---------- */
.stepper {
  width: 100%;
  max-width: 820px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: start;
  margin-bottom: clamp(24px, 4vw, 48px);
}

.step {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

/* соединительная линия — рисуем справа от узла, кроме последнего */
.step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: clamp(13px, 2.4vw, 22px);
  left: 50%;
  width: 100%;
  height: 4px;
  background: var(--future-ln);
  z-index: 0;
  border-radius: 4px;
}
.step.done:not(:last-child)::after { background: var(--accent); }
.step.current:not(:last-child)::after {
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent) 35%, var(--future-ln) 95%);
}

.node {
  position: relative;
  z-index: 1;
  width: clamp(28px, 4.8vw, 46px);
  height: clamp(28px, 4.8vw, 46px);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg);
}

/* будущий узел — пустое кольцо */
.node--future {
  border: 3px solid var(--future);
}
/* пройденный/текущий — жёлтый диск с галочкой-прорезью (marker.svg).
   Тёмная подложка нужна, чтобы прорезь-галочка читалась тёмной, а не сливалась. */
.node--done {
  background: var(--bg) center / 100% no-repeat url("/assets/marker.svg");
}
.node--current {
  background: var(--bg) center / 100% no-repeat url("/assets/marker.svg");
  box-shadow: 0 0 0 6px rgba(255,206,0,0.14);
}
.node--attention {
  background: var(--attention);
  box-shadow: 0 0 0 6px rgba(255,122,60,0.16);
}
.node--attention::before {
  content: "!";
  font-weight: 800;
  color: #fff;
  font-size: clamp(15px, 2.6vw, 24px);
}

.step-label {
  margin-top: 10px;
  font-size: clamp(10px, 1.5vw, 15px);
  font-weight: 600;
  line-height: 1.2;
  color: var(--future);
  padding: 0 3px;
  /* переносим только между словами, слова по слогам не рвём */
  hyphens: none;
  word-break: normal;
  overflow-wrap: break-word;
}
.step.done .step-label { color: var(--muted); }
.step.current .step-label { color: var(--accent); font-weight: 700; }
.step.attention .step-label { color: var(--attention); font-weight: 700; }

/* ---------- БЛОК СТАТУСА ---------- */
.status-title {
  margin: 0 0 clamp(8px, 1.4vw, 16px);
  font-weight: 800;
  color: var(--accent);
  font-size: clamp(38px, 8vw, 84px);
  line-height: 1;
  letter-spacing: -0.02em;
}
.status-title.attention { color: var(--attention); }

.status-block {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.status-desc {
  margin: 0 auto;
  color: var(--muted);
  font-size: clamp(14px, 2.4vw, 22px);
  font-weight: 500;
  max-width: 40ch;
  line-height: 1.45;
}

.back-link {
  margin-top: clamp(20px, 3vw, 40px);
  color: var(--dim);
  text-decoration: none;
  font-size: clamp(12px, 1.6vw, 15px);
  font-weight: 600;
  transition: color .2s;
}
.back-link:hover { color: var(--muted); }

/* ---------- ЭКРАН ВВОДА ---------- */
.input-card {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.input-title {
  margin: 0 0 10px;
  font-weight: 800;
  color: var(--accent);
  font-size: clamp(30px, 7vw, 56px);
  line-height: 1.05;
}
.input-sub {
  margin: 0 0 clamp(22px, 4vw, 36px);
  color: var(--muted);
  font-size: clamp(14px, 2.6vw, 19px);
  font-weight: 500;
  max-width: 34ch;
}
.track-form {
  width: 100%;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.code-input {
  flex: 1 1 240px;
  min-width: 0;
  padding: clamp(14px, 2.4vw, 18px) clamp(16px, 3vw, 22px);
  font-family: inherit;
  font-size: clamp(16px, 2.6vw, 20px);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
  background: var(--bg-2);
  border: 2px solid #241b3f;
  border-radius: 14px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  text-align: center;
}
.code-input::placeholder { color: var(--dim); font-weight: 500; letter-spacing: 0; }
.code-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(255,206,0,0.12);
}
.track-btn {
  flex: 0 0 auto;
  padding: clamp(14px, 2.4vw, 18px) clamp(24px, 4vw, 34px);
  font-family: inherit;
  font-size: clamp(16px, 2.6vw, 20px);
  font-weight: 700;
  color: #1a1200;
  /* iOS Safari перебивает цвет текста кнопки своим системным — фиксируем жёстко */
  -webkit-text-fill-color: #1a1200;
  -webkit-appearance: none;
  appearance: none;
  background: var(--accent);
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: transform .1s, background .2s;
}
.track-btn:hover { background: var(--accent-2); }
.track-btn:active { transform: translateY(1px); }
.track-btn--ghost {
  display: inline-block;
  text-decoration: none;
  margin-top: 24px;
  background: transparent;
  color: var(--accent);
  -webkit-text-fill-color: var(--accent);
  border: 2px solid var(--accent);
}
.track-btn--ghost:hover { background: rgba(255,206,0,0.1); }

.input-error {
  margin: 16px 0 0;
  color: var(--attention);
  font-size: 14px;
  font-weight: 600;
}

/* ---------- ЗАГРУЗКА / ОШИБКА ---------- */
.view--loading { min-height: 40vh; justify-content: center; }
.spinner {
  width: 46px; height: 46px;
  border: 4px solid rgba(255,206,0,0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.err-card { display: flex; flex-direction: column; align-items: center; }
.err-title {
  margin: 0 0 12px;
  font-weight: 800;
  color: var(--text);
  font-size: clamp(26px, 6vw, 46px);
}
.err-text {
  margin: 0;
  color: var(--muted);
  font-size: clamp(14px, 2.6vw, 19px);
  max-width: 34ch;
}

/* ---------- АДАПТИВ ---------- */

/* Узкие телефоны: степпер компактнее, подписи мельче */
@media (max-width: 380px) {
  .stepper { max-width: 100%; }
  .step-label { font-size: 9.5px; }
}

/* Планшет и выше — картинка крупнее */
@media (min-width: 768px) {
  .art-media { height: clamp(300px, 40vh, 420px); }
}

/* Большие экраны / ТВ */
@media (min-width: 1600px) {
  .view { max-width: 1320px; }
  .order-title  { font-size: clamp(48px, 3.4vw, 64px); }
  .status-title { font-size: clamp(72px, 5.4vw, 104px); }
  .status-desc  { font-size: clamp(20px, 1.5vw, 28px); }
  .art-media    { height: clamp(380px, 30vh, 560px); }
  .stepper      { max-width: 1000px; }
  .step-label   { font-size: clamp(15px, 1.1vw, 20px); }
}

/* Пейзаж на невысоких экранах — ужимаем вертикальные отступы */
@media (max-height: 560px) and (orientation: landscape) {
  .art-media { height: clamp(150px, 34vh, 240px); }
  .status-title { font-size: clamp(30px, 6vh, 54px); }
  .order-title { font-size: clamp(22px, 5vh, 34px); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition: none !important; }
}
