:root {
  --bg-1: #f6f5ef;
  --bg-2: #dce8e2;
  --paper: #fffefa;
  --ink: #1d2a28;
  --muted: #536662;
  --accent: #1f7a66;
  --accent-2: #ea9f47;
  --error: #a73737;
  --ok: #176a31;
  --card-shadow: 0 20px 50px rgba(18, 37, 33, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(234, 159, 71, 0.23), transparent 45%),
    radial-gradient(circle at 90% 100%, rgba(31, 122, 102, 0.25), transparent 40%),
    linear-gradient(140deg, var(--bg-1), var(--bg-2));
  font-family: "Manrope", "Segoe UI", sans-serif;
}

.app-shell {
  width: min(1400px, 90vw);
  margin: 0.8rem auto 1rem;
}

.hero {
  margin-bottom: 0.55rem;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
  font-weight: 700;
}

h1,
h2 {
  font-family: "Fraunces", Georgia, serif;
}

h1 {
  margin: 0.1rem 0 0.2rem;
  font-size: clamp(1.6rem, 2.5vw, 2.5rem);
  line-height: 1.1;
}

.intro {
  margin: 0;
  color: var(--muted);
  max-width: 70ch;
  font-size: 0.93rem;
}

.trainer-card {
  background: var(--paper);
  border: 1px solid rgba(29, 42, 40, 0.1);
  box-shadow: var(--card-shadow);
  border-radius: 20px;
  padding: 0.95rem;
  display: grid;
  gap: 0.8rem;
}

.scoreboard {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

#score-label {
  font-weight: 700;
}

.controls-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.difficulty-label {
  font-size: 0.92rem;
  color: var(--muted);
}

#difficulty-select,
#scale-select,
#question-type-select {
  border: 1px solid #9eb0ab;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 0.96rem;
  padding: 0.55rem 0.7rem;
}

#difficulty-select:focus,
#scale-select:focus,
#question-type-select:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 25%, white);
  outline-offset: 1px;
  border-color: var(--accent);
}

#question-prompt {
  margin: 0;
  padding: 0.5rem 0.6rem;
  border: 1px solid rgba(29, 42, 40, 0.18);
  border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 6%, white);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.92rem;
}

button {
  border: 0;
  border-radius: 10px;
  background: linear-gradient(140deg, var(--accent), #0f5a4a);
  color: #fff;
  font-weight: 700;
  padding: 0.65rem 0.95rem;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}

button:hover {
  filter: brightness(1.06);
}

button:active {
  transform: translateY(1px) scale(0.99);
}

.notation-wrap,
.keyboard-wrap {
  border: 1px solid rgba(29, 42, 40, 0.12);
  border-radius: 14px;
  padding: 0.55rem;
  background: #fff;
}

.keyboard-wrap {
  display: grid;
  grid-template-rows: auto 1fr;
}

h2 {
  margin: 0 0 0.35rem;
  font-size: 1.02rem;
}

#notation {
  width: 100%;
  min-height: 250px;
  overflow-x: auto;
}

.keyboard {
  position: relative;
  height: 156px;
  width: 100%;
  border: 1px solid #bac7c4;
  border-radius: 10px;
  overflow: hidden;
  background: #f8f8f6;
  align-self: center;
}

.key {
  position: absolute;
  border: 1px solid #111;
  border-radius: 0 0 6px 6px;
  transition: background-color 150ms ease;
}

.keyboard.complete-mode .key {
  cursor: pointer;
}

.keyboard.complete-mode .key:hover {
  background: color-mix(in srgb, var(--accent) 35%, white);
}

.keyboard.complete-mode .key.black:hover {
  background: color-mix(in srgb, var(--accent) 55%, black);
}

.key.white {
  background: #fff;
  width: var(--white-width);
  height: 100%;
  z-index: 1;
}

.key.black {
  background: #181818;
  width: var(--black-width);
  height: 62%;
  z-index: 3;
}

.key.active.white {
  background: color-mix(in srgb, var(--accent-2) 55%, white);
}

.key.active.black {
  background: color-mix(in srgb, var(--accent-2) 80%, black);
}

#answer-form {
  display: grid;
  gap: 0.35rem;
}

label {
  font-weight: 700;
}

.answer-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
  align-items: start;
}

.autocomplete-wrap {
  position: relative;
}

input {
  width: 100%;
  border: 1px solid #9eb0ab;
  border-radius: 10px;
  font-size: 1rem;
  padding: 0.52rem 0.65rem;
}

input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 25%, white);
  outline-offset: 1px;
  border-color: var(--accent);
}

.suggestions {
  position: absolute;
  top: calc(100% + 0.3rem);
  left: 0;
  right: 0;
  z-index: 30;
  margin: 0;
  padding: 0.2rem;
  list-style: none;
  background: #fff;
  border: 1px solid #b9c8c4;
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(16, 36, 32, 0.16);
  max-height: 160px;
  overflow-y: auto;
}

.suggestions[hidden] {
  display: none;
}

.suggestion-item {
  border-radius: 8px;
  padding: 0.42rem 0.5rem;
  cursor: pointer;
  font-size: 0.95rem;
}

.suggestion-item:hover,
.suggestion-item.active {
  background: color-mix(in srgb, var(--accent) 16%, white);
}

#feedback {
  margin: 0;
  min-height: 1.1rem;
  color: var(--muted);
  font-size: 0.93rem;
}

#feedback.good {
  color: var(--ok);
  font-weight: 700;
}

#feedback.bad {
  color: var(--error);
  font-weight: 700;
}

#bass-pattern-info {
  margin: 0;
  min-height: 1rem;
  color: var(--muted);
  font-size: 0.88rem;
}

@media (min-width: 780px) {
  .trainer-card {
    grid-template-columns: minmax(340px, 1fr) minmax(420px, 1.25fr);
    grid-template-areas:
      "scoreboard scoreboard"
      "notation keyboard"
      "answer answer";
    align-items: stretch;
  }

  .scoreboard {
    grid-area: scoreboard;
  }

  .notation-wrap {
    grid-area: notation;
  }

  .keyboard-wrap {
    grid-area: keyboard;
  }

  #answer-form {
    grid-area: answer;
  }
}

@media (max-width: 760px) {
  .app-shell {
    margin: 0.65rem auto 1rem;
  }

  .trainer-card {
    padding: 0.7rem;
    border-radius: 16px;
  }

  .answer-row {
    grid-template-columns: 1fr;
  }

  .controls-group {
    width: 100%;
  }

  #difficulty-select,
  #scale-select,
  #question-type-select,
  #next-btn {
    flex: 1;
  }
}
