* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(160deg, #8a3f16, #d9822b);
  font-family: ui-rounded, "Avenir Next", "Trebuchet MS", system-ui, sans-serif;
  color: #3b1d0c;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  /* room at the top so a tall card never slides under the mic button */
  padding: calc(58px + env(safe-area-inset-top)) 0 calc(12px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.hidden { display: none !important; }

/* ---------- mic ---------- */

#topRight {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 10;
}

#micBtn {
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  background: rgba(60, 20, 0, 0.45);
  color: #fff;
  font-size: 12px;
  letter-spacing: 2px;
  padding: 8px 12px;
  min-height: 40px;
}

#micBtn[aria-pressed="true"] { background: rgba(255, 255, 255, 0.92); color: #a2410f; }

/* ---------- cards ---------- */

.card {
  width: min(600px, calc(100% - 24px));
  max-height: 100%;
  overflow-y: auto;
  padding: 20px 20px 24px;
  border-radius: 28px;
  background: #fff8ee;
  box-shadow: 0 10px 0 rgba(60, 20, 0, 0.3);
  text-align: center;
  animation: pop 0.3s ease-out;
}

@keyframes pop {
  from { transform: scale(0.92); opacity: 0; }
}

h1, h2 {
  margin: 4px 0 6px;
  letter-spacing: 1.5px;
  color: #b4471a;
}

h1 { font-size: clamp(26px, 7vw, 38px); }
h2 { font-size: clamp(22px, 6vw, 30px); }

.tag { margin: 4px 0 10px; font-size: 17px; }
.tag b { color: #2f8a3a; }
.note { margin: 10px 0; font-size: 14px; opacity: 0.75; }
.ask { margin: 18px 0 8px; font-size: 20px; font-weight: 700; }

.label {
  font-size: 12px;
  letter-spacing: 2px;
  font-weight: 700;
  color: #b4471a;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.buddy { font-size: 52px; line-height: 1; display: inline-block; }

.big {
  margin-top: 12px;
  padding: 14px 24px;
  border: 0;
  border-radius: 18px;
  background: #ffd23f;
  box-shadow: 0 6px 0 #d9a400;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1.5px;
}

.big:active { transform: translateY(4px); box-shadow: 0 2px 0 #d9a400; }
.big.plain { background: #f6e3cc; box-shadow: 0 6px 0 #dcbf9c; }
.big.plain:active { box-shadow: 0 2px 0 #dcbf9c; }

.small {
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  background: #f6e3cc;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  min-height: 36px;
}

.buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 12px; }

/* ---------- lesson list ---------- */

#lessonList {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

#lessonList button {
  border: 0;
  border-radius: 16px;
  background: #f6e3cc;
  box-shadow: 0 4px 0 #dcbf9c;
  padding: 10px 8px;
  font-size: 15px;
  font-weight: 700;
  min-height: 70px;
}

#lessonList button:active { transform: translateY(3px); box-shadow: 0 1px 0 #dcbf9c; }
#lessonList .num { display: block; font-size: 11px; letter-spacing: 2px; color: #b4471a; }
#lessonList .got { display: block; font-size: 14px; margin-top: 4px; letter-spacing: 2px; }

/* ---------- slides ---------- */

#slidePic {
  margin: 4px auto 10px;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 46vh;
  border-radius: 18px;
  background: #f6e3cc;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 90px;
}

#slidePic img { width: 100%; height: 100%; object-fit: contain; }

#slidePic { position: relative; }
.bowHold { width: 100%; height: 100%; }
.bowHold [data-part] { opacity: 0; transition: opacity 0.7s, transform 0.9s ease-out; }
.bowHold .fromTop { transform: translateY(-40px); }
.bowHold .fromBottom { transform: translateY(40px); }
.bowHold [data-part].in { opacity: 1; transform: none; }
.bowHold .tags text { font-size: 14px; font-weight: 700; fill: #7a4a2a; }
.bowHold.finished .tags text { fill: #2f8a3a; }
#slidePic .again { position: absolute; right: 10px; bottom: 10px; }

/* ---------- meters ---------- */

.meter {
  position: relative;
  height: 54px;
  margin: 12px 0 4px;
  border-radius: 14px;
  background: linear-gradient(90deg, #ffd0c2, #fff3df 35%, #fff3df 65%, #ffd0c2);
  overflow: hidden;
}

.meter .zone {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 20%;
  transform: translateX(-50%);
  background: #bfe8b9;
}

.meter .mid {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 2px;
  background: #2f8a3a;
}

.meter .needle {
  position: absolute;
  top: 6px; bottom: 6px;
  left: 50%;
  width: 10px;
  margin-left: -5px;
  border-radius: 5px;
  background: #999;
  opacity: 0;
  transition: left 0.08s linear, background 0.15s;
}

.meter.on .needle { opacity: 1; }
.meter.good .needle { background: #2f8a3a; }
.meter.off .needle { background: #e2571b; }

.meter .lo, .meter .hi {
  position: absolute;
  bottom: 3px;
  font-size: 11px;
  letter-spacing: 1px;
  opacity: 0.6;
}

.meter .lo { left: 8px; }
.meter .hi { right: 8px; }

.hint { margin: 8px 0; font-size: 19px; font-weight: 700; min-height: 2.6em; }
.hint.good { color: #2f8a3a; }
.hint.off { color: #d3480f; }

/* ---------- tuner ---------- */

#tuneNote { font-size: 72px; font-weight: 800; line-height: 1; color: #b4471a; }

#tuneStrings {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

#tuneStrings .str {
  border-radius: 16px;
  background: #f6e3cc;
  padding: 8px 4px;
  font-weight: 800;
  font-size: 28px;
  border: 3px solid transparent;
}

#tuneStrings .str.now { border-color: #2f8a3a; box-shadow: 0 0 0 4px #4fd65a; color: #2f8a3a; }
#tuneStrings .str.ok { background: #bfe8b9; }
#tuneStrings .str small { display: block; font-size: 11px; letter-spacing: 1px; font-weight: 700; opacity: 0.7; }
#tuneStrings .str button { margin-top: 6px; }

/* ---------- lesson ---------- */

#lesson {
  width: min(1100px, calc(100% - 20px));
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: pop 0.3s ease-out;
}

.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
}

.bar .label { color: #fff; }

#micBanner {
  background: #fff3c4;
  border-radius: 14px;
  padding: 8px 12px;
  text-align: center;
  font-weight: 700;
}

.staffBox {
  background: #fff8ee;
  border-radius: 20px;
  padding: 4px 8px;
  flex: none;
}

#staff { display: block; width: 100%; height: clamp(90px, 16vh, 140px); }

.lessonBody {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(120px, 32%) 1fr;
  gap: 10px;
}

#board {
  width: 100%;
  height: 100%;
  background: #fff8ee;
  border-radius: 20px;
}

.panel {
  background: #fff8ee;
  border-radius: 20px;
  padding: 14px 16px;
  overflow-y: auto;
  text-align: center;
}

#noteName { font-size: clamp(56px, 11vh, 96px); font-weight: 800; line-height: 1; color: #b4471a; }
#noteHow { font-size: 19px; font-weight: 700; margin-top: 2px; }

#bow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 6px 16px;
  border-radius: 999px;
  background: #f6e3cc;
  font-size: 17px;
  font-weight: 700;
}

#bow .sign { font-size: 24px; color: #b4471a; }
#bow.flip { animation: flip 0.6s ease-in-out 3; }

@keyframes flip {
  50% { background: #ffd23f; transform: scale(1.08); }
}

.hold {
  height: 12px;
  border-radius: 6px;
  background: #f0dcc4;
  overflow: hidden;
}

#holdFill { height: 100%; width: 0; background: #2f8a3a; border-radius: 6px; }

.panel .big { font-size: 15px; padding: 12px 16px; }

/* ---------- done ---------- */

#stars { font-size: 48px; letter-spacing: 6px; margin: 6px 0; }
#stars .dim { opacity: 0.2; filter: grayscale(1); }
#done > .small { margin-top: 14px; }

@media (max-width: 640px) {
  .lessonBody { grid-template-columns: 110px 1fr; }
  .panel { padding: 10px; }
  .hint { font-size: 16px; }
  #noteHow { font-size: 16px; }
}
