:root{
  --bg:#0b1020;
  --text:#eef2ff;
  --muted:#b7c0ff;
  --stroke:rgba(255,255,255,.12);
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius: 18px;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:
    radial-gradient(1200px 700px at 15% 10%, rgba(63,169,245,.20), transparent 55%),
    radial-gradient(1200px 700px at 92% 22%, rgba(254,146,29,.14), transparent 55%),
    var(--bg);
  color:var(--text);
}

/* Header */
.topbar{
  display:flex;
  gap:14px;
  align-items:flex-start;
  padding:18px 18px 0;
  max-width:1200px;
  margin:0 auto;
}
.back{
  color:var(--text);
  text-decoration:none;
  border:1px solid var(--stroke);
  border-radius:999px;
  padding:10px 12px;
  background: rgba(0,0,0,.18);
}
.title h1{margin:0; font-size:24px}
.title p{margin:4px 0 0; color:var(--muted)}

/* Layout */
.layout{
  max-width:1200px;
  margin:16px auto 24px;
  padding:0 18px;
  display:grid;
  grid-template-columns: 420px 1fr;
  gap:16px;
}

/* Panel */
.panel{
  background: rgba(0,0,0,.18);
  border:1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding:14px;
  backdrop-filter: blur(10px);
  height: fit-content;
}

.hud{
  display:grid;
  grid-template-columns: repeat(4, 1fr);
  gap:10px;
  margin-bottom: 12px;
}
.stat{
  border:1px solid var(--stroke);
  border-radius: 14px;
  padding:10px;
  background: rgba(255,255,255,.04);
}
.stat.wide{grid-column: 1 / -1;}
.label{
  display:block;
  font-size:12px;
  color:var(--muted);
  margin-bottom:6px;
}
.stat span:last-child{
  font-size:18px;
  font-weight:1000;
}

.settings{
  border-top: 1px solid var(--stroke);
  padding-top: 10px;
  margin-top: 6px;
}
label{
  display:flex;
  flex-direction:column;
  gap:6px;
  font-size:13px;
  color: var(--muted);
}
select{
  border-radius: 12px;
  border:1px solid var(--stroke);
  background: rgba(0,0,0,.22);
  color: var(--text);
  padding:10px;
  font-size:16px;
}

.help{
  border-top: 1px solid var(--stroke);
  padding-top: 10px;
  margin-top: 10px;
  color: rgba(255,255,255,.86);
  line-height: 1.35;
}
.helpRow{
  display:flex;
  gap:10px;
  align-items:baseline;
  margin: 6px 0;
}
.helpRow strong{white-space:nowrap}
.helpRow small{color: var(--muted)}

/* Stage */
.stage{
  position: relative;
  background: rgba(0,0,0,.18);
  border:1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  padding: 14px;
  display:flex;
  flex-direction:column;
  gap:12px;
}

.topStrip{
  display:flex;
  gap:12px;
  align-items:stretch;
  justify-content:space-between;
  flex-wrap: wrap;
}

.prompt{
  flex: 1;
  min-width: 260px;
  border:1px solid rgba(255,255,255,.14);
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(255,255,255,.06);
}
.promptTitle{
  font-size: 18px;
  font-weight: 1000;
}
.promptSub{
  margin-top: 4px;
  color: rgba(255,255,255,.82);
  font-size: 14px;
  font-weight: 800;
}

.topButtons{
  display:flex;
  gap:10px;
  align-items:stretch;
}

.primary,.secondary{
  border-radius: 16px;
  border:1px solid rgba(255,255,255,.14);
  padding: 14px 16px;
  font-size: 16px;
  font-weight: 1000;
  color: white;
  background: rgba(255,255,255,.08);
  box-shadow: 0 10px 22px rgba(0,0,0,.35);
  cursor:pointer;
  user-select:none;
  -webkit-user-select:none;
  touch-action: manipulation;
}
.primary:active,.secondary:active{transform: scale(.99)}
.primary[disabled], .secondary[disabled]{
  opacity: .45;
  cursor: not-allowed;
}

.progress{
  width: 180px;
  border:1px solid rgba(255,255,255,.14);
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(255,255,255,.06);
}
.progressLabel{
  font-size:12px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 900;
}
.progressValue{
  font-size: 22px;
  font-weight: 1000;
}

/* Keyboard */
.keyboard{
  display:grid;
  grid-template-columns: repeat(8, 1fr); /* now includes high C (octave) */
  gap: 10px;
  width: 100%;
  user-select:none;
  -webkit-user-select:none;
  touch-action: manipulation;
}

.key{
  position:relative;
  border-radius: 18px;
  border: 2px solid rgba(255,255,255,.14);
  height: min(48vh, 360px);
  min-height: 220px;
  box-shadow: 0 14px 28px rgba(0,0,0,.35);
  overflow:hidden;
  cursor:pointer;

  display:flex;
  align-items:flex-end;
  justify-content:center;

  padding: 14px 10px;
}

.key::after{
  content:"";
  position:absolute;
  inset:0;
  background: radial-gradient(600px 240px at 50% 15%, rgba(255,255,255,.22), transparent 60%);
  opacity: .9;
  pointer-events:none;
}

.keyInner{
  position:relative;
  z-index:2;
  width: 100%;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap: 10px;
}

.noteLabel{
  font-size: 46px;
  font-weight: 1000;
  color: white;
  text-shadow: 0 6px 14px rgba(0,0,0,.35);
  line-height: 1;
}

.degreeLabel{
  font-size: 18px;
  font-weight: 1000;
  color: rgba(255,255,255,.92);
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(0,0,0,.14);
  padding: 6px 10px;
  border-radius: 999px;
  box-shadow: 0 10px 20px rgba(0,0,0,.22);
}

/* DEMO highlight */
.key.isLit{
  transform: translateY(-2px);
  border-color: rgba(255,255,255,.55);
  box-shadow: 0 18px 38px rgba(0,0,0,.45);
  outline: 6px solid rgba(255,255,255,.40);
  outline-offset: 2px;
}

/* PRESS highlight (always shown on touch, even during demo) */
.key.isPressed{
  transform: translateY(-1px);
  border-color: rgba(255,255,255,.65);
  box-shadow: 0 18px 38px rgba(0,0,0,.50);
  outline: 6px solid rgba(255,255,255,.60);
  outline-offset: 2px;
}

/* Feedback states */
.key.isGood{
  outline: 6px solid rgba(122,201,67,.85);
  outline-offset: 2px;
}

.key.isBad{
  outline: 6px solid rgba(255,29,37,.85);
  outline-offset: 2px;
}

/* Big message */
.bigMessage{
  min-height: 44px;
  text-align:center;
  font-weight: 1000;
  font-size: 22px;
  color: rgba(255,255,255,.92);
}

/* Modal */
.modal{
  position:absolute;
  inset: 14px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(0,0,0,.55);
  border-radius: 16px;
}
.hidden{ display:none; }

.modalCard{
  width: min(620px, 94%);
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(20,26,52,.92);
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
  padding: 16px;
}
.modalCard h2{
  margin: 0 0 8px 0;
  font-size: 28px;
}
.modalCard p{
  margin: 0 0 14px 0;
  color: rgba(255,255,255,.92);
  line-height: 1.35;
  font-size: 16px;
  white-space: pre-line;
}
.modalButtons{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.modalSmall{
  margin-top: 10px;
  color: rgba(255,255,255,.75);
  font-size: 13px;
}

/* Responsive */
@media (max-width: 980px){
  .layout{grid-template-columns: 1fr;}
  .keyboard{
    grid-template-columns: repeat(4, 1fr);
  }
  .key{
    height: 220px;
    min-height: 180px;
  }
  .noteLabel{font-size: 40px;}
  .progress{width: 160px;}
  .modalButtons{grid-template-columns: 1fr;}
}
