:root {
  color-scheme: light;
  --ink: #231d3c;
  --plum: #393050;
  --pink: #ff82bc;
  --mint: #9df2cd;
  --paper: #f9f4ff;
  --rim: #403453;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font:
    17px/1.45 "Arial Hebrew",
    Arial,
    sans-serif;
  background-color: #f1ebfa;
  background-image: radial-gradient(#cec1e1 0.85px, transparent 1px);
  background-size: 12px 12px;
}
button,
a {
  touch-action: manipulation;
}
button {
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
button:focus-visible,
a:focus-visible,
canvas:focus-visible {
  outline: 3px solid #0757aa;
  outline-offset: 3px;
}
button:disabled {
  cursor: wait;
}
.topbar {
  background: #231c37;
  color: #fff8ff;
  min-height: 62px;
  display: flex;
  direction: ltr;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(calc((100vw - 990px) / 2), 5vw);
  border-bottom: 4px solid #9474ab;
}
.brand {
  display: inline-flex;
  align-items: center;
  color: #fff;
  text-decoration: none;
  gap: 4px;
  font:
    bold 27px/1 "Arial Hebrew",
    Arial,
    sans-serif;
  letter-spacing: normal;
  text-shadow: 1px 2px #725384;
}
.brand > span:last-child {
  color: #f9a7d3;
}
.cassette {
  width: 34px;
  height: 23px;
  background: #fb94c3;
  border: 2px solid #171222;
  border-radius: 4px;
  box-shadow:
    inset 0 -4px #c05797,
    2px 2px #8c76a2;
  position: relative;
  margin-inline-end: 7px;
  transform: rotate(-6deg);
}
.cassette:before {
  content: "";
  position: absolute;
  inset: 4px 3px 6px;
  border: 1px solid #594566;
  border-radius: 4px;
  background:
    radial-gradient(circle at 17% 50%, #383048 2px, transparent 2.5px),
    radial-gradient(circle at 83% 50%, #383048 2px, transparent 2.5px), #ffe6c8;
}
nav {
  display: flex;
  gap: 8px;
  direction: rtl;
}
nav button {
  color: #fcf2ff;
  border: 1px solid #73617f;
  background: #382e49;
  border-radius: 7px;
  font-size: 14px;
  min-height: 35px;
  padding: 3px 12px;
}
nav button:hover {
  background: #524062;
}
main {
  max-width: 990px;
  width: 90%;
  margin: 26px auto 22px;
}
.heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 17px;
}
.activity {
  font-weight: 700;
  color: #73507e;
  font-size: 14px;
  margin: 0;
}
.heading h1 {
  margin: 0;
  font-size: clamp(35px, 4.4vw, 56px);
  line-height: 1.12;
  letter-spacing: -2.5px;
}
.heading h1 span {
  vertical-align: top;
  color: #b95a9b;
  font-size: 0.48em;
  margin-inline-start: 8px;
}
.progress-button,
.close {
  background: #fffbff;
  border: 1.5px solid #726384;
  border-radius: 9px;
  padding: 7px 13px;
  font-size: 14px;
  box-shadow: 0 2px #b4a3c4;
}
.cabinet {
  background: var(--plum);
  border: 3px solid #201930;
  border-radius: 19px;
  padding: 0 12px 11px;
  box-shadow:
    0 5px #6e5686,
    0 8px #29213a,
    0 18px 28px #5c387324;
  overflow: hidden;
}
.cabinet-head {
  direction: ltr;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 33px;
  padding: 0 7px;
  color: #efe3ff;
  font-size: 12px;
}
.stage-name {
  letter-spacing: 0.12em;
  color: #e1cdec;
  font: bold 11px monospace;
}
.stage-name i,
.save-light {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--mint);
  box-shadow: 0 0 6px #7ce3be;
  margin-right: 5px;
}
.meter {
  direction: rtl;
  display: flex;
  align-items: center;
  gap: 12px;
}
.meter b {
  display: inline-block;
  width: 10px;
  height: 6px;
  background: #665777;
  margin-left: 3px;
}
.meter b.on {
  background: var(--pink);
}
.screen {
  overflow: hidden;
  border: 2px solid #20172f;
  border-radius: 9px 9px 2px 2px;
  background: #40295a;
}
canvas {
  display: block;
  width: 100%;
  aspect-ratio: 12/5;
  image-rendering: pixelated;
  touch-action: manipulation;
}
.console {
  background: var(--paper);
  border: 2px solid #231a30;
  border-radius: 2px 2px 9px 9px;
  position: relative;
  padding: 21px 25px 22px;
}
.speaker {
  position: absolute;
  bottom: 6px;
  left: 12px;
  width: 24px;
  height: 3px;
  background: repeating-linear-gradient(
    to right,
    #a99ab6 0 3px,
    transparent 3px 6px
  );
}
#lesson {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
#lesson h2,
#info h2 {
  margin: 2px 0;
  font-size: clamp(21px, 3vw, 33px);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.6px;
}
#lesson p {
  margin: 5px 0 0;
  color: #52435d;
}
#lesson .eyebrow {
  font-size: 13px;
  font-weight: bold;
  color: #834a7b;
  margin: 0;
}
.math {
  display: inline-block;
  unicode-bidi: isolate;
  direction: ltr;
  font-family: "Arial", sans-serif;
  font-variant-numeric: tabular-nums;
}
#lesson .formula {
  font-size: clamp(30px, 4vw, 47px);
  letter-spacing: 0;
  line-height: 1.12;
}
.primary,
.pad,
.hop {
  background: var(--mint);
  border: 2px solid var(--ink);
  border-radius: 9px;
  box-shadow: 0 4px #403252;
  padding: 11px 18px;
  white-space: nowrap;
  font-size: 17px;
}
.primary:hover,
.hop:hover {
  background: #bcffde;
}
.primary:active,
.pad:active,
.hop:active {
  transform: translateY(2px);
  box-shadow: 0 2px #403252;
}
.primary {
  min-width: 146px;
}
.pad-list {
  display: flex;
  direction: ltr;
  gap: 9px;
  flex-wrap: wrap;
}
.pad {
  min-width: 54px;
  padding: 7px 11px;
  background: #fff;
  line-height: 1.2;
  font: 700 23px/1.2 monospace;
}
.pad:hover {
  background: #ffdcf0;
}
.coach-layout {
  flex-direction: column;
  align-items: stretch !important;
  gap: 12px !important;
}
.coach-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.hop {
  font-size: 15px;
  padding: 7px 13px;
  background: #e3ceff;
}
.under {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #685b76;
  font-size: 12px;
  margin: 19px 4px;
}
.under > span:last-child {
  letter-spacing: 1px;
  font: bold 11px monospace;
}
.save-light {
  width: 6px;
  height: 6px;
  background: #648a75;
  margin-inline-end: 4px;
  box-shadow: none;
}
dialog {
  background: #fff8ff;
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 13px;
  box-shadow: 0 6px #8d6ea8;
  padding: 24px;
  max-width: min(90vw, 440px);
}
dialog::backdrop {
  background: #24152f99;
}
dialog li {
  margin-block: 8px;
}
.close {
  float: left;
  font-size: 23px;
  padding: 1px 10px;
  margin: 0 10px 6px 0;
}
.under bdi {
  font-family: monospace;
}
@media (min-width: 900px) and (max-height: 780px) {
  main {
    max-width: 880px;
    margin-top: 13px;
  }
  .heading {
    margin-bottom: 10px;
  }
  .heading h1 {
    font-size: 41px;
  }
  .console {
    padding-block: 15px;
  }
}
@media (max-width: 660px) {
  body {
    font-size: 16px;
  }
  .topbar {
    padding: 0 4%;
    min-height: 55px;
  }
  .brand {
    font-size: 21px;
  }
  .cassette {
    width: 27px;
    height: 20px;
    margin-inline-end: 3px;
  }
  nav button {
    padding: 3px 8px;
    font-size: 12px;
  }
  main {
    width: 96%;
    margin-top: 20px;
  }
  .heading {
    margin-inline: 2%;
    margin-bottom: 13px;
  }
  .cabinet {
    padding: 0 5px 6px;
    border-radius: 12px;
  }
  .console {
    padding: 15px 12px 18px;
  }
  #lesson {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
  }
  .primary {
    align-self: stretch;
  }
  .pad-list {
    gap: 7px;
  }
  .pad {
    flex: 1;
    min-height: 44px;
  }
  .stage-name {
    font-size: 9px;
  }
  .under {
    font-size: 11px;
    margin-inline: 2%;
  }
  .speaker {
    bottom: 5px;
  }
  .progress-button {
    font-size: 12px;
  }
  .cabinet-head {
    min-height: 28px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *:before,
  *:after {
    scroll-behavior: auto;
  }
}
.help-link {
  display: block;
  border: 0;
  background: none;
  text-decoration: underline;
  color: #6c3e76;
  font-size: 14px;
  margin: 6px auto -4px;
  padding: 5px 10px;
}
.guided-help {
  font-weight: bold;
}
.coach-actions > span {
  color: #675774;
  font-size: 14px;
}
.character-intro {
  display: flex;
  align-items: center;
  gap: 15px;
}
.portrait {
  width: 61px;
  height: 66px;
  flex: none;
  border: 2px solid var(--ink);
  border-radius: 8px;
  box-shadow: 2px 2px #c4a9d4;
  background: #dfb5e8 url(stage.jpg) 51% 20%/235% auto no-repeat;
}
.hop:disabled {
  opacity: 0.65;
}

#lesson .formula,
#lesson p.math {
  display: block;
  width: fit-content;
}

.coach-story > p {
  max-width: 65ch;
}
.coach-story .formula {
  margin-block: 6px 12px;
}
.coach-actions {
  padding-top: 12px;
  border-top: 1px solid #d8cce4;
}
.coach-actions > strong {
  flex-basis: 100%;
}

[hidden] {
  display: none !important;
}
#balance {
  color: #ffe6a1;
  white-space: nowrap;
  margin-inline-start: 5px;
}
nav {
  flex-wrap: wrap;
  justify-content: flex-start;
}
body[data-view="home"] .cabinet,
body[data-view="shop"] .cabinet {
  display: grid;
  grid-template-columns: 1fr 1fr;
  direction: ltr;
}
body[data-view="home"] .cabinet-head,
body[data-view="shop"] .cabinet-head {
  grid-column: 1 / -1;
}
body[data-view="home"] .console,
body[data-view="shop"] .console {
  direction: rtl;
  border-radius: 0 8px 8px 0;
  display: flex;
  align-items: center;
}
body[data-view="home"] .screen,
body[data-view="shop"] .screen {
  border-radius: 8px 0 0 8px;
  align-content: center;
}
body[data-view="home"] #lesson,
body[data-view="shop"] #lesson {
  flex-direction: column;
  align-items: start;
  gap: 10px;
}
body[data-view="memory"] .screen,
body[data-view="recall"] .screen {
  display: none;
}
.game-menu {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  margin-top: 25px;
}
.game-card {
  text-align: right;
  padding: 19px;
  display: grid;
  grid-template-columns: 55px 1fr;
  gap: 4px 13px;
  border: 2px solid var(--ink);
  background: #fffaff;
  color: var(--ink);
  border-radius: 13px;
  box-shadow: 0 4px #ac91c0;
}
.game-card:hover {
  background: #fff0f8;
  transform: translateY(-1px);
}
.game-icon {
  grid-row: 1 / 4;
  display: grid;
  place-items: center;
  font: bold 37px monospace;
  border: 2px solid #6d5489;
  background: #e9dcff;
  border-radius: 9px;
  width: 55px;
  height: 64px;
}
.game-card:nth-child(2) .game-icon {
  background: #fbd5e8;
}
.game-card:nth-child(3) .game-icon {
  background: #d8f3e7;
}
.game-card:nth-child(4) .game-icon {
  background: #ffedbd;
}
.game-card strong {
  font-size: 23px;
  line-height: 1.1;
}
.game-detail {
  font-size: 15px;
  font-weight: normal;
  color: #60506d;
}
.game-reward {
  color: #79406e;
  font-size: 13px;
  margin-top: 8px;
}
#lesson.mini-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  gap: 16px;
}
.memory-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 11px;
  direction: ltr;
}
.memory-card {
  background: #6a4a88;
  border: 2px solid #342644;
  border-radius: 9px;
  height: 88px;
  font: bold 27px monospace;
  box-shadow: 0 4px #a68cb7;
  color: white;
}
.memory-card .card-back {
  color: #ffcfe8;
  background: #9670b4;
  padding: 8px 20px;
  border: 1px solid #c7a5d9;
  border-radius: 6px;
}
.memory-card.flipped {
  background: #fffaf0;
  color: var(--ink);
}
.memory-card.matched {
  background: #d3f4e6;
  border-color: #51806b;
  box-shadow: 0 4px #abd0bd;
  cursor: default;
}
.game-message {
  min-height: 1.5em;
}
.end-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.secondary {
  border: 2px solid #6f5d7c;
  border-radius: 9px;
  padding: 8px 14px;
  background: #fffaff;
  color: var(--ink);
  min-height: 43px;
}
.secondary:hover {
  background: #f4e6ff;
}
button:disabled {
  opacity: 0.68;
  cursor: default;
}
.answer-form {
  display: flex;
  gap: 12px;
}
.answer-form input {
  width: 130px;
  min-width: 80px;
  direction: ltr;
  text-align: center;
  font: bold 30px Arial;
  padding: 6px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: white;
  color: var(--ink);
}
.answer-form input:focus {
  outline: 3px solid #b892d1;
  outline-offset: 2px;
}
#lesson .formula {
  margin-bottom: 6px;
}
.recall-panel .help-link {
  margin-inline: 0;
  align-self: flex-start;
}
.recall-hint {
  overflow-wrap: anywhere;
}
.shop-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-top: 25px;
}
.shop-card {
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 20px;
  background: #fffaff;
  box-shadow: 0 4px #b5a0c2;
  text-align: center;
}
.shop-card h2 {
  margin: 9px 0;
  font-size: 22px;
}
.shop-card p {
  margin: 6px 0;
  font-size: 15px;
}
.shop-card .price {
  display: block;
  font: bold 25px monospace;
  margin: 16px 0;
}
.prop-symbol {
  display: inline-grid;
  width: 80px;
  height: 75px;
  place-items: center;
  font-size: 45px;
  background: #fce0ed;
  border-radius: 12px;
  border: 2px solid #ad8bbb;
}
.prop-crown {
  color: #996414;
  background: #fff0bc;
}
.prop-headphones {
  color: #315b60;
  background: #d3f7ec;
}
#lesson > .math {
  font-size: 30px;
}
@media (max-width: 700px) {
  .topbar {
    padding-block: 8px;
    gap: 9px;
    flex-wrap: wrap;
  }
  nav {
    gap: 5px;
    width: 100%;
    justify-content: space-between;
  }
  .brand {
    font-size: 24px;
  }
  .game-menu {
    gap: 12px;
    margin-top: 20px;
  }
  .game-card {
    grid-template-columns: 1fr;
    padding: 15px 12px;
  }
  .game-icon {
    grid-row: auto;
    width: 44px;
    height: 44px;
    font-size: 27px;
    margin-bottom: 7px;
  }
  .game-card strong {
    font-size: 21px;
  }
  .game-detail {
    font-size: 14px;
  }
  body[data-view="home"] .cabinet,
  body[data-view="shop"] .cabinet {
    display: block;
  }
  body[data-view="home"] .screen,
  body[data-view="shop"] .screen {
    max-height: 150px;
    overflow: hidden;
  }
  body[data-view="home"] .console,
  body[data-view="shop"] .console {
    border-radius: 0 0 8px 8px;
  }
  .shop-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .memory-board {
    gap: 9px;
    grid-template-columns: repeat(3, 1fr);
  }
  .memory-card {
    height: 78px;
    font-size: clamp(16px, 5vw, 22px);
    padding: 2px;
  }
  .memory-card .card-back {
    padding: 8px 13px;
  }
  .answer-form .primary {
    min-width: 0;
    flex: 1;
    padding-inline: 10px;
  }
  .end-actions {
    flex-direction: column;
  }
}

body[data-view="memory"] .cabinet,
body[data-view="recall"] .cabinet {
  display: grid;
  grid-template-columns: minmax(0, 0.75fr) minmax(0, 1.25fr);
  direction: ltr;
}
body[data-view="memory"] .cabinet-head,
body[data-view="recall"] .cabinet-head {
  grid-column: 1 / -1;
}
body[data-view="memory"] .screen,
body[data-view="recall"] .screen {
  display: block;
  align-content: center;
  background: #392849;
  border-radius: 8px 0 0 8px;
}
body[data-view="memory"] .console,
body[data-view="recall"] .console {
  direction: rtl;
  border-radius: 0 8px 8px 0;
}
@media (max-width: 700px) {
  body[data-view="memory"] .cabinet,
  body[data-view="recall"] .cabinet {
    display: block;
  }
  body[data-view="memory"] .screen,
  body[data-view="recall"] .screen {
    max-height: 135px;
    overflow: hidden;
  }
  body[data-view="memory"] .console,
  body[data-view="recall"] .console {
    border-radius: 0 0 8px 8px;
  }
}

@media (min-width: 701px) {
  body[data-view="memory"] .screen,
  body[data-view="recall"] .screen {
    position: relative;
    overflow: hidden;
  }
  body[data-view="memory"] .screen canvas,
  body[data-view="recall"] .screen canvas {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: auto;
    height: 100%;
    max-width: none;
  }
}

.round-progress {
  width: 100%;
  flex-basis: 100%;
  padding-bottom: 12px;
  border-bottom: 1px solid #d8cce4;
}
.progress-copy {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 7px;
}
.progress-copy strong {
  color: #583369;
  font-size: 18px;
}
.progress-copy span {
  color: #65526f;
  font-size: 14px;
}
.round-progress progress {
  width: 100%;
  height: 13px;
  display: block;
  accent-color: #9d5ca2;
}
#lesson.with-progress {
  flex-wrap: wrap;
}
@media (max-width: 500px) {
  .progress-copy {
    align-items: start;
  }
  .progress-copy strong {
    font-size: 17px;
  }
  .progress-copy span {
    font-size: 12px;
  }
}
