* {
  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: 3px 4px 4px #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(58% / var(--white-count));
  height: 57%;
}
.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;
}
#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;
  }
}

.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);
}
#piano.trainingKeys {
  overflow-x: auto;
  overflow-y: hidden;
  touch-action: pan-x;
  scrollbar-width: thin;
  direction: ltr;
  isolation: isolate;
}
.trainingKeys .key {
  flex: 0 0 calc(max(100%, var(--keyboard-width)) / var(--white-count));
  width: calc(max(100%, var(--keyboard-width)) / var(--white-count));
  touch-action: pan-x;
}
.trainingKeys .black {
  width: calc(max(100%, var(--keyboard-width)) / var(--white-count) * 0.58);
  touch-action: pan-x;
}
.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;
  }
}
