:root {
  --bg: #fff4ef;
  --surface: #ffffff;
  --surface-2: #fffaf7;
  --text: #243042;
  --muted: #6f7b8f;
  --primary: #5abf41;
  --primary-dark: #2f8a1c;
  --shadow: 0 14px 38px rgba(34, 45, 68, 0.12);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, Arial, sans-serif;
  background: linear-gradient(180deg, #fff6f0 0%, #ffe9ee 100%);
  color: var(--text);
  min-height: 100vh;
}

body.detail-open {
  overflow: hidden;
}

button { font: inherit; }

.app-shell {
  width: min(1100px, 100%);
  margin: 0 auto;
  min-height: 100vh;
  padding: 16px;
}

.topbar {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand__emoji {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 28px;
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.6rem, 2vw, 2.2rem);
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
}

.mode-switch {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mode-btn {
  border: 0;
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  cursor: pointer;
  font-weight: 700;
}

.mode-btn.is-active {
  background: var(--primary);
  color: #fff;
}

.mode-btn--baby {
  background: #fff7d6;
}

.mode-btn--baby.is-active {
  background: #ffb703;
  color: #1f2937;
}

.view { display: none; }
.view--active { display: block; }

.status-bar {
  min-height: 24px;
  margin-bottom: 14px;
  color: var(--muted);
  font-weight: 600;
}

.animal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 18px;
}

.animal-card {
  background: rgba(255,255,255,0.92);
  border: 0;
  border-radius: var(--radius-xl);
  padding: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.animal-card:hover,
.animal-card:active {
  transform: translateY(-2px);
}

.animal-card img {
  width: 100%;
  height: 120px;
  object-fit: contain;
  display: block;
  margin-bottom: 10px;
}

.animal-card__title {
  text-align: center;
  font-weight: 700;
  font-size: 1.05rem;
}

.detail-view {
  position: relative;
}

body.detail-open .topbar {
  display: none;
}

body.detail-open .detail-view {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: linear-gradient(180deg, #fff6f0 0%, #ffe9ee 100%);
  padding: calc(8px + env(safe-area-inset-top, 0px)) calc(8px + env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) calc(8px + env(safe-area-inset-left, 0px));
}

.back-btn {
  margin-bottom: 10px;
}

body.detail-open .back-btn {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top, 0px));
  left: calc(8px + env(safe-area-inset-left, 0px));
  z-index: 120;
  width: 46px;
  height: 46px;
  border-radius: 999px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 900;
  color: #ffffff;
  background: linear-gradient(180deg, #ff7a18 0%, #ff4d00 100%);
  border: 0;
  box-shadow: 0 10px 18px rgba(255, 77, 0, 0.35);
}

body.detail-open .back-btn:active {
  transform: translateY(1px);
}

.icon-btn {
  border: 0;
  background: var(--surface);
  box-shadow: var(--shadow);
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
}

.card-stage {
  min-height: calc(100vh - 140px);
  display: grid;
  place-items: center;
}

.card-panel {
  width: min(900px, 100%);
  display: grid;
  grid-template-columns: 72px 1fr 72px;
  gap: 14px;
  align-items: center;
}

.card-content {
  background: rgba(255,255,255,0.94);
  border-radius: 36px;
  box-shadow: var(--shadow);
  padding: 24px 22px 28px;
  text-align: center;
}

.hero-button {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  width: 100%;
}

.hero-image {
  width: 100%;
  max-height: 58vh;
  object-fit: contain;
}

.hero-title {
  margin: 16px 0 14px;
  font-size: clamp(2rem, 4vw, 3.2rem);
}

.sound-btn,
.nav-btn {
  border: 0;
  cursor: pointer;
  font-weight: 800;
}

body.baby-mode .brand p,
body.baby-mode .mode-btn[data-mode="en"],
body.baby-mode .mode-btn[data-mode="cz"] {
  display: none;
}

body.hide-en .mode-btn[data-mode="en"] {
  display: none;
}

body.hide-cz .mode-btn[data-mode="cz"] {
  display: none;
}

.mode-btn#btnAutoplay.is-active {
  background: #2563eb;
  color: #fff;
}

.mode-btn#btnRandom {
  background: #f3f4f6;
}

body.baby-mode .hero-title {
  font-size: clamp(2.4rem, 5vw, 3.6rem);
}

body.baby-mode .sound-btn {
  font-size: 1.05rem;
  padding: 16px 26px;
}

body.baby-mode .nav-btn {
  width: 76px;
  height: 76px;
}

.sound-btn {
  background: var(--primary);
  color: #fff;
  padding: 14px 22px;
  border-radius: 999px;
  box-shadow: 0 12px 26px rgba(90, 191, 65, 0.28);
}

.nav-btn {
  width: 72px;
  height: 72px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 2rem;
}

@media (max-width: 768px) {
  .app-shell {
    padding: 10px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .brand {
    align-items: flex-start;
  }

  .card-stage {
    min-height: calc(100vh - 170px);
  }

  body.detail-open .card-stage {
    min-height: calc(100vh - 20px);
  }

  .card-panel {
    grid-template-columns: 52px 1fr 52px;
    align-items: center;
    gap: 8px;
  }

  .card-content {
    padding: 16px 10px 18px;
    border-radius: 24px;
  }

  .hero-image {
    max-height: 62vh;
  }

  .hero-title {
    margin: 12px 0;
    font-size: clamp(2.2rem, 8vw, 3rem);
  }

  .nav-btn {
    width: 52px;
    height: 52px;
    justify-self: center;
  }

  .sound-btn {
    padding: 12px 18px;
    font-size: 1rem;
  }

  .animal-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  .animal-card {
    min-height: 132px;
    padding: 14px 10px;
  }

  .animal-card img {
    height: 96px;
  }

  body.baby-mode .hero-image {
    max-height: 68vh;
  }

  body.baby-mode .hero-title {
    font-size: clamp(2.6rem, 10vw, 3.5rem);
  }
}

@media (max-width: 768px) and (orientation: portrait) {
  body.baby-mode .card-panel {
    grid-template-columns: 1fr;
  }

  body.baby-mode .nav-btn {
    display: none;
  }

  body.baby-mode .hero-image {
    max-height: 74vh;
  }

  body.baby-mode .card-content {
    padding: 10px 8px 14px;
  }
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 100;
}

.modal.is-open {
  display: block;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.modal__panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 420px);
  background: #fff;
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.modal__panel h3 {
  margin: 0 0 12px;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 10px;
}

.setting-row--column {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.modal__actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
}

.quiz-view { display:none; }
.quiz-view.view--active { display:block; }
.quiz-shell { max-width: 980px; margin: 0 auto; padding: 12px 0 28px; }
.quiz-topbar { display:flex; align-items:center; justify-content:space-between; margin-bottom: 12px; }
.quiz-badge { background:#fff4dc; color:#a05a00; padding:10px 14px; border-radius:999px; font-weight:800; }
.quiz-card { background:#fff; border-radius:28px; padding:20px; box-shadow:0 20px 50px rgba(0,0,0,.08); }
.quiz-prompt { font-size: clamp(26px, 4vw, 40px); font-weight: 900; margin: 0 0 18px; text-align:center; }
.quiz-options { display:grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.quiz-option { border:none; border-radius:22px; background:#fff8ef; padding:12px; font:inherit; box-shadow:0 10px 24px rgba(0,0,0,.05); }
.quiz-option img { width:100%; aspect-ratio:1/1; object-fit:contain; }
.quiz-option span { display:block; margin-top:10px; font-weight:800; font-size:20px; }
.quiz-feedback { min-height: 32px; text-align:center; font-weight:900; font-size:24px; margin: 16px 0 8px; }
.quiz-feedback.is-good { color:#0b8f41; }
.quiz-feedback.is-bad { color:#d9485f; }
.quiz-actions { display:flex; justify-content:center; gap:10px; flex-wrap:wrap; }
.quiz-score { text-align:center; margin-top:14px; font-size:20px; font-weight:800; }
