:root {
  --bg: #16151a;
  --surface: #222127;
  --line: #34323b;
  --ivory: #f1eadb;
  --text: #e3dccd;
  --muted: #9a9384;
  --accent: #c9a361;
  --accent-2: #e2c07f;
  --key-white: #f4efe4;
  --key-white-2: #ddd6c6;
  --key-black: #141317;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: "Vazirmatn", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.9;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; }
h1:focus, h2:focus { outline: none; }

.app {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
  background: radial-gradient(900px 500px at 50% -10%, #27252e, transparent 70%);
}

/* ---------- top ---------- */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px clamp(20px, 5vw, 48px);
}
.logo { color: var(--accent); font-size: 1.4rem; }
.progress { display: flex; align-items: center; gap: 12px; }
.progress-label { font-size: .85rem; color: var(--muted); }
.progress-bar {
  width: 120px;
  height: 2px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--line);
}
.progress-bar i { display: block; width: 0; height: 100%; background: var(--accent); transition: width .5s ease; }

/* ---------- steps ---------- */
.stage {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 16px clamp(20px, 5vw, 48px) 64px;
}
.step {
  width: 100%;
  max-width: 640px;
  text-align: center;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .4s ease, transform .4s ease;
}
.step.in { opacity: 1; transform: none; }
.step.out { opacity: 0; transform: translateY(-10px); }

.kicker { margin: 0 0 .6em; font-size: .85rem; color: var(--accent); }
.script {
  font-family: "Great Vibes", "Brush Script MT", cursive;
  font-size: clamp(2.2rem, 5vw, 3rem);
  line-height: 1.3;
  direction: ltr;
  unicode-bidi: isolate;
}
.kicker.script { margin-bottom: .1em; }
h1, h2 { margin: 0 0 .4em; font-weight: 500; line-height: 1.6; color: var(--ivory); }
h1 { font-size: clamp(1.9rem, 5vw, 3rem); }
h2 { font-size: clamp(1.6rem, 4vw, 2.4rem); }
.lead {
  max-width: 44ch;
  margin: 0 auto 1.2em;
  color: var(--muted);
  font-size: clamp(1rem, 1.6vw, 1.12rem);
}
.text { max-width: 52ch; margin: 0 auto; }
.text p { margin: 0 0 1em; font-size: clamp(1.02rem, 1.7vw, 1.15rem); }
.hint { margin: 1.6em 0 0; font-size: .8rem; color: var(--muted); }

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 1.4em;
}
.btn {
  padding: .75em 1.8em;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #17151a;
  font-weight: 500;
  cursor: pointer;
  transition: background .2s, border-color .2s, transform .15s, opacity .2s;
}
.btn:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--ivory); outline-offset: 3px; }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn:disabled:hover { background: var(--accent); border-color: var(--accent); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { background: rgba(255, 255, 255, .03); border-color: var(--muted); }

/* ---------- piano step ---------- */
.message {
  max-width: 560px;
  min-height: 96px;
  margin: 0 auto 20px;
  padding: 14px 22px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.message-note {
  display: inline-block;
  margin-bottom: 2px;
  padding: 0 .7em;
  border: 1px solid rgba(201, 163, 97, .4);
  border-radius: 999px;
  font-size: .75rem;
  color: var(--accent);
}
.message p { margin: 0; font-size: clamp(1rem, 1.8vw, 1.15rem); color: var(--ivory); }
.message.pop { animation: pop .4s ease; }
@keyframes pop { from { opacity: .4; transform: scale(.97); } }

.piano {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: 12px;
  background: linear-gradient(180deg, #2a282f, #1c1b20);
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, .8);
}
.keyboard {
  position: relative;
  display: flex;
  gap: 3px;
  height: clamp(170px, 28vw, 210px);
  padding: 4px;
  border-radius: 6px;
  background: #0e0d10;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.white-key {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding: 0 0 10px;
  border: 0;
  border-radius: 0 0 6px 6px;
  background: linear-gradient(180deg, #faf6ec, var(--key-white) 80%, var(--key-white-2));
  color: #6b655a;
  line-height: 1.4;
  cursor: pointer;
  box-shadow: inset 0 -6px 0 #cfc7b6;
  transition: transform .08s, background .2s, box-shadow .08s;
  -webkit-tap-highlight-color: transparent;
}
.white-key .solf { font-weight: 500; font-size: .9rem; }
.white-key.found .solf { color: #9a7a3a; }
.white-key.found::before { content: "•"; color: var(--accent); }
.white-key.pressed {
  transform: translateY(2px);
  background: linear-gradient(180deg, #efe6d2, #e2d7bd);
  box-shadow: inset 0 -2px 0 #c2b79f;
}
.black-key {
  position: absolute;
  top: 4px;
  z-index: 2;
  width: calc((100% - 29px) / 8 * .6);
  height: 60%;
  padding: 0;
  border: 0;
  border-radius: 0 0 5px 5px;
  background: linear-gradient(180deg, #2b2a30, var(--key-black));
  cursor: pointer;
  transform: translateX(-50%);
  box-shadow: inset 0 -5px 0 #000, 0 4px 6px rgba(0, 0, 0, .5);
  transition: background .2s, box-shadow .08s;
  -webkit-tap-highlight-color: transparent;
}
.black-key.pressed { background: linear-gradient(180deg, #3d3b44, #232227); box-shadow: inset 0 -2px 0 #000; }
.keyboard kbd { font: inherit; font-size: .65rem; opacity: .45; }
.black-key kbd { position: absolute; bottom: 8px; left: 0; right: 0; color: #fff; }
.white-key:focus-visible, .black-key:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.dots { display: flex; justify-content: center; gap: 8px; margin: 22px 0 4px; }
.dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--line); transition: background .3s, transform .3s; }
.dots span.on { background: var(--accent); transform: scale(1.2); }
.counter { margin: 0; font-size: .9rem; color: var(--muted); }

@media (hover: none) {
  .keyboard kbd, .hint.kbd { display: none; }
}

/* ---------- note ---------- */
.note {
  padding: clamp(24px, 5vw, 40px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  text-align: start;
}
.note p { margin: 0 0 1em; font-size: clamp(1rem, 1.7vw, 1.12rem); }
.note .note-greet { color: var(--ivory); font-weight: 500; }
.note .sign { margin: 1.2em 0 0; text-align: left; color: var(--accent); }

/* ---------- responsive / motion ---------- */
@media (max-width: 480px) {
  .piano { padding: 8px; }
  .white-key .solf { font-size: .78rem; }
  .progress-bar { width: 70px; }
  .actions .btn { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) {
  .step, .step.in, .step.out { transition: none; transform: none; }
  .message.pop { animation: none; }
}
