/* Dín — warm daylight. Duun words: Andika; UI: Baloo 2. */

:root {
  --paper: #f5ebd8;
  --paper-deep: #eaddc2;
  --ink: #3a2a1a;
  --ink-soft: #6b5540;
  --ochre: #e8a13d;
  --ochre-deep: #c87f2b;
  --laterite: #9c3b22;
  --indigo: #29457c;
  --leaf: #6b8f3d;
  --rose: #c96a50;
  --white: #fffdf7;
  --shadow: 0 6px 0 rgba(58, 42, 26, 0.16);
  --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

html { height: 100%; }

body {
  min-height: 100%;
  background:
    radial-gradient(140% 90% at 50% -30%, rgba(232, 161, 61, 0.25), transparent 60%),
    var(--paper);
  color: var(--ink);
  font-family: "Baloo 2", system-ui, sans-serif;
  padding-bottom: 58px;
  overflow-x: hidden;
}

[lang^="dux"] { font-family: "Andika", sans-serif; }

#confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 90;
}

/* ---------- header ---------- */

#top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 16px 6px;
}

#top h1 {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--laterite);
  line-height: 1;
}

#top h1 .sub {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}

#home-btn {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 16px;
  background: var(--white);
  color: var(--indigo);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  transition: transform 0.2s var(--bounce);
}

#home-btn:active { transform: scale(0.88); }
#home-btn svg { width: 24px; height: 24px; }

#stars {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--white);
  border-radius: 999px;
  padding: 7px 14px 7px 10px;
  box-shadow: var(--shadow);
  color: var(--ochre-deep);
  font-weight: 800;
  font-size: 1.05rem;
}

#stars svg { width: 20px; height: 20px; }

#stars.pop { animation: starpop 0.5s var(--bounce); }

@keyframes starpop {
  40% { transform: scale(1.25) rotate(6deg); }
}

/* ---------- home ---------- */

#view { padding: 10px 16px 30px; max-width: 560px; margin: 0 auto; }

.hello {
  text-align: center;
  font-size: 1.02rem;
  color: var(--ink-soft);
  margin: 6px 0 16px;
  font-weight: 600;
}

.cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }

.cat-card {
  border: 0;
  border-radius: 24px;
  padding: 18px 12px 14px;
  background: var(--white);
  box-shadow: var(--shadow);
  text-align: center;
  transition: transform 0.25s var(--bounce);
  animation: bounce-in 0.5s var(--bounce) both;
  animation-delay: calc(var(--i) * 60ms);
}

.cat-card:active { transform: scale(0.92); }

.cat-card .glyph {
  width: 62px;
  height: 62px;
  margin: 0 auto 8px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--white);
}

.cat-card .glyph svg { width: 34px; height: 34px; }

.cat-card .name { display: block; font-size: 1.15rem; font-weight: 800; color: var(--ink); line-height: 1.1; }
.cat-card .count { display: block; font-size: 0.8rem; color: var(--ink-soft); font-weight: 600; margin-top: 3px; }

@keyframes bounce-in {
  from { opacity: 0; transform: scale(0.6) translateY(20px); }
}

.game-cta {
  margin-top: 18px;
  width: 100%;
  border: 0;
  border-radius: 26px;
  padding: 20px;
  background: linear-gradient(140deg, var(--indigo), #1d3560);
  color: var(--white);
  font-family: inherit;
  font-size: 1.35rem;
  font-weight: 800;
  box-shadow: 0 8px 0 rgba(29, 53, 96, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition: transform 0.25s var(--bounce);
  animation: bounce-in 0.5s var(--bounce) 0.45s both;
}

.game-cta:active { transform: scale(0.95); }
.game-cta svg { width: 30px; height: 30px; }
.game-cta .small { display: block; font-size: 0.8rem; font-weight: 600; opacity: 0.85; }

/* ---------- deck (card pager) ---------- */

.deck-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 4px 0 12px;
  font-weight: 800;
  font-size: 1.2rem;
}

.deck-head .glyph {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--white);
}

.deck-head .glyph svg { width: 19px; height: 19px; }

.photo-card {
  position: relative;
  background: var(--white);
  border-radius: 26px;
  box-shadow: 0 10px 24px rgba(58, 42, 26, 0.18);
  padding: 14px 14px 20px;
  transform: rotate(var(--tilt, -1.2deg));
  animation: card-in 0.4s var(--bounce) both;
}

@keyframes card-in {
  from { opacity: 0; transform: translateX(60px) rotate(4deg) scale(0.9); }
  to { opacity: 1; transform: rotate(var(--tilt, -1.2deg)); }
}

.photo-card.leaving { animation: card-out 0.25s ease both; }

@keyframes card-out {
  to { opacity: 0; transform: translateX(-70px) rotate(-6deg) scale(0.9); }
}

.photo-card img {
  width: 100%;
  aspect-ratio: 1 / 0.86;
  object-fit: cover;
  border-radius: 16px;
  background: var(--paper-deep);
}

.photo-card .word-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}

.photo-card .word {
  font-size: 2.3rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.photo-card .fr {
  text-align: center;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 1rem;
  margin-top: 2px;
}

.photo-card.saying img { animation: wiggle 0.6s ease; }

@keyframes wiggle {
  25% { transform: rotate(2.2deg) scale(1.03); }
  60% { transform: rotate(-2deg) scale(1.02); }
}

.speak-hint {
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-soft);
  font-weight: 600;
  margin-top: 12px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}

.pager .nav {
  width: 62px;
  height: 62px;
  border: 0;
  border-radius: 50%;
  background: var(--ochre);
  color: var(--white);
  box-shadow: 0 6px 0 var(--ochre-deep);
  display: grid;
  place-items: center;
  transition: transform 0.2s var(--bounce);
}

.pager .nav:active { transform: scale(0.88) translateY(3px); box-shadow: 0 2px 0 var(--ochre-deep); }
.pager .nav:disabled { opacity: 0.35; }
.pager .nav svg { width: 28px; height: 28px; }

.pager .where { font-weight: 800; color: var(--ink-soft); font-size: 1.05rem; }

/* audio button on cards */
.say-btn {
  flex: 0 0 auto;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: var(--laterite);
  color: var(--white);
  box-shadow: 0 5px 0 #6d2a19;
  display: grid;
  place-items: center;
  transition: transform 0.2s var(--bounce);
}

.say-btn:active { transform: scale(0.85); }
.say-btn svg { width: 24px; height: 24px; }
.say-btn.playing { animation: pulse-btn 0.9s ease infinite; }

@keyframes pulse-btn {
  50% { transform: scale(1.12); }
}

/* ---------- game ---------- */

.game-word {
  text-align: center;
  margin: 2px 0 14px;
}

.game-word .listen {
  border: 0;
  background: var(--indigo);
  color: var(--white);
  border-radius: 999px;
  padding: 14px 26px;
  font-family: inherit;
  font-size: 1.25rem;
  font-weight: 800;
  box-shadow: 0 6px 0 #1d3560;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: transform 0.2s var(--bounce);
}

.game-word .listen:active { transform: scale(0.93); }
.game-word .listen svg { width: 24px; height: 24px; }

.game-round { text-align: center; font-weight: 800; color: var(--ink-soft); margin-bottom: 10px; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.choice {
  border: 5px solid transparent;
  border-radius: 22px;
  background: var(--white);
  box-shadow: var(--shadow);
  padding: 10px;
  transition: transform 0.25s var(--bounce), border-color 0.2s;
  animation: bounce-in 0.45s var(--bounce) both;
}

.choice:nth-child(2) { animation-delay: 90ms; }

.choice img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 14px;
  background: var(--paper-deep);
}

.choice .label {
  display: block;
  text-align: center;
  font-weight: 700;
  font-size: 1.05rem;
  padding-top: 7px;
  color: var(--ink);
}

.choice.right { border-color: var(--leaf); animation: rightpop 0.5s var(--bounce); }
.choice.wrong { border-color: var(--rose); animation: shake 0.4s ease; }
.choice:disabled { pointer-events: none; }

@keyframes rightpop { 40% { transform: scale(1.07); } }

@keyframes shake {
  20% { transform: translateX(-9px); }
  45% { transform: translateX(8px); }
  70% { transform: translateX(-5px); }
  90% { transform: translateX(3px); }
}

.celebrate {
  text-align: center;
  padding: 30px 10px;
  animation: bounce-in 0.6s var(--bounce) both;
}

.celebrate .big-star { width: 110px; height: 110px; color: var(--ochre); margin-bottom: 10px; }
.celebrate h2 { font-size: 1.7rem; color: var(--laterite); margin-bottom: 6px; }
.celebrate p { color: var(--ink-soft); font-weight: 600; margin-bottom: 20px; }

.big-btn {
  border: 0;
  border-radius: 22px;
  background: var(--ochre);
  color: var(--white);
  font-family: inherit;
  font-size: 1.2rem;
  font-weight: 800;
  padding: 15px 30px;
  box-shadow: 0 6px 0 var(--ochre-deep);
  margin: 5px;
  transition: transform 0.2s var(--bounce);
}

.big-btn:active { transform: scale(0.93); }
.big-btn.blue { background: var(--indigo); box-shadow: 0 6px 0 #1d3560; }

/* ---------- footer ---------- */

#foot {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 18px calc(9px + env(safe-area-inset-bottom));
  background: rgba(245, 235, 216, 0.94);
  border-top: 2px dashed rgba(58, 42, 26, 0.15);
  font-size: 0.8rem;
  font-weight: 700;
}

#foot a { color: var(--indigo); text-decoration: none; }

#net-badge {
  border: 2px solid var(--ochre);
  color: var(--ochre-deep);
  border-radius: 999px;
  padding: 1px 10px;
}

button { cursor: pointer; font-family: inherit; }

.g-animaux { background: var(--leaf); }
.g-plantes { background: #4d7c43; }
.g-objets { background: var(--indigo); }
.g-musique { background: var(--laterite); }
.g-corps { background: var(--rose); }
.g-actions { background: var(--ochre-deep); }
.g-village { background: #8a6d3b; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
