/* =========================================================
   Colmena de Palabras — estilos
   Paleta: amarillo miel, negro suave, rosa panal, cielo, menta
   ========================================================= */

:root {
  --honey: #ffc93c;
  --honey-dark: #f5a623;
  --honey-deep: #e8890c;
  --ink: #2b2340;
  --ink-soft: #55507a;
  --cream: #fffaf0;
  --panel: #ffffff;
  --pink: #ff6fa5;
  --mint: #29d3a2;
  --sky: #4ea8ff;
  --red: #ff5c5c;
  --shadow: 0 10px 25px rgba(43, 35, 64, 0.12);
  --radius: 20px;
  --radius-sm: 12px;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Baloo 2", "Comic Sans MS", "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(circle at 10% 10%, #fff6dd 0%, transparent 45%),
    radial-gradient(circle at 90% 20%, #ffe4f1 0%, transparent 40%),
    linear-gradient(160deg, #fff8e8 0%, #fdf1de 100%);
  color: var(--ink);
  overflow-x: hidden;
}

@font-face {
  font-family: "Baloo 2";
  src: local("Baloo 2");
}

h1, h2, h3 { font-weight: 800; margin: 0 0 .4rem; }
p { line-height: 1.5; }

.screen { display: none; }
.screen.active { display: block; }

/* ---------------- Welcome screen ---------------- */

#screen-welcome {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
}
#screen-welcome.active { display: flex; }

.hive-bg { position: absolute; inset: 0; overflow: hidden; z-index: 0; pointer-events: none; }
.floating-bee {
  position: absolute;
  font-size: 2.5rem;
  opacity: .5;
  animation: float 7s ease-in-out infinite;
}
.b1 { top: 8%; left: 8%; animation-delay: 0s; }
.b2 { top: 70%; left: 85%; animation-delay: 1.5s; font-size: 3rem; }
.b3 { top: 20%; left: 82%; animation-delay: 3s; font-size: 2rem; }
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-22px) rotate(6deg); }
}

.welcome-card {
  max-width: 520px;
  width: 100%;
  text-align: center;
  z-index: 1;
  padding: 40px 32px;
}
.welcome-card h1 { font-size: 2.1rem; color: var(--honey-deep); }
.subtitle { color: var(--ink-soft); margin-bottom: 1.5rem; font-size: 1.05rem; }

.player-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-bottom: 18px;
}
.player-chip {
  background: var(--cream);
  border: 3px solid var(--honey);
  border-radius: 16px;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: transform .15s ease, background .15s ease;
  min-width: 92px;
}
.player-chip:hover { transform: translateY(-3px) scale(1.03); background: #fff2cf; }
.player-chip .avatar { font-size: 1.8rem; }

.new-player-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  border-top: 2px dashed #f0d9a8;
  padding-top: 18px;
  margin-top: 8px;
}
#new-player-name {
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 3px solid #f0d9a8;
  font-size: 1.1rem;
  text-align: center;
  font-family: inherit;
}
#new-player-name:focus { outline: none; border-color: var(--honey); }

.avatar-picker { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.avatar-choice {
  font-size: 1.5rem;
  padding: 8px;
  border-radius: 12px;
  border: 3px solid transparent;
  background: var(--cream);
  cursor: pointer;
}
.avatar-choice.selected { border-color: var(--honey); background: #fff2cf; }

/* ---------------- Buttons ---------------- */

.btn {
  font-family: inherit;
  font-weight: 800;
  border: none;
  border-radius: 14px;
  padding: 12px 20px;
  cursor: pointer;
  font-size: 1rem;
  transition: transform .12s ease, box-shadow .12s ease, background .15s ease;
  box-shadow: 0 4px 0 rgba(0,0,0,.12);
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.12); }
.btn-primary { background: linear-gradient(180deg, var(--honey), var(--honey-dark)); color: var(--ink); }
.btn-success { background: linear-gradient(180deg, #5be0b3, var(--mint)); color: #0a3f30; }
.btn-ghost { background: #fff; color: var(--ink-soft); border: 2px solid #eee0c2; box-shadow: none; }
.btn-ghost:active { transform: translateY(1px); }
.btn-big { padding: 16px 28px; font-size: 1.15rem; border-radius: 18px; }
.btn-small { padding: 8px 14px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------- App shell ---------------- */

#app { padding-bottom: 90px; }

#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
  gap: 10px;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.hdr-avatar {
  font-size: 2rem;
  background: #fff2cf;
  border-radius: 50%;
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  border: 3px solid var(--honey);
}
.hdr-name { font-weight: 800; font-size: 1.05rem; }
.hdr-level { font-size: .8rem; color: var(--ink-soft); }
.header-right { display: flex; align-items: center; gap: 8px; }
.xp-pill, .streak-pill {
  background: var(--cream);
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 800;
  font-size: .9rem;
  display: flex;
  gap: 5px;
  align-items: center;
  border: 2px solid #f0d9a8;
}
.streak-pill { border-color: #ffd0b0; }

.level-bar-wrap { padding: 8px 18px 0; }
.level-bar { height: 10px; background: #f1e6c8; border-radius: 999px; overflow: hidden; }
.level-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--honey), var(--pink));
  transition: width .6s ease;
  border-radius: 999px;
}
.level-bar-label { font-size: .75rem; color: var(--ink-soft); margin-top: 4px; text-align: center; }

#app-nav {
  display: flex;
  overflow-x: auto;
  gap: 6px;
  padding: 10px 12px;
  position: sticky;
  top: 78px;
  z-index: 19;
  background: rgba(255,248,232,.92);
  backdrop-filter: blur(4px);
}
.nav-btn {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 1.3rem;
  background: #fff;
  border: 2px solid #f0e0b8;
  border-radius: 14px;
  padding: 8px 14px;
  cursor: pointer;
  color: var(--ink-soft);
  font-family: inherit;
}
.nav-btn span { font-size: .68rem; font-weight: 700; }
.nav-btn.active { background: linear-gradient(180deg, var(--honey), var(--honey-dark)); color: var(--ink); border-color: var(--honey-dark); }

#views { max-width: 920px; margin: 0 auto; padding: 16px; }
.view { display: none; }
.view.active { display: block; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

.hint { color: var(--ink-soft); font-size: .92rem; }

/* ---------------- Home ---------------- */

.daily-card { background: linear-gradient(160deg, #fff2cf, #ffe6c2); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip {
  background: #fff;
  border: 2px solid #f0d9a8;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: .85rem;
  font-weight: 700;
}
.chips-clickable .chip { cursor: pointer; }
.chips-clickable .chip:hover { background: #fff2cf; }
.daily-status { margin-top: 8px; font-weight: 700; color: var(--mint); }

.stat-row { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 6px; }
.progress-track { height: 12px; background: #f1e6c8; border-radius: 999px; overflow: hidden; margin-bottom: 14px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--mint), var(--sky)); width: 0%; transition: width .6s ease; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-box { background: var(--cream); border-radius: 14px; padding: 10px; text-align: center; }
.stat-num { font-size: 1.4rem; font-weight: 800; color: var(--honey-deep); }
.stat-lbl { font-size: .7rem; color: var(--ink-soft); font-weight: 700; }

.leaderboard-list { display: flex; flex-direction: column; gap: 8px; }
.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--cream);
  border-radius: 14px;
  padding: 10px 14px;
  font-weight: 700;
}
.leaderboard-row .rank { width: 24px; text-align: center; }
.leaderboard-row .avatar { font-size: 1.4rem; }
.leaderboard-row .name { flex: 1; }
.leaderboard-row .xp { color: var(--honey-deep); }
.leaderboard-row.me { outline: 3px solid var(--honey); }

.howto-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-top: 12px; }
.howto-item { text-align: center; background: var(--cream); border-radius: 14px; padding: 12px; }
.howto-item span { font-size: 1.8rem; }
.howto-item p { font-size: .78rem; color: var(--ink-soft); margin: 4px 0 0; }

/* ---------------- Game cards (listen / scramble / missing / contest) ---------------- */

.game-card { text-align: center; }
.game-topbar { display: flex; justify-content: space-between; margin-bottom: 10px; }
.combo-pill, .progress-pill {
  background: var(--cream);
  border-radius: 999px;
  padding: 5px 12px;
  font-weight: 800;
  font-size: .85rem;
}

.speak-btn {
  font-size: 2.4rem;
  background: linear-gradient(180deg, var(--sky), #2f8dee);
  border: none;
  border-radius: 50%;
  width: 92px; height: 92px;
  cursor: pointer;
  color: #fff;
  box-shadow: 0 6px 0 #1f6fc4;
  margin: 10px auto;
  display: flex; align-items: center; justify-content: center;
}
.speak-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #1f6fc4; }
.speak-btn-lg { width: auto; height: auto; border-radius: 999px; font-size: 1.1rem; padding: 16px 26px; gap: 8px; }

.word-meta { color: var(--ink-soft); font-weight: 700; min-height: 1.4em; margin-bottom: 10px; }

.answer-form { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.answer-form input[type=text] {
  flex: 1;
  min-width: 220px;
  max-width: 340px;
  padding: 14px 16px;
  font-size: 1.2rem;
  text-align: center;
  border-radius: 14px;
  border: 3px solid #f0d9a8;
  font-family: inherit;
  letter-spacing: 1px;
}
.answer-form input:focus { outline: none; border-color: var(--sky); }

.feedback { min-height: 2.4em; margin-top: 14px; font-weight: 800; font-size: 1.05rem; }
.feedback.correct { color: #1c9a6c; }
.feedback.wrong { color: var(--red); }
.feedback .correct-answer { display: block; font-size: .85rem; color: var(--ink-soft); font-weight: 700; margin-top: 4px; }

/* Letter slots / scramble bank */
.letter-slots { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 14px 0; min-height: 52px; }
.letter-slot {
  width: 40px; height: 46px;
  border-bottom: 4px solid var(--honey-dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 800;
  background: var(--cream);
  border-radius: 8px 8px 0 0;
  cursor: pointer;
}
.letter-slot.space { border-bottom: none; width: 18px; background: none; }
.letter-bank { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 10px; }
.letter-tile {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: linear-gradient(180deg, #fff, #fdf1de);
  border: 2px solid #f0d9a8;
  font-weight: 800;
  font-size: 1.25rem;
  cursor: pointer;
  box-shadow: 0 3px 0 #e8d3a0;
}
.letter-tile:active { transform: translateY(2px); box-shadow: none; }
.letter-tile.used { visibility: hidden; }
.scramble-controls { display: flex; gap: 10px; justify-content: center; margin-top: 8px; }

/* Missing letters */
.missing-blanks { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 14px 0; }
.missing-fixed, .missing-input-box {
  width: 38px; height: 46px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; font-weight: 800;
}
.missing-fixed { background: var(--cream); color: var(--ink-soft); }
.missing-input-box input {
  width: 100%; height: 100%;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 800;
  border: 3px solid var(--sky);
  border-radius: 8px;
  font-family: inherit;
  text-transform: lowercase;
}
.missing-input-box input:focus { outline: none; border-color: var(--pink); }
.missing-space { width: 16px; }

/* ---------------- Sentence dictation ---------------- */

.blank-sentence {
  background: var(--cream);
  border-radius: 14px;
  padding: 16px 18px;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.6;
  margin: 14px 0;
  color: var(--ink);
}
.blank-sentence .blank {
  display: inline-block;
  min-width: 90px;
  border-bottom: 4px solid var(--pink);
  color: transparent;
  user-select: none;
}

/* ---------------- Spell aloud (voice) ---------------- */

.voice-unsupported {
  background: #fff1e0;
  border: 2px solid #ffcf9e;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  color: #9a5300;
  margin: 12px 0;
}

.mic-btn {
  font-family: inherit;
  font-weight: 800;
  font-size: 1.1rem;
  border: none;
  border-radius: 999px;
  padding: 16px 30px;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(180deg, var(--red), #d43f3f);
  box-shadow: 0 6px 0 #a92e2e;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px auto;
}
.mic-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #a92e2e; }
.mic-btn.recording {
  background: linear-gradient(180deg, #ff8a8a, var(--red));
  animation: mic-pulse 1.1s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 6px 0 #a92e2e, 0 0 0 0 rgba(255,92,92,.5); }
  50% { box-shadow: 0 6px 0 #a92e2e, 0 0 0 14px rgba(255,92,92,0); }
}

.live-transcript {
  min-height: 1.6em;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink-soft);
  background: var(--cream);
  border-radius: 12px;
  padding: 10px 14px;
  margin-top: 6px;
}

.voice-verdict-wrap { margin-top: 14px; }
.voice-compare { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 10px; }
.voice-compare-box {
  background: var(--cream);
  border-radius: 14px;
  padding: 10px 18px;
  min-width: 130px;
}
.vc-label { font-size: .72rem; color: var(--ink-soft); font-weight: 700; }
.vc-value { font-size: 1.2rem; font-weight: 800; letter-spacing: 1px; color: var(--honey-deep); margin-top: 2px; }
.verdict-buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------------- Study / flashcards ---------------- */

.flashcard-card { text-align: center; }
.flash-progress { color: var(--ink-soft); font-weight: 700; margin-bottom: 10px; }
.flashcard {
  background: linear-gradient(160deg, #fff8e8, #ffeccf);
  border-radius: 22px;
  padding: 32px 20px;
  border: 3px solid var(--honey);
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.flash-emoji { font-size: 3rem; }
.flash-word { font-size: 2rem; font-weight: 800; letter-spacing: 1px; color: var(--honey-deep); }
.flash-syll { color: var(--ink-soft); font-weight: 700; }
.flash-es { font-style: italic; color: var(--pink); font-weight: 700; }
.flash-sentence { max-width: 400px; margin-top: 6px; }
.flash-hint { margin-top: 8px; font-size: .85rem; background: #fff; border-radius: 10px; padding: 6px 12px; }
.flash-controls { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }

/* ---------------- Contest mode ---------------- */

.contest-length-label { display: block; margin: 14px 0; font-weight: 700; }
.contest-length-label select {
  display: block;
  margin-top: 6px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 3px solid #f0d9a8;
  font-family: inherit;
  font-size: 1rem;
}
.contest-card { background: linear-gradient(160deg, #fff, #fff6e5); }
.judge { font-size: 3rem; }
.contest-stage { display: flex; flex-direction: column; align-items: center; }
.cr-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed #eee; font-weight: 700; text-align: left; }
.contest-results { text-align: center; }

/* ---------------- Badges / album ---------------- */

.badges-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.badge-item {
  text-align: center;
  padding: 14px 8px;
  border-radius: 16px;
  background: var(--cream);
  border: 2px solid #f0d9a8;
  opacity: .45;
  filter: grayscale(1);
}
.badge-item.earned { opacity: 1; filter: none; background: linear-gradient(160deg, #fff8e2, #ffe9bd); border-color: var(--honey); }
.badge-item .b-emoji { font-size: 2rem; }
.badge-item .b-name { font-weight: 800; font-size: .82rem; margin-top: 4px; }
.badge-item .b-desc { font-size: .68rem; color: var(--ink-soft); margin-top: 2px; }

.stickers-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 10px; }
.sticker-item {
  aspect-ratio: 1;
  border-radius: 14px;
  background: var(--cream);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px solid #f0d9a8;
  font-size: 1.6rem;
  opacity: .35;
  filter: grayscale(1);
}
.sticker-item.unlocked {
  opacity: 1;
  filter: none;
  background: linear-gradient(160deg, #fff, #ffeecb);
  border-color: var(--honey-dark);
  animation: pop .3s ease;
}
.sticker-item .s-word { font-size: .6rem; font-weight: 800; margin-top: 2px; text-align: center; padding: 0 2px; }
@keyframes pop { from { transform: scale(.6); } to { transform: scale(1); } }

/* ---------------- Toasts / confetti ---------------- */

#toast-layer {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 800;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
  animation: toast-in .3s ease, toast-out .4s ease 2.4s forwards;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.toast-level { background: linear-gradient(90deg, var(--honey-dark), var(--pink)); }
.toast.toast-badge { background: linear-gradient(90deg, var(--mint), var(--sky)); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-16px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px) scale(.95); } }

#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 99;
}

/* shake animation for wrong answers */
.shake { animation: shake .4s ease; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}

.pulse-correct { animation: pulse-correct .5s ease; }
@keyframes pulse-correct {
  0% { transform: scale(1); }
  40% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

@media (max-width: 480px) {
  .welcome-card { padding: 28px 18px; }
  .card { padding: 16px; }
  .speak-btn { width: 76px; height: 76px; font-size: 2rem; }
}
