/* =====================================================
   Rhythmus-Lernapp – Globale Styles
   BEM-Konvention, kein CSS-Nesting (Safari-Kompatibilitaet)
   ===================================================== */

/* 1. Custom Properties */
:root {
  --color-ganze: #FFD700;
  --color-halbe: #00CC00;
  --color-viertel: #FF6600;
  --color-achtel: #87CEEB;
  --color-ganze-light: #FFF3B0;
  --color-halbe-light: #A8E6A8;
  --color-viertel-light: #FFCC99;
  --color-achtel-light: #D4EEFF;
  --color-correct: #22C55E;
  --color-wrong: #EF4444;
  --color-neutral: #D1D5DB;
  --color-bg: #F9FAFB;
  --color-text: #1F2937;
  --color-text-muted: #6B7280;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.15);
  --font: 'Nunito', sans-serif;
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
}

/* 2. Reset & Base */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 1rem;
  min-height: 100vh;
  line-height: 1.5;
}

img {
  max-width: 100%;
  height: auto;
}

button {
  font-family: var(--font);
  cursor: pointer;
}

a {
  color: inherit;
}

/* 3. App Layout */
#app {
  max-width: 700px;
  margin: 0 auto;
  padding: var(--spacing-md);
  min-height: calc(100vh - 60px);
}

.app-footer {
  text-align: center;
  padding: 12px var(--spacing-md);
  font-size: 13px;
  color: #9CA3AF;
  max-width: 700px;
  margin: 0 auto;
}

.app-footer a {
  text-decoration: underline;
  color: #9CA3AF;
}

/* 4. Level-Auswahl */
.level-select {
  padding-top: var(--spacing-sm);
}

.level-select__title {
  font-size: 28px;
  font-weight: 800;
  text-align: center;
  margin-bottom: var(--spacing-lg);
  color: var(--color-text);
}

.stage-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: var(--spacing-md);
  box-shadow: var(--shadow);
}

.stage-card__title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--color-text);
}

.stage-card__subtitle {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-sm);
  margin-top: var(--spacing-sm);
}

.level-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
}

.level-btn {
  min-width: 52px;
  min-height: 44px;
  padding: var(--spacing-sm) 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--color-neutral);
  color: var(--color-text);
  font-family: var(--font);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}

.level-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.level-btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.level-btn:focus-visible {
  outline: 3px solid var(--color-achtel);
  outline-offset: 2px;
}

/* 5. Level-Header */
.level-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: var(--spacing-sm);
}

.level-header__back {
  background: none;
  border: 2px solid var(--color-neutral);
  border-radius: var(--radius-sm);
  padding: var(--spacing-sm) 14px;
  font-family: var(--font);
  font-size: 16px;
  color: var(--color-text);
  cursor: pointer;
  min-height: 44px;
  white-space: nowrap;
  transition: border-color 0.15s ease;
}

.level-header__back:hover {
  border-color: var(--color-text-muted);
}

.level-header__title {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  flex: 1;
}

.level-header__progress {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  position: relative;
}

.progress-bar {
  font-size: 16px;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.error-tolerance {
  display: flex;
  gap: 3px;
}

.error-tolerance__symbol {
  font-size: 16px;
  line-height: 1;
}

.error-tolerance__symbol--used {
  opacity: 0.25;
}

.error-hint-popup {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: white;
  border: 2px solid var(--color-neutral);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 18px;
  font-weight: 500;
  line-height: 1.5;
  width: 260px;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.error-hint-popup__close {
  display: block;
  margin-top: 10px;
  margin-left: auto;
  background: none;
  border: 2px solid var(--color-neutral);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
}

/* 6. Feedback */
.feedback {
  text-align: center;
  padding: 12px var(--spacing-md);
  border-radius: var(--radius);
  font-size: 20px;
  font-weight: 700;
  min-height: 52px;
  margin: 12px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.feedback--correct {
  background: #DCFCE7;
  color: #166534;
}

.feedback--wrong {
  background: #FEE2E2;
  color: #991B1B;
}

/* 7. Animationen */
@keyframes pulse-correct {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.3); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.btn--correct-animate {
  animation: pulse-correct 0.4s ease;
}

.btn--wrong-animate {
  animation: shake 0.4s ease;
}

/* 8. Summary / Zusammenfassung */
.summary {
  text-align: center;
  padding: var(--spacing-xl) var(--spacing-md);
}

.summary__score {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: var(--spacing-md);
  color: var(--color-text);
}

.summary__rating {
  font-size: 22px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-sm);
}

.summary__actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: var(--spacing-lg);
}

/* 9. Basis-Buttons */
.btn-primary {
  min-height: 48px;
  padding: 10px var(--spacing-lg);
  border: none;
  border-radius: var(--radius);
  background: var(--color-correct);
  color: white;
  font-family: var(--font);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-primary:active {
  opacity: 1;
  transform: translateY(0);
}

.btn-primary:focus-visible {
  outline: 3px solid var(--color-correct);
  outline-offset: 2px;
}

.btn-secondary {
  min-height: 48px;
  padding: 10px var(--spacing-lg);
  border: 2px solid var(--color-neutral);
  border-radius: var(--radius);
  background: white;
  color: var(--color-text);
  font-family: var(--font);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-secondary:hover {
  border-color: var(--color-text-muted);
  transform: translateY(-1px);
}

.btn-secondary:active {
  transform: translateY(0);
}

.btn-secondary:focus-visible {
  outline: 3px solid var(--color-neutral);
  outline-offset: 2px;
}

/* 10. Quiz-Placeholder (wird in Phase 2 erweitert) */
.quiz {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}


.quiz__symbol {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--spacing-lg);
  border-radius: var(--radius);
  min-height: 120px;
}

.quiz__answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-sm);
}

.quiz__answer-btn {
  min-height: 56px;
  padding: 10px var(--spacing-sm);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  background: white;
  color: var(--color-text);
  font-family: var(--font);
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  -webkit-tap-highlight-color: transparent;
}

.quiz__answer-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.quiz__answer-btn:active {
  transform: translateY(0);
}

.quiz__answer-btn:focus-visible {
  outline: 3px solid var(--color-achtel);
  outline-offset: 2px;
}

.quiz__answer-btn--correct {
  background: #DCFCE7;
  border-color: var(--color-correct);
  color: #166534;
}

.quiz__answer-btn--wrong {
  background: #FEE2E2;
  border-color: var(--color-wrong);
  color: #991B1B;
}

/* 11. Responsive Anpassungen */
@media (max-width: 480px) {
  .level-select__title {
    font-size: 24px;
  }

  .stage-card__title {
    font-size: 18px;
  }

  .level-btn {
    min-width: 48px;
    font-size: 16px;
  }

  .quiz__answers {
    grid-template-columns: 1fr;
  }

  .summary__score {
    font-size: 26px;
  }
}

@media (min-width: 600px) {
  .level-select__title {
    font-size: 32px;
  }
}

/* 12. Quiz-Styles (Phase 2) */
.quiz__prompt {
  text-align: center;
  margin-bottom: 20px;
}

.quiz__question {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 16px;
  line-height: 1.4;
}

.quiz__prompt-visual {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 20px 32px;
  border-radius: 12px;
  margin: 8px 0;
  min-width: 120px;
  min-height: 100px;
}

.quiz__prompt-text {
  font-size: 36px;
  font-weight: 800;
  text-align: center;
  line-height: 1.3;
}

.quiz__options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.quiz__option {
  min-height: 72px;
  padding: 12px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  background: var(--color-neutral);
  -webkit-tap-highlight-color: transparent;
}

.quiz__option:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.quiz__option:disabled {
  cursor: default;
  transform: none;
}

.quiz__option:focus-visible {
  outline: 3px solid var(--color-achtel);
  outline-offset: 2px;
}

.quiz__option-label {
  font-size: 13px;
  font-weight: 600;
}

.quiz__prompt-visual img {
  height: 160px;
  width: auto;
}

.quiz__option img {
  height: 160px;
  width: auto;
  max-width: 100%;
}

@media (max-width: 480px) {
  .quiz__options {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .quiz__option {
    min-height: 64px;
    font-size: 16px;
    padding: 8px;
  }

  .quiz__prompt-text {
    font-size: 28px;
  }

  .quiz__question {
    font-size: 19px;
  }

  .quiz__prompt-visual img {
    height: 110px;
  }

  .quiz__option img {
    height: 110px;
  }
}

/* 13. Grid */
.grid {
  display: grid;
  width: 100%;
  min-height: 64px;
  position: relative;
  border: 2px solid var(--color-neutral);
  border-radius: var(--radius);
  overflow: hidden;
}

.grid__cell {
  height: 160px;
  border-right: 1px solid var(--color-neutral);
  background: white;
}

.grid__cell:last-child {
  border-right: none;
}

.grid__block {
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding-left: 4px;
  border-radius: 4px;
  z-index: 1;
  position: relative;
  min-height: 60px;
  border-right: 2px solid rgba(0, 0, 0, 0.15);
}

.grid__block img {
  height: 160px;
  width: auto;
}

/* Doppelachtel: vertikale Trennlinie bei 55% */
.grid__block--doppelachtel {
  position: relative;
  justify-content: center;
  padding-left: 0;
}

.grid__block--doppelachtel::after {
  content: '';
  position: absolute;
  left: 55%;
  top: 10%;
  height: 80%;
  width: 2px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 1px;
}

.grid__block--neutral {
  background: white;
  border: 2px solid #9CA3AF;
}

.grid__block--neutral-dashed {
  border-style: dashed;
}

/* Beat-Labels */
.grid__beat-labels {
  display: grid;
  width: 100%;
  margin-top: 6px;
}

.grid__beat-label {
  text-align: center;
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
  user-select: none;
}

.grid__beat-label--neutral {
  color: var(--color-neutral);
}

/* 14. Slider (Level 2.1) */
.slider__aufgabe {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  margin: 16px 0;
}

.slider__grid-wrapper {
  margin: 16px 0 4px;
}

.slider__beat-labels-container {
  margin-bottom: 16px;
}

.slider__arrows {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin: 12px 0;
}

.slider__arrow {
  min-width: 56px;
  min-height: 56px;
  border: 2px solid var(--color-neutral);
  border-radius: var(--radius);
  background: white;
  font-size: 24px;
  cursor: pointer;
  font-family: var(--font);
}

.slider__arrow:disabled {
  opacity: 0.3;
  cursor: default;
}

.slider__ok {
  display: block;
  margin: 12px auto;
}

/* 15. Identify (Stufe 2) */
.identify__aufgabe { font-size: 22px; font-weight: 700; text-align: center; margin: 16px 0; line-height: 1.4; }
.identify__svg-wrapper { display: flex; flex-direction: column; align-items: center; padding: 16px 24px; border-radius: var(--radius); margin: 8px auto; gap: 8px; width: fit-content; }
.identify__note-name { font-size: 16px; font-weight: 700; }
.identify__grid-wrapper { margin: 12px 0; }
.identify__beat-labels-wrapper { margin-bottom: 8px; }
.identify__toggles { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin: 16px 0; }
.toggle-btn { min-height: 52px; border: 2px solid var(--color-neutral); border-radius: 8px; font-family: var(--font); font-size: 18px; font-weight: 700; cursor: pointer; background: var(--color-neutral); color: #6B7280; transition: transform 0.1s; padding: 4px; }
.toggle-btn:hover { transform: scale(1.05); }
.toggle-btn--aus { background: var(--color-neutral); color: #6B7280; }
.toggle-btn--angeschlagen { color: white; font-weight: 800; }
.toggle-btn--nicht-angeschlagen { font-weight: 600; }
.identify__pruefen { display: block; margin: 8px auto; }
.identify__optionen { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 16px; }
.identify__option-btn { min-height: 72px; border: none; border-radius: var(--radius); font-family: var(--font); font-size: 16px; font-weight: 700; cursor: pointer; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 6px; transition: transform 0.1s; padding: 8px 8px 8px 12px; }
.identify__option-btn--doppelachtel { align-items: center; padding-left: 8px; }
.identify__option-btn:hover { transform: translateY(-2px); }
.identify__option-btn img { height: 160px; width: auto; }
.identify__option-label { font-size: 13px; }
.identify__svg-wrapper img { height: 160px; width: auto; }
.identify__zz-hinweis { font-size: 16px; text-align: center; color: #6B7280; margin: 8px 0; }
.identify__toggles--4 { grid-template-columns: repeat(4, 1fr); }
.identify__korrektur { margin: 12px 0; }
.identify__korrektur-labels { margin-bottom: 8px; }
.identify__naechste { display: block; margin: 12px auto 0; }

/* 16. Drag & Drop */
.drag-ghost {
  cursor: grabbing;
  user-select: none;
  touch-action: none;
}

.drag-ghost img {
  height: 160px;
  width: auto;
}

.grid__snap-preview {
  background: rgba(34, 197, 94, 0.25);
  border: 2px dashed #22C55E;
  border-radius: 4px;
  pointer-events: none;
  z-index: 2;
}

.grid__snap-preview--invalid {
  background: rgba(239, 68, 68, 0.25);
  border-color: #EF4444;
}

/* Vorrats-Bereich (Stufe 3) */
.vorrat {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  padding: 12px;
  background: white;
  border: 2px solid var(--color-neutral);
  border-radius: var(--radius);
}

.vorrat__block {
  min-height: 60px;
  min-width: 60px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: grab;
  padding: 8px;
  gap: 4px;
  user-select: none;
  touch-action: none;
}

.vorrat__block img {
  height: 160px;
  width: auto;
}

.vorrat__block:active {
  cursor: grabbing;
}

/* 17. Builder (Stufe 3) */
.builder__aufgabe { font-size: 22px; font-weight: 700; text-align: center; margin: 16px 0; }
.builder__grid-wrapper { margin: 12px 0; }
.builder__beat-labels-wrapper { margin-bottom: 8px; }
.builder__pattern { display: grid; gap: 4px; margin: 12px 0; }
.builder__pattern-cell { text-align: center; font-size: 22px; font-weight: 800; padding: 8px 4px; border-radius: 6px; }
.builder__pattern-cell--angeschlagen { background: var(--color-correct); color: white; }
.builder__pattern-cell--leer { background: var(--color-neutral); color: #9CA3AF; }
.builder__vorrat { margin-top: 16px; }
.vorrat__label { font-size: 12px; font-weight: 700; text-align: center; }
.builder__pruefen { display: block; margin: 12px auto; }
.builder__audio-btn { display: block; margin: 8px auto; }
.builder__naechste { display: block; margin: 16px auto; }
.builder__notation { font-size: 28px; font-weight: 800; text-align: center; letter-spacing: 0.3em; margin: 16px 0; color: var(--color-text); }

/* ── Stufe 2: Bündelung (Zuordnen) ─────────────────── */
.bundle__description {
  font-size: 18px;
  text-align: center;
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-md);
}

.bundle__header {
  display: grid;
  gap: var(--spacing-sm);
  font-weight: bold;
  text-align: center;
  font-size: 14px;
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-xs);
  padding: 0 var(--spacing-sm);
}

.bundle__rows {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.bundle__row {
  display: grid;
  align-items: center;
  gap: var(--spacing-sm);
  background: white;
  border-radius: 8px;
  padding: var(--spacing-sm);
  box-shadow: var(--shadow);
}

.bundle__anchor {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60px;
  gap: 4px;
}

.bundle__anchor img {
  height: 48px;
  width: auto;
}

.bundle__anchor--achtel img {
  height: 34px;
}

.bundle__slot {
  min-height: 44px;
  min-width: 44px;
  border: 2px dashed var(--color-neutral);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  transition: border-color 0.2s, background-color 0.2s;
  padding: 4px;
}

.bundle__slot--filled {
  border-style: solid;
}

.bundle__slot--highlight {
  border-color: var(--color-correct);
  background: rgba(34, 197, 94, 0.1);
}

.bundle__slot--correct {
  border-color: var(--color-correct);
  background: rgba(34, 197, 94, 0.15);
}

.bundle__slot--wrong {
  border-color: var(--color-wrong);
  background: rgba(239, 68, 68, 0.15);
}

.bundle__chip {
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: grab;
  user-select: none;
  touch-action: none;
  font-size: 1rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.2s;
}

.bundle__chip img {
  height: 32px;
  width: auto;
}

.bundle__chip--placed {
  cursor: pointer;
}

.bundle__vorrat {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  padding: var(--spacing-md);
  background: white;
  border: 2px solid var(--color-neutral);
  border-radius: 10px;
  min-height: 60px;
  justify-content: center;
  margin-top: var(--spacing-md);
}

.bundle__correction {
  font-size: 0.85rem;
  color: #166534;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.bundle__correction img {
  height: 24px;
  width: auto;
}

.bundle__pruefen {
  display: block;
  margin: 16px auto;
}

.bundle__anchor--text {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  min-height: 48px;
  padding: 4px;
  word-break: break-word;
}

.bundle__zwischenfeedback {
  max-width: 480px;
  margin: 32px auto;
  padding: 24px;
  text-align: center;
}

.bundle__runden-liste {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bundle__runden-item {
  font-size: 1.1rem;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
}

.bundle__runden-item--korrekt {
  background: #D1FAE5;
  color: #065F46;
}

.bundle__runden-item--falsch {
  background: #FEE2E2;
  color: #991B1B;
}

.bundle__zwischenfeedback-text {
  font-size: 1.1rem;
  margin: 0 0 24px;
  line-height: 1.5;
}

.bundle__zwischenfeedback-btn {
  min-width: 200px;
}

/* 18. Responsive Design */
/* Phone (<480px) */
@media (max-width: 480px) {
  html { font-size: 16px; }
  #app { padding: 10px; }
  .level-select__title { font-size: 22px; }
  .quiz__options { grid-template-columns: 1fr 1fr; gap: 8px; }
  .quiz__option { min-height: 60px; font-size: 16px; }
  .identify__toggles { gap: 4px; }
  .toggle-btn { font-size: 16px; min-height: 44px; }
  .builder__pattern { gap: 2px; }
  .builder__pattern-cell { font-size: 18px; padding: 6px 2px; }
  .vorrat { gap: 6px; padding: 8px; }
  .vorrat__block { min-width: 48px; min-height: 52px; }
  .bundle__chip { font-size: 0.85rem; padding: 6px 8px; }
  .bundle__anchor img { height: 36px; }
  .bundle__anchor--achtel img { height: 26px; }
  .bundle__vorrat { padding: var(--spacing-sm); gap: 6px; }
}

/* iPad Portrait (768px) */
@media (min-width: 481px) and (max-width: 900px) {
  #app { max-width: 90%; padding: 16px; }
  .quiz__options { grid-template-columns: 1fr 1fr; gap: 12px; }
  .identify__toggles { gap: 8px; }
}

/* Desktop (>1024px) */
@media (min-width: 1024px) {
  #app { max-width: 700px; }
  .quiz__options { grid-template-columns: 1fr 1fr; }
  .grid { max-width: 600px; margin: 0 auto; }
  .grid__beat-labels { max-width: 600px; margin: 0 auto; }
}

/* Grid responsiv */
.grid-container {
  width: min(90%, 600px);
  margin: 0 auto;
}

/* 19. Verbesserte Animationen */
@keyframes pulse-correct-v2 {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(34,197,94,0); }
  50% { transform: scale(1.08); box-shadow: 0 0 0 8px rgba(34,197,94,0.3); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

@keyframes shake-v2 {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-8px); }
  30% { transform: translateX(8px); }
  45% { transform: translateX(-6px); }
  60% { transform: translateX(6px); }
  75% { transform: translateX(-4px); }
  90% { transform: translateX(4px); }
}

@keyframes snap-in {
  0% { transform: scale(0.9); opacity: 0.5; }
  100% { transform: scale(1); opacity: 1; }
}

.grid__block {
  animation: snap-in 0.2s ease;
}

/* 20. Touch & Edge Cases */

/* Doppeltipp-Praevention */
button {
  touch-action: manipulation;
}

/* Drag-Bereiche */
.vorrat__block {
  touch-action: none;
}

.grid__block {
  touch-action: none;
}

/* Smooth Block-Snap */
.grid__block {
  transition: background-color 0.15s ease;
}

/* Cursor-Balken fuer Audio-Playback */
.grid__cursor {
  position: absolute;
  top: 0;
  width: 3px;
  height: 100%;
  background: rgba(0,0,0,0.6);
  pointer-events: none;
  z-index: 3;
  transition: left 0.1s linear;
}

/* 21. Accessibility */

/* Sichtbarer Focus-Indikator */
button:focus-visible {
  outline: 3px solid #3B82F6;
  outline-offset: 2px;
}

/* Focus fuer Toggle-Buttons */
.toggle-btn:focus-visible {
  outline: 3px solid #3B82F6;
  outline-offset: 2px;
}

/* =====================
   Onboarding Modal
   ===================== */

.onboarding-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.onboarding-modal {
  background: white;
  border-radius: 16px;
  padding: 24px 24px 20px;
  max-width: 360px;
  width: calc(100% - 32px);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.onboarding-modal__close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 44px;
  height: 44px;
  border: none;
  background: none;
  font-size: 20px;
  cursor: pointer;
  border-radius: 8px;
  color: #6B7280;
  display: flex;
  align-items: center;
  justify-content: center;
}

.onboarding-modal__close:hover {
  background: #F3F4F6;
}

.onboarding-modal__title {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  color: var(--color-text);
}

.onboarding-modal__previews {
  display: flex;
  align-items: center;
  gap: 8px;
}

.onboarding-modal__preview-btn {
  width: 52px;
  height: 52px;
  border: 2px solid var(--color-neutral);
  border-radius: 8px;
  font-family: var(--font);
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  padding: 0;
}

.onboarding-modal__preview-btn--aus {
  background: var(--color-neutral);
  color: #6B7280;
}

.onboarding-modal__preview-btn--angeschlagen {
  background: #FF6600;
  border-color: #FF6600;
  color: white;
}

.onboarding-modal__preview-btn--nicht-angeschlagen {
  background: #FFCC99;
  border-color: #FFCC99;
  color: #374151;
}

.onboarding-modal__arrow {
  font-size: 20px;
  color: #9CA3AF;
  user-select: none;
}

.onboarding-modal__demo-btn {
  font-size: 24px;
  width: 72px;
  height: 72px;
}

@keyframes onboarding-hinweis {
  0%   { transform: scale(1); }
  20%  { transform: scale(1.25); }
  40%  { transform: scale(0.95); }
  60%  { transform: scale(1.15); }
  80%  { transform: scale(0.98); }
  100% { transform: scale(1); }
}

.onboarding-modal__demo-btn--hinweis {
  animation: onboarding-hinweis 0.6s ease-in-out;
}

.onboarding-modal__dots {
  display: flex;
  gap: 8px;
}

.onboarding-modal__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-neutral);
  transition: background 0.15s;
}

.onboarding-modal__dot--active {
  background: #FF6600;
}

.onboarding-modal__cta {
  width: 100%;
  margin-top: 4px;
}

.onboarding-modal--scrollable {
  max-height: 85vh;
  overflow-y: auto;
}

/* =====================
   Reverse-Tutorial (Level 3.3)
   ===================== */

.tutorial-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  width: 100%;
  gap: 4px;
}

.tutorial-header .onboarding-modal__close {
  position: static;
  flex-shrink: 0;
}

.tutorial-progress {
  font-size: 0.85rem;
  color: #9CA3AF;
  margin: 0;
  white-space: nowrap;
}

.tutorial-example {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  margin: 0;
  letter-spacing: 0.05em;
  color: #111827;
}

.tutorial-steps {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.tutorial-step {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tutorial-step__frage {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  text-align: center;
  color: #111827;
}

.tutorial-step__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.tutorial-step__feedback {
  min-height: 1.2em;
  font-size: 0.9rem;
  text-align: center;
  margin: 0;
}

.tutorial-step__feedback--wrong {
  color: #EF4444;
  font-weight: 600;
}

.tutorial-success {
  font-size: 1.2rem;
  font-weight: 700;
  color: #22C55E;
  text-align: center;
  margin: 0;
}

/* Screenreader-only Text */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Ausreichend Kontrast fuer neutrale Buttons */
.level-btn {
  color: #374151;
}

/* Disabled State */
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.quiz__option:disabled {
  cursor: default;
}

/* =====================
   Stufe 4: Explorer
   ===================== */

/* Gesperrte Stufe-Karte */
.stage-card--locked {
  opacity: 0.65;
}

.stage-card__lock-hint {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: var(--spacing-sm);
}

.level-btn--locked {
  cursor: not-allowed;
  opacity: 0.5;
  position: relative;
}

/* Notenreihe (Modus 4.1) */
.note-row-wrapper {
  overflow-x: auto;
  margin: var(--spacing-md) 0;
  border-radius: var(--radius-sm);
}

.note-row {
  display: flex;
  align-items: stretch;
  min-height: 160px;
  border: 3px solid var(--color-text);
  border-radius: var(--radius-sm);
  min-width: min-content;
  background: white;
}

.note-row__barline {
  flex: 0 0 4px;
  background: var(--color-text);
  align-self: stretch;
}

.note-row__block {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 2px;
  position: relative;
  min-height: 160px;
  transition: filter 0.2s ease;
  background: white;
}

.note-row__block img {
  height: 160px;
  width: auto;
  max-width: none;
}

.note-row__block--highlight {
  filter: brightness(0.85);
  outline: 3px solid var(--color-text);
  outline-offset: -3px;
  z-index: 1;
}

/* Tappbare Lücken zwischen Noten */
.note-row__gap {
  flex: 0 0 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  background: #F3F4F6;
  transition: background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.note-row__gap::after {
  content: '';
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 50%;
  width: 2px;
  background: #9CA3AF;
  border-radius: 1px;
  transform: translateX(-50%);
  transition: background 0.15s ease, width 0.1s ease;
}

.note-row__gap--set::after {
  width: 4px;
  background: var(--color-text);
  top: 0;
  bottom: 0;
}

.note-row__gap--validated {
  cursor: default;
  pointer-events: none;
}

.note-row__gap--correct::after {
  background: var(--color-correct);
  width: 4px;
  top: 0;
  bottom: 0;
}

.note-row__gap--wrong {
  background: #FEE2E2;
}

.note-row__gap--wrong::after {
  background: var(--color-wrong);
  width: 4px;
  top: 0;
  bottom: 0;
}

.note-row__gap--missing {
  background: #FEF9C3;
}

.note-row__gap--missing::after {
  background: #CA8A04;
  width: 3px;
  border: none;
  border-style: dashed;
  top: 0;
  bottom: 0;
}

/* Explorer Actions (Nächste Runde + Übersicht) */
.explorer__actions {
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
  margin-top: var(--spacing-lg);
}

/* Play-Zeile im Hördiktat */
.explorer__play-row {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  margin: var(--spacing-md) 0;
}

.explorer__play-btn {
  min-width: 140px;
}

.explorer__countdown {
  font-size: 32px;
  font-weight: 800;
  color: var(--color-viertel);
  min-width: 44px;
  text-align: center;
  display: inline-block;
  transition: opacity 0.1s ease;
}
