:root {
  --memory-ink: #172033;
  --memory-muted: #657087;
  --memory-line: #d8deea;
  --memory-surface: #ffffff;
  --memory-page: #f4f6fb;
  --memory-accent: #4057d6;
  --memory-accent-dark: #3045b8;
  --memory-cool: #e8edf7;
  --memory-cool-dark: #39475f;
  --memory-correct: #147a70;
  --memory-wrong: #b24c36;
}

main.view-spatial-contrast.spatial-contrast-setup-mode > :not(#spatial-contrast-trainer-screen):not(.site-header),
main.view-spatial-contrast:not(.spatial-contrast-setup-mode) > :not(#spatial-contrast-trainer-screen):not(.site-header) {
  display: none !important;
}

#spatial-contrast-trainer-screen {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-height: calc(100vh - 76px);
  overflow-x: clip;
  color: var(--memory-ink);
}

#spatial-contrast-trainer-screen *,
#spatial-contrast-trainer-screen *::before,
#spatial-contrast-trainer-screen *::after {
  box-sizing: border-box;
}

#spatial-contrast-trainer-screen:not(.stage-results) button {
  font: inherit;
}

#spatial-contrast-trainer-screen button:focus-visible {
  outline: 3px solid #8da0ff;
  outline-offset: 3px;
}

.trainer-tile-spatial-contrast .spatial-contrast-card-art {
  position: relative;
  display: block;
  overflow: hidden;
  background: #10295a url("./attention-square-card.jpg") center / cover no-repeat;
}

.trainer-tile-spatial-contrast .spatial-contrast-card-art::before {
  content: none;
}

.trainer-tile-spatial-contrast .spatial-contrast-card-art::after {
  content: none;
}

.trainer-tile-spatial-contrast .spatial-tile-position {
  display: none;
}

.trainer-tile-spatial-contrast .tile-one {
  top: 30%;
  left: 31%;
}

.trainer-tile-spatial-contrast .tile-two {
  top: 30%;
  right: 31%;
}

.trainer-tile-spatial-contrast .tile-three {
  bottom: 28%;
  left: 31%;
}

.trainer-tile-spatial-contrast .tile-four {
  right: 31%;
  bottom: 28%;
}

.trainer-tile-spatial-contrast .spatial-tile-position.is-active {
  box-shadow: 0 7px 14px rgba(31, 43, 70, .2);
}

.trainer-tile-spatial-contrast .spatial-tile-position.color-0 {
  border-color: #ffbd38;
  background: linear-gradient(145deg, #fff4c0, #ffbd38);
}

.trainer-tile-spatial-contrast .spatial-tile-position.color-1 {
  border-color: #10bab2;
  background: linear-gradient(145deg, #14cabf, #259df2);
}

.spatial-memory-shell {
  width: 100%;
  min-height: calc(100vh - 76px);
  background: var(--memory-page);
}

.spatial-memory-setup {
  display: grid;
  width: min(760px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 56px;
  gap: 14px;
}

.spatial-memory-setup-header {
  display: grid;
  justify-items: start;
  padding: 0 4px 8px;
}

.spatial-memory-back {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  margin: 0 0 18px;
  border: 0;
  background: transparent;
  color: var(--memory-muted);
  padding: 0;
  gap: 8px;
  font-size: .92rem;
  font-weight: 800;
  cursor: pointer;
}

.spatial-memory-back span {
  font-size: 1.2rem;
}

.spatial-memory-kicker {
  margin: 0 0 8px;
  color: var(--memory-accent-dark);
  font-size: .76rem;
  font-weight: 900;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.spatial-memory-setup-header h1 {
  margin: 0;
  color: var(--memory-ink);
  font-size: clamp(2rem, 7vw, 3.7rem);
  font-weight: 950;
  letter-spacing: -.045em;
  line-height: .98;
}

.spatial-memory-setup-header > p:last-child {
  max-width: 620px;
  margin: 14px 0 0;
  color: var(--memory-muted);
  font-size: 1rem;
  font-weight: 620;
  line-height: 1.55;
}

.spatial-memory-panel {
  display: grid;
  border: 1px solid var(--memory-line);
  border-radius: 20px;
  background: var(--memory-surface);
  padding: 18px;
  gap: 16px;
  box-shadow: 0 14px 38px rgba(27, 38, 65, .06);
}

.spatial-memory-section-heading {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.spatial-memory-section-heading > span {
  display: grid;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 10px;
  background: #edf0ff;
  color: var(--memory-accent-dark);
  font-size: .86rem;
  font-weight: 950;
}

.spatial-memory-section-heading h2 {
  margin: 0;
  color: var(--memory-ink);
  font-size: 1.05rem;
  font-weight: 920;
}

.spatial-memory-section-heading p {
  margin: 3px 0 0;
  color: var(--memory-muted);
  font-size: .88rem;
  font-weight: 620;
}

.spatial-memory-difficulties {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.spatial-memory-choice {
  position: relative;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  min-height: 78px;
  border: 1px solid var(--memory-line);
  border-radius: 14px;
  background: #fafbfe;
  color: var(--memory-ink);
  padding: 11px;
  gap: 10px;
  text-align: left;
  cursor: pointer;
}

.spatial-memory-choice:hover {
  border-color: #aeb9d6;
}

.spatial-memory-choice.is-selected {
  border-color: var(--memory-accent);
  background: #f0f2ff;
  box-shadow: inset 0 0 0 1px var(--memory-accent);
}

.spatial-memory-choice-count {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  background: var(--memory-cool);
  color: var(--memory-cool-dark);
  font-size: 1.15rem;
  font-weight: 950;
}

.spatial-memory-choice.is-selected .spatial-memory-choice-count {
  background: var(--memory-accent);
  color: #fff;
}

.spatial-memory-choice > span:nth-child(2) {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.spatial-memory-choice strong {
  font-size: .96rem;
  font-weight: 900;
}

.spatial-memory-choice small {
  overflow: hidden;
  color: var(--memory-muted);
  font-size: .76rem;
  font-weight: 650;
  line-height: 1.25;
  text-overflow: ellipsis;
}

.spatial-memory-choice > i {
  position: absolute;
  top: 9px;
  right: 9px;
  display: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--memory-accent);
}

.spatial-memory-choice > i::before {
  position: absolute;
  top: 4px;
  left: 5px;
  width: 7px;
  height: 4px;
  border-bottom: 2px solid #fff;
  border-left: 2px solid #fff;
  content: "";
  transform: rotate(-45deg);
}

.spatial-memory-choice.is-selected > i {
  display: block;
}

.spatial-memory-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-radius: 12px;
  background: #eef1f7;
  padding: 4px;
  gap: 4px;
}

.spatial-memory-tabs button {
  min-height: 48px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--memory-muted);
  font-size: .9rem;
  font-weight: 850;
  cursor: pointer;
}

.spatial-memory-tabs button.is-selected {
  background: #fff;
  color: var(--memory-ink);
  box-shadow: 0 4px 12px rgba(31, 43, 70, .09);
}

.spatial-memory-option-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.spatial-memory-option-row button {
  display: grid;
  min-height: 60px;
  place-content: center;
  border: 1px solid var(--memory-line);
  border-radius: 12px;
  background: #fff;
  color: var(--memory-ink);
  padding: 8px;
  text-align: center;
  cursor: pointer;
}

.spatial-memory-option-row button.is-selected {
  border-color: var(--memory-accent);
  background: #f0f2ff;
  box-shadow: inset 0 0 0 1px var(--memory-accent);
}

.spatial-memory-option-row strong {
  font-size: 1.08rem;
  font-weight: 950;
}

.spatial-memory-option-row small {
  color: var(--memory-muted);
  font-size: .72rem;
  font-weight: 700;
}

.spatial-memory-start {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
  border: 0;
  border-radius: 16px;
  background: var(--memory-accent);
  color: #fff;
  padding: 0 20px;
  font-size: 1rem;
  font-weight: 900;
  box-shadow: 0 14px 28px rgba(64, 87, 214, .24);
  cursor: pointer;
}

.spatial-memory-start:hover {
  background: var(--memory-accent-dark);
}

.spatial-memory-start span:last-child {
  font-size: 1.35rem;
}

.spatial-memory-hint {
  margin: 0;
  color: var(--memory-muted);
  font-size: .78rem;
  font-weight: 650;
  text-align: center;
}

.spatial-memory-hint kbd {
  display: inline-grid;
  min-width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid var(--memory-line);
  border-radius: 6px;
  background: #fff;
  color: var(--memory-ink);
  font: inherit;
  font-weight: 900;
}

html.spatial-memory-play-mode,
body.spatial-memory-play-mode {
  overflow: hidden;
  overscroll-behavior: none;
}

body.spatial-memory-play-mode .site-header {
  display: none !important;
}

body.spatial-memory-play-mode #root,
body.spatial-memory-play-mode main.view-spatial-contrast,
body.spatial-memory-play-mode #spatial-contrast-trainer-screen {
  min-height: 100dvh;
}

.spatial-memory-shell.stage-play {
  min-height: 100dvh;
  background: var(--memory-page);
}

.spatial-memory-game {
  position: relative;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  width: min(100%, 700px);
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--memory-page);
  padding: max(10px, env(safe-area-inset-top)) 16px max(14px, env(safe-area-inset-bottom));
}

.spatial-memory-game-header {
  display: grid;
  grid-template-columns: 1fr 1fr 48px;
  align-items: center;
  min-height: 58px;
  gap: 10px;
}

.spatial-memory-game-header > div {
  display: grid;
  gap: 1px;
}

.spatial-memory-game-header .spatial-memory-score {
  justify-items: center;
}

.spatial-memory-game-header span,
.spatial-memory-game-header div > span {
  color: var(--memory-muted);
  font-size: .72rem;
  font-weight: 720;
}

.spatial-memory-game-header strong {
  color: var(--memory-ink);
  font-size: 1rem;
  font-weight: 950;
  font-variant-numeric: tabular-nums;
}

.spatial-memory-pause {
  position: relative;
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid var(--memory-line);
  border-radius: 15px;
  background: #fff;
  color: var(--memory-ink);
  cursor: pointer;
}

.spatial-memory-pause:disabled {
  opacity: .45;
  cursor: default;
}

.spatial-memory-pause > span,
.spatial-memory-pause > span::after {
  width: 4px;
  height: 17px;
  border-radius: 3px;
  background: currentColor;
  content: "";
}

.spatial-memory-pause > span {
  position: relative;
  transform: translateX(-4px);
}

.spatial-memory-pause > span::after {
  position: absolute;
  left: 8px;
}

.spatial-memory-progress {
  width: 100%;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe4ee;
}

.spatial-memory-progress > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--memory-accent);
  transition: width .12s linear;
}

.spatial-memory-game-main {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  min-height: 0;
  align-items: center;
  justify-items: center;
  padding: clamp(14px, 3dvh, 24px) 0 0;
  gap: clamp(12px, 2dvh, 20px);
}

.spatial-memory-question {
  width: 100%;
  max-width: 430px;
  min-height: 44px;
  margin: 0;
  color: var(--memory-ink);
  font-size: clamp(.98rem, 4vw, 1.12rem);
  font-weight: 850;
  line-height: 1.3;
  text-align: center;
}

.spatial-memory-answer-timer {
  display: grid;
  width: 100%;
  max-width: 430px;
  gap: 5px;
}

.spatial-memory-answer-timer > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--memory-muted);
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.spatial-memory-answer-timer strong {
  color: var(--memory-ink);
  font-size: .78rem;
  font-variant-numeric: tabular-nums;
}

.spatial-memory-answer-timer > i {
  display: block;
  width: 100%;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe4ee;
}

.spatial-memory-answer-timer > i > b {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #ffbd38;
  transition: width .05s linear;
}

.spatial-memory-card-stack {
  position: relative;
  display: grid;
  width: min(78vw, 40dvh, 320px);
  min-width: 220px;
  aspect-ratio: 1;
  place-items: center;
}

.spatial-memory-stack-layer {
  position: absolute;
  inset: 0;
  border: 1px solid #e4e7ef;
  border-radius: 24px;
  background: rgba(255, 255, 255, .62);
  box-shadow: 0 12px 30px rgba(31, 43, 70, .05);
}

.spatial-memory-stack-layer.layer-two {
  transform: translate(9px, 10px) scale(.975);
  opacity: .42;
}

.spatial-memory-stack-layer.layer-one {
  transform: translate(5px, 6px) scale(.988);
  opacity: .7;
}

.spatial-memory-card {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 2px solid #edf0f5;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 18px 46px rgba(31, 43, 70, .09);
  will-change: opacity, transform;
}

.spatial-memory-card.has-correct {
  border-color: var(--memory-correct);
}

.spatial-memory-card.has-wrong {
  border-color: var(--memory-wrong);
}

.spatial-memory-card.is-entering {
  animation: spatial-memory-card-in 260ms cubic-bezier(.22, 1, .36, 1) both;
}

.spatial-memory-card.is-exiting {
  animation: spatial-memory-card-out 280ms cubic-bezier(.22, 1, .36, 1) both;
}

.spatial-memory-card.has-correct.is-exiting {
  animation: spatial-memory-correct-flash 280ms ease-out both;
}

.spatial-memory-card.has-wrong.is-exiting {
  animation: spatial-memory-wrong-flash 280ms ease-out both;
}

@keyframes spatial-memory-card-in {
  from { opacity: 0; transform: translateX(40px) scale(.97); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes spatial-memory-card-out {
  0%, 32% { opacity: 1; transform: translateX(0) scale(1); }
  to { opacity: 0; transform: translateX(-24px) scale(.96); }
}

@keyframes spatial-memory-correct-flash {
  0% {
    background: #fff;
    border-color: var(--memory-line);
    box-shadow: inset 0 0 0 0 rgba(25, 184, 111, 0);
  }
  42% {
    background: #adf3cc;
    border-color: #0abf65;
    box-shadow: inset 0 0 0 999px rgba(25, 184, 111, .16);
  }
  100% {
    background: #d9fbe8;
    border-color: #12a85a;
    box-shadow: inset 0 0 0 0 rgba(25, 184, 111, 0);
  }
}

@keyframes spatial-memory-wrong-flash {
  0% {
    background: #fff;
    border-color: var(--memory-line);
    box-shadow: inset 0 0 0 0 rgba(255, 58, 38, 0);
  }
  42% {
    background: #ffb7ac;
    border-color: #ff2f1a;
    box-shadow: inset 0 0 0 999px rgba(255, 58, 38, .18);
  }
  100% {
    background: #ffd8d1;
    border-color: #ef321f;
    box-shadow: inset 0 0 0 0 rgba(239, 50, 31, 0);
  }
}

.spatial-memory-positions {
  display: grid;
  width: 76%;
  height: 76%;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: clamp(8px, 2vw, 11px);
}

.spatial-memory-position {
  position: relative;
  display: block;
  min-width: 0;
  aspect-ratio: 1;
  border: 1px solid rgba(17, 24, 39, .12);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 8px 18px rgba(16, 19, 24, .06), inset 0 0 0 1px rgba(255, 255, 255, .5);
  transition: transform .12s ease, background .12s ease, border-color .12s ease, box-shadow .12s ease;
}

.spatial-memory-position.is-active {
  transform: translateY(-2px);
}

.spatial-memory-position.color-0 {
  border-color: #ffbd38;
  background: radial-gradient(circle at 50% 38%, #fff4c0, #ffd25c 64%, #ffbd38);
  box-shadow: 0 0 0 4px rgba(255, 189, 56, .14), 0 18px 36px rgba(255, 189, 56, .28);
}

.spatial-memory-position.color-1 {
  border-color: #10bab2;
  background: linear-gradient(135deg, #14cabf, #259df2);
  box-shadow: 0 0 0 4px rgba(16, 186, 178, .13), 0 18px 36px rgba(37, 157, 242, .22);
}

.spatial-memory-position.color-2 {
  border-color: #596ee8;
  background: linear-gradient(135deg, #7f92ff, #6451d8);
  box-shadow: 0 0 0 4px rgba(89, 110, 232, .13), 0 18px 36px rgba(100, 81, 216, .22);
}

.spatial-memory-position.color-3 {
  border-color: #ef6b62;
  background: linear-gradient(135deg, #ff9c71, #e95882);
  box-shadow: 0 0 0 4px rgba(239, 107, 98, .13), 0 18px 36px rgba(233, 88, 130, .21);
}

.spatial-memory-feedback {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  min-height: 34px;
  border-radius: 999px;
  background: #fff;
  padding: 5px 10px 5px 6px;
  gap: 7px;
  font-size: .74rem;
  box-shadow: 0 7px 18px rgba(31, 43, 70, .12);
}

.spatial-memory-feedback > span {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-size: 1rem;
  font-weight: 950;
}

.spatial-memory-feedback.is-correct {
  color: var(--memory-correct);
}

.spatial-memory-feedback.is-correct > span {
  background: var(--memory-correct);
}

.spatial-memory-feedback.is-wrong {
  color: var(--memory-wrong);
}

.spatial-memory-feedback.is-wrong > span {
  background: var(--memory-wrong);
}

.spatial-memory-answer-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  max-width: 430px;
  gap: 14px;
}

.spatial-memory-answer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  min-height: 60px;
  border: 1px solid transparent;
  border-radius: 17px;
  padding: 0 18px;
  font-size: 1rem;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.spatial-memory-answer span {
  font-size: 1.15rem;
}

.spatial-memory-answer.answer-no {
  border-color: #cfd6e5;
  background: var(--memory-cool);
  color: var(--memory-cool-dark);
}

.spatial-memory-answer.answer-yes {
  background: var(--memory-accent);
  color: #fff;
  box-shadow: 0 10px 20px rgba(64, 87, 214, .2);
}

.spatial-memory-answer:disabled {
  cursor: default;
  opacity: .6;
}

.spatial-memory-answer.is-correct-answer {
  border-color: var(--memory-correct);
  box-shadow: inset 0 0 0 2px var(--memory-correct), 0 0 0 3px rgba(20, 122, 112, .12);
  opacity: 1;
}

.spatial-memory-memorize {
  display: grid;
  width: 100%;
  max-width: 430px;
  min-height: 60px;
  place-items: center;
  border: 1px solid #d6dcec;
  border-radius: 17px;
  background: #eef1fb;
  color: var(--memory-accent-dark);
  font-size: .96rem;
  font-weight: 850;
}

.spatial-memory-sr-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.spatial-memory-game.is-paused .spatial-memory-game-main {
  visibility: visible;
  opacity: .88;
  filter: saturate(.9);
}

.spatial-memory-game.is-paused .spatial-memory-answer-row,
.spatial-memory-game.is-paused .spatial-memory-current-question {
  opacity: .88;
  filter: saturate(.9);
}

.spatial-memory-pause-backdrop {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(20, 28, 45, .48);
  padding: 20px;
}

.spatial-memory-pause-dialog {
  display: grid;
  width: min(100%, 360px);
  justify-items: center;
  border-radius: 24px;
  background: #fff;
  padding: 28px 22px 22px;
  box-shadow: 0 24px 70px rgba(15, 22, 38, .24);
}

.spatial-memory-pause-symbol {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: #edf0ff;
}

.spatial-memory-pause-symbol::before,
.spatial-memory-pause-symbol::after {
  position: absolute;
  top: 17px;
  width: 6px;
  height: 22px;
  border-radius: 4px;
  background: var(--memory-accent);
  content: "";
}

.spatial-memory-pause-symbol::before { left: 19px; }
.spatial-memory-pause-symbol::after { right: 19px; }

.spatial-memory-pause-dialog h2 {
  margin: 16px 0 6px;
  font-size: 1.45rem;
  font-weight: 950;
}

.spatial-memory-pause-dialog p {
  margin: 0 0 20px;
  color: var(--memory-muted);
  font-size: .92rem;
  font-weight: 630;
  line-height: 1.5;
  text-align: center;
}

.spatial-memory-pause-dialog button {
  width: 100%;
  min-height: 54px;
  border-radius: 14px;
  font-weight: 880;
  cursor: pointer;
}

.spatial-memory-pause-dialog [data-resume] {
  border: 0;
  background: var(--memory-accent);
  color: #fff;
}

.spatial-memory-pause-dialog [data-finish] {
  margin-top: 8px;
  border: 1px solid var(--memory-line);
  background: #fff;
  color: var(--memory-muted);
}

.spatial-memory-shell.stage-results {
  display: grid;
  min-height: calc(100vh - 76px);
  place-items: center;
  padding: 28px 14px 54px;
}

.spatial-memory-results {
  display: grid;
  width: min(100%, 680px);
  justify-items: center;
  border: 1px solid var(--memory-line);
  border-radius: 26px;
  background: #fff;
  padding: clamp(24px, 6vw, 42px);
  box-shadow: 0 22px 60px rgba(31, 43, 70, .09);
}

.spatial-memory-result-mark {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 19px;
  background: #e6f4f2;
  color: var(--memory-correct);
  font-size: 1.8rem;
  font-weight: 950;
}

.spatial-memory-results .spatial-memory-kicker {
  margin: 17px 0 6px;
  color: var(--memory-muted);
}

.spatial-memory-results h1 {
  margin: 0;
  color: var(--memory-ink);
  font-size: clamp(3.2rem, 13vw, 5.4rem);
  font-weight: 950;
  letter-spacing: -.07em;
  line-height: .95;
}

.spatial-memory-result-lead {
  margin: 12px 0 24px;
  color: var(--memory-accent-dark);
  font-size: 1rem;
  font-weight: 820;
  text-align: center;
}

.spatial-memory-result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  gap: 10px;
}

.spatial-memory-result-grid article {
  display: grid;
  min-height: 86px;
  align-content: center;
  border-radius: 15px;
  background: #f5f7fb;
  padding: 14px;
  gap: 5px;
}

.spatial-memory-result-grid span {
  color: var(--memory-muted);
  font-size: .76rem;
  font-weight: 700;
}

.spatial-memory-result-grid strong {
  color: var(--memory-ink);
  font-size: 1rem;
  font-weight: 920;
}

.spatial-memory-result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
  margin-top: 18px;
  gap: 10px;
}

.spatial-memory-result-actions button {
  min-height: 56px;
  border-radius: 15px;
  font-weight: 880;
  cursor: pointer;
}

.spatial-memory-result-actions [data-repeat] {
  border: 0;
  background: var(--memory-accent);
  color: #fff;
}

.spatial-memory-result-actions [data-levels] {
  border: 1px solid var(--memory-line);
  background: #fff;
  color: var(--memory-ink);
}

@media (max-width: 680px) {
  .spatial-memory-difficulties {
    grid-template-columns: 1fr;
  }

  .spatial-memory-choice {
    min-height: 68px;
  }
}

@media (max-width: 420px) {
  .spatial-memory-setup {
    width: min(100% - 22px, 760px);
    padding-top: 16px;
  }

  .spatial-memory-panel {
    border-radius: 18px;
    padding: 14px;
  }

  .spatial-memory-game {
    padding-right: 12px;
    padding-left: 12px;
  }

  .spatial-memory-game-main {
    gap: 11px;
  }

  .spatial-memory-card {
    border-radius: 22px;
  }

  .spatial-memory-answer-row {
    gap: 12px;
  }

  .spatial-memory-answer {
    min-height: 58px;
    padding: 0 15px;
  }

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

  .spatial-memory-result-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 650px) and (orientation: portrait) {
  .spatial-memory-game-main {
    padding-top: 8px;
    gap: 8px;
  }

  .spatial-memory-question {
    min-height: 34px;
    font-size: .92rem;
  }

  .spatial-memory-card-stack {
    width: min(68vw, 42dvh, 270px);
  }

  .spatial-memory-answer,
  .spatial-memory-memorize {
    min-height: 56px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spatial-memory-card.is-entering,
  .spatial-memory-card.is-exiting {
    animation-duration: 140ms;
    animation-name: spatial-memory-crossfade;
  }

  .spatial-memory-progress > span {
    transition: none;
  }

  .spatial-memory-answer-timer > i > b {
    transition: none;
  }
}

/* Setup screen mirrors the visual system used by “Код внимания”. */
#spatial-contrast-trainer-screen.stage-setup {
  min-height: calc(100dvh - 76px);
  background:
    radial-gradient(circle at 18% 12%, rgba(37, 157, 242, .08), transparent 32%),
    radial-gradient(circle at 82% 70%, rgba(121, 44, 239, .07), transparent 34%),
    #f9fbff;
  color: #071238;
}

#spatial-contrast-trainer-screen .switch-screen {
  box-sizing: border-box;
}

#spatial-contrast-trainer-screen .switch-hero-copy {
  display: grid;
  justify-items: start;
  gap: 9px;
}

#spatial-contrast-trainer-screen .switch-hero h1 {
  margin: 0;
  color: #071238;
  font-size: 3rem;
  font-weight: 950;
  letter-spacing: -.025em;
  line-height: 1;
}

#spatial-contrast-trainer-screen .switch-rainbow {
  display: block;
  width: min(300px, 100%);
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, #12c7bf 0%, #37a2f5 40%, #8954ee 68%, #f6b24a 100%);
}

#spatial-contrast-trainer-screen .switch-hero p {
  max-width: 410px;
  margin: 0;
  color: #4f6389;
  font-size: 1.05rem;
  font-weight: 560;
  line-height: 1.42;
}

#spatial-contrast-trainer-screen .switch-brain {
  display: block;
  justify-self: end;
  width: min(180px, 100%);
  max-height: 190px;
  object-fit: contain;
  filter:
    sepia(1)
    saturate(2.8)
    hue-rotate(342deg)
    brightness(.74)
    contrast(1.16)
    drop-shadow(0 24px 36px rgba(92, 55, 30, .2));
}

#spatial-contrast-trainer-screen .switch-card,
#spatial-contrast-trainer-screen .switch-about {
  box-sizing: border-box;
  width: 100%;
  min-height: 0;
  border: 1px solid #dfe8f5;
  border-radius: 8px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 14px 42px rgba(16, 19, 24, .08);
}

#spatial-contrast-trainer-screen .switch-card {
  display: grid;
  min-height: 112px;
  padding: 22px 24px;
  gap: 7px;
}

#spatial-contrast-trainer-screen .switch-card h2,
#spatial-contrast-trainer-screen .switch-about h2 {
  display: flex;
  align-items: center;
  margin: 0;
  color: #071238;
  font-size: .86rem;
  font-weight: 920;
  letter-spacing: 0;
  line-height: 1.15;
}

#spatial-contrast-trainer-screen .switch-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

#spatial-contrast-trainer-screen .switch-options button {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 44px;
  place-items: center;
  overflow: visible;
  border: 1px solid #d9e3f1;
  border-radius: 8px;
  background: #fff;
  color: #071238;
  padding: 6px 8px;
  font: inherit;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(52, 81, 145, .05);
}

#spatial-contrast-trainer-screen .switch-options button span {
  display: flex;
  align-items: baseline;
  gap: 5px;
  color: inherit;
  font-size: .96rem;
  line-height: 1;
  white-space: nowrap;
}

#spatial-contrast-trainer-screen .switch-options button span strong {
  color: inherit;
  font-size: 1.28rem;
  font-weight: 950;
  line-height: 1;
}

#spatial-contrast-trainer-screen .switch-options-mode button strong {
  color: inherit;
  font-size: .9rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

#spatial-contrast-trainer-screen .switch-options button.selected {
  border-color: #10bab2;
  background: linear-gradient(135deg, #eafffb, #fff);
  color: #079e96;
  box-shadow: 0 15px 32px rgba(16, 186, 178, .16);
}

#spatial-contrast-trainer-screen .switch-options button em {
  position: absolute;
  top: -6px;
  right: -3px;
  display: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #12c7bf, #089a94);
  box-shadow: 0 10px 22px rgba(10, 166, 158, .24);
  pointer-events: none;
}

#spatial-contrast-trainer-screen .switch-options button em::after {
  position: absolute;
  top: 4px;
  left: 6px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  content: "";
  transform: rotate(42deg);
}

#spatial-contrast-trainer-screen .switch-options button.selected em {
  display: block;
}

#spatial-contrast-trainer-screen .switch-start {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(100deg, #05c8bd 0%, #259df2 52%, #792cef 100%);
  color: #fff;
  padding: 0;
  gap: 12px;
  font: inherit;
  font-size: 1.08rem;
  font-weight: 920;
  cursor: pointer;
  box-shadow: 0 18px 42px rgba(83, 80, 222, .2);
}

#spatial-contrast-trainer-screen .switch-start .sw-icon {
  justify-self: end;
  width: 26px;
  height: 26px;
  background: currentColor;
  clip-path: polygon(52% 0, 78% 20%, 88% 45%, 72% 45%, 58% 73%, 36% 95%, 31% 68%, 5% 63%, 28% 42%, 55% 28%);
}

#spatial-contrast-trainer-screen .switch-start b {
  justify-self: end;
  width: 13px;
  height: 13px;
  margin-right: 18px;
  border-top: 4px solid currentColor;
  border-right: 4px solid currentColor;
  transform: rotate(45deg);
}

#spatial-contrast-trainer-screen .switch-about {
  display: grid;
  padding: 14px 16px;
  gap: 8px;
}

#spatial-contrast-trainer-screen .switch-about h2 {
  gap: 14px;
  font-size: 1.08rem;
}

#spatial-contrast-trainer-screen .switch-about h2::before {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 2px solid #75aef7;
  border-radius: 50%;
  background: #f4f9ff;
  color: #4d9af0;
  font-size: .78rem;
  font-weight: 880;
  content: "i";
  box-shadow: inset 0 0 0 4px rgba(117, 174, 247, .08);
}

#spatial-contrast-trainer-screen .switch-about p {
  max-width: none;
  margin: 0;
  color: #4f6389;
  font-size: .98rem;
  font-weight: 650;
  line-height: 1.38;
}

#spatial-contrast-trainer-screen .switch-about strong {
  color: #071238;
}

@media (min-width: 721px) {
  #spatial-contrast-trainer-screen .switch-options button em::after {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(42deg);
    transform-origin: center;
  }

  #spatial-contrast-trainer-screen .switch-screen {
    display: grid;
    width: min(1060px, calc(100% - 44px));
    max-width: 1060px;
    grid-template-columns: minmax(0, 1fr) minmax(330px, 410px);
    grid-template-rows: repeat(3, auto) auto;
    align-items: start;
    margin: 0 auto;
    padding: 18px 0 34px;
    gap: 14px 18px;
    overflow: hidden;
  }

  #spatial-contrast-trainer-screen .switch-card,
  #spatial-contrast-trainer-screen .switch-start {
    grid-column: 2;
  }

  #spatial-contrast-trainer-screen .switch-hero {
    display: grid;
    grid-column: 1;
    grid-row: 1 / span 2;
    grid-template-columns: minmax(0, 1fr) minmax(112px, 180px);
    align-items: center;
    min-height: 0;
    margin: 0;
    gap: 14px;
  }

  #spatial-contrast-trainer-screen .switch-card:nth-of-type(2) {
    grid-row: 1;
  }

  #spatial-contrast-trainer-screen .switch-card:nth-of-type(3) {
    grid-row: 2;
  }

  #spatial-contrast-trainer-screen .switch-card:nth-of-type(4) {
    grid-row: 3;
  }

  #spatial-contrast-trainer-screen .switch-start {
    grid-row: 4;
  }

  #spatial-contrast-trainer-screen .switch-about {
    grid-column: 1;
    grid-row: 3 / span 2;
  }
}

@media (min-width: 721px) and (max-width: 900px) {
  #spatial-contrast-trainer-screen .switch-screen {
    width: min(100% - 28px, 820px);
    grid-template-columns: minmax(0, 1fr) minmax(300px, 340px);
    gap: 12px;
  }

  #spatial-contrast-trainer-screen .switch-hero {
    grid-template-columns: minmax(0, 1fr) 118px;
    gap: 12px;
  }

  #spatial-contrast-trainer-screen .switch-hero h1 {
    font-size: 2.35rem;
  }

  #spatial-contrast-trainer-screen .switch-rainbow {
    width: 196px;
  }

  #spatial-contrast-trainer-screen .switch-hero p {
    font-size: .86rem;
    line-height: 1.34;
  }

  #spatial-contrast-trainer-screen .switch-brain {
    max-height: 132px;
  }

  #spatial-contrast-trainer-screen .switch-card {
    min-height: 106px;
    padding: 20px 22px;
  }
}

@media (max-width: 720px) {
  #spatial-contrast-trainer-screen.stage-setup {
    min-height: calc(100dvh - 62px);
  }

  #spatial-contrast-trainer-screen .switch-screen {
    display: grid;
    width: min(100% - 20px, 430px);
    margin: 0 auto;
    padding: 8px 0 28px;
    gap: 9px;
  }

  #spatial-contrast-trainer-screen .switch-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 122px;
    grid-template-rows: auto auto auto;
    align-items: center;
    min-height: 0;
    margin: 0;
    padding: 4px 2px 10px;
    column-gap: 10px;
    row-gap: 8px;
  }

  #spatial-contrast-trainer-screen .switch-hero-copy {
    display: contents;
  }

  #spatial-contrast-trainer-screen .switch-hero h1 {
    grid-column: 1 / -1;
    grid-row: 1;
    max-width: none;
    white-space: nowrap;
    font-size: clamp(1.62rem, 7.7vw, 2.05rem);
    letter-spacing: -.04em;
  }

  #spatial-contrast-trainer-screen .switch-rainbow {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    height: 4px;
  }

  #spatial-contrast-trainer-screen .switch-hero p {
    grid-column: 1;
    grid-row: 3;
    align-self: center;
    max-width: none;
    font-size: .97rem;
    line-height: 1.43;
  }

  #spatial-contrast-trainer-screen .switch-brain {
    grid-column: 2;
    grid-row: 3;
    align-self: center;
    justify-self: end;
    width: 122px;
    max-width: 122px;
    max-height: 126px;
    margin: 0;
  }

  #spatial-contrast-trainer-screen .switch-card {
    min-height: 88px;
    padding: 11px 10px 9px;
    gap: 8px;
  }

  #spatial-contrast-trainer-screen .switch-card h2 {
    font-size: .82rem;
  }

  #spatial-contrast-trainer-screen .switch-options {
    gap: 6px;
  }

  #spatial-contrast-trainer-screen .switch-options button {
    min-height: 43px;
    padding: 5px 6px;
  }

  #spatial-contrast-trainer-screen .switch-options button span {
    font-size: .77rem;
  }

  #spatial-contrast-trainer-screen .switch-options button span strong {
    font-size: 1rem;
  }

  #spatial-contrast-trainer-screen .switch-options-mode button strong {
    font-size: .78rem;
  }

  #spatial-contrast-trainer-screen .switch-start {
    min-height: 52px;
    font-size: 1rem;
  }

  #spatial-contrast-trainer-screen .switch-about {
    margin-top: 1px;
    padding: 12px;
  }

  #spatial-contrast-trainer-screen .switch-about h2 {
    gap: 9px;
    font-size: .98rem;
  }

  #spatial-contrast-trainer-screen .switch-about p {
    font-size: .88rem;
    line-height: 1.34;
  }
}

@media (max-width: 380px) {
  #spatial-contrast-trainer-screen .switch-hero {
    grid-template-columns: minmax(0, 1fr) 108px;
    column-gap: 8px;
  }

  #spatial-contrast-trainer-screen .switch-hero h1 {
    font-size: clamp(1.5rem, 7.35vw, 1.88rem);
  }

  #spatial-contrast-trainer-screen .switch-hero p {
    font-size: .92rem;
  }

  #spatial-contrast-trainer-screen .switch-brain {
    width: 108px;
    max-width: 108px;
    max-height: 114px;
  }

  #spatial-contrast-trainer-screen .switch-about {
    padding: 10px;
  }
}

@keyframes spatial-memory-crossfade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Countdown and play layout mirror the proven Code Attention trainer. */
html.spatial-memory-countdown-mode,
body.spatial-memory-countdown-mode,
html.spatial-memory-play-mode,
body.spatial-memory-play-mode {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body.spatial-memory-countdown-mode .site-header,
body.spatial-memory-play-mode .site-header {
  display: none !important;
}

body.spatial-memory-countdown-mode #root,
body.spatial-memory-countdown-mode main.view-spatial-contrast,
body.spatial-memory-countdown-mode #spatial-contrast-trainer-screen,
body.spatial-memory-play-mode #root,
body.spatial-memory-play-mode main.view-spatial-contrast,
body.spatial-memory-play-mode #spatial-contrast-trainer-screen {
  width: 100%;
  height: 100dvh;
  min-height: 0;
}

body.spatial-memory-countdown-mode main.view-spatial-contrast,
body.spatial-memory-play-mode main.view-spatial-contrast {
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

#spatial-contrast-trainer-screen.stage-countdown {
  max-width: none;
  margin: 0;
  padding: 0;
  background: #e8edf2;
}

.spatial-memory-countdown-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 4px;
  background: #e8edf2;
}

.spatial-memory-countdown-panel {
  box-sizing: border-box;
  display: grid;
  grid-template-rows: auto auto;
  align-content: center;
  justify-items: center;
  gap: clamp(22px, 4vh, 44px);
  width: min(940px, calc(100vw - 8px));
  height: min(990px, calc(100dvh - 8px));
  overflow: hidden;
  padding: clamp(24px, 5vh, 54px) clamp(18px, 5vw, 56px);
  border: 1px solid #edf1f5;
  border-radius: 30px;
  background: #fff;
  box-shadow: 0 18px 54px rgba(43, 63, 88, .08);
  text-align: center;
}

.spatial-memory-countdown-copy {
  display: grid;
  justify-items: center;
  gap: clamp(7px, 1.2vh, 13px);
  width: max-content;
  max-width: 100%;
}

.spatial-memory-countdown-copy > span {
  display: grid;
  justify-self: start;
  gap: 5px;
  color: #111827;
  font-size: clamp(.9rem, 1.6vw, 1.2rem);
  font-weight: 950;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.spatial-memory-countdown-copy > span::after {
  width: 100%;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  content: "";
}

.spatial-memory-countdown-copy h1 {
  margin: 0;
  color: #102642;
  font-size: clamp(2.35rem, 6vw, 5.2rem);
  font-weight: 900;
  line-height: .96;
  letter-spacing: -.055em;
  white-space: nowrap;
}

.spatial-memory-countdown-copy img {
  display: block;
  width: clamp(62px, 8vw, 86px);
  height: auto;
  margin-top: 3px;
}

.spatial-memory-countdown-copy p {
  margin: 0;
  color: #667b94;
  font-size: clamp(1.15rem, 2.4vw, 1.65rem);
  font-weight: 850;
}

.spatial-memory-countdown-panel > strong {
  display: block;
  min-width: 1em;
  margin: 0;
  color: #102642;
  font-family: Inter, Arial, sans-serif;
  font-size: clamp(10rem, 24vw, 15rem);
  font-weight: 900;
  line-height: .82;
  letter-spacing: -.07em;
  text-align: center;
  text-shadow: 0 16px 34px rgba(33, 70, 114, .12);
}

.spatial-memory-countdown-panel > strong.is-changing {
  animation: spatial-memory-countdown-pop .28s cubic-bezier(.2, .78, .24, 1);
}

@keyframes spatial-memory-countdown-pop {
  0% { opacity: .2; transform: scale(.84); }
  70% { opacity: 1; transform: scale(1.04); }
  100% { opacity: 1; transform: scale(1); }
}

#spatial-contrast-trainer-screen.stage-play {
  max-width: none;
  margin: 0;
  padding: 0;
  background: #f8fbfc;
}

#spatial-contrast-trainer-screen.stage-play .spatial-memory-game {
  box-sizing: border-box;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  gap: 7px;
  width: 100%;
  max-width: none;
  height: 100dvh;
  min-height: 0;
  margin: 0;
  overflow: hidden;
  padding: 8px 12px calc(90px + env(safe-area-inset-bottom));
  border: 0;
  border-radius: 0;
  background: #f8fbfc;
  box-shadow: none;
}

.spatial-memory-play-session {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
}

.spatial-memory-play-session > div {
  display: grid;
  gap: 2px;
}

.spatial-memory-play-session span,
.spatial-memory-play-round span,
.spatial-memory-current-question span {
  color: #66707d;
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.spatial-memory-play-session strong,
.spatial-memory-play-round strong {
  color: #101318;
  font-size: 1.1rem;
  font-weight: 950;
}

.spatial-memory-play-session > i {
  grid-column: 1 / -1;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4ebf0;
}

.spatial-memory-play-session > i > b,
.spatial-memory-play-round > i > b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #12b8ad;
  transition: width .05s linear;
}

.spatial-memory-play-round {
  display: grid;
  gap: 7px;
}

.spatial-memory-play-round > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.spatial-memory-play-round > i {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4ebf0;
}

.spatial-memory-play-history {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  align-items: center;
  gap: 5px;
  padding: 0 0 2px;
  transform: translateY(2px);
}

.spatial-memory-play-history span {
  height: 9px;
  border-radius: 999px;
  background: #dbe4ea;
}

.spatial-memory-play-history span.hit { background: #25b56c; }
.spatial-memory-play-history span.miss { background: #ef6b62; }

.spatial-memory-current-question {
  display: grid;
  align-content: center;
  gap: 2px;
  min-height: 48px;
  padding: 7px 11px;
  border: 1px solid #dce5eb;
  border-radius: 8px;
  background: #fff;
}

.spatial-memory-current-question strong {
  color: #102642;
  font-size: clamp(.88rem, 3.8vw, 1.08rem);
  font-weight: 950;
  line-height: 1.12;
}

#spatial-contrast-trainer-screen.stage-play .spatial-memory-game-main {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

#spatial-contrast-trainer-screen.stage-play .spatial-memory-card-stack {
  width: min(76vw, 40dvh, 300px);
  min-width: 176px;
  max-width: 100%;
  margin: 0;
}

.spatial-memory-answer-row {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid #dce5eb;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(14px);
}

#spatial-contrast-trainer-screen.stage-play .spatial-memory-answer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 64px;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  font-size: 1.58rem;
  font-weight: 900;
  box-shadow: none;
}

#spatial-contrast-trainer-screen.stage-play .spatial-memory-answer span,
#spatial-contrast-trainer-screen.stage-play .spatial-memory-answer strong {
  color: inherit;
  font: inherit;
}

#spatial-contrast-trainer-screen.stage-play .spatial-memory-answer.answer-yes { background: #17b6a6; }
#spatial-contrast-trainer-screen.stage-play .spatial-memory-answer.answer-no { background: #f06449; }
#spatial-contrast-trainer-screen.stage-play .spatial-memory-answer:disabled { opacity: .52; }

.spatial-memory-game-actions {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  right: max(8px, calc((100vw - 366px) / 2));
  z-index: 1200;
  display: flex;
  gap: 12px;
}

.spatial-memory-action-button {
  position: relative;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(145, 158, 171, .38);
  border-radius: 9px;
  box-shadow: 0 4px 12px rgba(35, 50, 65, .12);
}

.spatial-memory-action-button:disabled { opacity: .46; }

.spatial-memory-pause-button {
  background: linear-gradient(145deg, #ffd769, #f4b63f);
}

.spatial-memory-pause-button > span::before,
.spatial-memory-pause-button > span::after {
  position: absolute;
  top: 9px;
  width: 4px;
  height: 14px;
  border-radius: 2px;
  background: #102642;
  content: "";
}

.spatial-memory-pause-button > span::before { left: 11px; }
.spatial-memory-pause-button > span::after { right: 11px; }

.spatial-memory-pause-button.is-paused {
  border-color: rgba(16, 175, 119, .34);
  background: linear-gradient(135deg, #26cf98, #11b878);
}

.spatial-memory-pause-button.is-paused > span::before {
  top: 8px;
  left: 12px;
  width: 0;
  height: 0;
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  border-left: 13px solid #fff;
  border-radius: 2px;
  background: transparent;
}

.spatial-memory-pause-button.is-paused > span::after {
  content: none;
}

.spatial-memory-exit-button { background: #fff; }

.spatial-memory-exit-button > span::before,
.spatial-memory-exit-button > span::after {
  position: absolute;
  top: 15px;
  left: 8px;
  width: 18px;
  height: 3px;
  border-radius: 999px;
  background: #ef6b62;
  content: "";
}

.spatial-memory-exit-button > span::before { transform: rotate(45deg); }
.spatial-memory-exit-button > span::after { transform: rotate(-45deg); }

@media (max-width: 720px) {
  .spatial-memory-countdown-overlay { padding: 2px; }

  .spatial-memory-countdown-panel {
    gap: clamp(20px, 4vh, 34px);
    width: calc(100vw - 4px);
    height: calc(100dvh - 4px);
    padding: 24px 14px;
    border-radius: 25px;
  }

  .spatial-memory-countdown-copy h1 {
    font-size: clamp(1.7rem, 8.33vw, 2.25rem);
    line-height: 40px;
  }

  .spatial-memory-countdown-copy { gap: 6px; }
  .spatial-memory-countdown-copy > span { font-size: .82rem; }
  .spatial-memory-countdown-copy img { width: 66px; }
  .spatial-memory-countdown-copy p { font-size: 1.12rem; }

  .spatial-memory-countdown-panel > strong {
    font-size: clamp(9rem, 47vw, 11.5rem);
  }
}

@media (min-width: 721px) {
  #spatial-contrast-trainer-screen.stage-play .spatial-memory-game {
    grid-template-rows: auto auto auto auto auto auto;
    align-content: start;
    width: min(760px, calc(100% - 20px));
    max-width: 760px;
    margin: 0 auto;
    padding: 10px 0 14px;
  }

  #spatial-contrast-trainer-screen.stage-play .spatial-memory-card-stack {
    width: min(320px, 43dvh);
  }

  #spatial-contrast-trainer-screen.stage-play .spatial-memory-game-main {
    grid-template-rows: auto;
    padding: 28px 0;
  }

  #spatial-contrast-trainer-screen.stage-play .spatial-memory-answer-row {
    position: static;
    width: 100%;
    max-width: none;
    justify-self: stretch;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    backdrop-filter: none;
  }

  #spatial-contrast-trainer-screen.stage-play .spatial-memory-answer {
    min-height: 62px;
    font-size: 1.2rem;
  }

  .spatial-memory-game-actions {
    right: max(20px, calc((100vw - 760px) / 2 + 10px));
  }
}

@media (max-height: 700px) {
  .spatial-memory-countdown-panel { gap: 14px; padding-top: 12px; padding-bottom: 12px; }
  .spatial-memory-countdown-panel > strong { font-size: clamp(7rem, 28vh, 9rem); }

  #spatial-contrast-trainer-screen.stage-play .spatial-memory-game {
    gap: 5px;
    padding-top: 6px;
  }

  #spatial-contrast-trainer-screen.stage-play .spatial-memory-card-stack {
    width: min(62vw, 32dvh, 230px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spatial-memory-countdown-panel > strong.is-changing { animation: none; }
}

/* Mobile play geometry follows Code Attention exactly. */
@media (max-width: 720px) {
  #spatial-contrast-trainer-screen.stage-play .spatial-memory-game {
    grid-template-rows: auto 36px 25px 48px 336px 90px;
    align-content: start;
    gap: 6px;
    padding: 8px 12px 12px;
  }

  #spatial-contrast-trainer-screen.stage-play .spatial-memory-play-session {
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  #spatial-contrast-trainer-screen.stage-play .spatial-memory-play-session > i {
    height: 9px;
  }

  #spatial-contrast-trainer-screen.stage-play .spatial-memory-play-round {
    height: 36px;
    transform: translateY(1px);
  }

  #spatial-contrast-trainer-screen.stage-play .spatial-memory-play-history {
    min-height: 25px;
    align-self: center;
    padding: 0 0 2px;
    transform: translateY(2px);
  }

  #spatial-contrast-trainer-screen.stage-play .spatial-memory-current-question {
    width: 100%;
    height: 48px;
    min-height: 48px;
    padding: 7px 11px;
  }

  #spatial-contrast-trainer-screen.stage-play .spatial-memory-game-main {
    width: 100%;
    height: 336px;
    min-height: 336px;
    max-height: 336px;
  }

  #spatial-contrast-trainer-screen.stage-play .spatial-memory-answer-row {
    position: static;
    z-index: auto;
    width: 100%;
    max-width: none;
    height: 90px;
    align-self: start;
    justify-self: stretch;
    margin: -1px 0 0;
    padding: 0;
    border: 0;
    background: transparent;
    backdrop-filter: none;
  }

  #spatial-contrast-trainer-screen.stage-play .spatial-memory-answer {
    width: 100%;
    height: 90px;
    min-height: 90px;
    font-size: 1.18rem;
  }
}

/* Results inherit the exact live Code Attention component styles. */
#spatial-contrast-trainer-screen.stage-results {
  display: block;
  width: 100%;
  max-width: none;
  min-height: calc(100dvh - 76px);
  margin: 0;
  padding: 0;
  place-items: initial;
  background: transparent;
  color: var(--ink);
}

@media (max-width: 430px) {
  #spatial-contrast-trainer-screen.stage-results {
    min-height: calc(100dvh - 64px);
  }
}
