* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  color: #653274;
}
button {
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
body {
  background: #f3ceae;
}
#app {
  height: 100dvh;
  width: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(180deg, #ffffff05 0%, #ffdda11a 38%, #6e2f13cc 100%),
    url("room-top.jpg") top center / 100% 35% no-repeat,
    linear-gradient(115deg, #c87b5e, #f7d6a3 50%, #d38c68);
}
header {
  height: 15%;
  min-height: 55px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 2.5%;
  gap: 8px;
  position: relative;
  z-index: 2;
}
.brand {
  font-size: clamp(17px, 2.8vw, 38px);
  font-weight: 1000;
  color: #fff8fb;
  text-shadow:
    0 3px 2px #693b6b,
    0 5px 9px #53243c;
  white-space: nowrap;
  background: linear-gradient(100deg, #a65320, #c0782e, #8d401c);
  padding: 6px 18px;
  border: 4px ridge #efb464;
  border-radius: 22px;
  box-shadow: 0 5px 0 #693719;
}
.headerGroup {
  display: flex;
  align-items: center;
  gap: 7px;
}
.pill {
  border: 2px solid #ead2ba;
  background: #fff9ed;
  color: #63378b;
  border-radius: 28px;
  padding: 8px 13px;
  font-weight: 900;
  box-shadow: 0 4px #8e59b5;
  white-space: nowrap;
  font-size: clamp(12px, 1.6vw, 19px);
}
#board {
  position: relative;
  margin: 0 3.2%;
  height: 38%;
  min-height: 145px;
  border-radius: 26px;
  border: 11px ridge #d69855;
  background: linear-gradient(#fffdf3f7, #fff7eaf8);
  box-shadow:
    inset 0 0 0 3px #fff1c6,
    0 9px 0 #784018,
    0 14px 18px #48220d99;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-around;
  padding: 2px 14px;
}
#noteRow {
  height: 33%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  direction: rtl;
  font-size: clamp(16px, 2.5vw, 29px);
  font-weight: 1000;
  white-space: nowrap;
}
#noteIcon {
  width: clamp(50px, 7vw, 88px);
  height: 95%;
  object-fit: contain;
  filter: drop-shadow(0 2px 2px #a67b5a44);
}
#staff {
  height: 53%;
  width: 100%;
  overflow: visible;
}
#prompt {
  height: 13%;
  font-size: clamp(11px, 1.5vw, 17px);
  font-weight: 800;
  text-align: center;
}
#wood {
  margin: 1.2% 2.5% 0;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(
    180deg,
    #f3b46c 0%,
    #8c431c 7%,
    #57260e 11%,
    #a95c29 14%,
    #9e4d21 94%,
    #50260f 100%
  );
  border: 9px ridge #b96e31;
  border-radius: 23px 23px 15px 15px;
  padding: 4.5% 1.3% 2.5%;
  box-shadow:
    0 7px 0 #57270f,
    0 15px 20px #32190c8a;
}
#piano {
  direction: ltr;
  display: flex;
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  border: 3px solid #6b351e;
  border-top: 7px solid #48210f;
  border-radius: 6px 6px 14px 14px;
  overflow: hidden;
  background: #eee;
}
.key {
  position: relative;
  flex: 0 0 12.5%;
  width: 12.5%;
  border: 1px solid #c7b6a7;
  border-right: 2px solid #b29d8c;
  border-bottom: 9px solid #d7c5b3;
  border-radius: 0 0 9px 9px;
  background: linear-gradient(
    90deg,
    #eee5dc 0%,
    #fffefa 16%,
    #fffefa 80%,
    #e3d8cc 100%
  );
  padding: 0;
  min-width: 0;
}
.key.active {
  background: #fff1ad;
}
.key img {
  position: absolute;
  width: 60%;
  height: 29%;
  object-fit: contain;
  left: 50%;
  bottom: 6%;
  transform: translateX(-50%);
  pointer-events: none;
  filter: drop-shadow(0 2px 1px #65432122);
}
.black {
  position: absolute;
  top: 0;
  width: 7.2%;
  height: 56%;
  z-index: 4;
  transform: translateX(-50%);
  border: 1px solid #09080c;
  border-radius: 0 0 7px 7px;
  background: linear-gradient(
    90deg,
    #0b090c,
    #343139 34%,
    #121015 80%,
    #050407
  );
  box-shadow: 0 2px 2px #0008;
}
#rotate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: linear-gradient(140deg, #f5d7b5, #e8c7ed);
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 25px;
}
.rotateCard {
  max-width: 450px;
  padding: 24px;
  border-radius: 25px;
  background: #fffaf1;
  border: 5px solid #c7844b;
  box-shadow: 0 12px 30px #59301a55;
}
.rotateCard h2 {
  font-size: 25px;
}
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 15px;
  background: linear-gradient(125deg, #713b6cef, #d58c4aef);
  color: white;
  text-align: center;
  overflow: auto;
}
.overlay[hidden] {
  display: none;
}
.overlay h2 {
  margin: 0;
  font-size: clamp(22px, 4vw, 42px);
}
.overlay p {
  margin: 0;
}
.choices {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.choice {
  background: #fff8e9;
  color: #643786;
  border: 3px solid #f1bf6e;
  border-radius: 22px;
  padding: 9px 16px;
  font-weight: 900;
  box-shadow: 0 5px #794e9d;
}
.choice.selected {
  background: #ffeb91;
}
.settingList {
  display: grid;
  grid-template-columns: repeat(2, minmax(190px, 1fr));
  gap: 9px;
}
.settingList label {
  background: #fff9ed;
  color: #653781;
  padding: 12px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
}
.settingList input {
  width: 20px;
  height: 20px;
  accent-color: #834ecb;
}
.stats {
  display: flex;
  gap: 12px;
}
.stat {
  background: #fff9ed;
  color: #653781;
  padding: 15px;
  border-radius: 15px;
}
.stat b {
  display: block;
  font-size: 26px;
}
.simple #app {
  background: #f4eef8;
}
.simple #board {
  border: 4px solid #a8b7de;
  box-shadow: none;
}
.simple #wood {
  border: 4px solid #aaa;
  background: #ddd;
  box-shadow: none;
  padding-top: 1%;
}
.noHint #prompt[data-feedback="false"] {
  visibility: hidden;
}
@media (orientation: portrait) {
  #rotate {
    display: flex;
  }
  #app {
    visibility: hidden;
  }
}
@media (orientation: landscape) and (max-height: 460px) {
  header {
    height: 14%;
    min-height: 36px;
  }
  .brand {
    padding: 2px 10px;
    border-width: 2px;
  }
  .pill {
    padding: 4px 8px;
  }
  #board {
    height: 37%;
    min-height: 110px;
    border-width: 6px;
  }
  #wood {
    padding-top: 3.5%;
    padding-bottom: 1%;
    border-width: 5px;
  }
  #noteIcon {
    width: 45px;
  }
  .overlay {
    gap: 6px;
  }
  .choice {
    padding: 5px 12px;
  }
  .settingList label {
    padding: 6px;
  }
}

/* Illustrated room: real controls sit in front of a window and velvet curtains. */
#app {
  isolation: isolate;
  background:
    repeating-linear-gradient(0deg, #0000 0 42px, #b3735a22 43px 45px),
    linear-gradient(100deg, #c77a59, #ffe0ac 50%, #c77a59);
}
.room {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}
.window {
  position: absolute;
  top: -4%;
  left: 28%;
  width: 44%;
  height: 37%;
  border: 10px ridge #c48a47;
  border-radius: 0 0 50% 50%;
  background:
    radial-gradient(ellipse at 12% 95%, #639c44 0 20%, transparent 21%),
    radial-gradient(ellipse at 88% 95%, #80b64d 0 24%, transparent 25%),
    linear-gradient(#7ecbe6, #e6f8df);
  box-shadow: 0 0 30px #fff2bc;
}
.window:after {
  content: "";
  position: absolute;
  left: 49%;
  height: 100%;
  border-left: 6px solid #dca15f;
}
.curtain {
  position: absolute;
  top: 0;
  width: 31%;
  height: 28%;
  background: repeating-linear-gradient(
    100deg,
    #a44669,
    #e79b9e 9%,
    #ba5979 18%,
    #f1b3a5 23%,
    #ad4d72 30%
  );
  box-shadow: 0 8px 12px #75403955;
}
.curtain.left {
  left: 0;
  border-radius: 0 0 90% 0;
}
.curtain.right {
  right: 0;
  transform: scaleX(-1);
  border-radius: 0 0 90% 0;
}
header {
  height: 18%;
  min-height: 58px;
}
.brand {
  font-size: clamp(16px, 2.6vw, 36px);
}
#board {
  height: 35%;
  flex-shrink: 0;
  min-height: 0;
}
#wood {
  padding-top: 2%;
  margin-top: 1.5%;
  padding-bottom: 1.4%;
}
#piano {
  touch-action: none;
}
.key {
  flex-basis: calc(100% / var(--white-count));
  width: calc(100% / var(--white-count));
}
.key img {
  width: 48%;
  height: 25%;
  bottom: 7%;
  filter: none;
}
.black {
  width: calc(52% / var(--white-count));
  height: 54%;
}
.black.active {
  background: linear-gradient(#4c346a, #9566bb);
}
.key:focus-visible,
.black:focus-visible {
  outline: 3px solid #aa56bd;
  outline-offset: -4px;
}
#noteIcons {
  position: relative;
  width: clamp(48px, 7vw, 88px);
  height: 100%;
  flex-shrink: 0;
}
#noteIcons img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
#noteIcons img[hidden] {
  display: none;
}
/* Hidden friend: a question mark until the right key is found. */
#noteRow.concealed #noteIcons img,
#noteRow.concealed #noteLabel {
  visibility: hidden;
}
#noteRow.concealed #noteIcons::after {
  content: "؟";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(32px, 5vw, 60px);
  font-weight: bold;
  color: #8b6a9c;
}
#noteRow {
  height: 29%;
}
#staff {
  height: 57%;
  overflow: hidden;
}
#prompt {
  height: 14%;
  margin: 0;
  align-content: center;
}
#feedback {
  min-width: 14em;
  text-align: center;
}
.boardFooter {
  height: 17%;
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: center;
  width: 100%;
}
.boardFooter #prompt {
  height: auto;
}
.next {
  font-size: clamp(11px, 1.4vw, 17px);
  padding: 3px 14px;
  box-shadow: 0 2px #794e9d;
}
.next:disabled {
  opacity: 0.45;
  cursor: default;
}
#rangeLabel {
  position: absolute;
  top: 5px;
  left: 15px;
  color: #fff0c4;
  font-size: clamp(10px, 1.3vw, 16px);
  direction: ltr;
}
#wood {
  position: relative;
}
.overlay {
  background: linear-gradient(125deg, #713b6cf5, #d58c4af5);
}
.settingList {
  grid-template-columns: repeat(2, minmax(165px, 1fr));
}
.settingList select {
  font: inherit;
  max-width: 130px;
}
.settingList label {
  padding: 8px;
}
.overlay .choice:disabled {
  opacity: 0.6;
}
#loadStatus {
  min-height: 1.5em;
  font-size: 14px;
}
.stats {
  flex-wrap: wrap;
}
#score {
  cursor: default;
}
.simple #app {
  background: #f4eef8;
}
.simple .room {
  display: none;
}
@media (orientation: portrait) {
  #rotate {
    display: none;
  }
  #app {
    visibility: visible;
  }
}
@media (orientation: portrait) and (pointer: coarse) and (max-width: 1400px) {
  #rotate {
    display: flex;
  }
  #app {
    visibility: hidden;
  }
}
@media (orientation: landscape) and (max-height: 460px) {
  header {
    height: 17%;
    min-height: 44px;
  }
  .brand {
    font-size: clamp(16px, 2.5vw, 23px);
    padding: 3px 8px;
  }
  .headerGroup {
    gap: 4px;
  }
  .pill {
    font-size: 12px;
    padding: 4px 7px;
  }
  #board {
    height: 36%;
    min-height: 0;
    padding: 2px 9px;
    border-width: 6px;
    border-radius: 18px;
  }
  #noteRow {
    font-size: 18px;
    gap: 7px;
  }
  #noteIcons {
    width: 42px;
  }
  #wood {
    padding-top: 2.5%;
    margin-top: 1.4%;
    border-width: 5px;
  }
  #rangeLabel {
    top: 0;
    font-size: 10px;
  }
  .overlay h2 {
    font-size: 23px;
  }
  .settingList label {
    padding: 5px;
  }
  .boardFooter {
    gap: 8px;
  }
  .next {
    padding: 1px 10px;
  }
  #prompt {
    font-size: 11px;
  }
  .window {
    height: 30%;
  }
}
@media (max-width: 740px) {
  .brand {
    font-size: 16px;
  }
  .brand .flower {
    display: none;
  }
  .pill {
    font-size: 11px;
    padding: 4px;
  }
  .headerGroup {
    gap: 3px;
  }
  #noteRow {
    font-size: 16px;
  }
  .settingList {
    gap: 5px;
  }
  .overlay {
    padding: 8px;
  }
}

.keysHidden .key img,
.hideIcons .key img {
  visibility: hidden;
}

/* Only the scenic window area of the supplied reference is used, never its baked controls. */
.window {
  background-image: url("room-top.jpg");
  background-size: auto 400%;
  background-position: 50% 0;
}

/* Advanced teaching uses the same music room, furniture and image banks. */
[hidden] {
  display: none !important;
}
.learningPanel {
  justify-content: flex-start;
  align-items: stretch;
  background: linear-gradient(125deg, #713b6cfb, #bb793ffb);
}
.panelHeading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}
.learningColumns {
  display: grid;
  grid-template-columns: minmax(300px, 1.3fr) minmax(260px, 1fr);
  gap: 20px;
  min-height: 0;
  width: min(1100px, 100%);
  margin: 0 auto;
  overflow: auto;
  padding: 10px;
}
.learningColumns > section {
  min-width: 0;
}
.lessonSelect {
  display: flex;
  gap: 15px;
  align-items: center;
  font-weight: 800;
}
.lessonSelect select,
.customPractice select {
  font: inherit;
  padding: 5px;
  border-radius: 10px;
  background: #fff7e7;
  color: #643786;
}
#lessonList {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.lessonCard {
  text-align: right;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 2px solid #eab773;
  border-radius: 15px;
  padding: 12px;
  background: #fff7e8;
  color: #653781;
  box-shadow: 0 3px #794e9d;
  font: inherit;
}
.lessonCard span {
  font-size: 12px;
  white-space: nowrap;
}
.lessonCard:hover {
  background: #ffefc2;
}
.customPractice {
  background: #fff2dc;
  color: #653781;
  border: 4px ridge #d69855;
  border-radius: 20px;
  padding: 16px;
  align-self: start;
}
.customPractice h3 {
  margin-top: 0;
}
.customPractice p {
  font-size: 13px;
  margin: 8px 0;
}
.customPractice fieldset {
  border: 1px solid #c49371;
  border-radius: 12px;
  margin: 12px 0;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.customPractice label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}
.customPractice input {
  accent-color: #834ecb;
  width: 18px;
  height: 18px;
}
#keySelection {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px 0;
}
.customPractice details {
  border-block: 1px solid #c49371;
  padding: 8px 0;
}
.customPractice summary {
  cursor: pointer;
  font-weight: bold;
}
#settings {
  justify-content: flex-start;
  padding-block: 20px;
}
.settingsSubtitle {
  margin: 12px 0 0;
}
.settingsNote {
  max-width: 650px;
  font-size: 13px;
}
#tutorialContent {
  width: min(750px, 100%);
  margin: auto;
  background: #fff6e5;
  color: #653781;
  border: 7px ridge #d69855;
  border-radius: 24px;
  padding: 26px;
  text-align: right;
  line-height: 2;
  font-size: clamp(16px, 2vw, 23px);
}
#tutorialContent h3 {
  margin-top: 0;
}
#tutorialPanel .choices {
  align-items: center;
  flex-shrink: 0;
  margin-top: 16px;
}
#trainingBar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 1% 3% 0;
  font-size: clamp(11px, 1.2vw, 16px);
  font-weight: 700;
}
#trainingStats {
  direction: inherit;
}
#overview {
  width: 94%;
  height: 28px;
  min-height: 28px;
  margin: 3px auto 0;
  display: block;
  cursor: crosshair;
}
.overviewHint {
  fill: #b9e6a5 !important;
}
.training #board {
  height: 33%;
}
.training #noteRow {
  font-size: clamp(12px, 1.7vw, 23px);
  white-space: normal;
}
.training #wood {
  margin-top: 1%;
  padding-top: 2.5%;
}
.training #noteIcons {
  width: clamp(35px, 5vw, 65px);
}
.hintKey {
  outline: 3px solid #7eae45;
  outline-offset: -5px;
}
.black.hintKey {
  box-shadow:
    inset 0 -6px #7eae45,
    3px 4px 4px #0008;
}
#trainingResult {
  font-size: clamp(17px, 2.8vw, 32px);
  max-width: 700px;
  line-height: 1.8;
}
@media (orientation: landscape) and (max-height: 460px) {
  .learningPanel {
    padding: 9px;
  }
  .panelHeading h2 {
    font-size: 19px;
  }
  .learningColumns {
    gap: 10px;
    padding: 6px;
  }
  .lessonCard {
    padding: 8px;
  }
  .customPractice {
    padding: 10px;
  }
  .customPractice h3 {
    margin-bottom: 5px;
  }
  #settings {
    padding-block: 8px;
    gap: 6px;
  }
  #settings h2 {
    font-size: 20px;
  }
  .settingsSubtitle {
    font-size: 16px;
  }
  .advancedSettings label {
    font-size: 12px;
  }
  #trainingBar {
    margin-top: 3px;
    font-size: 10px;
  }
  #overview {
    height: 18px;
    min-height: 18px;
    margin-top: 0;
  }
  .training #board {
    height: 33%;
  }
  .training #wood {
    padding-top: 2%;
    margin-top: 3px;
  }
  .training #noteRow {
    font-size: 12px;
  }
  .training #rangeLabel {
    font-size: 9px;
  }
  #tutorialContent {
    padding: 12px;
    font-size: 15px;
    line-height: 1.8;
  }
  #tutorialContent p {
    margin: 0;
  }
}
@media (max-width: 700px) {
  .learningColumns {
    grid-template-columns: minmax(270px, 1fr) minmax(250px, 1fr);
    overflow: auto;
  }
  .panelHeading .choice {
    font-size: 12px;
  }
  .lessonCard {
    flex-wrap: wrap;
    gap: 3px;
  }
  .training #clefLabel {
    font-size: 11px;
  }
}

.learningColumns {
  flex: 1;
  overflow: hidden;
}
.learningColumns > section {
  overflow-y: auto;
  min-height: 0;
}
.learningColumns .customPractice {
  max-height: 100%;
  overflow-y: auto;
}
.training #board {
  height: 41%;
  display: grid;
  grid-template-columns: minmax(125px, 25%) 1fr;
  grid-template-rows: minmax(0, 1fr) 25px;
  gap: 0 8px;
  justify-content: initial;
  align-items: center;
}
.training #noteRow {
  grid-column: 1;
  grid-row: 1;
  flex-direction: column;
  height: 100%;
  white-space: normal;
  justify-content: center;
  gap: 3px;
  text-align: center;
}
.training #staff {
  grid-column: 2;
  grid-row: 1;
  height: 100%;
  width: 100%;
}
.training .boardFooter {
  grid-row: 2;
  grid-column: 1 / -1;
  height: 100%;
}
.training #noteIcons {
  height: 38%;
  min-height: 28px;
  flex-shrink: 1;
}
.training #clefLabel {
  font-size: clamp(10px, 1.2vw, 16px);
}
@media (orientation: landscape) and (max-height: 460px) {
  .training #board {
    height: 41%;
    grid-template-columns: 140px 1fr;
    grid-template-rows: minmax(0, 1fr) 23px;
  }
  .training #noteRow {
    font-size: 12px;
  }
  .training #trainingBar {
    font-size: 9px;
  }
  .training #wood {
    padding-top: 2%;
  }
  .training #noteIcons {
    width: 35px;
    height: 32px;
  }
  .training #clefLabel {
    font-size: 10px;
  }
  .training #trainingTitle {
    max-width: 150px;
  }
  .training .boardFooter #prompt {
    font-size: 10px;
  }
}

/* Main stations: a piano where every white key is a friend, low on the left. */
.stationsPanel {
  justify-content: flex-start;
  gap: 8px;
}
.stationsPrompt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 64px;
  margin: 0;
  font-size: clamp(17px, 2.4vw, 24px);
  font-weight: bold;
}
.stationsPrompt img {
  width: 64px;
  height: 64px;
  object-fit: contain;
}
.stationsStatus {
  min-height: 1.4em;
  margin: 0;
}
.stationsChoices {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  min-height: 60px;
  direction: ltr;
}
.stationChoice {
  display: grid;
  justify-items: center;
  gap: 2px;
  width: clamp(80px, 11vw, 118px);
  padding: 6px;
  border: 3px solid #f4c76b;
  border-radius: 18px;
  background: #fffaf0;
  color: #5b3f6b;
  font: inherit;
  font-size: clamp(13px, 1.65vw, 18px);
  font-weight: bold;
}
.stationChoice img {
  width: clamp(48px, 7vw, 76px);
  height: clamp(48px, 7vw, 76px);
  object-fit: contain;
}
.stationChoice.right {
  border-color: #3fae6b;
  box-shadow: 0 0 0 5px #3fae6b66;
}
.familyFlashcards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  width: min(900px, 100%);
}
.familyFlashcard {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-inline-size: 0;
  justify-items: center;
  align-content: start;
  gap: 10px;
  padding: 12px;
  border: 3px solid #f4c76b;
  border-radius: 22px;
  background: #fffaf0;
  color: #5b3f6b;
  font: inherit;
  font-weight: bold;
  cursor: pointer;
}
.familyFlashcard img {
  display: block;
  min-inline-size: 0;
  width: 100%;
  max-inline-size: 100%;
  height: clamp(100px, 20vh, 180px);
  object-fit: contain;
}
@media (orientation: landscape) and (max-height: 460px) {
  .familyFlashcards {
    grid-template-columns: repeat(
      auto-fit,
      minmax(clamp(72px, 16vw, 122px), 1fr)
    );
    gap: 8px;
  }
  .familyFlashcard {
    padding: 6px;
    gap: 4px;
  }
  .familyFlashcard img {
    height: clamp(70px, 24vh, 112px);
  }
}
.familyFlashcard.revealed {
  border-color: #3fae6b;
  background: #f0fff5;
}
.familyFlashcard:focus-visible {
  outline: 3px solid #7852b5;
  outline-offset: 3px;
}
.familyFlashcardNav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: 100%;
  direction: inherit;
}
.stationsChoices:has(.familyFlashcards) {
  width: min(900px, 100%);
  direction: inherit;
}
.stationsPiano[hidden] {
  display: none;
}
.stationChoice.tryAgain {
  opacity: 0.45;
}
.stationsPiano {
  display: flex;
  width: min(100%, 1100px);
  height: clamp(120px, 26vh, 200px);
  padding: 6px;
  border-radius: 16px;
  background: #3b2a3f;
}
.stationKey {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 1px 6px;
  border: 1px solid #b9a9bd;
  border-radius: 0 0 8px 8px;
  background: #fff;
  transition: background 160ms ease;
}
.stationKey img {
  width: 100%;
  max-width: 34px;
  aspect-ratio: 1;
  object-fit: contain;
}
.stationKey.station {
  background: #ffe7a3;
}
.stationKey .stationBlack {
  position: absolute;
  top: 0;
  left: 100%;
  z-index: 1;
  width: 46%;
  height: 50%;
  transform: translateX(-50%);
  border: 1px solid #140e19;
  border-radius: 0 0 4px 4px;
  background: linear-gradient(90deg, #211727, #45364d 45%, #211727);
  pointer-events: none;
}
.stationKey.target {
  background: #b6e3ff;
}
.stationKey.walk {
  background: #c9f2c7;
}
.stationKey.found {
  background: #9fe6a8;
}
.stationKey.arrive {
  background: #ffc94d;
  box-shadow: inset 0 0 0 3px #e08b00;
}
.stationKey.oops {
  animation: gentleWiggle 420ms ease;
}
.stationProgress strong {
  display: block;
}
.stationChart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 110px;
  margin-top: 8px;
}
.stationDay {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: 1fr auto;
  align-items: end;
  height: 100%;
  gap: 1px;
}
.stationDay .bar {
  min-height: 2px;
  border-radius: 3px 3px 0 0;
}
.stationDay small {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 10px;
}
.stationChart .families,
.stationLegend .families::before {
  background: #f0a04b;
}
.stationChart .stations,
.stationLegend .stations::before {
  background: #5b8def;
}
.stationChart .staff,
.stationLegend .staff::before {
  background: #3fae6b;
}
/* Staff game: one friend's note on the staff, above the piano. */
.stationStaff {
  width: min(420px, 100%);
  height: clamp(130px, 28vh, 230px);
  border-radius: 18px;
  background: #fffaf0;
}
/* «نت روی خط»: score and accuracy, and the note names under the staff. */
.stationsChoices:has(.staffNames) {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
}
.staffBoard {
  display: flex;
  gap: 18px;
  font-size: clamp(15px, 2.2vw, 22px);
  font-weight: bold;
}
.staffBoard span {
  padding: 2px 14px;
  border-radius: 999px;
  background: #fffaf0;
  color: #5b3f6b;
}
.staffBoard .staffTime {
  font-variant-numeric: tabular-nums;
}
.staffBoard .staffTime.low {
  background: #ffd9d9;
  color: #b3261e;
}
.staffNames {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}
.staffName {
  display: grid;
  place-items: center;
  min-width: clamp(48px, 7vw, 72px);
  min-height: 48px;
  padding: 4px 6px;
  border: 3px solid #f4c76b;
  border-radius: 14px;
  background: #fffaf0;
  color: #232020;
  font:
    bold clamp(17px, 2.6vw, 26px) / 1.1 system-ui,
    sans-serif;
  cursor: pointer;
}
.staffName small {
  color: #7b6a60;
  font-size: 0.6em;
}
.staffName.found {
  border-color: #2f8f55;
  background: #c9f0d5;
}
.staffName.target {
  border-color: #e08b00;
  box-shadow: 0 0 0 4px #ffd65a;
}
.staffName.oops {
  animation: gentleWiggle 420ms ease;
}
/* Short landscape screens: score on one side, names on the other, so the
   staff in the middle keeps its height. */
@media (orientation: landscape) and (max-height: 500px) {
  .stationsChoices:has(.staffNames) {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    width: 100%;
    gap: 10px;
  }
  .staffBoard {
    flex-direction: column;
    gap: 6px;
    font-size: 14px;
  }
  .stationsChoices:has(.staffNames) .stationStaff {
    width: 100%;
    height: clamp(100px, 31vh, 160px);
  }
  .staffNames {
    display: grid;
    grid-template-columns: repeat(4, auto);
    gap: 4px;
  }
  .staffName {
    min-width: 50px;
    min-height: 34px;
    padding: 1px 4px;
    font-size: 17px;
  }
  .staffName small {
    display: none;
  }
}
.stationLegend span {
  margin: 0 8px;
}
.stationLegend span::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-inline-end: 4px;
  border-radius: 2px;
}
@media (orientation: landscape) and (max-height: 500px) {
  .stationsPanel {
    gap: 4px;
    padding: 6px 10px;
  }
  .stationsPanel h2 {
    font-size: 17px;
  }
  .stationsPrompt {
    min-height: 44px;
    font-size: 16px;
  }
  .stationsPrompt img,
  .stationChoice img {
    width: 40px;
    height: 40px;
  }
  .stationChoice {
    width: 74px;
    padding: 3px;
    font-size: 11px;
  }
  .stationsPiano {
    height: 34vh;
  }
  .stationStaff {
    height: 30vh;
  }
}

/* Fa land tale: which part this is, and the way to the next one. */
.storyEpisode {
  display: block;
  margin: -4px 0 6px;
  color: #8b6a9c;
  font-weight: bold;
}
.storyPrevious {
  display: block;
  margin: 0 0 6px;
  color: #6b5a74;
  font-style: italic;
}
/* The story is heard, not read: its text stays for screen readers only. */
#storyText {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.childNameField {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 6px 0;
  font-weight: bold;
}
.childNameField input {
  width: 10em;
  padding: 6px 10px;
  border: 2px solid #c9b3d6;
  border-radius: 12px;
  font: inherit;
  text-align: center;
}
/* The story is being told: buttons wait until it ends. */
#adventurePanel.telling button {
  opacity: 0.45;
  filter: grayscale(0.6);
}
.gameCard.resting {
  opacity: 0.5;
  filter: grayscale(0.7);
}
/* Stations: the piano keys hide the friends until help is needed. */
.stationsPiano:not(.showPictures) .stationKey img {
  visibility: hidden;
}
/* Stickers (stickers.js): a pop for every right answer, and the album. */
#stickerPop {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
}
.stickerPop {
  position: absolute;
  inset: 0;
  margin: auto;
  width: min(180px, 40vw);
  height: min(180px, 40vw);
  display: grid;
  place-items: center;
  font-size: min(110px, 24vw);
  background: #fff;
  border-radius: 50%;
  border: 7px solid #f5c400;
  box-shadow: 0 10px 40px #0004;
  animation: stickerPop 1.4s ease forwards;
}
.stickerPop .popName {
  position: absolute;
  bottom: -42px;
  inset-inline: -60px;
  text-align: center;
  font-size: 26px;
  color: #fff;
  text-shadow: 0 2px 6px #0009;
}
@keyframes stickerPop {
  0% {
    transform: scale(0.2) rotate(-20deg);
    opacity: 0;
  }
  20% {
    transform: scale(1.12) rotate(6deg);
    opacity: 1;
  }
  32% {
    transform: scale(1) rotate(0);
  }
  75% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(38vw, -42vh) scale(0.2);
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .stickerPop {
    animation: none;
  }
}
.stickerBadge {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 6px;
  border-radius: 10px;
  background: #e63946;
  color: #fff;
  font-size: 0.8em;
}
.stickersPanel {
  text-align: center;
}
.stickerAlbumCount {
  color: #fff;
  font-weight: bold;
  font-size: 1.1em;
  text-shadow: 0 1px 4px #0008;
}
#stickerPage {
  color: #fff;
  font-weight: bold;
}
.stickerGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(76px, 20vw), 1fr));
  gap: 10px;
  max-width: 620px;
  margin: 10px auto;
}
.albumSticker {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  font-size: 40px;
  background: #f1ece5;
  border-radius: 50%;
  border: 3px dashed #d8cfc4;
  color: #bbb;
}
.albumSticker.shape-1 {
  border-radius: 22%;
}
.albumSticker.shape-2 {
  border-radius: 50% 50% 22% 22%;
}
.albumSticker.shape-3 {
  border-radius: 30% 70% 30% 70%;
}
.albumSticker.got {
  background: #fff;
  border: 4px solid #f5c400;
  color: inherit;
}
.albumSticker.got.tier-1 {
  border-color: #5aa9e6;
}
.albumSticker.got.tier-2 {
  border-color: #2bb673;
  background: #effbf4;
}
.albumSticker.got.tier-3 {
  border-color: #e75480;
  border-width: 5px;
  background: #fff0f5;
}
.albumSticker.got.tier-4 {
  border-color: #d4a017;
  border-width: 6px;
  background: #fff8dc;
  box-shadow: 0 0 0 3px #f6e27a;
}
.albumSticker.newest {
  outline: 3px dashed #e63946;
  outline-offset: 3px;
}
.albumCount {
  position: absolute;
  bottom: -6px;
  inset-inline-start: -4px;
  background: #e63946;
  color: #fff;
  font-size: 14px;
  line-height: 1;
  padding: 4px 7px;
  border-radius: 12px;
}
.stickerNav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 8px 0;
}
/* Families: the names of one note's friends; a found one shows its picture. */
.familyNames {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.familyName {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 4px 14px;
  border-radius: 22px;
  border: 3px dashed #c9b3d6;
  background: #fff;
  font-weight: bold;
  font-size: 1.1em;
}
.familyName.found {
  border: 3px solid #2bb673;
  background: #effbf4;
  animation: bump 0.5s;
}
.familyName img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}
.stationsPiano .stationKey.found img {
  visibility: visible;
}
@keyframes bump {
  50% {
    transform: scale(1.12);
  }
}
.familyName {
  color: #4b2d63;
}
/* In the families game the gold «دو» keys would give the answer away. */
.stationsPiano.families .stationKey.station:not(.found) {
  background: #fff;
}
/* 🖍️ Colouring (coloring.js) */
.coloringPanel {
  text-align: center;
}
.coloringStatus {
  color: #fff;
  font-weight: bold;
  text-shadow: 0 1px 4px #0008;
}
.coloringGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(110px, 28vw), 1fr));
  gap: 10px;
  max-width: 900px;
  margin: 8px auto;
}
.coloringCard {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 8px;
  border-radius: 18px;
  border: 3px solid #f5c400;
  background: #fff;
  font: inherit;
  font-weight: bold;
  color: #4b2d63;
}
.coloringCard img {
  width: 76px;
  height: 76px;
  object-fit: contain;
}
.coloringCard.todo {
  border-style: dashed;
  border-color: #c9b3d6;
}
.coloringCard.todo img {
  filter: grayscale(1) opacity(0.45);
}
.coloringBody {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.coloringBoard {
  position: relative;
  width: min(480px, 62vh, 92vw);
  aspect-ratio: 1;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 6px 20px #0003;
  touch-action: none;
}
.coloringBoard canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.coloringLines {
  pointer-events: none;
}
.coloringSide {
  display: grid;
  gap: 10px;
  justify-items: center;
  width: min(240px, 92vw);
}
.coloringExample {
  width: 130px;
  height: 130px;
  display: grid;
  place-items: center;
  background: #fff;
  border-radius: 18px;
  border: 3px solid #2bb673;
}
.coloringExample img {
  max-width: 110px;
  max-height: 110px;
}
.coloringPencils {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.penBtn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: var(--c, #fff);
  box-shadow: 0 2px 6px #0004;
  font-size: 24px;
}
.penBtn.on {
  outline: 4px solid #4b2d63;
  outline-offset: 2px;
  transform: scale(1.1);
}
.coloringDone:disabled {
  opacity: 0.5;
}
.coloringTools {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.bookPage {
  margin: 0;
  padding: 8px;
  background: #fff;
  border-radius: 16px;
  border: 3px solid #f5c400;
  color: #4b2d63;
  font-weight: bold;
  font-size: 0.85em;
}
.bookPage img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 10px;
}
.coloringBook {
  grid-template-columns: repeat(auto-fill, minmax(min(150px, 40vw), 1fr));
}
.printArea {
  display: none;
}
@media print {
  body.printing > *:not(#printArea) {
    display: none !important;
  }
  body.printing {
    background: #fff !important;
  }
  body.printing .printArea {
    display: block;
  }
  .printSheet {
    break-after: page;
    page-break-after: always;
    display: grid;
    grid-template-columns: 30% 1fr;
    grid-template-rows: auto 1fr;
    gap: 12px;
    height: 95vh;
    padding: 10mm;
    border: 2px solid #8bc34a;
    border-radius: 12px;
    box-sizing: border-box;
  }
  .printSheet header {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #333;
    font-family: inherit;
  }
  .printSheet h2 {
    margin: 0;
    font-size: 28pt;
    color: #000;
  }
  .printExample {
    width: 100%;
    object-fit: contain;
    align-self: start;
  }
  .printOutline {
    width: 100%;
    height: 100%;
    max-height: 78vh;
    min-height: 0;
    object-fit: contain;
  }
}
.voiceField {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0;
  font-weight: bold;
}

/* ⏱️ Beats (beats.js): hold a key while each beat fills. */
.beatsStage {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 0;
  /* Music reads left to right: the note, then its beats. */
  direction: ltr;
  flex-shrink: 0;
}
/* With the teacher's sheet open the note on the stage is smaller. */
.beatsPanel:has(.beatSheet) .beatsStage .beatNote {
  width: clamp(110px, 15vw, 170px);
}
.beatsPanel:has(.beatSheet) .beatDot {
  width: clamp(36px, 5vw, 50px);
}
.beatsStage:empty {
  display: none;
}
.beatNote {
  width: clamp(170px, 30vw, 280px);
  height: auto;
  border-radius: 18px;
  background: #fffaf0;
}
.beatNote.bare {
  width: 100%;
  height: 100%;
  background: none;
}
.beatDots {
  display: flex;
  gap: 10px;
}
.beatDot {
  --p: 0;
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(44px, 8vw, 64px);
  aspect-ratio: 1;
  overflow: hidden;
  border: 4px solid #f4c76b;
  border-radius: 50%;
  background: #fffaf0;
  color: #5b3f6b;
  font-size: clamp(18px, 3vw, 26px);
}
.beatDot i {
  position: absolute;
  inset: 0;
  background: #ffd65a;
  transform: scaleY(var(--p));
  transform-origin: bottom;
}
.beatDot b {
  position: relative;
}
.beatDot.counting {
  border-color: #e08b00;
  transform: scale(1.08);
}
.beatDot.done i {
  background: #ffc94d;
}
.beatsStage.letGo .beatDot,
.beatsStage.right .beatDot {
  border-color: #3fae6b;
}
.beatsStage.letGo .beatDot i,
.beatsStage.right .beatDot i {
  background: #9fe6a8;
}
.beatsStage.letGo .beatDots::after {
  content: "✋";
  align-self: center;
  font-size: 34px;
  animation: bump 0.5s infinite;
}
.beatsStage.tooLong .beatDot,
.beatsStage.wrong .beatDot {
  border-color: #e8675f;
}
.beatsStage.tooLong .beatDot i {
  background: #f7b2ad;
}
.beatCards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: 100%;
}
.beatCard {
  display: grid;
  justify-items: center;
  gap: 2px;
  width: clamp(110px, 20vw, 160px);
  padding: 8px;
  border: 3px solid #f4c76b;
  border-radius: 20px;
  background: #fffaf0;
  color: #5b3f6b;
  font: inherit;
  font-weight: bold;
  cursor: pointer;
}
.beatCard .beatNote {
  width: 100%;
}
.beatCard span {
  font-weight: normal;
}
.beatsPiano {
  width: min(100%, 620px);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.beatsPiano.listening .stationKey {
  pointer-events: none;
}
.stationKey.held {
  background: #ffd65a;
}
.beatsChoices:has(.beatSheet),
.beatsChoices:has(.beatCards) {
  width: min(900px, 100%);
}
/* Nothing in the panel squeezes under the piano. */
.beatsPanel > * {
  flex-shrink: 0;
}
.beatSheet {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 6px 10px;
  border-radius: 18px;
  background: #fffaf0;
}
.beatLine {
  display: flex;
  border-bottom: 1px dashed #ead8b8;
  justify-content: flex-start;
}
.beatBar {
  display: flex;
  flex: 1;
  justify-content: space-around;
  border-inline-end: 3px solid #e9879d;
}
.beatCell {
  width: clamp(26px, 4.5vw, 44px);
  height: clamp(32px, 6vh, 54px);
  border-radius: 10px;
}
.beatCell.now {
  background: #ffe7a3;
  box-shadow: 0 0 0 3px #e08b00;
}
.beatCell.done ellipse,
.beatCell.done line,
.beatCell.done circle {
  stroke: #2f8f55;
}
.beatCell.done [data-head="filled"],
.beatCell.done circle {
  fill: #2f8f55;
}
.beatCell.oops {
  animation: gentleWiggle 420ms ease;
}
@media (orientation: landscape) and (max-height: 500px) {
  .beatNote {
    width: 150px;
  }
  .beatDot {
    width: 38px;
    font-size: 16px;
  }
  .beatCard {
    width: 84px;
    padding: 2px 4px;
    font-size: 12px;
    gap: 0;
  }
  .beatCard .beatNote {
    height: 44px;
  }
  .beatsChoices .heroChoice {
    min-height: 0;
    padding: 6px 14px;
    font-size: 14px;
  }
  .beatsChoices {
    gap: 6px;
    min-height: 0;
  }
  .beatSheet {
    gap: 0;
    padding: 2px 8px;
  }
  .beatCell {
    height: 30px;
  }
  /* Only the line being played, so the piano stays in view. */
  .beatSheet:has(.now) .beatLine:not(:has(.now)) {
    display: none;
  }
  .beatsPanel:has(.beatSheet) .beatsStage .beatNote {
    width: 110px;
  }
  .beatsPanel .beatsPiano {
    height: 24vh;
  }
  .beatsPiano {
    height: 28vh;
  }
}

/* Phones held sideways, with the browser's bars taking their share: often
   under 340px of height. Nothing in the stations and beats panels may
   squeeze under the piano; the title goes, the home button moves to the
   corner, and the staff and piano share what is left. */
.stationsPanel > * {
  flex-shrink: 0;
}
@media (orientation: landscape) and (max-height: 340px) {
  .stationsPanel {
    gap: 3px;
    padding: 4px 8px;
  }
  .stationsPanel h2 {
    display: none;
  }
  .stationsPanel > .choice:last-child {
    position: absolute;
    top: 4px;
    inset-inline-start: 6px;
    min-height: 0;
    padding: 3px 10px;
    font-size: 13px;
  }
  .stationsPrompt {
    min-height: 0;
    padding-inline: 70px;
    font-size: 14px;
  }
  .stationsStatus {
    margin: 0;
    font-size: 12px;
  }
  .stationsChoices {
    min-height: 0;
    gap: 6px;
  }
  .stationsChoices .choice {
    min-height: 0;
    padding: 5px 12px;
    font-size: 14px;
  }
  /* The piano takes the height that is left. */
  .stationsPanel > .stationsPiano {
    flex: 1 1 0;
    height: auto;
    min-height: 64px;
    max-height: 46vh;
  }
  .stationStaff,
  .stationsChoices:has(.staffNames) .stationStaff {
    height: 36vh;
    min-height: 84px;
  }
  .staffBoard {
    gap: 3px;
    font-size: 12px;
  }
  .staffBoard span {
    padding: 1px 8px;
  }
  .staffName {
    min-width: 40px;
    min-height: 28px;
    font-size: 15px;
  }
  .beatNote,
  .beatsPanel:has(.beatSheet) .beatsStage .beatNote {
    width: 120px;
  }
  .beatDot,
  .beatsPanel:has(.beatSheet) .beatDot {
    width: 30px;
    border-width: 3px;
    font-size: 13px;
  }
  .beatCell {
    height: 24px;
  }
  /* The teacher's sheet and its back button share one row. */
  .beatsChoices:has(.beatSheet) {
    flex-wrap: nowrap;
    align-items: center;
  }
  .beatsChoices .beatSheet {
    flex: 1;
    min-width: 0;
  }
}

@font-face {
  font-family: "Noto Naskh Arabic";
  src: url("assets/fonts/NotoNaskhArabic-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Noto Naskh Arabic";
  src: url("assets/fonts/NotoNaskhArabic-Bold.ttf") format("truetype");
  font-weight: 700 900;
  font-display: swap;
}
html:lang(fa) {
  font-family: "Noto Naskh Arabic", system-ui, sans-serif;
}
html:lang(fa) body {
  font-family: inherit;
}
