:root {
  --pink: #ff7acb;
  --yellow: #ffd46a;
  --blue: #47b7ff;
  --green: #4fd6a3;
  --purple: #8a7bff;
  --ink: #2b2b2b;
  --card: #ffffff;
  --soft: #f7f7ff;
  --shadow: 0 12px 28px rgba(0,0,0,0.08);
  --ui-scale: 1.06;
}

* { box-sizing: border-box; font-family: "Fredoka", system-ui, -apple-system, sans-serif; }
body {
  margin: 0;
  color: var(--ink);
  background: radial-gradient(circle at top, #fff1fa 0%, #f4f9ff 55%, #f6fff8 100%);
  overflow-x: hidden;
}

.app {
  max-width: 460px;
  margin: auto;
  padding: 18px;
  height: calc(100vh / var(--ui-scale));
  display: flex;
  flex-direction: column;
  transform: scale(var(--ui-scale));
  transform-origin: top center;
}
.screen { height: 100%; display: flex; flex-direction: column; }
.hiddenScreen { display: none; }
.hiddenBox { display: none; }


.homeCard, .winCard {
  margin: auto;
  width: 100%;
  padding: 22px;
  border-radius: 24px;
  background: var(--card);
  border: 2px solid #f0f0ff;
  box-shadow: var(--shadow);
}

.heroRow {
  display: flex;
  gap: 26px;
  align-items: center;
  margin-bottom: 12px;
}
.mascotFrame {
  width: 96px;
  height: 96px;
  border-radius: 24px;
  background: linear-gradient(135deg, #fff3b0, #ffd1f3);
  border: 2px solid #ffe6f6;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 20px rgba(255, 122, 203, 0.18);
}
.mascotFrame img {
  width: 86px;
  height: 86px;
  object-fit: contain;
}
.gameMascot { width: 120px; height: 120px; }
.gameMascot img { width: 110px; height: 110px; }
.winMascot { width: 120px; height: 120px; margin: 0 auto 8px auto; }

.homeTitle { margin: 0; font-size: 28px; font-weight: 800; }
.homeSubtitle { margin: 6px 0 8px 0; font-size: 14px; color: #5d5d6e; }
.heroPill {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  background: #fff5d6;
  border: 1px solid #ffe6a6;
}

.homeSections { display: flex; flex-direction: column; gap: 14px; }
.block {
  padding: 14px;
  border-radius: 18px;
  background: var(--soft);
  border: 1px solid #e9e9ff;
}
.blockTitle { font-weight: 800; margin-bottom: 10px; }

.categoryGrid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.categoryCard {
  padding: 12px;
  border-radius: 16px;
  border: 2px solid transparent;
  background: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: transform .08s ease, border-color .08s ease;
}
.categoryCard:active { transform: scale(0.98); }
.categoryCard.selected { border-color: var(--purple); box-shadow: 0 8px 14px rgba(138,123,255,0.18); }
.categoryCard.locked { opacity: 0.5; cursor: not-allowed; }
.categoryIcon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #f5f5ff;
}
.categoryIconImage {
  width: 34px;
  height: 34px;
  object-fit: contain;
}
.categoryLabel { font-weight: 700; font-size: 14px; }
.categorySub { font-size: 12px; color: #6b6b7c; }

.modeRow { display: flex; gap: 10px; }
.modeBtn{
  flex: 1;
  padding: 12px 10px;
  border-radius: 14px;
  border: 2px solid #e9e9ff;
  background: #fff;
  font-weight: 800;
  cursor: pointer;
}
.modeBtn.active{ background: #e8f5ff; border-color: #7ac7ff; }

.playerNames {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}
.playerField {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  color: #5d5d6e;
}
.voiceField{
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  color: #5d5d6e;
}
.voiceField select{
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid #e9e9ff;
  font-weight: 800;
  font-size: 14px;
  color: #2b2b2b;
  background: white;
}
.playerField input {
  padding: 10px 12px;
  border-radius: 12px;
  border: 2px solid #e9e9ff;
  font-weight: 800;
  font-size: 14px;
  color: #2b2b2b;
}

.primaryBtn {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: none;
  background: linear-gradient(135deg, var(--pink), var(--yellow));
  color: #2b2b2b;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
  margin-top: 14px;
}
.ghostBtn {
  width: 100%;
  margin-top: 10px;
  padding: 12px 16px;
  border-radius: 16px;
  border: 2px solid #e9e9ff;
  background: white;
  color: #2b2b2b;
  font-weight: 800;
  cursor: pointer;
}
.smallBtn { width: auto; padding: 8px 12px; border-radius: 12px; margin-top: 0; }
.homeHint { margin-top: 12px; color: #6a7a77; font-size: 13px; }

.progressTableWrap{
  width: 100%;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid #e6eeec;
  background: #fbfdfc;
}
.progressTable{
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.progressTable th,
.progressTable td{
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #eef3f1;
  font-weight: 800;
}
.progressTable thead th{
  font-size: 12px;
  color: #5d5d6e;
  background: #f6faf8;
}
.progressTable tbody tr:last-child td{ border-bottom: 1px solid #eef3f1; }
.progressTable tfoot td{
  background: #f6faf8;
  font-weight: 900;
}
.progressTable td:last-child,
.progressTable th:last-child{ text-align: right; }
.progressTable th:nth-child(2),
.progressTable td:nth-child(2){ text-align: right; }

.progressCard{
  width: min(92vw, 520px);
  background: white;
  border-radius: 22px;
  padding: 22px;
  border: 2px solid #f0f0ff;
  box-shadow: 0 18px 32px rgba(40, 40, 60, 0.12);
  display: grid;
  gap: 12px;
}
.progressTitle{
  margin: 0;
  font-size: 28px;
  font-weight: 900;
  text-align: center;
}
.progressSubtitle{
  margin: 0 0 8px 0;
  text-align: center;
  color: #51605d;
  font-size: 14px;
  font-weight: 700;
}

.mascotMiniRow { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mascotName { font-weight: 800; }
.mascotMiniInfo { display: flex; align-items: center; gap: 10px; }
.mascotMiniAvatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #fff3b0, #ffd1f3);
  border: 2px solid #ffe6f6;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 12px rgba(255, 122, 203, 0.12);
}
.mascotMiniAvatar img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 40, 0.4);
  display: grid;
  place-items: center;
  z-index: 10;
}
.overlay.hiddenScreen { display: none; }
.overlayCard {
  width: min(92vw, 420px);
  background: white;
  border-radius: 22px;
  padding: 20px;
  border: 2px solid #f0f0ff;
  box-shadow: var(--shadow);
  text-align: center;
}
.overlayTitle { margin: 0; font-size: 22px; }
.overlaySubtitle { margin: 6px 0 16px; color: #6b6b7c; }
.mascotGrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.mascotChoice {
  border: 2px solid #f0f0ff;
  border-radius: 18px;
  background: #fff;
  padding: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.mascotAvatar {
  width: 120px;
  height: 120px;
  border-radius: 20px;
  background: linear-gradient(135deg, #fff0b7, #ffe3f6);
  display: grid;
  place-items: center;
  position: relative;
}
.mascotChoice img { width: 110px; height: 110px; object-fit: contain; }
.mascotFallback {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 800;
  color: #7a6bff;
}
.mascotChoice.broken img { display: none; }
.mascotChoice.broken .mascotFallback { display: flex; }
.mascotChoice span { display: block; margin-top: 8px; font-weight: 800; }

/* Game */
header { display: flex; justify-content: space-between; align-items: flex-start; font-weight: bold; }
.leftInfo { display: flex; flex-direction: column; gap: 6px; }
.levelLabel { font-size: 13px; color: #51605d; font-weight: 800; }
.playerTurn { font-size: 12px; color: #6b6b7c; font-weight: 800; }
.topStars{ font-weight: 900; }

main { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 18px; }
#gameScreen main {
  justify-content: flex-start;
  padding-top: 8px;
  gap: 12px;
}
header { margin-bottom: 6px; }
.prompt { display: flex; align-items: center; gap: 12px; font-size: 28px; font-weight: 900; }
#speaker { font-size: 26px; border: none; background: none; cursor: pointer; }

#options { display: flex; gap: 14px; margin-top: 6px; flex-wrap: wrap; justify-content: center; }
.option {
  width: 200px;
  height: 72px;
  padding: 6px 12px;
  background: #f7f7ff;
  border-radius: 16px;
  border: 2px solid #e6e6ff;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 34px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.1s ease;
  text-align: center;
}
.option:active { transform: scale(0.95); }
.option.correct{
  border-color: #4fd6a3;
  box-shadow: 0 0 0 3px rgba(79, 214, 163, 0.25);
}
.option .optionText {
  font-size: clamp(14px, 3.2vw, 20px);
  line-height: 1.1;
  text-align: center;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
}
.option .colorSwatch {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  border: 2px solid rgba(0,0,0,0.08);
}
.option svg { width: 64px; height: 64px; }
.optionImage { width: 64px; height: 64px; object-fit: contain; }

.lettersGame{ width: 100%; max-width: 380px; }
.wordTarget, .letterBankWrap{
  width: 100%;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid #e6eeec;
  background: #fbfdfc;
}
.wordLabel{ font-weight: 900; color:#23302d; margin-bottom: 10px; }
.builtWord{ min-height: 52px; display: flex; flex-wrap: wrap; gap: 10px; }
.letterBank{ display: flex; flex-wrap: wrap; gap: 10px; }
.letterTile{
  width: 54px;
  height: 54px;
  border-radius: 16px;
  border: 1px solid #e6eeec;
  background: #dff1ee;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 900;
  cursor: pointer;
  user-select: none;
}
.letterTile:active{ transform: scale(0.97); }
.letterTile.used{ background: #f1f6f5; color: #9aa7a4; cursor: not-allowed; }
.lettersActions{ display:flex; gap:10px; justify-content:center; margin-top: 10px; }

.typingGame{ width: 100%; max-width: 420px; display: grid; gap: 12px; }
.typingGame.hiddenBox{ display: none; }
.typingPrompt{
  width: 100%;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid #e6eeec;
  background: #fbfdfc;
  display: grid;
  gap: 10px;
  justify-items: center;
}
.typingFigure{
  min-height: 84px;
  min-width: 120px;
  padding: 10px 14px;
  border-radius: 16px;
  border: 2px dashed #e6eeec;
  background: #ffffff;
  display: grid;
  place-items: center;
}
.typingFigure .optionText{
  font-size: clamp(18px, 3.4vw, 26px);
  font-weight: 900;
}
.typingFigure .colorSwatch{ width: 76px; height: 76px; border-radius: 18px; }
.typingFigure svg { width: 76px; height: 76px; }
.typingFigure .optionImage { width: 76px; height: 76px; }

.typingControls{
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto;
  align-items: center;
}
.typingInput{
  padding: 12px 14px;
  border-radius: 14px;
  border: 2px solid #e9e9ff;
  font-weight: 800;
  font-size: 16px;
  color: #2b2b2b;
  width: 100%;
}
.typingInput:focus{
  outline: none;
  border-color: #7ac7ff;
  box-shadow: 0 0 0 3px rgba(122, 199, 255, 0.25);
}
.typingInput.shake{
  animation: shake 280ms ease;
}
.typingHint{
  font-size: 12px;
  color: #6a7a77;
  text-align: center;
}

#reinforcement { font-size: 22px; font-weight: 900; margin-top: 4px; color: #333; transition: opacity 0.25s ease; }
.hidden { opacity: 0; }
.visible { opacity: 1; }

.winTitle { margin: 6px 0 0 0; font-size: 32px; letter-spacing: -0.5px; text-align: center; }
.winSubtitle { margin: 8px 0 14px 0; color: #51605d; font-size: 15px; text-align: center; }
.winStats { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 14px; }
.statPill { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-radius: 999px; background: #dff1ee; font-weight: 900; }

.badgeUnlock {
  margin: 10px 0 16px 0;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid #e6eeec;
  background: #fbfdfc;
  text-align: center;
}
.bigBadge {
  width: 76px; height: 76px; margin: 10px auto 6px auto; border-radius: 22px;
  display: flex; align-items: center; justify-content: center;
  background: #c9efe8; border: 1px solid #e6eeec; font-size: 40px; animation: pop 650ms ease both;
}
.badgeLabel { color: #51605d; font-weight: 800; font-size: 14px; }
@keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }

/* Confetti */
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.winCard { position: relative; }
.confetti::before, .confetti::after {
  content: ""; position: absolute; top: -20px; left: 0; right: 0; height: 120px;
  background-image:
    radial-gradient(circle, rgba(71,183,255,0.25) 0 4px, transparent 5px),
    radial-gradient(circle, rgba(255,212,106,0.35) 0 4px, transparent 5px),
    radial-gradient(circle, rgba(255,122,203,0.26) 0 4px, transparent 5px);
  background-size: 26px 26px, 30px 30px, 34px 34px;
  background-position: 0 0, 10px 10px, 18px 2px;
  animation: confettiDrop 900ms ease-out both;
  opacity: 0.9;
}
.confetti::after { top: 0; opacity: 0.6; animation-delay: 120ms; }
@keyframes confettiDrop { 0% { transform: translateY(-40px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }

.shake { animation: shake 260ms ease-in-out; }
@keyframes shake {
  0%   { transform: translateX(0); }
  25%  { transform: translateX(-6px); }
  50%  { transform: translateX(6px); }
  75%  { transform: translateX(-4px); }
  100% { transform: translateX(0); }
}
