/* Kleuter Leren – styles
   Touch-first, big targets (>= 64px), works on phone / tablet / laptop. */

:root {
  --bg: #fff8e7;
  --card: #ffffff;
  --ink: #2b2b2b;
  --muted: #6b6b6b;
  --primary: #4f7dff;
  --primary-ink: #ffffff;
  --accent: #ffd93d;
  --good: #43a047;
  --bad: #e53935;
  --radius: 24px;
  --shadow: 0 6px 0 rgba(0, 0, 0, .10), 0 10px 24px rgba(0, 0, 0, .08);
  --tap: 72px;
  --font: "Nunito", "Segoe UI Rounded", "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}
button:focus-visible { outline: 4px solid var(--primary); outline-offset: 3px; }

/* ---------- header ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}
.topbar h1 {
  flex: 1;
  margin: 0;
  font-size: clamp(1.2rem, 4vw, 1.8rem);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.iconbtn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 1.6rem;
  display: grid;
  place-items: center;
  transition: transform .1s;
}
.iconbtn:active { transform: translateY(3px); }

/* progress stars */
.progress {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 0 16px 8px;
  font-size: clamp(1.2rem, 4vw, 1.8rem);
}
.progress .star { opacity: .25; transition: transform .3s, opacity .3s; }
.progress .star.on { opacity: 1; animation: pop .4s; }

/* ---------- home ---------- */
.home {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 16px 24px;
  gap: 16px;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}
.hero {
  text-align: center;
  padding: 8px 0 0;
}
.hero .face { font-size: clamp(3rem, 12vw, 5rem); line-height: 1; }
.hero h1 { margin: 8px 0 0; font-size: clamp(1.6rem, 6vw, 2.6rem); }
.hero p { margin: 4px 0 0; color: var(--muted); font-size: clamp(1rem, 3vw, 1.2rem); }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}
.tile {
  min-height: 150px;
  border-radius: var(--radius);
  background: var(--tile, var(--card));
  color: #fff;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: clamp(1.1rem, 3.5vw, 1.5rem);
  font-weight: 800;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .15);
  transition: transform .1s;
}
.tile:active { transform: scale(.96); }
.tile .emoji { font-size: clamp(3rem, 10vw, 4.5rem); line-height: 1; }

.levels {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
.level {
  min-height: 64px;
  padding: 10px 22px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: var(--shadow);
  font-weight: 800;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 4px solid transparent;
}
.level.on { border-color: var(--primary); background: #e8efff; }

.hint {
  text-align: center;
  color: var(--muted);
  font-size: .95rem;
  margin: 0;
}

/* ---------- activity ---------- */
.activity {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 16px 24px;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
}
.prompt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  margin: 4px 0 16px;
  min-height: 64px;
}
.prompt .text {
  font-size: clamp(1.4rem, 5vw, 2.2rem);
  font-weight: 800;
  text-align: center;
}
.prompt .text b { color: var(--primary); }

.stage {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.options {
  width: 100%;
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(clamp(120px, 28vw, 200px), 1fr));
  justify-items: center;
}
.option {
  width: 100%;
  aspect-ratio: 1;
  max-width: 220px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  font-size: clamp(3rem, 14vw, 6rem);
  line-height: 1;
  transition: transform .1s, opacity .3s;
}
.option:active { transform: scale(.95); }
.option .swatch {
  width: 70%;
  height: 70%;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: inset 0 -8px 0 rgba(0, 0, 0, .12);
}
.option svg { width: 70%; height: 70%; }
.option.number { font-size: clamp(2.6rem, 12vw, 5rem); font-weight: 900; color: var(--primary); }
.option.right { background: #e6f5e8; animation: pop .5s; }
.option.wrong { animation: wobble .5s; }
.option.dim { opacity: .35; pointer-events: none; }
.option.hintme { animation: pulse 1s infinite; }

/* counting */
.items {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 600px;
  min-height: 120px;
}
.item {
  width: clamp(72px, 18vw, 110px);
  height: clamp(72px, 18vw, 110px);
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  font-size: clamp(2.6rem, 11vw, 4.2rem);
  line-height: 1;
  position: relative;
  transition: transform .1s;
}
.item:active { transform: scale(.92); }
.item.counted::after {
  content: attr(data-n);
  position: absolute;
  right: -6px;
  top: -6px;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 1rem;
  font-weight: 900;
  display: grid;
  place-items: center;
  animation: pop .3s;
}
.numbers { grid-template-columns: repeat(auto-fit, minmax(clamp(72px, 18vw, 120px), 1fr)); }
.numbers .option { max-width: 130px; border-radius: 20px; }

/* explore (animals) */
.explore {
  grid-template-columns: repeat(auto-fit, minmax(clamp(96px, 22vw, 150px), 1fr));
}
.explore .option {
  max-width: 160px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
  padding: 6px;
  font-size: clamp(2.4rem, 9vw, 3.6rem);
}
.explore .option > span:first-child { line-height: 1.15; }
.explore .option .label {
  font-size: 1rem;
  font-weight: 800;
  color: var(--muted);
  line-height: 1.2;
}
.option.bounce { animation: bounce .6s; }

/* ---------- done screen ---------- */
.done {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
  padding: 24px;
}
.done .big { font-size: clamp(4rem, 20vw, 8rem); line-height: 1; animation: bounce 1s; }
.done h2 { margin: 0; font-size: clamp(1.6rem, 6vw, 2.4rem); }
.bigbtn {
  min-height: var(--tap);
  padding: 14px 32px;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-ink);
  font-weight: 800;
  font-size: 1.25rem;
  box-shadow: var(--shadow);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: transform .1s;
}
.bigbtn.secondary { background: var(--card); color: var(--ink); }
.bigbtn:active { transform: translateY(3px); }

/* ---------- confetti ---------- */
#confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}
.piece {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 18px;
  border-radius: 3px;
  animation: fall linear forwards;
}

/* ---------- animations ---------- */
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes wobble {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px) rotate(-4deg); }
  40% { transform: translateX(10px) rotate(4deg); }
  60% { transform: translateX(-8px) rotate(-3deg); }
  80% { transform: translateX(8px) rotate(3deg); }
}
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  30% { transform: translateY(-22px) scale(1.06); }
  60% { transform: translateY(0); }
  80% { transform: translateY(-8px); }
}
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes fall {
  0% { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: .8; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* landscape phones: keep everything on one screen */
@media (max-height: 480px) and (orientation: landscape) {
  .hero .face { display: none; }
  .tile { min-height: 110px; }
  .prompt { margin-bottom: 8px; min-height: 48px; }
  .option { max-width: 150px; }
}

/* ---------- login ---------- */
.login {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 8px 16px 24px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}
.login .prompt { margin-bottom: 4px; }
.card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card label { font-weight: 800; color: var(--muted); }
.card input {
  font: inherit;
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: .2em;
  text-align: center;
  text-transform: uppercase;
  padding: 12px;
  border: 4px solid #e5e5e5;
  border-radius: 16px;
  min-height: var(--tap);
  width: 100%;
}
.card input:focus { outline: none; border-color: var(--primary); }
.error { color: var(--bad); font-weight: 800; text-align: center; margin: 0; }
.linkbtn { color: var(--primary); font-weight: 800; text-decoration: underline; padding: 8px; min-height: 44px; }
.hint a { color: var(--primary); font-weight: 800; }

/* ---------- duel ---------- */
.scoreboard {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  max-width: 520px;
  margin-bottom: 4px;
}
.player {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border-radius: 999px;
  padding: 6px 14px 6px 8px;
  box-shadow: var(--shadow);
  border: 4px solid transparent;
}
.player.you { border-color: var(--primary); }
.player .av { font-size: 2rem; line-height: 1; }
.player .nm { flex: 1; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .sc { font-size: 1.6rem; font-weight: 900; color: var(--primary); min-width: 1.4em; text-align: center; }
.vs { font-size: 1.6rem; }
.waiting { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; max-width: 480px; }
.waiting .big { font-size: clamp(4rem, 18vw, 7rem); line-height: 1; }
.waiting .pulse { animation: pulse 1.4s infinite; }
.waiting p { margin: 0; font-size: 1.15rem; }
.items.small .item, .sum .item { width: clamp(44px, 10vw, 64px); height: clamp(44px, 10vw, 64px); font-size: clamp(1.7rem, 6vw, 2.6rem); border-radius: 14px; pointer-events: none; }
.sum { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
.sum .group { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 220px; }
.sum .plus { font-size: 2.6rem; font-weight: 900; color: var(--primary); }
.sumtext { font-size: clamp(1.6rem, 6vw, 2.4rem); font-weight: 900; }
.activity .done { padding: 8px; }
.stars { font-size: clamp(1.4rem, 5vw, 2rem); }

/* ---------- voice picker ---------- */
.voicelist { gap: 8px; max-width: 520px; }
.voice { display: flex; align-items: center; gap: 10px; }
.voice .voicepick { flex: 1; text-align: left; min-height: 56px; padding: 8px 14px; border-radius: 16px; border: 3px solid transparent; background: #f4f6fb; display: flex; flex-direction: column; }
.voice.on .voicepick { border-color: var(--primary); background: #e8efff; }
.voice small { color: var(--muted); }
.voice .iconbtn { width: 48px; height: 48px; font-size: 1.1rem; flex: 0 0 auto; }

/* ---------- animal photos (public/media/foto, optional) ---------- */
.option { position: relative; overflow: hidden; }
.option img.photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.option.hasphoto .label {
  position: absolute; left: 8px; right: 8px; bottom: 8px;
  background: rgba(255, 255, 255, .88); border-radius: 12px; padding: 4px 6px; color: var(--ink); text-align: center;
}
