/* Idika's Animal Quiz — light purple (lavender) theme */
@import url("https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&display=swap");

:root {
  --bg-1: #f3eeff;
  --bg-2: #e7deff;
  --card: #ffffff;
  --primary: #8b5cf6;
  --primary-dark: #7c3aed;
  --accent: #c4b5fd;
  --accent-soft: #ede9fe;
  --text: #3b2e5a;
  --text-soft: #6b5b8a;
  --correct: #34d399;
  --wrong: #fb7185;
  --gold: #fbbf24;
  --shadow: 0 10px 30px rgba(124, 58, 237, 0.18);
  --shadow-sm: 0 4px 14px rgba(124, 58, 237, 0.14);
}

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

body {
  font-family: "Fredoka", system-ui, sans-serif;
  color: var(--text);
  min-height: 100vh;
  background: linear-gradient(160deg, var(--bg-1) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px;
  -webkit-tap-highlight-color: transparent;
}

.app { width: 100%; max-width: 520px; }

/* Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.logo { font-size: 26px; font-weight: 700; color: var(--primary-dark); }
.logo small { display: block; font-size: 13px; font-weight: 500; color: var(--text-soft); }
.whoami { font-size: 14px; color: var(--text-soft); display: flex; align-items: center; gap: 8px; }

/* Cards */
.card {
  background: var(--card);
  border-radius: 26px;
  padding: 26px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card h2 { font-size: 22px; margin-bottom: 6px; }
.card p.sub { color: var(--text-soft); font-size: 15px; margin-bottom: 18px; }

/* Buttons */
.btn {
  font-family: inherit;
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: 18px;
  padding: 15px 22px;
  width: 100%;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.08s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn:hover { background: var(--primary-dark); }
.btn.secondary {
  background: var(--accent-soft);
  color: var(--primary-dark);
  box-shadow: none;
}
.btn.ghost { background: transparent; color: var(--text-soft); box-shadow: none; font-size: 15px; }
.btn.share-wa { background: #25d366; color: #fff; display: block; text-align: center; text-decoration: none; }
.btn.share-wa:hover { background: #1ebe5b; }
a.btn { display: block; text-align: center; text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn + .btn { margin-top: 10px; }

/* Inputs */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 15px; font-weight: 500; margin-bottom: 8px; }
.field input {
  font-family: inherit;
  font-size: 18px;
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--accent);
  border-radius: 16px;
  color: var(--text);
  background: #fff;
}
.field input:focus { outline: none; border-color: var(--primary); }

/* Picture-password grid */
.pic-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 14px 0;
}
.pic {
  aspect-ratio: 1;
  background: var(--accent-soft);
  border: 3px solid transparent;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  transition: transform 0.08s ease, border-color 0.12s ease;
  position: relative;
}
.pic .emoji { font-size: 30px; line-height: 1; }
.pic .label { font-size: 11px; font-weight: 600; color: var(--text-soft); } /* name under each picture */
.pic:active { transform: scale(0.92); }
.pic.picked { border-color: var(--primary); box-shadow: var(--shadow-sm); }

/* Soft "a little colorful" pastel tiles */
.pic.c-blue   { background: #dbeafe; }
.pic.c-pink   { background: #fce7f3; }
.pic.c-yellow { background: #fef3c7; }
.pic.c-orange { background: #ffedd5; }
.pic.c-green  { background: #dcfce7; }
.pic.c-purple { background: #ede9fe; }
.pic.c-cyan   { background: #cffafe; }
.pic.c-red    { background: #ffe4e6; }
.pic .order {
  position: absolute;
  top: -8px; right: -8px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

/* Sequence preview dots */
.seq-preview { display: flex; gap: 8px; justify-content: center; min-height: 40px; align-items: center; margin-bottom: 6px; }
.seq-preview .dot {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--accent-soft); display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.seq-preview .empty { background: repeating-linear-gradient(45deg, #f3eeff, #f3eeff 6px, #ece4ff 6px, #ece4ff 12px); }

/* Quiz */
.progress { height: 10px; background: var(--accent-soft); border-radius: 8px; overflow: hidden; margin-bottom: 18px; }
.progress > span { display: block; height: 100%; background: var(--primary); transition: width 0.3s ease; }
.q-emoji { font-size: 84px; text-align: center; margin: 6px 0 14px; }
.q-photo { width: 100%; max-height: 220px; object-fit: cover; border-radius: 18px; margin-bottom: 14px; }
.q-prompt { font-size: 22px; font-weight: 600; text-align: center; margin-bottom: 20px; }
.hear-btn {
  border: none; background: var(--accent-soft); color: var(--primary-dark);
  font-size: 18px; width: 38px; height: 38px; border-radius: 50%;
  cursor: pointer; vertical-align: middle; margin-left: 4px;
}
.hear-btn:active { transform: scale(0.9); }
.options { display: grid; gap: 12px; }
.option {
  font-family: inherit; font-size: 18px; font-weight: 500;
  background: #fff; color: var(--text);
  border: 3px solid var(--accent-soft);
  border-radius: 18px; padding: 16px; cursor: pointer; text-align: left;
  transition: transform 0.08s ease, border-color 0.12s ease;
}
.option { display: flex; align-items: center; gap: 12px; }
.opt-emoji { font-size: 28px; line-height: 1; flex-shrink: 0; }
.option:active { transform: scale(0.98); }
.option.correct { border-color: var(--correct); background: #ecfdf5; }
.option.wrong { border-color: var(--wrong); background: #fff1f2; }
.option:disabled { cursor: default; }
.badge-challenge {
  display: inline-block; background: var(--gold); color: #5b3d00;
  font-size: 13px; font-weight: 700; padding: 4px 12px; border-radius: 20px; margin-bottom: 10px;
}

/* Coins */
.coins { display: flex; align-items: center; gap: 6px; font-weight: 700; color: var(--text); }
.coins .c { color: var(--gold); }

/* Results */
.result-emoji { font-size: 92px; text-align: center; }
.result-score { font-size: 40px; font-weight: 700; text-align: center; color: var(--primary-dark); }
.result-msg { text-align: center; color: var(--text-soft); margin: 8px 0 20px; font-size: 17px; }

/* Leaderboard */
.lb-row { display: flex; align-items: center; gap: 12px; padding: 12px 6px; border-bottom: 1px solid var(--accent-soft); }
.lb-row:last-child { border-bottom: none; }
.lb-rank { font-weight: 700; color: var(--primary); width: 28px; }
.lb-name { flex: 1; font-weight: 500; }
.lb-score { font-weight: 700; color: var(--gold); }
.lb-row.me { background: var(--accent-soft); border-radius: 12px; }

/* Misc */
.msg { font-size: 15px; text-align: center; padding: 10px; border-radius: 12px; margin-top: 10px; }
.msg.error { background: #fff1f2; color: #be123c; }
.msg.ok { background: #ecfdf5; color: #047857; }

/* Memory-story helper */
.story { margin: 4px 0 6px; }
.story-line {
  background: var(--accent-soft); border-radius: 14px; padding: 12px 14px;
  text-align: center; font-size: 15px; color: var(--text);
}
.story-line b { color: var(--primary-dark); }
.story-tip { font-size: 13px; color: var(--text-soft); }

/* Grown-up setup + dropdown */
.setup { margin: 8px 0; }
.setup summary { cursor: pointer; color: var(--text-soft); font-size: 14px; padding: 6px 0; }
.select {
  font-family: inherit; font-size: 18px; width: 100%;
  padding: 14px 16px; border: 2px solid var(--accent); border-radius: 16px;
  color: var(--text); background: #fff; appearance: none; -webkit-appearance: none;
}
.select:focus { outline: none; border-color: var(--primary); }
.center { text-align: center; }
.hide { display: none !important; }
.hint { font-size: 13px; color: var(--text-soft); text-align: center; margin-top: 14px; }
.cat-btn { display: flex; justify-content: space-between; align-items: center; }
.cat-btn .n { font-size: 13px; opacity: 0.8; }

/* Music toggle (floating) */
.music-btn {
  position: fixed;
  top: 14px; right: 14px;
  z-index: 50;
  width: 48px; height: 48px;
  border: none; border-radius: 50%;
  background: #fff; color: var(--primary-dark);
  font-size: 22px; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s ease;
}
.music-btn:active { transform: scale(0.9); }
.music-btn.off { opacity: 0.55; }

/* Language switcher (flag, to the left of the music button) */
.lang-btn {
  position: fixed;
  top: 14px; right: 70px;
  z-index: 50;
  width: 48px; height: 48px;
  border: none; border-radius: 50%;
  background: #fff;
  font-size: 24px; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.1s ease;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.lang-btn:active { transform: scale(0.9); }

/* Kannada (Karnataka) flag — yellow over red, no emoji exists for it */
.kn-flag {
  display: inline-block; width: 24px; height: 17px; border-radius: 3px;
  vertical-align: -3px;
  background: linear-gradient(to bottom, #f9d616 0 50%, #e2231a 50% 100%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12) inset;
}
.lp-opt { text-align: center; }
.btn.picked-opt { outline: 3px solid var(--primary); outline-offset: 2px; }

/* Footer credit */
.credit {
  text-align: center; font-size: 12px; color: var(--text-soft);
  margin: 16px auto 6px; line-height: 1.5; padding: 0 10px;
}
.credit b { color: var(--primary-dark); }

/* Overlay (music chooser) */
.overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(59, 46, 90, 0.35);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.overlay-card {
  background: #fff; border-radius: 24px; padding: 22px;
  width: 100%; max-width: 320px; box-shadow: var(--shadow);
}
.mp-title { font-size: 19px; font-weight: 700; text-align: center; margin-bottom: 16px; color: var(--primary-dark); }
.mp-opt.picked-opt { outline: 3px solid var(--primary); outline-offset: 2px; }

/* End-of-game review */
.review-title { font-size: 17px; font-weight: 600; margin: 18px 0 10px; text-align: center; }
.review-row {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px; border-radius: 14px; margin-bottom: 8px;
  background: var(--accent-soft);
}
.review-row.ok { background: #ecfdf5; }
.review-row.no { background: #fff1f2; }
.review-mark { font-size: 20px; line-height: 1.2; }
.review-prompt { font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.review-ans { font-size: 14px; color: var(--text-soft); }
.review-ans b { color: var(--text); }

/* Tiny decorative emojis */
.deco { font-size: 18px; opacity: 0.8; }

/* ===== Avatar buddy ===== */
/* The figure: a coloured circle with a big character emoji + optional hat */
.a-figure-wrap { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.a-circle {
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.a-base { line-height: 1; }
.a-hat { position: absolute; top: -6%; left: 50%; transform: translateX(-50%); line-height: 1; }

/* Floating buddy, always on screen once logged in */
.avatar-float {
  position: fixed;
  left: 14px; bottom: 14px;
  z-index: 60;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.avatar-float .a-circle { width: 70px; height: 70px; }
.avatar-float .a-base { font-size: 40px; }
.avatar-float .a-hat { font-size: 26px; }

/* Idle gentle dance */
@keyframes buddy-bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-7px) rotate(3deg); }
}
.avatar-figure { animation: buddy-bob 2.2s ease-in-out infinite; transform-origin: bottom center; }

/* Tap poses */
@keyframes pose-jump { 0%,100% { transform: translateY(0) scale(1); } 40% { transform: translateY(-26px) scale(1.12); } }
@keyframes pose-spin { 0% { transform: rotate(0) scale(1); } 100% { transform: rotate(360deg) scale(1.1); } }
@keyframes pose-wiggle { 0%,100%{transform:rotate(0)} 20%{transform:rotate(-18deg)} 40%{transform:rotate(16deg)} 60%{transform:rotate(-12deg)} 80%{transform:rotate(8deg)} }
.pose-jump { animation: pose-jump 0.6s ease !important; }
.pose-spin { animation: pose-spin 0.7s ease !important; }
.pose-wiggle { animation: pose-wiggle 0.7s ease !important; }

/* Speech bubble */
.avatar-bubble {
  position: absolute;
  bottom: 78px; left: 0;
  background: #fff; color: var(--text);
  border: 2px solid var(--accent);
  border-radius: 16px; padding: 8px 12px;
  font-size: 14px; font-weight: 600;
  max-width: 180px; white-space: normal;
  box-shadow: var(--shadow-sm);
  animation: bubble-pop 0.2s ease;
}
.avatar-bubble::after {
  content: ""; position: absolute; bottom: -8px; left: 24px;
  border: 8px solid transparent; border-top-color: #fff; border-bottom: 0;
}
@keyframes bubble-pop { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Customisation screen */
.avatar-preview { display: flex; justify-content: center; margin: 8px 0 18px; }
.avatar-preview .a-circle { width: 120px; height: 120px; }
.avatar-preview .a-base { font-size: 68px; }
.avatar-preview .a-hat { font-size: 44px; }
.pick-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 16px; }
.pick {
  width: 54px; height: 54px; border-radius: 16px;
  background: var(--accent-soft); border: 3px solid transparent;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; cursor: pointer;
}
.pick.picked { border-color: var(--primary); background: #fff; }
.pick.color-pick { font-size: 0; }

/* ===== Versus / battle ===== */
.vs-players, .vs-result-top {
  display: flex; align-items: center; justify-content: space-around;
  gap: 8px; margin: 10px 0 18px;
}
.vs-p { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.vs-p .a-circle { width: 76px; height: 76px; }
.vs-p .a-base { font-size: 44px; }
.vs-p .a-hat { font-size: 28px; }
.vs-vs { font-size: 22px; font-weight: 700; color: var(--primary-dark); flex-shrink: 0; }
.vs-name { font-weight: 600; font-size: 15px; text-align: center; }
.vs-name-input {
  font-family: inherit; font-size: 15px; text-align: center; width: 100%;
  padding: 8px 6px; border: 2px solid var(--accent); border-radius: 12px; color: var(--text);
}
.vs-name-input:focus { outline: none; border-color: var(--primary); }
.vs-score { font-weight: 700; color: var(--gold); font-size: 18px; }
.vs-cat { margin-bottom: 8px; }
/* turn banner during play */
.vs-turn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent-soft); border-radius: 14px; padding: 8px;
  font-size: 15px; margin-bottom: 12px;
}
.vs-turn .a-circle { width: 32px; height: 32px; }
.vs-turn .a-base { font-size: 18px; }
.vs-turn .a-hat { font-size: 12px; }
/* round-by-round results */
.vs-round {
  display: grid; grid-template-columns: 1fr auto auto auto 1fr; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 12px; background: var(--accent-soft); margin-bottom: 6px;
  font-size: 16px;
}
.vr-n { font-weight: 600; font-size: 14px; color: var(--text-soft); grid-column: 1; }
.vr-vs { color: var(--text-soft); font-size: 13px; }
.vs-hand-emoji { font-size: 64px; text-align: center; }
