:root {
  --stage: #14110d;
  --board: #1c1813;
  --panel: #262019;
  --panel-raised: #302820;
  --text: #f5eee1;
  --muted: #b5a78f;
  --faint: #847765;
  --brass: #e9b04a;
  --brass-soft: #f8d790;
  --brass-dark: #8b5b16;
  --relay: #8fd0c6;
  --relay-dark: #285f5a;
  --ticket: #f8f3e7;
  --ticket-ink: #241f16;
  --ticket-muted: #695f50;
  --line: rgba(236, 205, 148, 0.18);
  --line-strong: rgba(236, 205, 148, 0.34);
  --correct: #63c49e;
  --correct-bg: #153b31;
  --incorrect: #ff8d83;
  --incorrect-bg: #4a211e;
  --focus: #ffd579;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --shadow: 0 28px 70px -38px rgba(0, 0, 0, 0.9);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--stage);
  scroll-behavior: smooth;
  scroll-padding-bottom: calc(132px + var(--safe-bottom));
}

body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(700px 420px at 78% -120px, rgba(233, 176, 74, 0.11), transparent 68%),
    radial-gradient(620px 440px at 5% 65%, rgba(143, 208, 198, 0.07), transparent 70%),
    linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    var(--stage);
  background-size: auto, auto, 100% 42px, auto;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "Noto Sans Arabic", "Noto Naskh Arabic", "Geeza Pro", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

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

button {
  color: inherit;
  touch-action: manipulation;
}

[lang="en"],
[dir="ltr"] {
  unicode-bidi: isolate;
}

button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

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

.skip-link {
  position: fixed;
  inset-inline-start: 14px;
  top: -80px;
  z-index: 100;
  border-radius: 10px;
  background: var(--focus);
  color: #241a0c;
  padding: 11px 16px;
  font-weight: 900;
  text-decoration: none;
  transition: top 160ms ease;
}

.skip-link:focus {
  top: 12px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--line);
  background: rgba(20, 17, 13, 0.92);
}

.site-header__inner {
  width: min(1120px, calc(100% - 28px));
  min-height: 62px;
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand,
.return-link {
  min-width: 0;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 820;
  text-decoration: none;
}

.brand__mark {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #388fe9, #245fd5);
  box-shadow: 0 8px 22px -13px rgba(79, 157, 239, 0.9);
  color: white;
  direction: ltr;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.return-link {
  max-width: 54%;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  padding-inline: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.return-link span {
  color: var(--relay);
  font-size: 18px;
}

.intro {
  width: min(1120px, calc(100% - 28px));
  min-height: calc(100dvh - 62px);
  margin-inline: auto;
  padding-block: 34px calc(46px + var(--safe-bottom));
  display: grid;
  align-items: center;
  gap: clamp(28px, 5vw, 72px);
}

.intro__copy,
.intro__scene {
  min-width: 0;
}

.eyebrow,
.panel-kicker {
  color: var(--brass-soft);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.045em;
}

.eyebrow {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(233, 176, 74, 0.25);
  border-radius: 999px;
  background: rgba(233, 176, 74, 0.07);
  padding: 5px 12px;
}

.intro h1 {
  max-width: 720px;
  margin: 16px 0 0;
  font-family: Georgia, "Times New Roman", "Noto Naskh Arabic", serif;
  font-size: clamp(34px, 7.7vw, 64px);
  font-weight: 560;
  line-height: 1.22;
  text-wrap: balance;
}

.intro__lead {
  max-width: 660px;
  margin: 13px 0 0;
  color: var(--muted);
  font-size: clamp(14px, 3.5vw, 17px);
  line-height: 1.9;
}

.intro__meta {
  margin-top: 21px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.intro__meta span {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  padding-inline: 13px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 750;
}

.intro__meta b {
  color: var(--relay);
  font-size: 13px;
}

.source-note {
  max-width: 650px;
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1px solid rgba(143, 208, 198, 0.2);
  border-radius: 17px;
  background: rgba(143, 208, 198, 0.055);
  padding: 12px 14px;
}

.source-note__lamp {
  width: 31px;
  height: 31px;
  flex: 0 0 31px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(143, 208, 198, 0.4);
  border-radius: 50%;
  background: var(--relay-dark);
  box-shadow: inset 0 0 0 4px rgba(0, 0, 0, 0.14), 0 0 20px rgba(143, 208, 198, 0.14);
  color: var(--relay);
  font-weight: 900;
}

.source-note b,
.source-note small {
  display: block;
}

.source-note b {
  color: var(--relay);
  font-size: 12px;
}

.source-note small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.6;
}

.intro__actions,
.result-actions {
  margin-top: 21px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
}

.primary-button,
.secondary-button,
.text-button,
.icon-button,
.reveal-button {
  min-height: 44px;
  border: 0;
  border-radius: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 850;
  text-decoration: none;
}

.primary-button {
  min-height: 50px;
  background: linear-gradient(180deg, var(--brass-soft), var(--brass));
  box-shadow: 0 14px 26px -17px rgba(233, 176, 74, 0.8), inset 0 1px rgba(255, 255, 255, 0.65);
  color: #281b0a;
  padding: 12px 19px;
}

.primary-button:active {
  transform: translateY(1px);
}

.primary-button:disabled {
  cursor: default;
  filter: saturate(0.45);
  opacity: 0.48;
}

.secondary-button {
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  padding: 10px 16px;
}

.text-button {
  background: transparent;
  color: var(--muted);
  padding: 8px 11px;
}

.text-button:hover,
.return-link:hover {
  color: var(--text);
}

.intro__scene {
  display: grid;
  place-items: center;
}

.exchange-board {
  width: min(100%, 460px);
  position: relative;
  border: 1px solid var(--line-strong);
  border-radius: 25px;
  background:
    linear-gradient(90deg, transparent 49.6%, rgba(233, 176, 74, 0.08) 50%, transparent 50.4%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.04), transparent 35%),
    var(--board);
  box-shadow: var(--shadow), inset 0 0 0 5px rgba(0, 0, 0, 0.18);
  padding: 27px 24px 22px;
}

.exchange-board::before,
.exchange-board::after {
  content: "";
  width: 8px;
  height: 8px;
  position: absolute;
  top: 12px;
  border-radius: 50%;
  background: #66533b;
  box-shadow: inset 0 1px 2px #0c0a07;
}

.exchange-board::before { inset-inline-start: 13px; }
.exchange-board::after { inset-inline-end: 13px; }

.exchange-ticket {
  width: min(82%, 300px);
  min-height: 116px;
  position: relative;
  border-radius: 14px 14px 20px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background:
    repeating-linear-gradient(0deg, transparent 0 12px, rgba(51, 40, 25, 0.035) 12px 13px),
    var(--ticket);
  box-shadow: 0 18px 34px -23px #000, inset 0 0 0 1px rgba(59, 43, 20, 0.18);
  color: var(--ticket-ink);
  padding: 18px 22px;
}

.exchange-ticket--condition {
  margin-inline-end: auto;
  border-inline-start: 7px solid var(--brass);
}

.exchange-ticket--result {
  margin-inline-start: auto;
  border-inline-end: 7px solid var(--relay);
}

.exchange-ticket small {
  color: var(--ticket-muted);
  font-size: 10px;
  font-weight: 850;
}

.exchange-ticket b {
  margin-top: 4px;
  direction: ltr;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 29px;
  letter-spacing: 0.08em;
}

.jack {
  width: 18px;
  height: 18px;
  position: absolute;
  inset-inline-start: 18px;
  inset-inline-end: auto;
  bottom: 16px;
  border: 4px solid var(--ticket-ink);
  border-radius: 50%;
  background: var(--brass);
  box-shadow: 0 0 0 3px rgba(36, 31, 22, 0.16);
}

.exchange-ticket--result .jack {
  background: var(--relay);
}

.exchange-rail {
  height: 86px;
  display: grid;
  grid-template-columns: 1fr 42px 1fr;
  align-items: center;
  gap: 8px;
  padding-inline: 11%;
}

.exchange-rail i {
  height: 4px;
  background: linear-gradient(90deg, var(--brass-dark), var(--brass));
  box-shadow: 0 2px #080604;
}

.exchange-rail i:last-child {
  background: linear-gradient(90deg, var(--relay), var(--relay-dark));
}

.exchange-gate {
  width: 42px;
  height: 42px;
  border: 2px solid var(--line-strong);
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--panel-raised);
  box-shadow: inset 0 0 0 4px var(--board);
  color: var(--brass-soft);
  font-family: Georgia, serif;
  font-size: 27px;
}

.exchange-settings {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.exchange-settings span {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 750;
}

.dial,
.toggle,
.gate-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border: 2px solid var(--brass);
  border-radius: 50%;
  display: inline-block;
  background: radial-gradient(circle, var(--brass) 0 3px, transparent 4px);
}

.toggle {
  width: 26px;
  flex-basis: 26px;
  border-radius: 999px;
  background: radial-gradient(circle at 72% 50%, var(--relay) 0 5px, transparent 6px);
}

.gate-icon {
  display: grid;
  place-items: center;
  border-radius: 5px;
  color: var(--brass-soft);
  font-family: Georgia, serif;
  font-style: normal;
}

.lesson {
  width: min(680px, calc(100% - 24px));
  margin-inline: auto;
  padding-block: 24px calc(104px + var(--safe-bottom));
}

.lesson__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.lesson__heading {
  min-width: 0;
}

.lesson__heading > span {
  color: var(--relay);
  font-size: 11px;
  font-weight: 850;
}

.lesson__heading h2 {
  margin: 5px 0 0;
  font-family: Georgia, "Times New Roman", "Noto Naskh Arabic", serif;
  font-size: clamp(26px, 6vw, 42px);
  font-weight: 560;
  line-height: 1.32;
}

.lesson__tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  width: 44px;
  flex: 0 0 44px;
  border: 1px solid var(--line);
  background: var(--board);
  color: var(--brass-soft);
  font-family: Georgia, serif;
}

.save-exit {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border-radius: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-decoration: none;
}

.mission-progress {
  margin: 24px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  list-style: none;
}

.mission-progress li {
  min-width: 0;
  min-height: 52px;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  background: var(--board);
  padding: 7px;
  color: var(--muted);
}

.mission-progress li::after {
  content: "";
  height: 2px;
  position: absolute;
  inset-inline: 9px;
  bottom: -5px;
  border-radius: 2px;
  background: transparent;
}

.mission-progress li[data-status="current"] {
  border-color: rgba(233, 176, 74, 0.45);
  color: var(--text);
}

.mission-progress li[data-status="current"]::after {
  background: var(--brass);
}

.mission-progress li[data-status="done"] {
  color: var(--relay);
}

.mission-progress li span {
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.055);
  font-size: 11px;
  font-weight: 900;
}

.mission-progress li[data-status="current"] span {
  background: var(--brass);
  color: #2a1d0b;
}

.mission-progress li[data-status="done"] span {
  background: var(--relay-dark);
}

.mission-progress small {
  min-width: 0;
  font-size: 9px;
  font-weight: 750;
  line-height: 1.45;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mission-model {
  margin-top: 19px;
  border: 1px solid var(--line);
  border-radius: 18px;
  display: grid;
  gap: 14px;
  background:
    linear-gradient(135deg, rgba(233, 176, 74, 0.045), transparent 45%),
    var(--board);
  padding: clamp(16px, 4vw, 24px);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.025);
}

.mission-model.is-collapsed {
  display: block;
  padding: 0;
  overflow: hidden;
}

.model-drawer summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  color: var(--brass-soft);
  cursor: pointer;
  font-size: 11px;
  font-weight: 850;
  list-style: none;
}

.model-drawer summary::-webkit-details-marker {
  display: none;
}

.model-drawer summary i {
  flex: 0 0 auto;
  color: var(--relay);
  font-size: 18px;
  font-style: normal;
  transition: transform 160ms ease;
}

.model-drawer[open] summary i {
  transform: rotate(180deg);
}

.model-drawer__body {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 13px;
  padding: 14px;
}

.model-copy p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.85;
}

.formula-strip {
  min-width: 0;
  border-inline-start: 4px solid var(--brass);
  border-radius: 10px;
  background: rgba(233, 176, 74, 0.08);
  padding: 11px 13px;
}

.formula-strip small,
.formula-strip b {
  display: block;
}

.formula-strip small {
  color: var(--brass-soft);
  font-size: 9.5px;
  font-weight: 850;
}

.formula-strip b {
  margin-top: 5px;
  overflow-wrap: anywhere;
  color: var(--text);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: clamp(11px, 2.8vw, 13px);
  font-weight: 650;
  line-height: 1.65;
}

.worked-grid {
  display: grid;
  gap: 9px;
}

.worked-ticket {
  min-width: 0;
  position: relative;
  border-radius: 12px;
  background: var(--ticket);
  box-shadow: 0 13px 25px -23px #000;
  color: var(--ticket-ink);
  padding: 13px 15px;
}

.worked-ticket::before {
  content: "";
  width: 5px;
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  border-radius: 12px 0 0 12px;
  background: var(--relay);
}

.worked-ticket span {
  color: var(--ticket-muted);
  font-size: 9px;
  font-weight: 850;
}

.worked-ticket p {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  text-align: left;
}

.task-area {
  margin-top: 14px;
  transition: padding-bottom 160ms ease;
}

.task-area.has-ready-dock {
  padding-bottom: calc(76px + var(--safe-bottom));
}

.task-card {
  border: 1px solid var(--line-strong);
  border-radius: 21px;
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.035), transparent 34%),
    var(--panel);
  box-shadow: var(--shadow), inset 0 0 0 5px rgba(0, 0, 0, 0.08);
  padding: clamp(16px, 4vw, 25px);
}

.task-card[data-assisted="true"] {
  border-color: rgba(233, 176, 74, 0.72);
  box-shadow: var(--shadow), inset 0 0 0 2px rgba(233, 176, 74, 0.22);
}

.task-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.task-card__header > div {
  min-width: 0;
}

.task-card h3 {
  margin: 7px 0 0;
  font-size: clamp(18px, 4.8vw, 25px);
  line-height: 1.55;
}

.task-index {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  padding: 6px 10px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 10px;
}

.signal-sentence {
  min-width: 0;
  margin-top: 17px;
  border: 1px solid rgba(233, 176, 74, 0.25);
  border-radius: 14px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: stretch;
  overflow: hidden;
  background: var(--ticket);
  color: var(--ticket-ink);
  direction: ltr;
}

.signal-sentence > span {
  display: grid;
  place-items: center;
  background: var(--brass);
  color: #2b1d08;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 10px;
  font-weight: 950;
  letter-spacing: 0.08em;
}

.signal-sentence p {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  padding: 14px 15px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: clamp(15px, 4vw, 19px);
  line-height: 1.55;
  text-align: left;
}

.assembled-preview {
  margin-top: 12px;
  border: 1px solid rgba(143, 208, 198, 0.18);
  border-radius: 13px;
  background: rgba(143, 208, 198, 0.055);
  padding: 11px 13px;
}

.assembled-preview > span {
  color: var(--relay);
  font-size: 9.5px;
  font-weight: 850;
}

.assembled-preview p {
  margin: 6px 0 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 12px;
  line-height: 1.65;
  text-align: left;
}

.assembled-preview mark {
  border-radius: 3px;
  background: rgba(233, 176, 74, 0.2);
  color: var(--brass-soft);
  padding-inline: 3px;
}

.channel-stack {
  margin-top: 17px;
}

.control-channel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--board);
  padding: 13px;
}

.control-channel__head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-channel h4 {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.channel-lamp {
  width: 11px;
  height: 11px;
  flex: 0 0 11px;
  border: 2px solid var(--brass-dark);
  border-radius: 50%;
  background: var(--brass);
  box-shadow: 0 0 9px rgba(233, 176, 74, 0.35);
}

.control-channel[data-channel="result"] .channel-lamp {
  border-color: var(--relay-dark);
  background: var(--relay);
  box-shadow: 0 0 9px rgba(143, 208, 198, 0.35);
}

.control-channel[data-channel="neutral"] .channel-lamp {
  border-color: #706553;
  background: var(--muted);
  box-shadow: none;
}

.option-bank {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.option-ticket {
  min-width: 0;
  min-height: 48px;
  border: 1px solid rgba(87, 73, 52, 0.23);
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--ticket);
  box-shadow: 0 8px 18px -17px #000;
  color: var(--ticket-ink);
  padding: 9px 11px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.4;
  text-align: start;
  scroll-margin-block: 92px;
}

.option-ticket span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.option-ticket i {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  border: 2px solid #b7aa96;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #18382f;
  font-size: 10px;
  font-style: normal;
}

.option-ticket.is-selected {
  border-color: var(--relay);
  box-shadow: inset 0 0 0 2px var(--relay), 0 10px 22px -18px rgba(143, 208, 198, 0.8);
  background: #e6f4ef;
}

.control-channel[data-channel="condition"] .option-ticket.is-selected {
  border-color: var(--brass);
  background: #fff1cf;
  box-shadow: inset 0 0 0 2px var(--brass), 0 10px 22px -18px rgba(233, 176, 74, 0.8);
}

.control-channel[data-channel="condition"] .option-ticket.is-selected i {
  border-color: var(--brass-dark);
  background: var(--brass);
}

.option-ticket.is-selected i {
  border-color: var(--relay-dark);
  background: var(--relay);
}

.option-ticket:disabled {
  cursor: default;
  opacity: 0.9;
}

.channel-wire {
  height: 31px;
  display: grid;
  place-items: center;
}

.channel-wire i {
  width: 4px;
  height: 31px;
  background: linear-gradient(var(--brass), var(--relay));
  box-shadow: 2px 0 #080604;
}

.feedback-panel {
  margin-top: 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
}

.feedback-panel[data-tone="correct"] {
  border-color: rgba(99, 196, 158, 0.32);
  background: var(--correct-bg);
}

.feedback-panel[data-tone="incorrect"] {
  border-color: rgba(255, 141, 131, 0.34);
  background: var(--incorrect-bg);
}

.feedback-panel[data-tone="neutral"] {
  border-color: rgba(143, 208, 198, 0.27);
  background: rgba(143, 208, 198, 0.07);
}

.feedback-panel__icon {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--relay);
  font-weight: 950;
}

.feedback-panel[data-tone="correct"] .feedback-panel__icon { color: var(--correct); }
.feedback-panel[data-tone="incorrect"] .feedback-panel__icon { color: var(--incorrect); }

.feedback-panel b {
  font-size: 12px;
}

.feedback-panel p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.reveal-button {
  margin-top: 12px;
  border: 1px dashed var(--line-strong);
  background: transparent;
  color: var(--brass-soft);
  padding: 9px 13px;
}

.action-dock {
  position: static;
  z-index: 40;
  margin-top: 14px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.35fr);
  gap: 9px;
  background: var(--board);
  box-shadow: 0 25px 50px -24px #000;
  padding: 9px 9px calc(9px + var(--safe-bottom));
}

.action-dock.is-ready {
  position: sticky;
  bottom: 10px;
}

.action-dock .secondary-button,
.action-dock .primary-button {
  width: 100%;
}

.action-dock button:disabled {
  cursor: default;
  opacity: 0.38;
}

.result-board {
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 0, rgba(233, 176, 74, 0.12), transparent 38%),
    var(--panel);
  padding: clamp(24px, 6vw, 45px);
  text-align: center;
}

.result-seal {
  width: 122px;
  height: 122px;
  margin: 0 auto 18px;
  border: 2px solid var(--brass);
  border-radius: 50%;
  display: grid;
  place-content: center;
  background: radial-gradient(circle, rgba(233, 176, 74, 0.16), transparent 68%);
  box-shadow: 0 0 0 8px rgba(233, 176, 74, 0.05), inset 0 0 0 5px var(--panel);
  color: var(--brass-soft);
  font-family: Georgia, serif;
  font-size: 39px;
  line-height: 1;
}

.result-seal small {
  margin-top: 4px;
  color: var(--muted);
  font-family: ui-monospace, monospace;
  font-size: 12px;
}

.result-board h3 {
  margin: 8px auto 0;
  max-width: 620px;
  font-family: Georgia, "Times New Roman", "Noto Naskh Arabic", serif;
  font-size: clamp(24px, 6vw, 37px);
  line-height: 1.45;
}

.result-board > p {
  max-width: 570px;
  margin: 10px auto 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.85;
}

.result-legend {
  max-width: 470px;
  margin: 20px auto 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.result-legend span {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.result-legend i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.result-legend .is-correct { background: var(--correct); }
.result-legend .is-missed { background: var(--incorrect); }

.result-actions {
  justify-content: center;
}

.source-dialog {
  width: min(570px, calc(100% - 24px));
  max-height: min(760px, calc(100dvh - 28px));
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 35px 90px -30px #000;
  color: var(--text);
  padding: 0;
}

.source-dialog::backdrop {
  background: rgba(5, 4, 3, 0.76);
}

.source-dialog form {
  position: relative;
  padding: clamp(20px, 5vw, 31px);
}

.dialog-close {
  width: 44px;
  height: 44px;
  position: absolute;
  top: 12px;
  inset-inline-end: 12px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--board);
  color: var(--muted);
  cursor: pointer;
  font-size: 24px;
}

.source-dialog h2 {
  margin: 12px 0 0;
  padding-inline-end: 44px;
  font-family: Georgia, "Times New Roman", "Noto Naskh Arabic", serif;
  font-size: clamp(23px, 5.8vw, 32px);
  line-height: 1.45;
}

.source-dialog p {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.9;
}

.source-dialog__limit {
  border-inline-start: 4px solid var(--brass);
  border-radius: 9px;
  background: rgba(233, 176, 74, 0.07);
  padding: 10px 12px;
}

.noscript {
  width: min(720px, calc(100% - 28px));
  margin: 24px auto;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--panel);
  padding: 14px;
  color: var(--muted);
  text-align: center;
}

@media (min-width: 820px) {
  .intro {
    grid-template-columns: minmax(0, 1.12fr) minmax(330px, 0.88fr);
  }

  .mission-model {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.85fr);
  }

  .worked-grid {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .site-header__inner {
    width: min(100% - 20px, 1120px);
  }

  .brand > span:last-child {
    display: none;
  }

  .return-link {
    max-width: calc(100% - 52px);
  }

  .intro {
    width: min(100% - 24px, 1120px);
    padding-top: 24px;
  }

  .exchange-board {
    width: min(100%, 390px);
    padding: 20px 16px 16px;
  }

  .exchange-ticket {
    min-height: 84px;
    padding: 13px 17px;
  }

  .exchange-ticket b {
    font-size: 22px;
  }

  .exchange-rail {
    height: 58px;
  }

  .exchange-settings span {
    min-height: 42px;
    font-size: 8.5px;
  }

  .lesson {
    width: min(100% - 16px, 680px);
    padding-top: 17px;
  }

  .lesson__header {
    align-items: center;
  }

  .save-exit {
    width: 44px;
    height: 44px;
    min-height: 44px;
    flex: 0 0 44px;
    border: 1px solid var(--line);
    border-radius: 50%;
    display: grid;
    place-items: center;
    overflow: hidden;
    color: transparent;
    font-size: 0;
  }

  .save-exit::before {
    content: "→";
    display: grid;
    place-items: center;
    color: var(--relay);
    font-size: 19px;
  }

  .mission-progress li {
    min-height: 42px;
    grid-template-columns: 1fr;
    place-items: center;
    padding: 5px;
  }

  .mission-progress small {
    display: none;
  }

  .mission-model {
    padding: 14px;
  }

  .mission-model.is-collapsed {
    padding: 0;
  }

  .mission-model.is-brief {
    gap: 9px;
    padding: 12px;
  }

  .mission-model.is-brief .model-copy p {
    margin-top: 3px;
    line-height: 1.65;
  }

  .option-bank {
    grid-template-columns: 1fr;
  }

  .channel-wire,
  .channel-wire i {
    height: 18px;
  }

  .action-dock.is-ready {
    bottom: 0;
    grid-template-columns: 48px minmax(0, 1fr);
    border-radius: 18px 18px 0 0;
  }

  .action-dock.is-ready .secondary-button {
    width: 48px;
    min-width: 48px;
    padding: 0;
    font-size: 0;
  }

  .action-dock.is-ready .secondary-button span {
    font-size: 19px;
  }
}

@media (max-width: 370px) {
  .exchange-settings {
    grid-template-columns: 1fr;
  }

  .exchange-settings span {
    min-height: 36px;
  }

  .intro__actions,
  .result-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .intro__actions > *,
  .result-actions > * {
    width: 100%;
  }

  .task-card__header {
    display: grid;
  }

  .task-index {
    width: fit-content;
  }

  .result-legend {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (forced-colors: active) {
  .channel-lamp,
  .result-legend i,
  .source-note__lamp,
  .option-ticket i {
    forced-color-adjust: none;
  }
}
