/* ============================================================
   Zoo Visit — Complete Stylesheet
   Tablet-first, portrait-optimized, no scrolling.
   ============================================================ */

/* ---- CSS Custom Properties (Design Tokens) ---- */
:root {
  /* Colors - semi-transparent so background video shows through */
  --bg-primary: rgba(255,248,240,0.75);
  --bg-secondary: rgba(240,235,227,0.7);
  --text-primary: #2D2D2D;
  --text-secondary: #6B6B6B;
  --accent-green: #4CAF50;
  --accent-blue: #5B8DEF;
  --accent-orange: #FF9800;
  --accent-giraffe: #F5DEB3;
  --accent-zebra: #E8E8E8;
  --accent-elephant: #D4D4D8;
  --confidence-low: #FFB74D;
  --confidence-mid: #FFD54F;
  --confidence-high: #81C784;
  --error-red: #EF5350;

  /* Typography - larger, cuter */
  --font-display: 'Nunito', 'Fredoka', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-body: 'Nunito', 'Fredoka', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --size-body: 22px;
  --size-heading: 40px;
  --size-subheading: 30px;
  --size-button: 24px;
  --size-speech: 28px;
  --size-small: 16px;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 36px;
  --space-2xl: 52px;

  /* Touch */
  --touch-min: 52px;
  --touch-primary: 64px;
  --touch-snap: 88px;

  /* Effects */
  --shadow-soft: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-card: 0 4px 20px rgba(0,0,0,0.12);
  --radius-sm: 10px;
  --radius-md: 18px;
  --radius-lg: 28px;
  --radius-xl: 36px;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  -webkit-overflow-scrolling: none;
  overscroll-behavior: none;
  font-family: var(--font-body);
  font-size: var(--size-body);
  color: var(--text-primary);
  background: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* Snap button disabled state */
.btn-snap:disabled,
.btn-snap.disabled {
  background: #ccc;
  border-color: #bbb;
  color: #999;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none;
}

/* Camera flash overlay */
.camera-flash {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 100;
  pointer-events: none;
  background: white;
  opacity: 0;
}

.camera-flash.flash {
  animation: flash-pop 0.3s ease-out forwards;
}

@keyframes flash-pop {
  0% { opacity: 0.9; }
  50% { opacity: 0.6; }
  100% { opacity: 0; }
}

/* Background animation video behind game */
#bg-video {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
  object-fit: cover;
}

/* Portrait lock */
@media (orientation: landscape) and (max-height: 600px) {
  body {
    background: transparent;
  }
}

/* ---- Typography ---- */
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 800;
  line-height: 1.2;
}

h1 { font-size: 36px; }
h2 { font-size: var(--size-heading); }
h3 { font-size: var(--size-subheading); }

p, li, label, .text-body {
  font-size: var(--size-body);
  line-height: 1.5;
}

/* ---- App Shell ---- */
#app {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-width: 1024px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
  overflow: hidden;
  background: transparent;
}

/* ---- Top Bar ---- */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-secondary);
  backdrop-filter: blur(6px);
  border-bottom: 2px solid rgba(0,0,0,0.05);
  flex-shrink: 0;
  z-index: 10;
  min-height: 48px;
}

.game-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--size-subheading);
  color: var(--text-primary);
}

.icon-btn {
  width: var(--touch-primary);
  height: var(--touch-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  transition: background 0.2s;
}

.icon-btn:active {
  background: rgba(0,0,0,0.1);
}

.dev-btn {
  border: 2px dashed #FF9800 !important;
  background: rgba(255,152,0,0.1) !important;
  font-size: 18px !important;
  margin-left: 4px;
}

/* ---- Phase Container ---- */
#phase-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ---- AI Status ---- */
.ai-status {
  position: absolute;
  bottom: var(--space-sm);
  right: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  background: rgba(255,255,255,0.9);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: var(--size-small);
  color: var(--text-secondary);
  z-index: 20;
  pointer-events: none;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-green);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: var(--size-button);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.2s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.95);
}

.btn-primary {
  background: var(--accent-blue);
  color: white;
  padding: var(--space-md) var(--space-xl);
  box-shadow: var(--shadow-soft);
}

.btn-primary:active {
  background: #4A7BD9;
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: var(--space-sm) var(--space-lg);
}

.btn-large {
  min-height: var(--touch-primary);
  min-width: 200px;
  font-size: 22px;
  padding: var(--space-md) var(--space-2xl);
}

.btn-snap {
  background: var(--accent-orange);
  color: white;
  font-size: 32px;
  min-width: var(--touch-snap);
  min-height: var(--touch-snap);
  border-radius: 50%;
  padding: 0;
  box-shadow: 0 4px 16px rgba(255,152,0,0.3);
  width: 88px;
  height: 88px;
}

.btn-snap:active {
  background: #F57C00;
}

.btn-success {
  background: var(--accent-green) !important;
  box-shadow: 0 4px 16px rgba(76,175,80,0.3) !important;
}

.btn-fallback {
  background: rgba(255,255,255,0.85);
  color: var(--text-primary);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--size-small);
  border: 2px solid var(--bg-secondary);
  min-height: var(--touch-min);
  border-radius: var(--radius-sm);
}

.btn-fallback:active {
  background: var(--bg-secondary);
}

.btn-retry {
  background: var(--accent-orange);
  color: white;
  padding: var(--space-sm) var(--space-lg);
  margin-top: var(--space-md);
  font-size: var(--size-button);
}

/* ---- Hidden Utility ---- */
.hidden {
  display: none !important;
}

/* ============================================================
   LOADING PHASE
   ============================================================ */
.loading-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: var(--space-lg);
  padding: var(--space-xl);
}

.bo-thumb {
  width: 160px;
  height: 160px;
}

/* Float animation is now in assets/bo.css */

@keyframes float-legacy {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.loading-title {
  color: var(--text-primary);
  font-size: var(--size-heading);
  text-align: center;
}

.loading-spinner {
  display: flex;
  gap: var(--space-md);
}

.spinner-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-blue);
  animation: bounce-dot 1.4s ease-in-out infinite;
}

.spinner-dot[data-index="0"] { animation-delay: 0s; }
.spinner-dot[data-index="1"] { animation-delay: 0.2s; }
.spinner-dot[data-index="2"] { animation-delay: 0.4s; }

@keyframes bounce-dot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.progress-bar-container {
  width: 80%;
  max-width: 400px;
  position: relative;
}

.progress-bar-fill {
  height: 8px;
  background: var(--accent-blue);
  border-radius: 4px;
  width: 0%;
  transition: width 0.3s ease-out;
}

.progress-text {
  display: block;
  text-align: center;
  margin-top: var(--space-sm);
  font-size: var(--size-small);
  color: var(--text-secondary);
}

.load-start-btn {
  margin-top: var(--space-lg);
  padding: var(--space-md) var(--space-xl);
  font-size: 1.4em;
  font-weight: 800;
  color: #fff;
  background: var(--accent-green, #4CAF50);
  border: none;
  border-radius: var(--radius-pill);
  cursor: pointer;
  min-width: 200px;
  touch-action: manipulation;
  animation: pulse-btn 1.5s ease-in-out infinite;
}

.load-start-btn:disabled {
  opacity: 0.6;
  cursor: default;
  animation: none;
}

@keyframes pulse-btn {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4); }
  50% { transform: scale(1.05); box-shadow: 0 0 0 12px rgba(76, 175, 80, 0); }
}

.loading-error {
  text-align: center;
  color: var(--error-red);
  font-size: var(--size-body);
}

/* ============================================================
   INTRO PHASE
   ============================================================ */
.intro-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  padding: var(--space-lg);
  gap: var(--space-lg);
  overflow: hidden;
}

.bo-greeting {
  display: flex;
  align-items: flex-start;
  gap: var(--space-lg);
  width: 100%;
  max-width: 90%;
}

.bo-avatar {
  width: 140px;
  height: 140px;
  flex-shrink: 0;
  overflow: visible;
}

.speech-bubble {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  box-shadow: var(--shadow-card);
  position: relative;
  font-size: var(--size-speech);
  line-height: 1.4;
}

.speech-bubble::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 30px;
  width: 20px;
  height: 20px;
  background: rgba(255,255,255,0.85);
  transform: rotate(45deg);
  box-shadow: -2px 2px 4px rgba(0,0,0,0.05);
}

.confidence-meter {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.confidence-label {
  font-weight: 700;
  font-size: var(--size-body);
}

.confidence-emoji {
  font-size: 32px;
  line-height: 1;
}

.confidence-text {
  font-size: var(--size-speech);
  color: var(--text-primary);
  width: 100%;
  margin-top: var(--space-sm);
}

.animals-intro {
  width: 100%;
  max-width: 600px;
}

.section-title {
  text-align: center;
  margin-bottom: var(--space-md);
  font-size: var(--size-subheading);
}

.animal-cards {
  display: flex;
  justify-content: center;
  gap: var(--space-lg);
}

.animal-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-lg);
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(6px);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  min-width: 100px;
  min-height: 120px;
  transition: transform 0.2s;
}

.animal-card:active {
  transform: scale(0.95);
}

.animal-icon {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.animal-icon.small {
  width: 56px;
  height: 56px;
}

.animal-card-name {
  font-weight: 700;
  font-size: var(--size-button);
  text-align: center;
}

/* ============================================================
   TEACH PHASE
   ============================================================ */
.teach-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  position: relative;
}

.teach-progress {
  padding: var(--space-sm) var(--space-md);
  text-align: center;
  font-weight: 700;
  font-size: var(--size-body);
  color: var(--text-secondary);
  background: var(--bg-secondary);
  backdrop-filter: blur(6px);
  flex-shrink: 0;
}

/* ===== CAMERA AREA ===== */
.camera-area {
  flex: 1 1 auto;
  min-height: 200px;
  position: relative;
  background: #000;
  overflow: hidden;
}

/* Layer 1 — camera feed fills the viewport, mirrored */
.camera-area > .camera-feed {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  z-index: 1;
}

/* Simple camera viewfinder frame — sits on top of video */
.camera-frame {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  border: 6px solid #fff;
  box-shadow: inset 0 0 0 3px rgba(0,0,0,0.3), 0 0 0 4px #333;
  border-radius: 14px;
}

/* Viewfinder corner accents */
.camera-frame::before,
.camera-frame::after {
  content: '';
  position: absolute;
  z-index: 4;
}
.camera-frame::before {
  top: 10px;
  left: 10px;
  width: 24px;
  height: 24px;
  border-top: 4px solid var(--accent-orange);
  border-left: 4px solid var(--accent-orange);
  border-radius: 4px 0 0 0;
}
.camera-frame::after {
  bottom: 10px;
  right: 10px;
  width: 24px;
  height: 24px;
  border-bottom: 4px solid var(--accent-orange);
  border-right: 4px solid var(--accent-orange);
  border-radius: 0 0 4px 0;
}

/* Red recording dot */
.camera-frame .rec-dot {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 12px;
  height: 12px;
  background: #ff3333;
  border-radius: 50%;
  animation: rec-pulse 1.5s ease-in-out infinite;
  box-shadow: 0 0 6px rgba(255,50,50,0.6);
}

@keyframes rec-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

/* Layer 2 — guide overlay (silhouette, prompt, dots) between video and frame */
.guide-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  padding: 24px;
  z-index: 2;
}

.guide-silhouette {
  width: 120px;
  height: auto;
  opacity: 0.3;
  margin-bottom: var(--space-md);
  animation: pulse-silhouette 2s ease-in-out infinite;
}

@keyframes pulse-silhouette {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 0.4; }
}

.angle-prompt {
  background: rgba(0,0,0,0.6);
  color: white;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  font-size: var(--size-speech);
  font-weight: 700;
  text-align: center;
  max-width: 80%;
  backdrop-filter: blur(4px);
  pointer-events: none;
}

.angle-dots {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.angle-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  border: 2px solid rgba(255,255,255,0.5);
}

.angle-dot.active {
  background: var(--accent-orange);
  border-color: var(--accent-orange);
}

.fallback-row {
  position: absolute;
  bottom: var(--space-md);
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  padding: 0 var(--space-md);
  z-index: 5;
}

.fallback-icon {
  width: 24px;
  height: 24px;
}

.teach-bottom {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  padding: var(--space-md);
  background: var(--bg-secondary);
  backdrop-filter: blur(6px);
  flex-shrink: 0;
  min-height: 90px;
}

.bo-mini {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex: 1;
  max-width: 95%;
}

.bo-avatar.bo-mini {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
}

.bo-mini-speech {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(6px);
  padding: var(--space-lg) var(--space-xl);
  border-radius: var(--radius-md);
  font-size: var(--size-speech);
  font-weight: 600;
  box-shadow: var(--shadow-soft);
  line-height: 1.3;
  flex: 1;
}

/* ============================================================
   QUIZ PHASE
   ============================================================ */
.quiz-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.quiz-progress {
  padding: var(--space-sm) var(--space-md);
  text-align: center;
  font-weight: 700;
  font-size: var(--size-body);
  color: var(--text-secondary);
  background: var(--bg-secondary);
  backdrop-filter: blur(6px);
  flex-shrink: 0;
}

.quiz-wrapper .camera-area {
  justify-content: flex-end;
  gap: var(--space-sm);
  padding-bottom: var(--space-sm);
}

.quiz-confidence {
  position: relative;
  bottom: auto;
  left: auto;
  transform: none;
  background: rgba(0,0,0,0.7);
  color: white;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-lg);
  font-size: 26px;
  font-weight: 700;
  z-index: 5;
  backdrop-filter: blur(4px);
  align-self: center;
  flex-shrink: 0;
}

.quiz-hint {
  position: relative;
  bottom: auto;
  left: auto;
  transform: none;
  background: rgba(255,152,0,0.9);
  color: white;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  font-size: var(--size-speech);
  font-weight: 700;
  z-index: 6;
  text-align: center;
  max-width: 90%;
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.quiz-hint-silhouette {
  width: 48px;
  height: auto;
  opacity: 0.7;
}

.hint-text {
  font-size: var(--size-body);
}

.quiz-bottom {
  display: flex;
  align-items: center;
  padding: var(--space-md) var(--space-xl);
  background: var(--bg-secondary);
  backdrop-filter: blur(6px);
  flex-shrink: 0;
  min-height: 80px;
}

.tour-bottom {
  display: flex;
  align-items: center;
  padding: var(--space-md);
  background: var(--bg-secondary);
  backdrop-filter: blur(6px);
  flex-shrink: 0;
  min-height: 80px;
}

/* ============================================================
   TOUR GUIDE PHASE
   ============================================================ */
.tourguide-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.tour-progress {
  padding: var(--space-sm) var(--space-md);
  text-align: center;
  font-weight: 700;
  font-size: var(--size-body);
  color: var(--text-secondary);
  background: var(--bg-secondary);
  backdrop-filter: blur(6px);
  flex-shrink: 0;
}

.tourguide-wrapper .camera-area {
  justify-content: flex-end;
  gap: var(--space-sm);
  padding-bottom: var(--space-sm);
}

.tour-confidence {
  position: relative;
  bottom: auto;
  left: auto;
  transform: none;
  background: rgba(0,0,0,0.7);
  color: white;
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-lg);
  font-size: 24px;
  font-weight: 700;
  z-index: 5;
  backdrop-filter: blur(4px);
  align-self: center;
  flex-shrink: 0;
}

.animal-picker {
  position: relative;
  top: auto;
  left: auto;
  transform: none;
  background: rgba(255,255,255,0.95);
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  z-index: 10;
  text-align: center;
  max-width: 90%;
  align-self: center;
  flex-shrink: 0;
}

.picker-title {
  margin-bottom: var(--space-md);
  font-size: var(--size-subheading);
}

.picker-cards {
  display: flex;
  gap: var(--space-md);
  justify-content: center;
  flex-wrap: wrap;
}

.picker-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  border: 3px solid transparent;
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.75);
  backdrop-filter: blur(6px);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
  min-width: 80px;
  min-height: 100px;
  touch-action: manipulation;
}

.picker-card:active {
  transform: scale(0.95);
  border-color: var(--accent-blue);
}

.picker-card-name {
  font-weight: 700;
  font-size: var(--size-body);
}

/* ============================================================
   CELEBRATION PHASE
   ============================================================ */
.celebration-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  padding: var(--space-lg);
  gap: var(--space-md);
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255,248,240,0.7) 0%, rgba(255,240,208,0.7) 100%);
}

.confetti-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.confetti-piece {
  position: absolute;
  top: -10px;
  left: var(--x, 50%);
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--color, #FF6B6B);
  animation: confetti-fall 3s ease-in var(--delay, 0s) infinite;
}

@keyframes confetti-fall {
  0% { transform: translateY(-10px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

.bo-center {
  position: relative;
  z-index: 1;
}

.bo-celebration {
  width: 180px;
  height: 180px;
}
}

@keyframes celebrate-bounce {
  from { transform: translateY(0) scale(1); }
  to { transform: translateY(-15px) scale(1.05); }
}

.star-burst {
  position: absolute;
  inset: -40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.star {
  position: absolute;
  font-size: 24px;
  animation: star-spin 3s linear var(--delay, 0s) infinite;
  transform-origin: center;
  transform: rotate(var(--angle, 0deg)) translateY(-60px);
}

@keyframes star-spin {
  from { transform: rotate(var(--angle, 0deg)) translateY(-60px); }
  to { transform: rotate(calc(var(--angle, 0deg) + 360deg)) translateY(-60px); }
}

.celebration-speech {
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(8px);
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  font-size: var(--size-speech);
  font-weight: 700;
  text-align: center;
  max-width: 500px;
  z-index: 1;
  line-height: 1.4;
  position: relative;
}

.learned-animals {
  display: flex;
  gap: var(--space-lg);
  z-index: 1;
  flex-wrap: wrap;
  justify-content: center;
}

.learned-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  min-width: 130px;
  animation: fade-in-up 0.5s ease-out forwards;
  opacity: 0;
  box-shadow: var(--shadow-soft);
}

.learned-card.giraffe { background: rgba(245,222,179,0.7); }
.learned-card.zebra { background: rgba(232,232,232,0.7); }
.learned-card.elephant { background: rgba(212,212,216,0.7); }

.learned-card:nth-child(1) { animation-delay: 0.5s; }
.learned-card:nth-child(2) { animation-delay: 0.8s; }
.learned-card:nth-child(3) { animation-delay: 1.1s; }

@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.learned-icon {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.learned-emoji {
  font-size: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.learned-name {
  font-weight: 800;
  font-size: var(--size-button);
}

.learned-fact {
  font-size: var(--size-small);
  color: var(--text-secondary);
  text-align: center;
}

#btn-play-again {
  z-index: 1;
  margin-top: var(--space-md);
}

/* ============================================================
   MODAL / PICKER OVERLAY
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fade-in 0.2s ease-out;
}

.modal-content {
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  padding: var(--space-xl);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  max-width: 90%;
  text-align: center;
  animation: scale-in 0.3s ease-out;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scale-in {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-title {
  margin-bottom: var(--space-lg);
  font-size: var(--size-heading);
}

.modal-card {
  min-width: 90px;
  min-height: 100px;
}

.modal-done {
  margin-top: var(--space-lg);
}

/* ============================================================
   SETTINGS PANEL
   ============================================================ */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fade-in 0.2s ease-out;
}

.settings-panel {
  background: white;
  padding: var(--space-xl);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  width: 350px;
  max-width: 90%;
  position: relative;
  animation: scale-in 0.3s ease-out;
}

.settings-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  width: var(--touch-min);
  height: var(--touch-min);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.settings-close:active {
  background: var(--bg-secondary);
}

.settings-title {
  margin-bottom: var(--space-lg);
  font-size: var(--size-heading);
}

.setting-group {
  margin-bottom: var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.setting-label {
  font-weight: 700;
  min-width: 80px;
  font-size: var(--size-body);
}

.setting-slider {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-secondary);
  border-radius: 3px;
  outline: none;
  min-height: 30px;
  cursor: pointer;
}

.setting-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent-blue);
  cursor: pointer;
}

.setting-value {
  font-weight: 700;
  min-width: 36px;
  text-align: center;
}

.setting-toggle {
  padding: var(--space-sm) var(--space-lg);
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--size-body);
  font-weight: 700;
  cursor: pointer;
  min-height: var(--touch-min);
  transition: background 0.2s;
}

.setting-toggle.on {
  background: var(--accent-green);
  color: white;
}

.setting-toggle.off {
  background: var(--confidence-low);
  color: white;
}

/* ============================================================
   RESPONSIVE — Smaller tablets / phones
   ============================================================ */
@media (max-width: 600px) {
  :root {
    --size-heading: 30px;
    --size-subheading: 24px;
    --size-body: 18px;
    --size-speech: 22px;
    --size-button: 20px;
  }

  .bo-avatar {
    width: 100px;
    height: 100px;
  }

  .bo-avatar.bo-mini {
    width: 60px;
    height: 60px;
  }

  .bo-thumb {
    width: 120px;
    height: 120px;
  }

  .animal-icon {
    width: 56px;
    height: 56px;
  }

  .btn-snap {
    width: 64px;
    height: 64px;
    min-width: 64px;
    min-height: 64px;
    font-size: 22px;
  }

  .animal-cards {
    gap: var(--space-md);
  }

  .animal-card {
    padding: var(--space-md);
    min-width: 80px;
    min-height: 100px;
  }

  .learned-card {
    min-width: 100px;
    padding: var(--space-md);
  }

  .confetti-piece {
    width: 6px;
    height: 6px;
  }
}

/* ============================================================
   VOICE PROMPT (tour guide — student names the animal)
   ============================================================ */
.voice-prompt {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(4px);
  z-index: 20;
  padding: var(--space-lg);
  animation: fade-in 0.3s ease-out;
}

.mic-icon {
  font-size: 64px;
  animation: mic-pulse 1.2s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.7; }
}

.voice-prompt-label {
  color: white;
  font-size: var(--size-subheading);
  font-weight: 700;
  text-align: center;
}

.voice-status {
  color: #FFD54F;
  font-size: var(--size-body);
  font-weight: 600;
  animation: fade-in 0.3s ease-out;
}

.voice-fallback-btn {
  font-size: var(--size-button);
  font-weight: 700;
  font-family: var(--font-body);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  border: 3px solid white;
  background: rgba(255,255,255,0.2);
  color: white;
  cursor: pointer;
  backdrop-filter: blur(4px);
  margin-top: var(--space-md);
  min-height: var(--touch-primary);
}

.voice-fallback-btn:active {
  background: rgba(255,255,255,0.4);
}

/* ============================================================
   EMOJI PICKER (tour guide — fallback) */
.emoji-picker {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 20;
  padding: var(--space-lg);
  animation: fade-in 0.3s ease-out;
}

.emoji-picker .picker-title {
  color: white;
  font-size: var(--size-subheading);
  margin-bottom: var(--space-md);
  text-align: center;
}

.emoji-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  justify-content: center;
  max-width: 520px;
  max-height: 60%;
  overflow-y: auto;
  padding: var(--space-sm);
}

.emoji-btn {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-body);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  border: 3px solid transparent;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(4px);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  min-width: 80px;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.emoji-btn:active {
  transform: scale(0.92);
  border-color: var(--accent-orange);
}

@media (max-height: 700px) {
  .bo-greeting {
    gap: var(--space-md);
  }
  
  .bo-avatar {
    width: 100px;
    height: 100px;
  }

  .bo-avatar.bo-mini {
    width: 60px;
    height: 60px;
  }
  
  .speech-bubble {
    padding: var(--space-md);
  }

  .teach-bottom {
    min-height: 70px;
    padding: var(--space-sm);
  }

  .animal-cards {
    gap: var(--space-sm);
  }
}

/* ============================================================
   BG CAPTURE OVERLAY (Teach Phase Step 0)
   ============================================================ */
.bg-capture-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 15;
  gap: var(--space-md);
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
}

.bg-capture-icon {
  font-size: 4em;
  animation: bg-capture-bounce 0.6s ease-in-out infinite alternate;
}

@keyframes bg-capture-bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-10px); }
}

.bg-capture-message {
  font-size: 1.4em;
  font-weight: 700;
  color: #fff;
  text-align: center;
  line-height: 1.4;
}

.bg-capture-bo {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  max-width: 560px;
}

.bg-capture-bo .speech-bubble {
  color: #333;
  font-size: 1.1em;
}

.bg-capture-countdown {
  font-size: 3em;
  font-weight: 800;
  color: var(--accent-yellow, #fde68a);
  min-height: 1.2em;
}

.bg-capture-btn-row {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
  justify-content: center;
}

.bg-capture-ready-btn {
  background: var(--accent-green, #4CAF50);
  color: #fff;
  border: none;
  padding: var(--space-md) var(--space-xl);
  font-size: 1.2em;
  font-weight: 700;
  border-radius: var(--radius-pill);
  cursor: pointer;
  min-width: 180px;
  touch-action: manipulation;
}

.bg-capture-ready-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.bg-capture-retake-btn {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.3);
  padding: var(--space-md) var(--space-xl);
  font-size: 1.1em;
  font-weight: 600;
  border-radius: var(--radius-pill);
  cursor: pointer;
  min-width: 140px;
  touch-action: manipulation;
}

.bg-capture-progress-bar {
  width: 80%;
  max-width: 300px;
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  overflow: hidden;
  margin-top: var(--space-sm);
}

.bg-capture-progress-fill {
  height: 100%;
  background: var(--accent-yellow, #fde68a);
  border-radius: 4px;
  transition: width 0.1s linear;
}

/* ============================================================
   RECORDING OVERLAY (Teach & Mystery Friend snap)
   ============================================================ */
.recording-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 15;
  gap: var(--space-sm);
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
}

.recording-emoji {
  font-size: 3.5em;
  animation: bg-capture-bounce 0.6s ease-in-out infinite alternate;
}

.recording-label {
  font-size: 1.4em;
  font-weight: 700;
  color: #fff;
  text-align: center;
}

.recording-countdown-num {
  font-size: 2.5em;
  font-weight: 800;
  color: var(--accent-yellow, #fde68a);
  min-height: 1.2em;
}

.recording-progress-bar {
  width: 80%;
  max-width: 300px;
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  overflow: hidden;
  margin-top: var(--space-sm);
}

.recording-progress-fill {
  height: 100%;
  background: var(--accent-red, #EF5350);
  border-radius: 4px;
  transition: width 0.1s linear;
}

.recording-hint {
  font-size: 1em;
  color: rgba(255, 255, 255, 0.7);
  margin-top: var(--space-xs);
}

.recording-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #EF5350;
  animation: rec-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes rec-pulse {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0.4; transform: scale(1.3); }
}

/* ============================================================
   ACCESSIBILITY
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-reduced-speech: reduce) {
  .tts-only {
    display: none;
  }
}

/* Focus indicator for keyboard users */
button:focus-visible {
  outline: 3px solid var(--accent-blue);
  outline-offset: 2px;
}
