/* ============================================================
   Count With Me — styles
   Wordless number-learning game for ~4-year-olds.
   Bright, friendly, big targets. Color & icons only.
   ============================================================ */

:root {
  --sky-1: #2a1e5c;
  --sky-2: #4b2e83;
  --ink: #fffaf2;
  --good: #3ddc84;
  --good-dark: #18a957;
  --bad: #ff6b6b;
  --gold: #ffd23f;
  --pink: #ff8fc8;
  --blue: #5ad1ff;
  --purple: #b388ff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--sky-1);
  color: var(--ink);
  font-family: "Baloo 2", "Comic Sans MS", "Trebuchet MS", system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

#stars-bg, #confetti-canvas { position: fixed; inset: 0; }
#stars-bg { z-index: 0; }
#confetti-canvas { z-index: 4; pointer-events: none; }

#app { position: relative; z-index: 1; height: 100vh; width: 100vw; }

/* ---------- Screen switching ---------- */
.screen { position: absolute; inset: 0; display: none; flex-direction: column; }
.screen.active { display: flex; }

/* ---------- Top bar / HUD ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  z-index: 5;
}

.icon-btn {
  font-size: 32px;
  line-height: 1;
  background: rgba(255,255,255,0.1);
  border: 3px solid rgba(255,255,255,0.22);
  border-radius: 18px;
  padding: 8px 14px;
  cursor: pointer;
  color: var(--ink);
  transition: transform .12s ease, background .12s ease;
}
.icon-btn:hover { background: rgba(255,255,255,0.2); }
.icon-btn:active { transform: scale(0.9); }

.star-counter {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 32px;
  font-weight: 900;
  background: rgba(255, 210, 63, 0.18);
  border: 3px solid rgba(255, 210, 63, 0.45);
  border-radius: 18px;
  padding: 6px 16px;
}
.star-icon { font-size: 30px; }
.star-bump { animation: starBump .45s ease; }

/* Level pill (grown-up difficulty control) */
.level-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 26px;
  font-weight: 900;
  color: var(--ink);
  background: rgba(90, 209, 255, 0.16);
  border: 3px solid rgba(90, 209, 255, 0.5);
  border-radius: 18px;
  padding: 6px 14px;
  cursor: pointer;
  transition: transform .12s ease, background .12s ease;
}
.level-pill:hover { background: rgba(90, 209, 255, 0.28); }
.level-pill:active { transform: scale(0.92); }
.level-icon { font-size: 24px; }

/* Friend progress meter */
.friend-wrap { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.friend-track {
  width: 160px; height: 20px;
  background: rgba(0,0,0,0.3);
  border: 3px solid rgba(255,255,255,0.25);
  border-radius: 14px;
  overflow: hidden;
}
#friend-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--pink), var(--purple));
  border-radius: 12px;
  transition: width .4s ease;
}
.next-friend { font-size: 28px; }

/* ============================================================
   OBJECT TRAY (things to count)
   ============================================================ */
.object-tray {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 10px 18px;
  padding: 20px 40px;
  max-width: 1100px;
  margin: 0 auto;
}
.count-obj {
  font-size: clamp(46px, 8vw, 84px);
  line-height: 1;
  cursor: pointer;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.4));
  animation: idleBob 3s ease-in-out infinite;
  transition: transform .1s ease;
}
/* stagger the idle bob so they don't move in lockstep */
.count-obj:nth-child(3n)   { animation-delay: .4s; }
.count-obj:nth-child(3n+1) { animation-delay: .8s; }
.count-obj.boing { animation: boing .5s ease; }
.count-obj.celebrate { animation: celebrate .6s ease; }

/* ============================================================
   ANSWER BOXES
   ============================================================ */
.answer-boxes {
  display: flex;
  justify-content: center;
  gap: clamp(12px, 3vw, 34px);
  padding: 16px 20px 40px;
  flex-wrap: wrap;
}
.answer-box {
  width: clamp(96px, 18vw, 150px);
  height: clamp(96px, 18vw, 150px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(52px, 10vw, 88px);
  font-weight: 900;
  color: #2a1e5c;
  border: none;
  border-radius: 28px;
  cursor: pointer;
  box-shadow: 0 8px 0 rgba(0,0,0,0.28), 0 12px 22px rgba(0,0,0,0.35);
  transition: transform .08s ease, box-shadow .08s ease;
}
/* four cheerful colors, cycled */
.answer-box:nth-child(1) { background: linear-gradient(180deg, #ffe27a, #ffd23f); }
.answer-box:nth-child(2) { background: linear-gradient(180deg, #9be8ff, #5ad1ff); }
.answer-box:nth-child(3) { background: linear-gradient(180deg, #ffb3da, #ff8fc8); }
.answer-box:nth-child(4) { background: linear-gradient(180deg, #c9b3ff, #b388ff); }

.answer-box:hover { transform: translateY(-4px); }
.answer-box:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,0.28), 0 6px 12px rgba(0,0,0,0.35); }

.answer-box.typing-match { outline: 6px solid var(--gold); outline-offset: 4px; }

.answer-box.correct {
  background: linear-gradient(180deg, #6bf0a4, #3ddc84) !important;
  color: #0c4a2a;
  animation: pop .5s ease;
}
.answer-box.wrong {
  background: linear-gradient(180deg, #ff9a9a, #ff6b6b) !important;
  animation: wobble .5s ease;
}
.answer-box.dim { opacity: 0.35; pointer-events: none; }
.answer-boxes.locked .answer-box { pointer-events: none; }

/* ============================================================
   COLLECTION / STICKER BOOK
   ============================================================ */
.friend-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, 120px);
  gap: 18px;
  justify-content: center;
  align-content: start;
  padding: 20px 24px 60px;
}
.friend-cell {
  width: 120px; height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  background: rgba(255,255,255,0.07);
  border: 3px solid rgba(255,255,255,0.18);
  border-radius: 24px;
}
.friend-cell.owned {
  background: rgba(255, 210, 63, 0.14);
  border-color: var(--gold);
  box-shadow: 0 0 18px rgba(255,210,63,0.3);
  animation: floaty 3s ease-in-out infinite;
}
.friend-cell.empty { opacity: 0.3; font-size: 40px; }

/* Big celebratory pop-in when a new friend is earned */
#friend-popup {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(20, 10, 50, 0.55);
}
#friend-popup.show { display: flex; }
#friend-popup .pop-friend {
  font-size: 180px;
  animation: friendPop .7s cubic-bezier(.2,1.5,.4,1);
  filter: drop-shadow(0 10px 18px rgba(0,0,0,0.5));
}

#reset-zone {
  position: fixed;
  bottom: 0; left: 0;
  width: 70px; height: 70px;
  z-index: 20;
}

/* ============================================================
   KEYFRAMES
   ============================================================ */
@keyframes idleBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
@keyframes boing {
  0% { transform: scale(1); }
  30% { transform: scale(1.4) translateY(-14px); }
  60% { transform: scale(0.9); }
  100% { transform: scale(1); }
}
@keyframes celebrate {
  0% { transform: scale(1) rotate(0); }
  25% { transform: scale(1.3) rotate(-12deg); }
  50% { transform: scale(1.2) rotate(12deg); }
  75% { transform: scale(1.25) rotate(-8deg); }
  100% { transform: scale(1) rotate(0); }
}
@keyframes pop { 0% { transform: scale(1); } 45% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes wobble {
  0%,100% { transform: translateX(0) rotate(0); }
  20% { transform: translateX(-10px) rotate(-5deg); }
  40% { transform: translateX(10px) rotate(5deg); }
  60% { transform: translateX(-7px) rotate(-3deg); }
  80% { transform: translateX(7px) rotate(3deg); }
}
@keyframes starBump {
  0% { transform: scale(1); }
  50% { transform: scale(1.35); color: var(--gold); }
  100% { transform: scale(1); }
}
@keyframes friendPop {
  0% { transform: scale(0) rotate(-40deg); }
  70% { transform: scale(1.25) rotate(10deg); }
  100% { transform: scale(1) rotate(0); }
}
