/* ============================================================
   TIER-ORCHESTER & ZÄHL-SAFARI - CSS STYLESHEET
   Speziell optimiert für iPad Safari & Touchscreens
   ============================================================ */

:root {
  --font-main: -apple-system, BlinkMacSystemFont, "Comic Sans MS", "Chalkboard SE", "Segoe UI", Roboto, sans-serif;
  
  /* Farbpalette - fröhlich, kontrastreich und warm */
  --bg-sky: #A0E7E5;
  --bg-gradient: linear-gradient(180deg, #B5EAEA 0%, #EDF6E5 60%, #FFDFBA 100%);
  --color-primary: #FF6B6B;
  --color-accent: #4D96FF;
  --color-success: #6BCB77;
  --color-sun: #FFD93D;
  --color-dark: #2C3E50;
  --color-white: #FFFFFF;

  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-button: 0 6px 0px rgba(0, 0, 0, 0.18);
  --shadow-button-active: 0 2px 0px rgba(0, 0, 0, 0.2);

  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  /* Verhindert versehentliches Markieren & iPad-Kopier-Menüs */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: fixed; /* Verhindert elastisches Bouncing in iOS Safari */
  font-family: var(--font-main);
  background: var(--bg-gradient);
  color: var(--color-dark);
  touch-action: manipulation; /* Kein Doppel-Tipp-Zoom */
}

/* ==================== LAYOUT ==================== */
.app-layout {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  position: relative;
  z-index: 10;
}

/* ==================== HEADER ==================== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  border-bottom: 3px solid rgba(255, 255, 255, 0.9);
  z-index: 50;
  gap: 12px;
}

.mode-tabs {
  display: flex;
  gap: 10px;
  flex: 1;
  max-width: 600px;
}

.tab-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1;
  padding: 10px 16px;
  font-size: 1.15rem;
  font-weight: 800;
  font-family: inherit;
  color: #555;
  background: #FFF;
  border: 3px solid #E2E8F0;
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 0 #CBD5E1;
  cursor: pointer;
  transition: all 0.15s ease-out;
  min-height: 54px;
}

.tab-btn:active, .tab-btn.active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #CBD5E1;
}

.tab-btn.active {
  background: var(--color-sun);
  color: #854D0E;
  border-color: #FBBF24;
  box-shadow: 0 2px 0 #D97706;
}

.tab-icon {
  font-size: 1.5rem;
}

.top-controls {
  display: flex;
  gap: 10px;
}

.circle-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  font-size: 1.4rem;
  background: #FFF;
  border: 3px solid #E2E8F0;
  box-shadow: 0 4px 0 #CBD5E1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease-out;
}

.circle-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #CBD5E1;
}

/* ==================== SPRECHBLASE ==================== */
.instruction-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #FFF;
  margin: 12px 20px 6px;
  padding: 10px 18px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  border: 3px solid var(--color-accent);
  animation: pulse-border 2.5s infinite;
}

.speaker-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}

.instruction-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-dark);
  line-height: 1.3;
}

/* ==================== SPIEL-ARENA ==================== */
.game-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 20px 16px;
  position: relative;
  overflow: hidden;
}

.game-mode {
  display: none;
  flex: 1;
  width: 100%;
  height: 100%;
  flex-direction: column;
  align-items: center;
}

.game-mode.active {
  display: flex;
}

/* ============================================================
   MODUS 1: TIER-XYLOPHON & BAND
   ============================================================ */
.song-selector-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.song-label {
  font-weight: 800;
  font-size: 1rem;
  color: #475569;
}

.pill-btn {
  padding: 8px 16px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  border-radius: 999px;
  background: #FFFFFF;
  border: 2px solid #CBD5E1;
  color: #334155;
  box-shadow: 0 3px 0 #CBD5E1;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill-btn.active {
  background: var(--color-accent);
  color: #FFF;
  border-color: #2563EB;
  box-shadow: 0 2px 0 #1D4ED8;
  transform: translateY(2px);
}

.xylophone-container {
  display: flex;
  flex: 1;
  width: 100%;
  max-width: 1100px;
  gap: 12px;
  align-items: stretch;
  justify-content: center;
  padding-bottom: 10px;
}

/* Ein einzelner Klangstab */
.xylo-bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  border-radius: var(--radius-xl);
  padding: 16px 8px;
  cursor: pointer;
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.16), 0 14px 20px rgba(0, 0, 0, 0.12);
  border: 4px solid rgba(255, 255, 255, 0.8);
  transition: transform 0.08s ease, filter 0.15s ease;
  position: relative;
  overflow: visible;
  touch-action: none;
}

.xylo-bar:active, .xylo-bar.pressed {
  transform: translateY(6px) scale(0.98);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
  filter: brightness(1.15);
}

.xylo-bar.highlight-next {
  animation: glow-bounce 1s infinite alternate;
}

.xylo-animal-emoji {
  font-size: 3.2rem;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.15));
  transition: transform 0.1s ease;
}

.xylo-bar:active .xylo-animal-emoji,
.xylo-bar.pressed .xylo-animal-emoji {
  transform: scale(1.3) rotate(-8deg);
}

.xylo-note-badge {
  background: rgba(255, 255, 255, 0.95);
  font-size: 1.1rem;
  font-weight: 900;
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--color-dark);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.xylo-instrument-icon {
  font-size: 1.4rem;
  background: rgba(255, 255, 255, 0.4);
  padding: 6px;
  border-radius: 50%;
}

/* Steigende Noten-Animation */
.rising-note {
  position: absolute;
  top: 10%;
  font-size: 2.2rem;
  pointer-events: none;
  animation: float-up-fade 0.8s forwards ease-out;
}

/* ============================================================
   MODUS 2: ZÄHL-SAFARI (Tiere füttern)
   ============================================================ */
.counting-arena {
  display: flex;
  width: 100%;
  max-width: 1050px;
  flex: 1;
  gap: 20px;
  align-items: center;
  justify-content: space-around;
}

@media (max-width: 800px) {
  .counting-arena {
    flex-direction: column;
  }
}

.animal-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.88);
  padding: 24px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-soft);
  border: 4px solid var(--color-sun);
  max-width: 440px;
  width: 100%;
}

.animal-avatar {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FFF9C4 0%, #FFF176 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: inset 0 4px 10px rgba(0,0,0,0.06), 0 8px 16px rgba(0,0,0,0.1);
  border: 4px solid #FBC02D;
  transition: transform 0.25s ease;
}

.animal-emoji {
  font-size: 6.5rem;
  user-select: none;
}

.animal-avatar.eating {
  animation: animal-eat 0.5s ease;
}

.animal-avatar.dancing {
  animation: animal-dance 1s infinite alternate ease-in-out;
}

.animal-name-badge {
  margin-top: 12px;
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--color-dark);
}

.counter-display {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.counter-label {
  font-size: 1.1rem;
  font-weight: 700;
  color: #64748B;
}

.counter-slots {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.counter-slot {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: #F1F5F9;
  border: 3px dashed #CBD5E1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.counter-slot.filled {
  background: #DCFCE7;
  border: 3px solid var(--color-success);
  transform: scale(1.1);
}

/* Futter-Tablett */
.food-tray-area {
  flex: 1.2;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, 0.9);
  padding: 24px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-soft);
  border: 4px solid var(--color-accent);
  max-width: 540px;
  width: 100%;
}

.food-tray-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: #1E293B;
  margin-bottom: 16px;
}

.food-items-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  width: 100%;
  justify-items: center;
}

.food-card {
  width: 90px;
  height: 90px;
  border-radius: var(--radius-lg);
  background: #FFF;
  border: 4px solid #E2E8F0;
  box-shadow: 0 6px 0 #CBD5E1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 3.2rem;
  transition: transform 0.15s ease, opacity 0.3s ease;
}

.food-card:active {
  transform: translateY(4px) scale(0.95);
  box-shadow: 0 2px 0 #CBD5E1;
}

.food-card.eaten {
  opacity: 0.15;
  pointer-events: none;
  transform: scale(0.5);
}

/* ============================================================
   MODUS 3: LAUSCH-RÄTSEL (Wer musiziert?)
   ============================================================ */
.hearing-arena {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 900px;
  flex: 1;
  justify-content: center;
  gap: 20px;
}

.mystery-box-card {
  background: rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-xl);
  padding: 24px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: var(--shadow-soft);
  border: 4px solid #A855F7;
  gap: 16px;
}

.mystery-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 140px;
}

.curtain-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.curtain-side {
  font-size: 5rem;
}

.mystery-actor {
  font-size: 5.5rem;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.mystery-actor.revealed {
  animation: reveal-pop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.big-listen-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #A855F7;
  color: #FFF;
  font-size: 1.3rem;
  font-weight: 800;
  font-family: inherit;
  padding: 14px 28px;
  border-radius: 999px;
  border: 3px solid #9333EA;
  box-shadow: 0 6px 0 #7E22CE;
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
}

.big-listen-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #7E22CE;
}

.hearing-choices-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--color-dark);
}

.hearing-choices-grid {
  display: flex;
  gap: 20px;
  width: 100%;
  justify-content: center;
  flex-wrap: wrap;
}

.animal-choice-card {
  width: 150px;
  height: 160px;
  background: #FFF;
  border-radius: var(--radius-xl);
  border: 4px solid #E2E8F0;
  box-shadow: 0 8px 0 #CBD5E1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  gap: 8px;
  transition: all 0.15s ease;
}

.animal-choice-card:active {
  transform: translateY(5px);
  box-shadow: 0 2px 0 #CBD5E1;
}

.animal-choice-emoji {
  font-size: 4.5rem;
}

.animal-choice-label {
  font-size: 1.2rem;
  font-weight: 800;
  color: #334155;
}

.animal-choice-card.wrong {
  animation: wiggle-shake 0.4s ease;
  border-color: #F87171;
}

.animal-choice-card.correct {
  border-color: var(--color-success);
  background: #ECFDF5;
  transform: scale(1.08);
}

/* ============================================================
   START-OVERLAY & MODAL
   ============================================================ */
.overlay, .modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.overlay.active, .modal.active {
  opacity: 1;
  pointer-events: all;
}

.start-card, .modal-card {
  background: #FFFFFF;
  border-radius: 36px;
  padding: 36px 32px;
  max-width: 520px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  border: 6px solid var(--color-sun);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  position: relative;
  animation: card-pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.start-decorations {
  display: flex;
  gap: 12px;
  font-size: 2.2rem;
}

.bubble {
  display: inline-block;
  animation: float-bubble 3s infinite alternate ease-in-out;
}
.b1 { animation-delay: 0s; }
.b2 { animation-delay: 0.5s; }
.b3 { animation-delay: 1s; }
.b4 { animation-delay: 1.5s; }
.b5 { animation-delay: 2s; }

.game-title {
  font-size: 2.4rem;
  font-weight: 900;
  color: #1E293B;
  line-height: 1.15;
}

.game-title .subtitle {
  color: var(--color-primary);
  font-size: 1.8rem;
}

.start-text {
  font-size: 1.2rem;
  color: #64748B;
  font-weight: 600;
}

.big-cta-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  max-width: 320px;
  padding: 18px 24px;
  font-size: 1.5rem;
  font-weight: 900;
  font-family: inherit;
  color: #FFF;
  background: var(--color-success);
  border: 4px solid #48BB78;
  border-radius: 999px;
  box-shadow: 0 8px 0 #2F855A, 0 12px 20px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  transition: all 0.12s ease;
  margin-top: 10px;
}

.big-cta-btn:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 #2F855A;
}

.hint-pill {
  font-size: 0.95rem;
  color: #475569;
  background: #F1F5F9;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  margin-top: 8px;
  line-height: 1.4;
}

.modal-stars {
  font-size: 3rem;
  animation: glow-bounce 1s infinite alternate;
}

.reward-actor {
  font-size: 5rem;
}

/* ==================== CANVAS & ANIMATIONEN ==================== */
#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 999;
}

@keyframes float-bubble {
  0% { transform: translateY(0px) rotate(0deg); }
  100% { transform: translateY(-12px) rotate(8deg); }
}

@keyframes float-up-fade {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-60px) scale(1.4); opacity: 0; }
}

@keyframes pulse-border {
  0%, 100% { border-color: var(--color-accent); }
  50% { border-color: var(--color-sun); }
}

@keyframes glow-bounce {
  0% { transform: scale(1); }
  100% { transform: scale(1.08); }
}

@keyframes wiggle-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px) rotate(-4deg); }
  75% { transform: translateX(8px) rotate(4deg); }
}

@keyframes animal-eat {
  0% { transform: scale(1); }
  50% { transform: scale(1.2) rotate(6deg); }
  100% { transform: scale(1); }
}

@keyframes animal-dance {
  0% { transform: translateY(0) rotate(-6deg); }
  100% { transform: translateY(-14px) rotate(6deg); }
}

@keyframes card-pop {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes reveal-pop {
  0% { transform: scale(0.3) rotate(-20deg); }
  70% { transform: scale(1.25) rotate(10deg); }
  100% { transform: scale(1) rotate(0deg); }
}
