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

:root {
  --sky1: #aee3ff;
  --sky2: #e8f7ff;
  font-size: 20px;
}

html, body {
  height: 100%;
  font-family: 'Comic Sans MS', 'Segoe UI', 'Trebuchet MS', sans-serif;
  overflow: hidden;
  user-select: none;
}

body {
  background: linear-gradient(180deg, var(--sky1) 0%, var(--sky2) 60%, #d8f3d8 100%);
  display: flex;
  flex-direction: column;
}

/* ─── Топ бар ─── */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}
#topbar .title {
  font-size: 1.15rem;
  font-weight: bold;
  color: #1e3a5f;
}
#stars {
  font-size: 1.2rem;
  letter-spacing: 2px;
  color: #f59e0b;
  min-width: 6rem;
  text-align: center;
}
#btn-sound {
  border: none;
  background: #ffffffaa;
  border-radius: 999px;
  font-size: 1.4rem;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
}
#btn-home {
  border: none;
  background: #ffffffaa;
  border-radius: 999px;
  font-size: 1rem;
  padding: 0.3rem 0.9rem;
  cursor: pointer;
  color: #1e3a5f;
  font-weight: bold;
}

/* ─── Сцена ─── */
#scene { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; padding: 0.5rem; position: relative; }

/* ─── Почетен екран ─── */
.home-logo {
  font-size: 3.4rem;
  line-height: 1.1;
  text-align: center;
  animation: bob 2.5s ease-in-out infinite;
}
.home-sub { font-size: 1.1rem; color: #1e50a0; font-weight: bold; margin-bottom: 0.6rem; }
.big-btns { display: flex; gap: 1.2rem; flex-wrap: wrap; justify-content: center; }
.big-btn {
  font-family: inherit;
  font-size: 1.5rem;
  font-weight: bold;
  border: 4px solid #ffffff;
  border-radius: 1.6rem;
  padding: 1rem 2.2rem;
  cursor: pointer;
  color: #fff;
  text-shadow: 1px 2px 0 #00000030;
  box-shadow: 0 6px 0 #0002, 0 10px 18px #0002;
  transition: transform .08s;
}
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #0002; }
.big-btn.num { background: #3b82f6; }
.big-btn.let { background: #ec4899; }
.big-btn.car { background: #f59e0b; }
.big-btn.star { background: #22c55e; }

/* ─── Избор на ниво ─── */
.lvl-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.8rem; padding: 0 1rem 1rem; max-width: 720px; }
@media (max-width: 640px) { .lvl-grid { grid-template-columns: repeat(3, 1fr); } }
.lvl-card {
  font-family: inherit;
  border: 4px solid #fff;
  border-radius: 1.2rem;
  background: #ffffffd9;
  padding: 0.7rem 0.4rem;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 5px 0 #0001, 0 8px 14px #0001;
  transition: transform .08s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}
.lvl-card:active { transform: translateY(3px); }
.lvl-card .ic { font-size: 2rem; }
.lvl-card .nm { font-size: 0.72rem; font-weight: bold; color: #1e3a5f; line-height: 1.15; }
.lvl-card.locked { filter: grayscale(1) opacity(0.55); cursor: not-allowed; }
.lvl-card .lock { font-size: 1rem; }
.lvl-card .done { color: #16a34a; font-weight: bold; font-size: 0.9rem; }

/* ─── Игра ─── */
#question { font-size: 1.5rem; font-weight: bold; color: #1e3a5f; text-align: center; padding: 0 0.5rem; }
.progress-dots { display: flex; gap: 0.45rem; }
.pdot {
  width: 0.9rem; height: 0.9rem; border-radius: 50%;
  background: #ffffff; border: 3px solid #9fc3e8;
}
.pdot.on { background: #f59e0b; border-color: #f59e0b; }
.pdot.ok { background: #22c55e; border-color: #22c55e; }

/* рамка за предмети за броење */
.items-zone {
  background: #ffffffb8;
  border: 4px dashed #ffffff;
  border-radius: 1.4rem;
  padding: 1rem 1.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: center;
  align-items: center;
  max-width: min(92vw, 620px);
  min-height: 3.2rem;
}
.items-zone .it { font-size: 2.1rem; animation: popin .25s ease-out; }

/* одговори */
.answers { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; padding: 0 0.5rem; }
.ans {
  font-family: inherit;
  font-size: 2.2rem;
  font-weight: bold;
  min-width: 4.2rem;
  padding: 0.8rem 1rem;
  border: 5px solid #fff;
  border-radius: 1.3rem;
  background: #ffffffd9;
  color: #1e3a5f;
  cursor: pointer;
  box-shadow: 0 6px 0 #0002;
  transition: transform .08s;
}
.ans.small-text { font-size: 1.5rem; }
.ans:active { transform: translateY(4px); }
.ans.right { background: #22c55e; color: #fff; animation: wiggle .35s; }
.ans.wrong { background: #ef4444; color: #fff; animation: shake .3s; }
.ans .em { font-size: 1.9rem; }

/* numberblock кукла */
.nblock {
  width: 4.6rem; height: 4.6rem;
  border-radius: 1rem 1rem 45% 45%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 2rem; font-weight: bold;
  text-shadow: 1px 2px 0 #0003;
  border: 4px solid #fff;
  box-shadow: 0 6px 0 #0002;
  animation: bob 2s ease-in-out infinite;
}
.add-row { display: flex; align-items: center; gap: 0.8rem; font-size: 2.4rem; color: #1e3a5f; font-weight: bold; }
.add-row .plus { font-size: 2rem; }

/* подредување */
.order-slots { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; }
.slot {
  width: 4.6rem; height: 4.6rem;
  border: 5px dashed #9fc3e8;
  border-radius: 1.1rem;
  background: #ffffff88;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem; font-weight: bold; color: #1e3a5f;
}
.slot.over { background: #bfdbfe; border-color: #3b82f6; }
.slot .blk { width: 100%; height: 100%; border-radius: 0.8rem 0.8rem 45% 45%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: bold; font-size: 2rem; border: 3px solid #fff; }
.tray { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; margin-top: 0.4rem; }
.tray .blk {
  width: 4.6rem; height: 4.6rem;
  border-radius: 0.9rem 0.9rem 45% 45%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: bold; font-size: 2rem;
  border: 4px solid #fff; cursor: grab;
  box-shadow: 0 6px 0 #0002;
}
.tray .blk:active { cursor: grabbing; }

/* ─── Крај на ниво ─── */
#overlay {
  position: absolute; inset: 0;
  background: #0f2540cc;
  display: none;
  align-items: center; justify-content: center;
  z-index: 10;
}
#overlay.show { display: flex; }
.dialog {
  background: #fff;
  border-radius: 1.6rem;
  padding: 1.6rem 2rem;
  text-align: center;
  max-width: min(90vw, 420px);
  box-shadow: 0 14px 40px #0005;
  animation: popin .3s ease-out;
  display: flex; flex-direction: column; gap: 0.9rem; align-items: center;
}
.dialog h2 { color: #16a34a; font-size: 1.6rem; }
.dialog .stars-big { font-size: 2.2rem; letter-spacing: 4px; color: #f59e0b; }
.dialog .btn-row { display: flex; gap: 0.8rem; flex-wrap: wrap; justify-content: center; }
.dialog button {
  font-family: inherit; font-size: 1.1rem; font-weight: bold;
  border: none; border-radius: 1rem; padding: 0.7rem 1.4rem; cursor: pointer;
  color: #fff;
}
.dialog button.green { background: #22c55e; }
.dialog button.blue { background: #3b82f6; }
.dialog button.grey { background: #64748b; }

/* ─── Анимации ─── */
@keyframes popin { 0% { transform: scale(0.3); opacity: 0; } 80% { transform: scale(1.12); } 100% { transform: scale(1); opacity: 1; } }
@keyframes wiggle { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-7px); } 75% { transform: translateX(7px); } }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes flyup { 0% { transform: translateY(0) scale(1); opacity: 1; } 100% { transform: translateY(-90px) scale(1.5); opacity: 0; } }

.flyup {
  position: absolute;
  font-size: 2rem;
  animation: flyup 0.9s ease-out forwards;
  pointer-events: none;
  z-index: 5;
}
