@font-face {
  font-family: "Rubik";
  src: url("assets/rubik.ttf") format("truetype");
  font-weight: 300 900;
  font-display: swap;
}

:root {
  --paper: #f2f0fa;
  --surface: #ffffff;
  --ink: #1d1838;
  --muted: #625d7d;
  --line: #dcd7ee;
  --violet: #4b2fe0;
  --violet-deep: #3a21bf;
  --violet-soft: #e6e1ff;
  --sun: #ffd23f;
  --error: #b42318;
  --ok: #157a46;

  --col: 880px;
  --r-lg: 26px;
  --r-md: 18px;
  --r-pill: 999px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: "Rubik", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  overflow-x: hidden;
}

img { display: block; max-width: 100%; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 3px solid var(--violet); outline-offset: 3px; }

/* Header */
.top {
  display: flex;
  justify-content: center;
  padding: 22px 20px 0;
}
.brand {
  font-weight: 800;
  font-size: 1.125rem;
  letter-spacing: -.01em;
  color: var(--ink);
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 6px;
  border-radius: 10px;
}
.brand-dot { color: var(--violet); }

/* Column */
.view {
  width: min(var(--col), 100% - 40px);
  margin-inline: auto;
  padding: clamp(36px, 8vh, 88px) 0 96px;
}
.view:not(.view-home) { padding-top: clamp(16px, 3vh, 32px); }
[tabindex="-1"]:focus { outline: none; }

/* Headline */
.title {
  margin: 0 auto;
  max-width: 15ch;
  text-align: center;
  font-weight: 750;
  font-size: clamp(2rem, 1.2rem + 4.4vw, 4.25rem);
  line-height: 1.08;
  letter-spacing: -.028em;
  text-wrap: balance;
}

/* URL field — the first action */
.url { margin: clamp(28px, 5vh, 48px) auto 0; max-width: 720px; }

.url-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 8px 22px;
  min-height: 76px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--r-pill);
  box-shadow: 0 1px 0 rgba(29, 24, 56, .04), 0 18px 40px -22px rgba(75, 47, 224, .45);
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.url-field:hover { border-color: #c5bde6; }
.url-field:focus-within {
  border-color: var(--violet);
  box-shadow: 0 0 0 5px rgba(75, 47, 224, .16), 0 18px 40px -22px rgba(75, 47, 224, .5);
}
.url-field.is-active { border-color: var(--violet); }
.url-field.is-error { border-color: var(--error); }
.url-field.is-error:focus-within { box-shadow: 0 0 0 5px rgba(180, 35, 24, .14); }
.url-field.is-dormant input { color: var(--muted); }

.url-icon { width: 24px; height: 24px; flex: none; color: var(--violet); }

.url-field input {
  flex: 1;
  min-width: 0;
  height: 56px;
  border: 0;
  background: transparent;
  font-size: 1.125rem;
  outline: none;
}
.url-field input::placeholder { color: #8a85a3; opacity: 1; }

.url-go {
  flex: none;
  height: 58px;
  padding: 0 28px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--violet);
  color: #fff;
  font-weight: 650;
  font-size: 1.0625rem;
  cursor: pointer;
  transition: background-color .15s var(--ease), transform .15s var(--ease);
}
.url-go:hover { background: var(--violet-deep); }
.url-go:active { transform: scale(.97); }
.url-go:focus-visible { outline-offset: 2px; }

.url-msg, .source-msg, .field-msg, .grammar-msg {
  margin: 10px 0 0;
  min-height: 1.5em;
  font-size: .9375rem;
  text-align: center;
}
.url-msg.is-error, .source-msg.is-error, .field-msg.is-error { color: var(--error); font-weight: 500; }
.url-msg.is-ok { color: var(--ok); font-weight: 500; }

/* Alternative: ready stories */
.or {
  margin: clamp(28px, 5vh, 44px) 0 18px;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -.01em;
}

.shelf {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(12px, 2.4vw, 24px);
}

.shelf { list-style: none; margin: 0; padding: 0; }
.story {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  border-radius: var(--r-lg);
  -webkit-tap-highlight-color: transparent;
}
.story:focus-visible { outline: none; }
.story:focus-visible .story-media { outline: 3px solid var(--violet); outline-offset: 4px; }
.story:active .story-media { transform: scale(.98); }

.story-media {
  position: relative;
  display: block;
  border-radius: var(--r-lg);
}
.story-media::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(29, 24, 56, .08);
  pointer-events: none;
  transition: box-shadow .18s var(--ease);
}
.story img {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: var(--r-lg);
  background: var(--line);
  box-shadow: 0 0 0 0 transparent, 0 14px 30px -20px rgba(29, 24, 56, .6);
  transition: box-shadow .2s var(--ease), filter .2s var(--ease);
}
.story-media { transition: transform .25s var(--ease); }
.story:hover .story-media { transform: translateY(-4px); }
.story:hover img { box-shadow: 0 22px 36px -20px rgba(29, 24, 56, .6); }

.story-text { display: grid; gap: 2px; padding: 12px 0 0; }
.story-game { font-size: .875rem; color: var(--muted); }
.story-title { font-size: 1.125rem; font-weight: 650; line-height: 1.25; }

.field-msg:empty, .grammar-msg:empty { min-height: 0; margin: 0; }

/* Level */
.step {
  margin: clamp(32px, 5vh, 48px) 0 0;
  padding: 0;
  border: 0;
  min-width: 0;
}
.step-legend { display: block; width: 100%; padding: 0; margin: 0; }
.step-title {
  margin: 0 0 18px;
  text-align: center;
  font-size: clamp(1.375rem, 1.1rem + 1vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -.015em;
}

.levels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  max-width: 720px;
  margin: 0 auto;
}
.level {
  position: relative;
  display: grid;
  gap: 2px;
  align-content: center;
  min-height: 88px;
  padding: 14px 18px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--r-md);
  cursor: pointer;
  text-align: center;
  transition: border-color .15s var(--ease), background-color .15s var(--ease), color .15s var(--ease);
}
.level:hover { border-color: #b9afe8; }
.level input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.level-name { font-weight: 650; font-size: 1.125rem; }
.level-note { font-size: .875rem; color: #57527a; }
.level:has(input:checked) {
  background: var(--violet);
  border-color: var(--violet);
  color: #fff;
}
.level:has(input:checked) .level-note { color: rgba(255, 255, 255, .82); }
.level:has(input:focus-visible) { outline: 3px solid var(--violet); outline-offset: 3px; }
.level.is-checked { background: var(--violet); border-color: var(--violet); color: #fff; }
.level.is-checked .level-note { color: rgba(255, 255, 255, .82); }

/* Grammar */
.grammar { max-width: 820px; margin: 8px auto 0; }
.grammar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 12px;
  text-align: center;
}
.grammar-auto { margin: 0; color: var(--muted); }
.grammar-auto strong { color: var(--ink); font-weight: 600; }
.grammar-toggle {
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--violet);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
}
.grammar-toggle:hover { background: var(--violet-soft); text-decoration: none; }

.grammar-panel { margin-top: 10px; }
.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.chip {
  min-height: 44px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 2px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface);
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s var(--ease), background-color .15s var(--ease);
}
.chip:hover { border-color: #b9afe8; }
.chips.is-auto .chip[data-topic]:not([data-topic="auto"]) { background: var(--violet-soft); border-color: transparent; color: var(--violet-deep); }
.chip[aria-pressed="true"] {
  border-color: var(--violet);
  background: var(--violet-soft);
  color: var(--violet-deep);
  font-weight: 600;
}
.chip[aria-pressed="true"]::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--violet);
}
.chips-empty { margin: 0; text-align: center; color: var(--muted); }
.grammar-msg { color: var(--muted); }

/* Final action */
.finish { margin-top: clamp(28px, 5vh, 48px); display: flex; justify-content: center; }
.cta {
  min-height: 64px;
  padding: 0 40px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--ink);
  color: #fff;
  font-weight: 650;
  font-size: 1.1875rem;
  cursor: pointer;
  box-shadow: 0 16px 30px -18px rgba(29, 24, 56, .8);
  transition: background-color .15s var(--ease), transform .15s var(--ease);
}
.cta:hover { background: var(--violet); }
.cta:active { transform: scale(.98); }

.finish-col { flex-direction: column; align-items: center; gap: 12px; }
.finish-row { flex-wrap: wrap; gap: 12px; }

/* ===================== Shared bits for inner screens ===================== */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  margin-bottom: clamp(12px, 3vh, 28px);
}
.bar-center { justify-content: center; }
.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 0 16px 0 10px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: inset 0 0 0 2px var(--line);
  font-weight: 600;
  cursor: pointer;
  transition: box-shadow .15s var(--ease), transform .15s var(--ease);
}
.back svg { width: 22px; height: 22px; }
.back:hover { box-shadow: inset 0 0 0 2px #b9afe8; }
.back:active { transform: scale(.97); }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  background: var(--violet-soft);
  color: var(--violet-deep);
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
}
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.tag-quiet { background: transparent; color: var(--muted); font-weight: 500; }
.tag-strong { background: var(--ink); color: #fff; }

.view-title {
  margin: 0 auto;
  text-align: center;
  font-weight: 750;
  font-size: clamp(1.875rem, 1.3rem + 2.4vw, 2.75rem);
  line-height: 1.08;
  letter-spacing: -.025em;
  text-wrap: balance;
}

.ghost {
  min-height: 56px;
  padding: 0 28px;
  border: 2px solid var(--ink);
  border-radius: var(--r-pill);
  background: transparent;
  font-weight: 600;
  font-size: 1.0625rem;
  cursor: pointer;
  transition: background-color .15s var(--ease), color .15s var(--ease), transform .15s var(--ease);
}
.ghost:hover { background: var(--ink); color: #fff; }
.ghost:active { transform: scale(.97); }

button:disabled { cursor: not-allowed; opacity: .5; transform: none !important; }
.item:has(input:disabled) { cursor: not-allowed; opacity: .7; }
.item:has(input:disabled):hover { transform: none; }
.item input:disabled { cursor: not-allowed; }
.result-video { display: block; width: min(720px, 100%); margin: 24px auto; border-radius: var(--r-md); background: var(--ink); }
#download { display: inline-flex; align-items: center; text-decoration: none; margin-top: 18px; }

/* ===================== Catalogue ===================== */
.games {
  display: flex;
  justify-content: center;
  gap: 6px;
  width: fit-content;
  max-width: 100%;
  margin: 22px auto 0;
  padding: 6px;
  background: var(--surface);
  border-radius: var(--r-pill);
  box-shadow: inset 0 0 0 2px var(--line);
}
.game {
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.game:hover { background: var(--violet-soft); }
.game[aria-pressed="true"] { background: var(--violet); color: #fff; }

.items {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(14px, 2.4vw, 24px);
  margin: clamp(24px, 4vh, 40px) 0 0;
  padding: 0;
  border: 0;
  min-width: 0;
}
.item {
  position: relative;
  display: grid;
  align-content: start;
  padding: 10px 10px 16px;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: inset 0 0 0 2px var(--line), 0 14px 30px -24px rgba(29, 24, 56, .55);
  cursor: pointer;
  transition: box-shadow .18s var(--ease), transform .25s var(--ease);
}
.item:hover { transform: translateY(-3px); box-shadow: inset 0 0 0 2px #b9afe8, 0 22px 36px -24px rgba(29, 24, 56, .6); }
.item input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.item-media { display: block; border-radius: 18px; overflow: hidden; background: var(--line); }
.item-media img { width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; transition: filter .2s var(--ease); }
.item-text { display: grid; gap: 2px; padding: 12px 6px 0; }
.item-title { font-weight: 650; font-size: 1.125rem; line-height: 1.25; }
.item-detail { font-size: .875rem; color: var(--muted); }
.item-check {
  position: absolute;
  top: 18px; right: 18px;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--violet);
  color: #fff;
  box-shadow: 0 0 0 3px #fff;
  opacity: 0;
  transform: scale(.6);
  transition: opacity .18s var(--ease), transform .25s var(--ease);
}
.item-check svg { width: 20px; height: 20px; }
.item:has(input:checked) { box-shadow: inset 0 0 0 3px var(--violet), 0 22px 36px -22px rgba(75, 47, 224, .6); }
.item:has(input:checked) .item-title { color: var(--violet); }
.item input:checked ~ .item-check { opacity: 1; transform: scale(1); }
.item:has(input:focus-visible) { outline: 3px solid var(--violet); outline-offset: 4px; }
.items.has-choice .item:not(:has(input:checked)) img { filter: saturate(.6) brightness(.97); }
.items.has-choice .item:hover img { filter: none; }

/* ===================== Configure: source card ===================== */
.src {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  max-width: 720px;
  margin: 0 auto;
  padding: 10px 14px 10px 10px;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: inset 0 0 0 2px var(--line), 0 18px 40px -26px rgba(75, 47, 224, .5);
}
.src-cover { border-radius: 16px; overflow: hidden; }
.src-cover .cover-provider { display: none; }   /* provider already named in the card text */
.src-body { min-width: 0; }
.src-kicker { margin: 0; font-size: .8125rem; font-weight: 600; color: var(--violet); }
.src-title { margin: 2px 0 0; font-weight: 700; font-size: 1.1875rem; line-height: 1.25; }
.src-meta { margin: 2px 0 0; font-size: .875rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src-meta.is-url { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .8125rem; }
.src-edit {
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--violet-soft);
  color: var(--violet-deep);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .15s var(--ease), transform .15s var(--ease);
}
.src-edit:hover { background: #d8d0ff; }
.src-edit:active { transform: scale(.97); }

/* Covers: catalogue art, or a neutral link cover (never unrelated game art) */
[data-cover] { position: relative; aspect-ratio: 16 / 9; background: var(--violet-soft); }
[data-cover] img { width: 100%; height: 100%; object-fit: cover; }
[data-cover].is-link {
  display: grid;
  place-items: center;
  color: var(--violet);
  background:
    radial-gradient(120% 90% at 20% 0%, #fff 0%, transparent 60%),
    repeating-linear-gradient(135deg, rgba(75, 47, 224, .06) 0 10px, transparent 10px 20px),
    var(--violet-soft);
}
[data-cover].is-link svg { width: 30%; max-width: 64px; height: auto; padding: 4%; border-radius: 50%; background: #fff; box-shadow: 0 8px 20px -10px rgba(75, 47, 224, .6); box-sizing: content-box; }
.cover-provider {
  position: absolute;
  left: 8px; bottom: 6px;
  font-size: .6875rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--violet-deep);
}

/* ===================== Waiting ===================== */
.view-wait { text-align: center; }
.stage { max-width: 560px; margin: 0 auto; padding: 0 8px; }
.stage-frame {
  position: relative;
  border-radius: 28px;
  padding: 10px;
  background: var(--ink);
  box-shadow: 0 30px 60px -30px rgba(29, 24, 56, .8);
  isolation: isolate;
}
.stage-cover { border-radius: 20px; overflow: hidden; }
.stage-cover.is-art img { filter: saturate(.85); }
.stage-sheen {
  position: absolute;
  inset: 10px 10px 10px 10px;
  border-radius: 20px;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, .35) 48%, transparent 66%);
  background-size: 250% 100%;
  background-position: 120% 0;
  mix-blend-mode: soft-light;
}
.stage-strip {
  position: absolute;
  left: 50%; bottom: -18px;
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  transform: translateX(-50%);
  background: var(--surface);
  border-radius: var(--r-pill);
  box-shadow: 0 10px 24px -14px rgba(29, 24, 56, .6);
}
.stage-strip i { display: block; width: 22px; height: 14px; border-radius: 4px; background: var(--line); transition: background-color .4s var(--ease); }
.view-wait[data-stage="0"] .stage-strip i:nth-child(-n+1),
.view-wait[data-stage="1"] .stage-strip i:nth-child(-n+2),
.view-wait[data-stage="2"] .stage-strip i { background: var(--violet); }

.bubble {
  position: absolute;
  z-index: 2;
  padding: 6px 12px;
  border-radius: 14px 14px 14px 4px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  font-size: .9375rem;
  box-shadow: 0 10px 22px -12px rgba(29, 24, 56, .7);
  opacity: 0;
  transform: translateY(8px) scale(.9);
  transition: opacity .5s var(--ease), transform .5s var(--ease);
}
.b1 { left: 22px; top: 16%; }
.b2 { right: 22px; top: 8%; background: var(--sun); border-radius: 14px 14px 4px 14px; }
.b3 { right: 4%; bottom: 22%; border-radius: 14px 14px 4px 14px; }
.b4 { left: 6%; bottom: 14%; background: var(--violet); color: #fff; }
.view-wait[data-stage="1"] .bubble, .view-wait[data-stage="2"] .bubble { opacity: 1; transform: none; }
.view-wait[data-stage="1"] .b3, .view-wait[data-stage="1"] .b4 { opacity: 0; transform: translateY(8px) scale(.9); }

.wait-title { margin-top: 44px; font-size: clamp(1.625rem, 1.2rem + 1.8vw, 2.25rem); }
.wait-src { margin: 8px 0 0; color: var(--muted); }

.steps {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 560px;
  margin: 28px auto 0;
  padding: 0;
  counter-reset: s;
}
.steps li {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 8px;
  font-size: .9375rem;
  line-height: 1.3;
  color: var(--muted);
}
.steps li::before {
  content: "";
  position: absolute;
  top: 9px; right: 50%;
  width: 100%; height: 2px;
  background: var(--line);
  z-index: -1;
}
.steps li:first-child::before { display: none; }
.steps li.is-done::before, .steps li.is-now::before { background: var(--violet); }
.steps .dot {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: inset 0 0 0 2px var(--line);
  transition: background-color .3s var(--ease), box-shadow .3s var(--ease);
}
.steps li.is-now { color: var(--ink); font-weight: 600; }
.steps li.is-now .dot { background: var(--surface); box-shadow: inset 0 0 0 6px var(--violet); }
.steps li.is-done { color: var(--ink); }
.steps li.is-done .dot { background: var(--violet); box-shadow: inset 0 0 0 2px var(--violet); }

.meter { max-width: 420px; margin: 28px auto 0; }
.meter-head { display: flex; justify-content: space-between; font-size: .8125rem; color: var(--muted); margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.meter-track { height: 8px; border-radius: var(--r-pill); background: var(--line); overflow: hidden; }
.meter-fill { height: 100%; background: var(--violet); border-radius: inherit; transform-origin: 0 50%; transform: scaleX(0); transition: transform .2s linear; }
.view-wait.is-paused .meter-fill { background: var(--muted); }

/* ===================== Result / error ===================== */
.view-result, .view-error { text-align: center; }
.res-cover {
  width: min(320px, 80%);
  margin: 4px auto 28px;
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: 0 0 0 4px var(--paper), 0 0 0 8px var(--violet), 0 22px 40px -22px rgba(75, 47, 224, .7);
}
.res-note { max-width: 30rem; margin: 12px auto 0; color: var(--muted); text-wrap: balance; }
.sum { max-width: 480px; margin: 24px auto 0; display: grid; gap: 8px; text-align: left; }
.sum > div { display: flex; justify-content: space-between; gap: 16px; padding: 14px 18px; background: var(--surface); border-radius: var(--r-md); }
.sum dt { color: var(--muted); flex: none; }
.sum dd { margin: 0; font-weight: 600; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.err-mark { width: 72px; height: 72px; margin: 8px auto 20px; display: grid; place-items: center; border-radius: 50%; background: #fde7e4; color: var(--error); }
.err-mark svg { width: 40px; height: 40px; }

/* ===================== Motion ===================== */
@media (prefers-reduced-motion: no-preference) {
  body[data-view="home"] .title, body[data-view="home"] .url,
  body[data-view="home"] .or, body[data-view="home"] .shelf { animation: rise .6s var(--ease) both; }
  body[data-view="home"] .url { animation-delay: .06s; }
  body[data-view="home"] .or { animation-delay: .12s; }
  body[data-view="home"] .shelf { animation-delay: .16s; }
  .view:not(.view-home) > * { animation: rise .4s var(--ease) both; }
  .item { animation: rise .45s var(--ease) both; animation-delay: calc(var(--i, 0) * 50ms); }
  @keyframes rise { from { opacity: 0; transform: translateY(12px); } }

  .view-wait .stage-sheen { animation: sheen 3.2s ease-in-out infinite; }
  .view-wait .stage-frame { animation: bob 5s ease-in-out infinite; }
  .view-wait .steps li.is-now .dot { animation: pulse 1.6s ease-in-out infinite; }
  .view-wait.is-paused * { animation-play-state: paused !important; }
  @keyframes sheen { 0% { background-position: 120% 0; } 60%, 100% { background-position: -40% 0; } }
  @keyframes bob { 50% { transform: translateY(-6px); } }
  @keyframes pulse { 50% { box-shadow: inset 0 0 0 6px var(--violet), 0 0 0 6px rgba(75, 47, 224, .15); } }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ===================== Small screens ===================== */
@media (max-width: 760px) {
  .items { grid-template-columns: 1fr; max-width: 480px; margin-inline: auto; }
  .item { grid-template-columns: 44% minmax(0, 1fr); align-items: center; gap: 12px; padding: 8px; }
  .item-text { padding: 0 34px 0 0; }
  .item-check { top: 50%; right: 12px; margin-top: -16px; width: 32px; height: 32px; }
}
@media (max-width: 620px) {
  .view { width: calc(100% - 32px); }
  .view-home { padding-top: 28px; }
  .top { padding-top: 12px; }
  .shelf {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: 40%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 16px;
    margin-inline: -16px;
    padding: 12px 16px 14px;
    scrollbar-width: none;
  }
  .shelf::-webkit-scrollbar { display: none; }
  .shelf li { scroll-snap-align: start; }

  .levels { grid-template-columns: 1fr; gap: 10px; }
  .level { min-height: 64px; text-align: left; padding: 10px 18px; }
  .cta { width: 100%; padding: 0 20px; font-size: 1.0625rem; }
  .finish-row .ghost, .finish-row .cta { width: 100%; }
  .finish-row { flex-direction: column-reverse; }

  .src { grid-template-columns: 112px minmax(0, 1fr); gap: 12px; padding: 8px; }
  .src-edit { grid-column: 1 / -1; width: 100%; }
  .src-title { font-size: 1.0625rem; }

  .games { width: 100%; }
  .game { flex: 1; padding: 0 8px; font-size: .9375rem; }

  .bubble { font-size: .8125rem; padding: 4px 10px; }
  .b1 { left: 16px; } .b2 { right: 16px; }
  .steps li { font-size: .8125rem; }
  .wait-title { margin-top: 40px; }
}
@media (max-width: 460px) {
  .url-field { flex-wrap: wrap; border-radius: 24px; padding: 8px; }
  .url-icon { margin-left: 12px; }
  .url-field input { height: 52px; font-size: 1rem; }
  .url-go { width: 100%; height: 54px; }
}
/* Account uses the approved violet, Rubik and centered column. */
.top { justify-content: space-between; align-items: center; width: min(1120px, 100%); margin: auto; gap: 12px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.top-actions button { min-height: 44px; border: 0; border-radius: var(--r-pill); padding: 0 16px; background: transparent; color: var(--violet-deep); font-weight: 600; cursor: pointer; }
.top-actions button:hover { background: var(--violet-soft); }
#auth-register, #auth-account { background: var(--violet) !important; color: white !important; }
.view-auth { text-align: center; max-width: 560px; }
.auth-form { display: grid; gap: 8px; text-align: left; margin: 24px auto 8px; }
.auth-form label { font-weight: 600; margin-top: 10px; }
.auth-form input { width: 100%; min-height: 52px; border: 2px solid var(--line); border-radius: 14px; background: white; padding: 0 16px; }
.auth-form .cta { margin-top: 14px; }
.account-refresh { display: flex; justify-content: flex-end; max-width: 720px; margin: 18px auto 0; }
.account-jobs { max-width: 720px; margin: 14px auto 0; display: grid; gap: 16px; }
.account-job { background: var(--surface); border: 2px solid var(--line); border-radius: var(--r-lg); padding: 20px; }
.account-job h2 { margin: 0; font-size: 1.25rem; overflow-wrap: anywhere; }
.account-job p { margin: 4px 0 16px; color: var(--muted); }
.account-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.account-actions .ghost { display: inline-flex; align-items: center; text-decoration: none; min-height: 44px; padding: 0 16px; font-size: .9375rem; }
#result-upsell { margin: 24px auto 0; gap: 8px; }
#result-upsell p { margin: 0; font-weight: 650; }
@media (max-width: 620px) {
  .top { flex-wrap: wrap; justify-content: center; padding-inline: 16px; }
  .top-actions { justify-content: center; width: 100%; }
  .top-actions button { padding-inline: 12px; font-size: .875rem; }
  .account-actions .ghost { flex: 1 1 auto; justify-content: center; }
}
@media (max-width: 360px) { .top-actions { flex-wrap: wrap; } }

