.listening-grid {
  grid-template-columns: repeat(auto-fit, minmax(0, 300px));
  justify-content: center;
  padding-block: 28px;
}

.listening-grid .card-top {
  justify-content: center;
  min-height: 104px;
}

.listening-content {
  --lilac-surface: #f5effa;
  --lilac-button: #e9dcf4;
  --lilac-hover: #decaef;
  --lilac-border: #bca3d1;
  --lilac-ink: #50366b;
  --lilac-accent: #765095;
  width: min(100%, 780px);
  margin-inline: auto;
  padding: clamp(16px, 4vw, 32px);
  color: #19334d;
  font-size: 17px;
  line-height: 1.55;
}

.instructions {
  margin-bottom: 16px;
  padding: 12px 16px;
  border: 1px solid var(--lilac-border);
  border-radius: 16px;
  background: var(--lilac-surface);
  color: var(--lilac-ink);
}

.genre-picker {
  margin-bottom: 16px;
  color: var(--lilac-ink);
}

.genre-picker h2 {
  font-size: 17px;
}

.genre-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.worksheet-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  min-height: 44px;
  padding: 6px 12px;
  border: 1px solid #a5d7db;
  border-radius: 10px;
  background: #e3f8fa;
  color: #144b51;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.worksheet-link:hover {
  background: #c8f3f1;
}

.genre-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.genre-tabs button {
  min-width: 76px;
  min-height: 44px;
  padding: 6px 16px;
  border: 1px solid var(--lilac-border);
  border-radius: 10px;
  background: var(--lilac-surface);
  color: var(--lilac-ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.genre-tabs button:hover {
  background: var(--lilac-button);
}

.genre-tabs button[aria-selected="true"] {
  background: var(--lilac-hover);
  border-color: var(--lilac-accent);
}

.song, .verse, .results {
  border: 1px solid #d7e5ef;
  border-radius: 16px;
  padding: clamp(13px, 3vw, 22px);
}

.song {
  background: var(--lilac-surface);
  border-color: var(--lilac-border);
  color: var(--lilac-ink);
}

.song h2, .lyrics h2, .results h2 {
  color: #0a0f4a;
  font-size: 22px;
}

.song h2 {
  color: var(--lilac-ink);
}

.song audio, .player-controls {
  width: 100%;
  margin-top: 12px;
}

.player-controls:not([hidden]) {
  display: flex;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
}

.playback-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.player-controls button, .choices button {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.player-controls button {
  border-radius: 50%;
  border: 1px solid var(--lilac-border);
  color: var(--lilac-ink);
  background: var(--lilac-surface);
}

.player-controls .play-button {
  width: 52px;
  height: 52px;
  background: var(--lilac-button);
}

.player-controls .play-button:hover,
.skip-button:hover:not(:disabled) {
  background: var(--lilac-hover);
}

.skip-button:disabled {
  opacity: .55;
  cursor: default;
}

.play-button .pause-icon,
.play-button.is-playing .play-icon {
  display: none;
}

.play-button.is-playing .pause-icon {
  display: block;
}

.playback-progress {
  flex: 1 1 210px;
}

.song-position {
  display: block;
  width: 100%;
  min-height: 28px;
  accent-color: var(--lilac-accent);
  cursor: pointer;
}

.playback-times {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.playback-error:not(:empty) {
  color: #a1202b;
  margin-top: 8px;
}

.lyrics, .results {
  margin-top: 24px;
}

.lyrics {
  line-height: 2.5;
}

@media screen and (min-width: 1001px) {
  .lyrics {
    font-size: 21px;
  }
}

.verse {
  margin-top: 12px;
}

.verse h3 {
  margin-bottom: 9px;
  color: #225a8e;
  font-size: 17px;
}

.lyric-line + .lyric-line {
  margin-top: 8px;
}

.learning-methods-lyrics .verse p + .lyric-line,
.learning-methods-lyrics .lyric-line + p {
  margin-top: 8px;
}

.refrain {
  margin-bottom: 8px;
  font-weight: 700;
}

.choices {
  display: inline-flex;
  gap: 4px;
  vertical-align: middle;
}

.choices button {
  position: relative;
  padding-inline: 8px;
  border: 1px solid var(--lilac-border);
  border-radius: 8px;
  background: var(--lilac-surface);
  color: var(--lilac-ink);
}

.choices button:hover:not(:disabled) {
  background: var(--lilac-button);
}

.choices button:disabled {
  cursor: default;
}

.choices button:disabled[aria-pressed="false"] {
  opacity: .32;
}

.choices .is-wrong {
  background: #ff91b8;
  border-color: #d62d68;
  color: #6e1035;
}

.choices .is-correct, .results.is-complete {
  background: #c8f3f1;
  border-color: #50a8aa;
  color: #144b51;
}

.confetti-burst {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  pointer-events: none;
}

.confetti-burst > span {
  position: absolute;
  inset: 0 auto auto 0;
  width: 6px;
  height: 9px;
  border-radius: 2px;
  color: #17a59a;
  background: currentColor;
  animation: confetti-pop 640ms ease-out both;
}

.confetti-burst > span:nth-child(3n + 2) {
  color: #a875cc;
}

.confetti-burst > span:nth-child(3n + 3) {
  color: #f3b740;
}

.confetti-burst > .confetti-note {
  width: 16px;
  height: 16px;
  background: transparent;
}

.confetti-note svg {
  display: block;
  width: 100%;
  height: 100%;
}

@keyframes confetti-pop {
  0% { transform: rotate(var(--angle)) translateY(-8px) scale(.5); }
  22% { opacity: 1; }
  100% {
    transform: rotate(var(--angle)) translateY(calc(-1 * var(--distance))) rotate(140deg);
    opacity: 0;
  }
}

.listening-content :focus-visible {
  outline: 3px solid var(--lilac-accent);
  outline-offset: 2px;
}

.results {
  background: var(--lilac-surface);
  border-color: var(--lilac-border);
}

.score {
  margin-top: 4px;
  font-weight: 700;
}

.retry-button {
  min-height: 44px;
  margin-top: 12px;
  padding: 8px 16px;
  border: 1px solid var(--lilac-border);
  border-radius: 8px;
  background: var(--lilac-button);
  color: var(--lilac-ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.retry-button:hover {
  background: var(--lilac-hover);
}

.song-credits {
  margin-top: 16px;
  padding: 12px 16px;
  border: 1px solid #9adadf;
  border-radius: 16px;
  background: #e3f8fa;
  color: #144b51;
  text-align: center;
  font-size: 14px;
}

.empty-state {
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.worksheet-view {
  display: block;
  min-height: 0;
  padding: 16px;
  color: #182630;
}

.worksheet-toolbar {
  max-width: 210mm;
  margin: 0 auto 12px;
  text-align: right;
}

.worksheet {
  page: listening-worksheet;
  max-width: 210mm;
  margin: 0 auto;
  padding: clamp(16px, 4vw, 12mm);
  background: #fff;
  font: 12pt/1.4 "Segoe UI", Arial, sans-serif;
}

.worksheet-header {
  padding-bottom: 3mm;
  border-bottom: 1px solid #5c4770;
}

.worksheet-header h1, .worksheet-key .worksheet-header h2 {
  font-size: 21pt;
  line-height: 1.15;
}

.worksheet-header p {
  margin-top: 1mm;
  color: #50366b;
  font-weight: 700;
}

.worksheet-details {
  display: grid;
  grid-template-columns: 2fr 2fr 1fr 1fr;
  gap: 4mm;
  margin: 4mm 0;
}

.worksheet-field {
  display: flex;
  align-items: baseline;
  gap: 1.5mm;
  font-size: 10pt;
}

.worksheet-field-line {
  flex: 1;
  min-width: 8mm;
  height: 1em;
  border-bottom: 1px solid #61717a;
}

.worksheet-instruction {
  margin-bottom: 3mm;
  font-weight: 700;
}

.worksheet-word-box {
  margin-bottom: 4mm;
  padding: 2.5mm 3mm;
  border: 1px solid #79658a;
  border-radius: 3mm;
  background: #f5effa;
  font-size: 10pt;
  break-inside: avoid;
}

.worksheet-word-box ul {
  display: flex;
  flex-wrap: wrap;
  gap: 1mm 4mm;
  margin-top: 1mm;
  list-style: none;
}

.worksheet-lyrics {
  column-count: 2;
  column-gap: 8mm;
  column-rule: 1px solid #4d4d4d;
}

.worksheet-verse {
  display: inline-block;
  width: 100%;
  margin-bottom: 3mm;
  break-inside: avoid;
}

.worksheet-verse h2 {
  margin-bottom: 1mm;
  color: #50366b;
  font-size: 12pt;
}

.worksheet-verse p + p {
  margin-top: .7mm;
}

.worksheet-blank {
  display: inline-block;
  white-space: nowrap;
}

.worksheet-blank sup {
  margin-inline-end: .8mm;
  font-size: 8pt;
  color: #50366b;
}

.worksheet-blank-line {
  display: inline-block;
  width: 28mm;
  height: .9em;
  border-bottom: 1px solid #384953;
}

.worksheet-questions {
  margin-top: 4mm;
  padding-top: 3mm;
  border-top: 1px solid #5c4770;
  break-inside: avoid;
}

.worksheet-questions h2 {
  margin-bottom: 2mm;
  font-size: 12pt;
}

.worksheet-questions ol {
  padding-inline-start: 6mm;
  column-count: 2;
  column-gap: 10mm;
  column-rule: 1px solid #4d4d4d;
}

.worksheet-questions-single-column ol {
  column-count: 1;
}

.worksheet-questions li {
  break-inside: avoid;
}

.worksheet-questions li + li {
  margin-top: 2mm;
}

.worksheet-answer-line {
  display: block;
  width: min(100%, 125mm);
  height: 6mm;
  border-bottom: 1px solid #384953;
}

.worksheet-true-false ol {
  padding-inline-start: 0;
  column-count: 1;
  list-style: none;
  counter-reset: true-false;
}

.worksheet-true-false li {
  display: grid;
  grid-template-columns: 18mm auto minmax(0, 1fr);
  align-items: start;
  column-gap: 2mm;
}

.worksheet-true-false li::before {
  counter-increment: true-false;
  content: counter(true-false) ".";
  grid-area: 1 / 2;
}

.worksheet-true-false-box {
  grid-area: 1 / 1;
  min-height: 7mm;
  border: 1px solid #384953;
  border-radius: 1mm;
}

.worksheet-statement {
  grid-area: 1 / 3;
}

.worksheet-key {
  margin-top: 16px;
}

.worksheet-key-section {
  margin-top: 5mm;
}

.worksheet-key-section h3 {
  margin-bottom: 2mm;
  font-size: 12pt;
}

.worksheet-key-section ol {
  padding-inline-start: 7mm;
}

.worksheet-key-section li {
  margin-bottom: 1mm;
  break-inside: avoid;
}

.worksheet-key-words {
  column-count: 3;
  column-gap: 12mm;
}

.worksheet-brand {
  width: 36mm;
  margin: 6mm 0 0 auto;
  color: #263845;
  text-align: center;
  font-size: 8pt;
  line-height: 1.25;
}

.worksheet-brand img {
  display: block;
  width: 26mm;
  height: 26mm;
  margin: 0 auto 2mm;
}

.worksheet-true-false-with-qr {
  position: relative;
  min-height: 44mm;
  padding-right: 40mm;
}

.worksheet-true-false-with-qr .worksheet-brand {
  position: absolute;
  top: 2mm;
  right: 0;
  margin: 0;
}

@media screen and (max-width: 680px) {
  .worksheet-lyrics { column-count: 1; }
  .worksheet-questions ol { column-count: 1; }
  .worksheet-details { grid-template-columns: 1fr 1fr; }
  .worksheet-key-words { column-count: 2; }
}

@page listening-worksheet {
  size: A4 portrait;
  margin: 12mm;
}

@media print {
  .worksheet-view {
    padding: 0;
    background: #fff;
  }

  .worksheet-toolbar { display: none; }
  .worksheet {
    display: flex;
    flex-direction: column;
    min-height: 270mm;
    max-width: none;
    padding: 0;
  }
  .worksheet-key { break-before: page; margin-top: 0; }
  .worksheet-lyrics { line-height: 1.22; }
  .worksheet-verse { margin-bottom: 2mm; }
  .worksheet-verse p + p { margin-top: .35mm; }
  .worksheet-questions { margin-top: 3mm; padding-top: 2mm; }
  .worksheet-questions li + li { margin-top: 1.3mm; }
  .worksheet-answer-line { height: 5mm; }
  .worksheet-brand { margin: auto 0 0 auto; padding-top: 2mm; break-inside: avoid; }
  .worksheet-compact { font-size: 11pt; }
  .worksheet-compact .worksheet-verse { margin-bottom: 1.5mm; }
  .worksheet-compact .worksheet-questions { margin-top: 2mm; padding-top: 1.5mm; }
  .worksheet-compact .worksheet-questions li + li { margin-top: 1mm; }
  .worksheet-compact .worksheet-answer-line { height: 4mm; }
}
