:root {
  --bg: #fff4d6;
  --ink: #3a2a1a;
  --orange: #ff9f1c;
  --green: #2a9d8f;
  --red: #e63946;
  --cream: #fffaf0;
  --shadow: 0 6px 0 rgba(0,0,0,.15);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Baloo 2', 'Comic Sans MS', system-ui, sans-serif;
  background: radial-gradient(circle at 20% 10%, #fff9e8, var(--bg) 60%, #ffe3a3);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; cursor: pointer; color: inherit; }
input {
  font-family: inherit; font-size: 18px; padding: 6px 12px;
  border: 3px solid #e7c98f; border-radius: 12px; background: #fff; color: var(--ink);
}
.hidden { display: none !important; }

.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }

.big-btn {
  font-size: 22px; font-weight: 800; padding: 12px 28px; border: none; border-radius: 18px;
  background: var(--orange); color: #fff; box-shadow: var(--shadow);
  transition: transform .1s;
}
.big-btn:hover { transform: translateY(-2px); }
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.15); }
.big-btn.green { background: var(--green); }
.big-btn.red { background: var(--red); }
.big-btn.gray { background: #8d99ae; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; border: none; background: #fff;
  font-size: 20px; box-shadow: 0 3px 0 rgba(0,0,0,.12);
}

/* ---------- Título ---------- */
#screen-title.active { display: grid; place-items: center; padding: 16px; }
.title-card {
  text-align: center; background: var(--cream); padding: 32px 28px; border-radius: 32px;
  box-shadow: 0 10px 0 #e7c98f; max-width: 620px; width: 100%;
}
.title-emojis { font-size: 44px; letter-spacing: 6px; animation: bob 3s ease-in-out infinite; }
h1 { font-size: clamp(32px, 6vw, 52px); margin: 8px 0 0; color: #e76f51; line-height: 1.1; }
.subtitle { font-size: 20px; margin: 8px 0 20px; }
.title-buttons { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.small { opacity: .75; }

/* ---------- Família ---------- */
.family-layout { max-width: 980px; margin: 0 auto; padding: 16px; }
.family-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.family-head h2 { margin: 0; font-size: 30px; }
.family-name { font-size: 20px; font-weight: 700; display: flex; gap: 8px; align-items: center; }
.members { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.member {
  position: relative; width: 96px; padding: 6px 4px 4px; border-radius: 16px; border: 3px solid transparent;
  background: #fff; text-align: center; box-shadow: 0 3px 0 rgba(0,0,0,.1);
}
.member.sel { border-color: var(--orange); }
.member svg { width: 64px; height: 96px; }
.member .mname { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member .del {
  position: absolute; top: -8px; right: -8px; width: 26px; height: 26px; border-radius: 50%;
  border: none; background: var(--red); color: #fff; font-size: 14px; line-height: 1;
}
.member.add { display: grid; place-items: center; font-size: 40px; color: var(--green); min-height: 120px; }
.member.add span { font-size: 14px; display: block; font-weight: 700; }
.editor {
  display: grid; grid-template-columns: 220px 1fr; gap: 20px; background: var(--cream);
  border-radius: 24px; padding: 18px; box-shadow: 0 6px 0 #e7c98f;
}
.preview { display: grid; place-items: center; background: linear-gradient(#bde0fe, #a8e6a1); border-radius: 20px; }
.preview svg { width: 200px; height: 300px; animation: bob 2.5s ease-in-out infinite; }
.opt-row { display: block; font-weight: 700; margin-bottom: 10px; }
.opt-row > .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.opt-row input { margin-left: 8px; }
.chip {
  border: 3px solid #e7c98f; background: #fff; border-radius: 12px; padding: 2px 10px; font-size: 15px; font-weight: 700;
}
.chip.sel { border-color: var(--orange); background: #fff1d6; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px #e7c98f; padding: 0; }
.swatch.sel { box-shadow: 0 0 0 4px var(--orange); }
.family-actions { text-align: center; margin: 20px 0; }

/* ---------- Mapa ---------- */
.hud {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 16px; background: var(--cream); box-shadow: 0 4px 0 #e7c98f;
}
.hud-title { font-size: 22px; font-weight: 800; }
.hud-players { display: flex; gap: 8px; flex-wrap: wrap; }
.pchip {
  display: flex; align-items: center; gap: 4px; background: #fff; border-radius: 14px; padding: 2px 10px 2px 4px;
  font-weight: 700; border: 3px solid transparent;
}
.pchip svg { width: 26px; height: 39px; }
.pchip.turn { border-color: var(--orange); background: #fff1d6; }
.pchip .pts { color: #e76f51; }
.hud-right { display: flex; gap: 8px; align-items: center; }
.hud-stars { font-size: 20px; font-weight: 800; margin-right: 6px; }

.map-wrap { max-width: 1200px; margin: 14px auto 0; padding: 0 12px; overflow-x: auto; }
.map {
  position: relative; aspect-ratio: 100 / 62; min-width: 760px; border-radius: 28px; overflow: hidden;
  box-shadow: 0 8px 0 #7cb26f;
}
.map > svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-hint { text-align: center; opacity: .7; margin: 10px; }

.station {
  position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center;
  background: none; border: none; padding: 0; z-index: 3;
}
.station .icon {
  width: 62px; height: 62px; border-radius: 50%; background: #fff; border: 4px solid var(--orange);
  font-size: 32px; display: grid; place-items: center; box-shadow: 0 4px 0 rgba(0,0,0,.25); transition: transform .15s;
}
.station:hover .icon { transform: scale(1.1); }
.station .label {
  margin-top: 3px; background: #fff; border-radius: 10px; padding: 0 8px; font-weight: 800; font-size: 13px;
  white-space: nowrap; box-shadow: 0 2px 0 rgba(0,0,0,.2);
}
.station .st-stars { font-size: 12px; letter-spacing: -1px; min-height: 16px; }
.station.locked .icon { filter: grayscale(1); opacity: .65; border-color: #999; }
.station.locked .icon::after { content: '🔒'; position: absolute; font-size: 18px; transform: translate(20px, 18px); }
.station.next .icon { animation: pulse 1.2s ease-in-out infinite; border-color: var(--red); }
.station.done .icon { border-color: var(--green); }
.station.shake { animation: shake .4s; }

.station.near .icon { transform: scale(1.18); box-shadow: 0 0 0 6px rgba(255,255,255,.8), 0 4px 0 rgba(0,0,0,.25); }

/* família no mapa */
.mwalker {
  position: absolute; width: 34px; height: 51px; transform: translate(-50%, -100%);
  pointer-events: none; filter: drop-shadow(0 2px 1px rgba(0,0,0,.3));
}
.mwalker .tk, .token .tk, .mz-token .tk { width: 100%; height: 100%; }
.mwalker svg, .token svg { width: 100%; height: 100%; display: block; }
.mwalker.flip .tk, .tk.flip { transform: scaleX(-1); }
.mwalker.walking svg, .token.walking svg, .mz-token.walking svg { animation: hop .22s ease-in-out infinite alternate; }
.mwalker.leader {
  width: 46px; height: 69px; pointer-events: auto; cursor: grab; touch-action: none;
  filter: drop-shadow(0 0 4px #fff) drop-shadow(0 2px 2px rgba(0,0,0,.35));
}
.mwalker.leader::after {
  content: ''; position: absolute; left: 50%; bottom: -5px; width: 46px; height: 12px; transform: translateX(-50%);
  border-radius: 50%; border: 3px solid var(--orange); animation: pulse 1.2s ease-in-out infinite; z-index: -1;
}
.mwalker.dragging { cursor: grabbing; }
.grab-hint {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); white-space: nowrap; pointer-events: none;
  background: var(--ink); color: #fff; font-size: 12px; font-weight: 800; border-radius: 10px; padding: 0 8px;
  animation: bob 1.6s ease-in-out infinite;
}
.mwalker.dragging .grab-hint { display: none; }

/* ---------- Overlay / desafio ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(30,20,10,.6); display: none; align-items: center; justify-content: center;
  z-index: 50; padding: 10px;
}
.overlay.open { display: flex; }
.panel {
  background: var(--cream); border-radius: 26px; width: min(940px, 100%); max-height: 97vh; overflow: auto;
  padding: 14px 18px 18px; box-shadow: 0 10px 0 #e7c98f;
}
.panel-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.panel-title { font-size: 24px; font-weight: 800; flex: 1; }
.panel-player { display: flex; align-items: center; gap: 4px; font-weight: 700; background: #fff1d6; border-radius: 14px; padding: 0 10px 0 4px; }
.panel-player svg { width: 30px; height: 45px; }

.intro { text-align: center; padding: 10px; }
.intro .big-icon { font-size: 80px; animation: bob 2s ease-in-out infinite; }
.intro p { font-size: 20px; max-width: 640px; margin: 8px auto; }
.intro .goal { background: #fff; border-radius: 16px; padding: 10px 14px; display: inline-block; font-weight: 700; margin-bottom: 16px; }
.turn-banner { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 22px; font-weight: 800; margin: 10px 0; }
.turn-banner svg { width: 60px; height: 90px; }

.bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; font-size: 18px; font-weight: 700; }
.targets { display: flex; flex-wrap: wrap; gap: 6px; }
.tgt { background: #fff; border: 3px dashed #e7c98f; border-radius: 12px; padding: 0 10px; }
.tgt.ok { border-style: solid; border-color: var(--green); background: #d8f3dc; text-decoration: line-through; }
.timer b { font-size: 22px; }
.timer.low b { color: var(--red); }

.scene { position: relative; height: min(58vh, 470px); border-radius: 20px; overflow: hidden; user-select: none; }
.scene-savana { background: linear-gradient(#ffe8a3 0%, #ffd56b 35%, #e9c46a 36%, #c9a227 100%); }
.scene-agua { background: linear-gradient(#4fc3f7, #0277bd 70%, #01579b); }
.scene-fazenda { background: linear-gradient(#bde0fe 0 28%, #95d5b2 28%, #74c69d); }
.scene-ceu { background: linear-gradient(#90e0ef, #caf0f8 70%, #ffe5b4); }
.decor { position: absolute; pointer-events: none; opacity: .85; }
.animal {
  position: absolute; background: none; border: none; padding: 0; line-height: 1;
  font-size: clamp(30px, 4.6vw, 46px); animation: bob 3s ease-in-out infinite; z-index: 2;
}
.animal:hover { filter: drop-shadow(0 0 6px #fff); }
.animal.found { animation: got .6s forwards; pointer-events: none; }
.float {
  position: absolute; z-index: 9; pointer-events: none; font-weight: 800; font-size: 18px; white-space: nowrap;
  background: #fff; border-radius: 10px; padding: 0 8px; box-shadow: 0 2px 0 rgba(0,0,0,.2);
  animation: floatUp 1.3s forwards; transform: translateX(-50%);
}

.quiz { text-align: center; }
.qcount { opacity: .7; font-weight: 700; }
.qbig { font-size: 70px; }
.qtext { font-size: 23px; font-weight: 700; margin: 6px auto 14px; max-width: 700px; }
.opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.opt {
  font-size: 20px; font-weight: 700; padding: 12px; border-radius: 16px; border: 3px solid #e7c98f; background: #fff;
  box-shadow: 0 4px 0 #e7c98f;
}
.opt:hover:not(:disabled) { background: #fff1d6; }
.opt.right { background: #d8f3dc; border-color: var(--green); }
.opt.wrong { background: #ffd6d9; border-color: var(--red); }
.qfact { min-height: 30px; margin: 12px auto 0; font-size: 18px; max-width: 700px; }
.qfact .big-btn { margin-top: 10px; font-size: 18px; }

.coaster { text-align: center; }
.track {
  position: relative; height: 150px; border-radius: 20px; overflow: hidden;
  background: linear-gradient(#90e0ef, #caf0f8 70%, #95d5b2 70%);
}
.track svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.cart { position: absolute; top: 40px; font-size: 46px; transform: translateX(-50%); }
.station-flag { position: absolute; top: 18px; font-size: 26px; transform: translateX(-50%); }
.meter { position: relative; height: 46px; background: #ffd6d9; border-radius: 23px; margin: 16px 0; border: 4px solid #fff; overflow: hidden; }
.zone { position: absolute; top: 0; bottom: 0; background: #52b788; }
.zone::after { content: 'FREIE AQUI'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #fff; }
.needle { position: absolute; top: -4px; bottom: -4px; width: 8px; background: var(--ink); border-radius: 4px; transform: translateX(-50%); }
.round-info { font-size: 20px; font-weight: 700; min-height: 32px; }
.hint { opacity: .7; user-select: none; }

.memory { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; max-width: 520px; margin: 0 auto; }
.card { aspect-ratio: 1; perspective: 600px; background: none; border: none; padding: 0; }
.card .inner { position: relative; width: 100%; height: 100%; transition: transform .4s; transform-style: preserve-3d; }
.card.flip .inner { transform: rotateY(180deg); }
.card .face {
  position: absolute; inset: 0; border-radius: 16px; display: grid; place-items: center; backface-visibility: hidden;
  font-size: clamp(30px, 7vw, 50px); box-shadow: 0 4px 0 rgba(0,0,0,.15);
}
.card .back { background: repeating-linear-gradient(45deg, #2d6a4f 0 10px, #40916c 10px 20px); color: #fff; font-size: 30px; }
.card .front { background: #fff; transform: rotateY(180deg); }
.card.matched .front { background: #d8f3dc; }

.simon { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 420px; margin: 10px auto; }
.pad {
  aspect-ratio: 1.3; border-radius: 26px; border: none; font-size: 56px; box-shadow: 0 6px 0 rgba(0,0,0,.25);
  opacity: .65; transition: transform .1s, opacity .1s;
}
.pad.lit { opacity: 1; transform: scale(1.06); filter: brightness(1.2); }
.pad:disabled { cursor: default; }
.simon-info { text-align: center; font-size: 22px; font-weight: 800; min-height: 36px; }

.flyer { position: absolute; background: none; border: none; padding: 0; font-size: clamp(34px, 5vw, 50px); line-height: 1; z-index: 2; }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; animation: flash .3s; z-index: 8; }
.wheel { position: absolute; left: -60px; bottom: -60px; font-size: 220px; opacity: .25; pointer-events: none; animation: spin 30s linear infinite; }

.result { text-align: center; padding: 10px; }
.result .stars { font-size: 64px; letter-spacing: 6px; }
.result .stars span { display: inline-block; animation: pop .5s backwards; }
.result .stars .off { filter: grayscale(1); opacity: .3; }
.result h3 { font-size: 30px; margin: 4px 0; }
.result p { font-size: 20px; margin: 6px 0; }
.result .btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }

/* ---------- Fim ---------- */
#screen-end.active { display: grid; place-items: center; padding: 16px; }
.end-card {
  background: var(--cream); border-radius: 32px; padding: 26px; max-width: 760px; width: 100%; text-align: center;
  box-shadow: 0 10px 0 #e7c98f; border: 6px double var(--orange);
}
.end-card h2 { font-size: 36px; margin: 0; color: #e76f51; }
.end-family { display: flex; justify-content: center; gap: 4px; flex-wrap: wrap; margin: 10px 0; }
.end-family svg { width: 76px; height: 114px; animation: hop .5s ease-in-out infinite alternate; }
.end-family svg:nth-child(2n) { animation-delay: .25s; }
.rank { list-style: none; padding: 0; max-width: 380px; margin: 10px auto; font-size: 20px; }
.rank li { display: flex; justify-content: space-between; background: #fff; border-radius: 12px; padding: 4px 14px; margin: 6px 0; font-weight: 700; }
.end-card .btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 120px); background: var(--ink); color: #fff;
  padding: 10px 20px; border-radius: 16px; font-size: 18px; font-weight: 700; z-index: 99; transition: transform .3s;
  max-width: 90vw; text-align: center;
}
#toast.show { transform: translate(-50%, 0); }

.confetti { position: fixed; top: -30px; font-size: 26px; z-index: 98; pointer-events: none; animation: fall linear forwards; }

@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes hop { from { transform: translateY(0); } to { transform: translateY(-6px); } }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.12); } }
@keyframes shake { 0%,100% { margin-left: 0; } 25% { margin-left: -8px; } 75% { margin-left: 8px; } }
@keyframes got { to { transform: scale(1.6); opacity: .35; } }
@keyframes floatUp { from { opacity: 1; margin-top: 0; } to { opacity: 0; margin-top: -50px; } }
@keyframes flash { from { opacity: .8; } to { opacity: 0; } }
@keyframes pop { from { transform: scale(0); } 70% { transform: scale(1.3); } to { transform: scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

@media (max-width: 640px) {
  .editor { grid-template-columns: 1fr; }
  .preview svg { width: 140px; height: 210px; }
  .panel { padding: 10px; }
  .panel-title { font-size: 19px; }
  .qtext { font-size: 19px; }
  .opt { font-size: 17px; }
}

/* ---------- Cenas com avatar arrastável ---------- */
.drag-scene { touch-action: none; cursor: pointer; }
.center { text-align: center; }
.token {
  position: absolute; width: 48px; height: 72px; transform: translate(-50%, -100%); z-index: 6; pointer-events: none;
  filter: drop-shadow(0 3px 2px rgba(0,0,0,.35));
}
.token .badge { position: absolute; right: -14px; top: 22px; font-size: 22px; }
.animal.centered { margin-left: -.5em; margin-top: -.5em; }
.animal.found { animation: got .6s forwards; }
.fog {
  position: absolute; inset: 0; z-index: 4; pointer-events: none; transition: opacity 1s;
  --x: 50%; --y: 90%;
  -webkit-mask-image: radial-gradient(circle at var(--x) var(--y), transparent 0, transparent 70px, #000 115px);
  mask-image: radial-gradient(circle at var(--x) var(--y), transparent 0, transparent 70px, #000 115px);
}
.fog-savana { background: repeating-linear-gradient(100deg, #8a9a2a 0 6px, #a3b336 6px 12px, #6f7f1f 12px 15px); }
.fog-agua { background: radial-gradient(circle at 50% 0, #023e8a, #03045e 70%); }
.fog.clear { opacity: 0; }

.pen {
  position: absolute; top: 3%; height: 30%; border-radius: 14px; border: 4px dashed #8d6e63; z-index: 1;
  display: flex; align-items: flex-start; justify-content: center;
}
.pen-label { background: #fff; border-radius: 10px; padding: 0 8px; font-weight: 800; font-size: 15px; margin-top: -12px; box-shadow: 0 2px 0 rgba(0,0,0,.2); }
.animal.farm { animation: none; transition: none; }
.animal.farm.flipx { transform: scaleX(-1); }
.animal.farm.found-home { filter: drop-shadow(0 0 6px #fff); }

.feed-animals { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.feed-animal {
  background: #fff; border-radius: 18px; border: 4px solid #e7c98f; text-align: center; padding: 8px 4px; position: relative;
  transition: transform .15s, border-color .15s;
}
.feed-animal.hover { transform: scale(1.08); border-color: var(--orange); background: #fff1d6; }
.feed-animal.fed { border-color: var(--green); background: #d8f3dc; }
.feed-animal.nope { animation: shake .4s; }
.fa-emoji { font-size: 54px; line-height: 1.1; }
.fa-name { font-weight: 800; }
.bubble { position: absolute; top: 4px; right: 8px; font-size: 20px; }
.tray {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin-top: 16px; padding: 14px;
  background: repeating-linear-gradient(45deg, #fff 0 12px, #ffe5ec 12px 24px); border-radius: 20px; border: 4px solid #ff8fab;
}
.food {
  width: 74px; height: 74px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-size: 44px;
  box-shadow: 0 4px 0 rgba(0,0,0,.15); cursor: grab; touch-action: none; user-select: none; position: relative; z-index: 2;
}
.food.dragging { cursor: grabbing; z-index: 30; box-shadow: 0 10px 20px rgba(0,0,0,.3); }

.maze-box {
  position: relative; width: 100%; max-height: 62vh; margin: 0 auto; border-radius: 16px; overflow: hidden;
  background: radial-gradient(circle at 30% 30%, #d8f3dc, #b7e4c7); border: 5px solid #2d6a4f;
}
.maze-box > svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.mz-item { position: absolute; transform: translate(-50%, -50%); font-size: clamp(20px, 3.4vw, 34px); pointer-events: none; }
.mz-item.goal { animation: bob 1.5s ease-in-out infinite; }
.mz-token {
  position: absolute; transform: translate(-50%, -62%); transition: left .1s linear, top .1s linear; z-index: 3; pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.35));
}
.mz-token .tk { aspect-ratio: 2 / 3; height: auto; }
.mz-token svg { width: 100%; height: 100%; display: block; }
.mz-token .baby { position: absolute; right: -8px; top: 45%; font-size: clamp(14px, 2vw, 22px); }

.cart { display: flex; flex-direction: column; align-items: center; }
.cart .rider { width: 34px; height: 51px; margin-bottom: -26px; position: relative; z-index: 0; }
.cart .rider svg { width: 100%; height: 100%; }
.cart .wagon { position: relative; z-index: 1; line-height: 1; }

.back-link { display: inline-block; border: none; background: none; font: inherit; font-size: 18px; cursor: pointer; margin-top: 10px; font-weight: 800; color: #e76f51; text-decoration: none; }
