@font-face {
  font-family: "Fredoka";
  src: url("fonts/fredoka-latin.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}
:root {
  --ink: #3b2410;
  --ink-soft: #8a6a52;
  --orange: #ff8d2e;
  --orange-light: #ffb547;
  --orange-deep: #d4600f;
  --blue: #3aa8f0;
  --blue-deep: #1f7cc0;
  --card: rgba(255, 255, 255, .94);
  --line: rgba(59, 36, 16, .1);
  --top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --bottom: calc(var(--tg-safe-area-inset-bottom, 0px) + var(--tg-content-safe-area-inset-bottom, 0px));
  /* altura real da janela (em position: fixed, 100% é a tela). A variável do Telegram chega atrasada
     e deixava o canvas com uma altura diferente da do desenho: a imagem esticava. */
  --height: 100%;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  background: #4fc3ff; color: var(--ink); user-select: none; -webkit-user-select: none; touch-action: manipulation;
  font: 500 16px/1.35 "Fredoka", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] { display: none !important; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- placar ---------- */
#hud {
  position: fixed; top: calc(10px + var(--top)); left: 0; right: 0; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
#score {
  font-size: 64px; font-weight: 700; line-height: 1; color: #fff;
  -webkit-text-stroke: 3px rgba(59, 36, 16, .55); paint-order: stroke fill;
  text-shadow: 0 4px 0 rgba(59, 36, 16, .25);
}
#score.bump { animation: bump .28s ease-out; }
@keyframes bump { 40% { transform: scale(1.28); } }
.hud-row { display: flex; gap: 6px; }
.coin-pill {
  font-size: 14px; font-weight: 700; color: #7a4a00; padding: 2px 10px; border-radius: 99px; background: #ffe066;
}
#hud-coins { display: inline-block; }
#hud-coins.bump { animation: bump .28s ease-out; }
#banner {
  position: fixed; left: 50%; top: 28%; transform: translateX(-50%); pointer-events: none; z-index: 3;
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; white-space: nowrap;
  padding: 10px 22px; border-radius: 20px; color: #fff; background: rgba(15, 10, 35, .55);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
#banner.show { animation: banner 2.6s ease-in-out both; }
#banner-title { font-size: 14px; font-weight: 600; opacity: .85; }
#banner-sub { font-size: 26px; font-weight: 700; }
@keyframes banner {
  0% { opacity: 0; transform: translate(-50%, 12px) scale(.9); }
  12%, 80% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -10px); }
}
#hud-best {
  font-size: 14px; font-weight: 600; color: #fff; padding: 2px 10px; border-radius: 99px;
  background: rgba(20, 30, 60, .22);
}
#hint {
  position: fixed; left: 0; right: 0; bottom: calc(14% + var(--bottom)); margin: 0; text-align: center; pointer-events: none;
  font-size: 22px; font-weight: 700; color: #fff;
  -webkit-text-stroke: 2px rgba(59, 36, 16, .45); paint-order: stroke fill;
  animation: float 1.1s ease-in-out infinite;
}
#hint::before { content: "👆"; display: block; font-size: 36px; -webkit-text-stroke: 0; margin-bottom: 4px; }
@keyframes float { 50% { transform: translateY(-8px); } }

/* ---------- tela inicial ---------- */
.screen {
  position: fixed; inset: 0; pointer-events: none;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: calc(12px + var(--top)) 20px calc(44px + var(--bottom)); /* 44px: espaço do selo gramfinale */
}
.screen > * { pointer-events: auto; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
#toggles { display: flex; gap: 6px; }
#toggles button {
  position: relative; width: 36px; height: 32px; padding: 0; font-size: 16px; border-radius: 99px; box-shadow: none;
  background: rgba(255, 255, 255, .85);
}
#toggles button[aria-pressed="false"] { background: rgba(255, 255, 255, .3); filter: grayscale(1); opacity: .75; }
#toggles button[aria-pressed="false"]::after {
  content: ""; position: absolute; left: 8px; right: 8px; top: 50%; height: 2px; border-radius: 2px;
  background: #fff; transform: rotate(-35deg);
}
#languages { display: flex; gap: 6px; justify-content: flex-end; }
#languages button {
  font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 99px; box-shadow: none;
  background: rgba(255, 255, 255, .3); color: #fff;
}
#languages button[aria-pressed="true"] { background: #fff; color: var(--orange-deep); }
.logo { text-align: center; margin-top: 2vh; animation: drop .6s cubic-bezier(.2, 1.4, .4, 1) both; }
h1 {
  margin: 0; font-size: clamp(54px, 17vw, 76px); font-weight: 700; letter-spacing: -1px; line-height: 1; color: #fff;
  -webkit-text-stroke: 5px var(--orange-deep); paint-order: stroke fill;
  text-shadow: 0 6px 0 rgba(122, 52, 18, .35); transform: rotate(-4deg);
}
.tagline {
  display: inline-block; margin: 14px 0 0; padding: 4px 14px; border-radius: 99px;
  font-size: 17px; font-weight: 600; color: #fff; background: rgba(20, 40, 80, .22);
}
@keyframes drop { from { transform: translateY(-40px); opacity: 0; } }
.actions { display: flex; flex-direction: column; gap: 12px; width: min(100%, 360px); margin: 0 auto; }
.pill {
  align-self: center; margin: 0 0 2px; padding: 5px 14px; border-radius: 99px;
  font-weight: 600; color: var(--ink); background: rgba(255, 255, 255, .85);
}
#best::before { content: "🏆 "; }
.pills { display: flex; gap: 8px; justify-content: center; }
.pill.coins { color: #7a4a00; background: #fff3c4; }
button.pill { box-shadow: none; font-size: 16px; }
.world-pill {
  align-self: center; padding: 8px 16px; border-radius: 99px; font-size: 16px; font-weight: 700; box-shadow: 0 3px 0 rgba(0, 0, 0, .18);
  color: #fff; background: rgba(20, 30, 60, .45); border: 2px solid rgba(255, 255, 255, .55);
}
.world-pill::before { content: "🗺️ "; }
.note { margin: 0; text-align: center; font-size: 13px; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .35); }

/* ---------- botões ---------- */
button {
  font: inherit; font-weight: 600; font-size: 16px; cursor: pointer; border: 0; border-radius: 16px; padding: 12px 16px;
  color: var(--ink); background: #fff; box-shadow: 0 4px 0 rgba(59, 36, 16, .16);
  transition: transform .08s, box-shadow .08s;
}
button:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 rgba(59, 36, 16, .16); }
button:disabled { opacity: .5; cursor: default; }
button.primary {
  color: #fff; background: linear-gradient(#ffb547, #ff8424); box-shadow: 0 5px 0 var(--orange-deep);
  text-shadow: 0 1px 0 rgba(122, 52, 18, .4);
}
button.primary:active:not(:disabled) { box-shadow: 0 2px 0 var(--orange-deep); }
button.big { font-size: 22px; font-weight: 700; padding: 14px; border-radius: 20px; }
button.secondary { background: rgba(255, 255, 255, .92); }
button.gold {
  color: #6a3a00; background: linear-gradient(#ffe56a, #ffc21a); box-shadow: 0 4px 0 #c98a06;
}
button.gold:active:not(:disabled) { box-shadow: 0 1px 0 #c98a06; }
button.accent { color: #fff; background: linear-gradient(#5cc0ff, var(--blue)); box-shadow: 0 4px 0 var(--blue-deep); }
button.accent:active:not(:disabled) { box-shadow: 0 1px 0 var(--blue-deep); }

/* ---------- cartões (fim de partida e loja) ---------- */
/* fim de partida: centralizado só na área livre (abaixo da barra do Telegram e acima da faixa de baixo) */
.card {
  position: fixed; left: 0; right: 0; top: calc(12px + var(--top)); bottom: calc(12px + var(--bottom)); margin: auto;
  width: min(92vw, 380px); height: fit-content; max-height: calc(100% - 24px - var(--top) - var(--bottom));
  overflow-y: auto; padding: 18px 18px 16px; border-radius: 26px;
  background: var(--card); box-shadow: 0 6px 0 rgba(59, 36, 16, .12), 0 20px 50px rgba(20, 30, 60, .3);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  display: flex; flex-direction: column; gap: 10px; text-align: center;
  animation: pop .32s cubic-bezier(.2, 1.4, .4, 1) both;
}
@keyframes pop { from { transform: translateY(16px) scale(.94); opacity: 0; } }
.eyebrow { margin: 0; font-size: 20px; font-weight: 700; color: var(--orange-deep); }
.final { margin: -4px 0 0; font-size: 60px; font-weight: 700; line-height: 1; color: var(--ink); }
.record { margin: 0 0 6px; font-weight: 600; color: var(--ink-soft); }
.record.new-best {
  align-self: center; padding: 4px 14px; border-radius: 99px; color: #7a4a00; background: #ffe066;
  animation: shine 1s ease-in-out infinite alternate;
}
@keyframes shine { to { transform: scale(1.06); } }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row button { font-size: 16px; padding: 12px 8px; }
h2 { margin: 10px 0 0; font-size: 16px; font-weight: 600; color: var(--ink-soft); }
.card-title { margin: 0 0 4px; font-size: 22px; font-weight: 700; color: var(--ink); }
.muted { color: var(--ink-soft); margin: 0; }
.small { font-size: 14px; }
ol, ul { margin: 0; padding: 0; list-style: none; text-align: left; }
#ranking { counter-reset: rank; }
#ranking li {
  counter-increment: rank; display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: center;
  padding: 7px 12px; border-radius: 12px;
}
#ranking li::before { content: counter(rank); font-weight: 700; color: var(--ink-soft); }
#ranking li:nth-child(1)::before { content: "🥇"; }
#ranking li:nth-child(2)::before { content: "🥈"; }
#ranking li:nth-child(3)::before { content: "🥉"; }
#ranking li:nth-child(odd) { background: rgba(59, 36, 16, .05); }
#ranking li.me { font-weight: 700; color: var(--orange-deep); background: #fff1df; }
#products { display: grid; gap: 10px; }
.product {
  border-radius: 16px; padding: 10px 10px 10px 12px; display: grid; grid-template-columns: 40px 1fr auto; gap: 0 10px; align-items: center;
  background: #fff7ee; border: 2px solid #ffe2c2;
}
.product::before {
  grid-row: 1 / span 3; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  font-size: 24px; background: #fff;
}
.product[data-id="revive_1"]::before { content: "💫"; }
.product[data-id^="coins_"]::before { content: "🪙"; background: #fff3c4; }
.product[data-id="coins_1500"]::before { content: "💰"; }
.product[data-id="coins_4000"]::before { content: "👑"; }
.product strong { font-weight: 700; font-size: 15px; line-height: 1.2; }
.product small { color: var(--ink-soft); font-size: 12px; line-height: 1.25; }
.product button { grid-row: 1 / span 3; grid-column: 3; min-width: 74px; padding: 9px 10px; font-size: 15px; white-space: nowrap; }
.product .owned { color: #2f9a47; font-size: 13px; font-weight: 600; }
.terms { display: flex; gap: 8px; align-items: center; justify-content: center; font-size: 15px; }
.terms input { width: 20px; height: 20px; accent-color: var(--orange); }
details { font-size: 14px; text-align: left; }
summary { color: var(--blue-deep); cursor: pointer; font-weight: 600; text-align: center; }
#terms-text, .terms-text {
  white-space: pre-line; color: var(--ink-soft); user-select: text; text-align: left; max-height: 30vh; overflow-y: auto;
}
#confirm details { margin: 0 0 12px; }
#confirm .small { margin: -6px 0 8px; }

/* ---------- pedido de avisos ---------- */
.ask {
  position: fixed; left: 50%; bottom: calc(16px + var(--bottom)); transform: translateX(-50%); z-index: 5;
  width: min(92vw, 380px); padding: 16px; border-radius: 22px; text-align: center;
  background: var(--card); box-shadow: 0 6px 0 rgba(59, 36, 16, .12), 0 16px 40px rgba(20, 30, 60, .3);
  animation: rise .3s cubic-bezier(.2, 1.4, .4, 1) both;
}
.ask p { margin: 0 0 12px; font-weight: 600; font-size: 17px; }
@keyframes rise { from { transform: translate(-50%, 30px); opacity: 0; } }

/* ---------- avisos ---------- */
#status {
  position: fixed; left: 50%; bottom: calc(14px + var(--bottom)); transform: translateX(-50%); margin: 0;
  max-width: min(92vw, 380px); padding: 8px 14px; border-radius: 14px; text-align: center; font-size: 14px;
  color: #fff; background: rgba(25, 20, 45, .78); pointer-events: none;
}
#status:empty { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}

/* ---------- fim de partida: moedas e mundos ---------- */
.earned { margin: -4px 0 2px; font-weight: 700; }
.earned { align-self: center; padding: 3px 12px; border-radius: 99px; color: #7a4a00; background: #fff3c4; }
.phase-result { margin: 0 0 2px; font-weight: 600; color: var(--ink-soft); }
.phase-result.clear {
  align-self: center; padding: 4px 14px; border-radius: 99px; font-weight: 700; color: #fff;
  background: linear-gradient(90deg, #22c55e, #16a34a); animation: shine 1s ease-in-out infinite alternate;
}
.goal-pill {
  font-size: 14px; font-weight: 700; color: #fff; padding: 2px 10px; border-radius: 99px; background: rgba(20, 30, 60, .35);
}
.goal-pill.done { background: #22c55e; }

/* ---------- coleção ---------- */
#items { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 7px; }
.item-button {
  position: relative; width: 100%; padding: 0 0 6px; border-radius: 16px; overflow: hidden; display: flex; flex-direction: column;
  align-items: center; gap: 1px; background: #fff; border: 2px solid transparent; box-shadow: 0 3px 0 rgba(59, 36, 16, .12);
}
.item.equipped .item-button { border-color: var(--orange); }
.item.locked .thumb { filter: saturate(.75) brightness(.92); }
.thumb { width: 100%; aspect-ratio: 88 / 96; display: block; background: linear-gradient(#cfeeff, #f3fbff); }
.item-name { font-size: 12px; font-weight: 700; line-height: 1.1; padding: 0 4px; }
.item-price { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.item.locked .item-price { color: #7a4a00; }
.item.equipped .item-price { color: var(--orange-deep); }
.badge { position: absolute; top: 4px; right: 4px; font-size: 14px; }
.number {
  position: absolute; top: 4px; left: 4px; min-width: 20px; padding: 0 5px; border-radius: 99px;
  font-size: 11px; font-weight: 700; color: #fff; background: rgba(0, 0, 0, .45);
}
.item.locked .item-button::after {
  content: "🔒"; position: absolute; top: 4px; left: 50%; transform: translateX(-50%); font-size: 13px;
  padding: 1px 5px; border-radius: 99px; background: rgba(255, 255, 255, .8);
}
#unlock-ask p#unlock-note:empty { display: none; }

/* ---------- selo do estúdio (gramfinale) ---------- */
.brand {
  position: fixed; left: 50%; bottom: calc(10px + var(--bottom)); transform: translateX(-50%); z-index: 1;
  display: flex; align-items: center; gap: 6px; padding: 4px 11px 4px 8px; border-radius: 99px;
  font-size: 15px; font-weight: 600; letter-spacing: -.2px; line-height: 1; color: #fff; text-decoration: none;
  background: rgba(27, 20, 66, .32); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  opacity: .9; transition: opacity .3s;
}
.brand img { width: 20px; height: 22px; display: block; margin: -2px 0; }
.brand b { font-weight: inherit; color: #ffc857; }
/* durante a partida vira marca d'água: mais apagado e não pega toque */
body[data-screen="playing"] .brand { opacity: .5; pointer-events: none; }
/* cartões e pedidos ficam na frente; o selo some para não brigar com eles */
body[data-screen="over"] .brand, body[data-screen="shop"] .brand, body[data-screen="collection"] .brand,
body[data-screen="map"] .brand { opacity: 0; pointer-events: none; }
.brand i { font-style: normal; font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 99px; color: #0b1b4d; background: #22c55e; }
/* versão Brasil: o "m" em amarelo, como no logotipo escuro da marca BR */
.brand.br b { color: #ffdf3a; }

/* ---------- abertura: nada de botão vazio enquanto os textos chegam ---------- */
#loader { display: none; }
body.booting #loader {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; align-content: center; gap: 0;
  background: radial-gradient(circle at 50% 40%, #8fdcff, #4fc3ff 70%);
}
.loader-ball {
  width: 46px; height: 46px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe1a8, #ff9a3c 55%, #e8731a);
  box-shadow: inset -4px -6px 0 rgba(160, 70, 10, .25); animation: hop .62s cubic-bezier(.3, 0, .5, 1) infinite alternate;
}
.loader-shadow { width: 40px; height: 8px; margin-top: 6px; border-radius: 50%; background: rgba(20, 60, 110, .22); animation: hop-shadow .62s cubic-bezier(.3, 0, .5, 1) infinite alternate; }
@keyframes hop { from { transform: translateY(0) scale(1.12, .88); } 30% { transform: translateY(-8px) scale(1); } to { transform: translateY(-46px); } }
@keyframes hop-shadow { to { transform: scale(.55); opacity: .5; } }
body.booting #home, body.booting #brand { visibility: hidden; }

/* ---------- tela principal: o mapa ---------- */
.map-screen { position: fixed; inset: 0; z-index: 2; background: #2a3a7a; animation: fade .3s ease-out both; }
@keyframes fade { from { opacity: 0; } }
.map-path {
  position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain; touch-action: pan-y; scrollbar-width: none;
  display: flex; flex-direction: column;
  padding: calc(76px + var(--top)) 0 calc(236px + var(--bottom));
  background: linear-gradient(var(--map-sky, #6fb6ff) 0 50%, var(--map-ground, #5cb85c) 50%) local;
}
.map-path::-webkit-scrollbar { display: none; }
.kingdom { position: relative; flex-shrink: 0; margin: 0; overflow: hidden; }
.kingdom-art { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity .45s ease-out; }
.kingdom-art.ready { opacity: 1; }
/* nuvem macia passando devagar por cima de cada reino */
.kingdom::after {
  content: ""; position: absolute; top: 22%; left: -40%; width: 170px; height: 60px; pointer-events: none; opacity: .42;
  background:
    radial-gradient(circle at 30% 65%, #fff 0 26px, transparent 27px),
    radial-gradient(circle at 55% 45%, #fff 0 32px, transparent 33px),
    radial-gradient(circle at 78% 66%, #fff 0 22px, transparent 23px);
  animation: drift 38s linear infinite;
}
.kingdom:nth-child(even)::after { top: 58%; animation-duration: 52s; animation-delay: -20s; opacity: .3; }
@keyframes drift { to { transform: translateX(calc(100vw + 260px)); } }
.kingdom-head {
  position: absolute; top: 14px; left: 12px; right: 12px; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  pointer-events: none;
}
.kingdom-head strong {
  padding: 5px 14px; border-radius: 99px; font-size: 18px; font-weight: 700; color: #fff;
  background: rgba(30, 20, 60, .42); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .3);
}
.kingdom-head span { padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; color: #fff; background: rgba(30, 20, 60, .3); }
.kingdom-head .kingdom-hazard { margin-left: auto; }

.node {
  position: absolute; z-index: 1; transform: translate(-50%, -50%); width: 128px; padding: 0; border: 0;
  background: none; box-shadow: none; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.node:active:not(:disabled) { transform: translate(-50%, -50%) scale(.92); box-shadow: none; }
.bubble {
  position: relative; display: grid; place-items: center; width: 58px; height: 58px; border-radius: 50%;
  font-size: 24px; font-weight: 700; color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .25);
  border: 4px solid #fff; background: radial-gradient(circle at 35% 28%, #c8ccd8, #8a90a6 70%);
  box-shadow: 0 5px 0 rgba(0, 0, 0, .28), inset 0 -6px 0 rgba(0, 0, 0, .14), inset 0 5px 0 rgba(255, 255, 255, .35);
}
.node.locked .bubble { font-size: 20px; opacity: .92; }
.node.done .bubble { background: radial-gradient(circle at 35% 28%, #8af0a8, #22b45a 70%); }
.node.open .bubble, .node.selected .bubble { background: radial-gradient(circle at 35% 28%, #ffd38a, #ff8424 70%); animation: pulse 1.6s ease-in-out infinite; }
.node.buy .bubble { color: #6a3a00; text-shadow: 0 1px 0 rgba(255, 255, 255, .5); background: radial-gradient(circle at 35% 28%, #fff0a0, #ffc21a 70%); }
.node.finale .bubble { width: 70px; height: 70px; font-size: 28px; border-color: #ffe066; }
@keyframes pulse {
  50% { box-shadow: 0 0 0 9px rgba(255, 255, 255, .35), 0 5px 0 rgba(0, 0, 0, .28), inset 0 -6px 0 rgba(0, 0, 0, .14), inset 0 5px 0 rgba(255, 255, 255, .35); }
}
.check {
  position: absolute; right: -6px; bottom: -4px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: 14px; font-style: normal; color: #fff; text-shadow: none; background: #16a34a; border: 2px solid #fff;
}
.crown { position: relative; z-index: 1; height: 0; top: -14px; font-size: 24px; line-height: 0; filter: drop-shadow(0 2px 1px rgba(0, 0, 0, .3)); }
.node-label {
  display: flex; flex-direction: column; align-items: center; max-width: 128px; padding: 2px 9px; border-radius: 10px;
  font-size: 12px; line-height: 1.1; color: #fff; background: rgba(30, 20, 60, .45);
}
.node-label b { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
.node-label small { font-size: 11px; font-weight: 600; opacity: .9; }
.node-label .price { color: #ffe066; opacity: 1; }
.node.locked .node-label { opacity: .75; }
.marker {
  position: absolute; z-index: 2; width: 48px; height: 52px; pointer-events: none;
  transform: translate(-50%, -100%); filter: drop-shadow(0 4px 2px rgba(0, 0, 0, .3)); animation: bob 1.1s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translate(-50%, calc(-100% - 7px)); } }
.map-foot { display: grid; place-items: center; padding: 14px 0 0; flex-shrink: 0; }
.brand.in-map { position: static; transform: none; opacity: .95; }
body[data-screen="home"] #brand, body[data-screen="shop"] #brand, body[data-screen="collection"] #brand,
body[data-screen="duel"] #brand { opacity: 0; pointer-events: none; }

.map-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3; display: flex; align-items: center; gap: 8px;
  padding: calc(10px + var(--top)) 12px 18px; background: linear-gradient(#1f1a45, rgba(31, 26, 69, .6) 55%, rgba(31, 26, 69, 0));
}
.map-top-mid { flex: 1; display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.map-top .pill { margin: 0; padding: 5px 12px; font-size: 15px; box-shadow: 0 3px 0 rgba(0, 0, 0, .15); }
.avatar, .round {
  flex-shrink: 0; width: 48px; height: 48px; padding: 0; border-radius: 50%; display: grid; place-items: center;
  border: 3px solid #fff; background: radial-gradient(circle at 40% 30%, #fff7e8, #ffd9a8); box-shadow: 0 4px 0 rgba(0, 0, 0, .2);
}
.avatar canvas { width: 42px; height: 42px; display: block; }
.round { font-size: 22px; background: rgba(255, 255, 255, .92); }
.map-bottom {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; display: flex; flex-direction: column; align-items: stretch; gap: 10px;
  padding: 34px max(16px, calc(50% - 200px)) calc(10px + var(--bottom));
  background: linear-gradient(rgba(20, 16, 50, 0), rgba(20, 16, 50, .62) 45%);
  pointer-events: none;
}
.map-bottom > * { pointer-events: auto; }
.map-progress { margin: 0; text-align: center; font-size: 14px; font-weight: 700; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .4); }
#play { font-size: 22px; padding: 15px 12px; animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.03); } }
#play:active:not(:disabled) { animation: none; }
.tabbar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 5px; border-radius: 20px; background: rgba(255, 255, 255, .9); box-shadow: 0 4px 0 rgba(0, 0, 0, .18); }
.tabbar button { display: flex; flex-direction: column; align-items: center; gap: 0; padding: 6px 4px; border-radius: 15px; background: none; box-shadow: none; font-size: 12px; color: var(--ink-soft); }
.tabbar button span { font-size: 22px; line-height: 1.1; transition: transform .2s cubic-bezier(.2, 1.6, .4, 1); }
.tabbar button b { font-weight: 700; }
.tabbar button.on { color: var(--orange-deep); background: #fff1df; }
.tabbar button.on span { transform: translateY(-2px) scale(1.12); }

/* loja e coleção abrem por cima do mapa */
.card { z-index: 4; }
body[data-screen="shop"] .map-bottom, body[data-screen="collection"] .map-bottom, body[data-screen="duel"] .map-bottom { visibility: hidden; }

/* ---------- folhas (loja, personagens, desafio, ajustes) ---------- */
/* Sobem de baixo e param antes da barra do Telegram; o fechar é o ✕ da própria folha. */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; margin: 0 auto; width: min(100%, 480px);
  max-height: calc(100% - 20px - var(--top)); display: flex; flex-direction: column; text-align: left;
  border-radius: 24px 24px 0 0; background: #fffaf3; padding-bottom: var(--bottom);
  box-shadow: 0 -6px 24px rgba(20, 16, 50, .25), 0 0 0 100vmax rgba(20, 16, 50, .42);
  animation: sheet-up .32s cubic-bezier(.2, 1.1, .4, 1) both;
}
@keyframes sheet-up { from { transform: translateY(60px); opacity: 0; } }
.sheet::before { content: ""; position: absolute; top: 7px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 4px; background: rgba(59, 36, 16, .16); }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 18px 14px 8px 18px; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 21px; font-weight: 700; color: var(--ink); }
.sheet-head .pill { margin: 0; padding: 4px 11px; font-size: 14px; }
.x {
  flex-shrink: 0; width: 34px; height: 34px; padding: 0; border-radius: 50%; display: grid; place-items: center;
  font-size: 15px; font-weight: 700; color: var(--ink-soft); background: rgba(59, 36, 16, .08); box-shadow: none;
}
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 2px 16px 14px; display: flex; flex-direction: column; gap: 10px; }
.sheet-foot { padding: 10px 16px 12px; border-top: 1px solid var(--line); display: grid; }
.sheet details { text-align: left; }
.setting {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 16px;
  background: rgba(59, 36, 16, .05); font-weight: 600;
}
.setting > span { display: flex; flex-direction: column; gap: 1px; }
.setting small { font-size: 12px; font-weight: 500; color: var(--ink-soft); line-height: 1.25; }
#settings #toggles button { width: 50px; height: 40px; font-size: 20px; background: #fff; box-shadow: 0 2px 0 rgba(59, 36, 16, .12); }
#settings #languages button { font-size: 14px; padding: 7px 14px; color: var(--ink); background: #fff; box-shadow: 0 2px 0 rgba(59, 36, 16, .12); }
#settings #languages button[aria-pressed="true"] { color: #fff; background: var(--orange); }
.switch {
  flex-shrink: 0; min-width: 84px; padding: 8px 10px; border-radius: 99px; font-size: 13px; font-weight: 700; box-shadow: none;
  color: var(--ink-soft); background: #fff; border: 2px solid rgba(59, 36, 16, .12);
}
.switch[aria-checked="true"] { color: #fff; background: #22c55e; border-color: #22c55e; }
/* pedidos por cima do mapa: o fundo escurece um pouco para o cartão se destacar */
#phase-sheet, #unlock-ask { box-shadow: 0 6px 0 rgba(59, 36, 16, .12), 0 0 0 100vmax rgba(20, 16, 50, .38); }

/* ---------- desafio entre amigos ---------- */
.map-status { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.duel-chip {
  max-width: 100%; padding: 6px 14px; border-radius: 99px; font-size: 14px; font-weight: 700; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; color: #fff; background: rgba(31, 26, 69, .78); box-shadow: none;
  border: 1.5px solid rgba(255, 255, 255, .45);
}
.duel-chip.news { color: #6a3a00; background: #ffe066; border-color: #fff3b0; animation: nudge 2.4s ease-in-out infinite; }
@keyframes nudge { 0%, 70%, 100% { transform: none; } 75% { transform: rotate(-2deg); } 85% { transform: rotate(2deg); } }
.tabbar button { position: relative; }
.dot { position: absolute; top: 4px; right: calc(50% - 20px); width: 10px; height: 10px; border-radius: 50%; background: #ff4d4d; border: 2px solid #fff; }
.news { display: grid; gap: 6px; }
.news li { padding: 9px 12px; border-radius: 14px; font-weight: 600; background: #fff3c4; color: #6a3a00; }
.news li::before { content: "🔔 "; }
.news li.joined { background: #e3f7e8; color: #1c6b34; }
.news li.joined::before { content: "🤝 "; }
.ranking { counter-reset: rank; }
.ranking li {
  counter-increment: rank; display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: center;
  padding: 9px 12px; border-radius: 12px; font-weight: 600;
}
.ranking li::before { content: counter(rank); font-weight: 700; color: var(--ink-soft); }
.ranking li:nth-child(1)::before { content: "🥇"; }
.ranking li:nth-child(2)::before { content: "🥈"; }
.ranking li:nth-child(3)::before { content: "🥉"; }
.ranking li:nth-child(odd) { background: rgba(59, 36, 16, .05); }
.ranking li.me { font-weight: 700; color: var(--orange-deep); background: #fff1df; }

/* ---------- como jogar (primeira vez) ---------- */
.intro {
  position: fixed; inset: 0; z-index: 9; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: calc(16px + var(--top)) 20px calc(16px + var(--bottom)); text-align: center;
  background: radial-gradient(circle at 50% 30%, #fff5e6, #ffe2bf 75%); animation: fade .3s both;
}
#intro-canvas {
  width: min(88vw, 380px); height: min(46vh, 380px); border-radius: 30px; display: block;
  box-shadow: 0 6px 0 rgba(59, 36, 16, .14), 0 16px 34px rgba(160, 90, 30, .22);
}
.intro h2 { margin: 8px 0 0; font-size: 26px; font-weight: 700; color: var(--ink); }
.intro p { margin: 0; max-width: 340px; font-size: 17px; color: var(--ink-soft); min-height: 3em; }
.dots { display: flex; gap: 7px; margin: 4px 0; }
.dots i { width: 9px; height: 9px; border-radius: 99px; background: rgba(59, 36, 16, .18); transition: width .25s, background .25s; }
.dots i.on { width: 26px; background: var(--orange); }
.intro .row { width: min(88vw, 380px); grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: 1fr; }

/* ---------- efeitos aconchegantes ---------- */
.fly-coin {
  position: fixed; z-index: 10; margin: -14px 0 0 -14px; font-size: 26px; line-height: 1; pointer-events: none;
  transition: transform .6s cubic-bezier(.5, -0.3, .7, 1), opacity .6s ease-in; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .25));
}
#hint.coin { font-size: 19px; bottom: calc(22% + var(--bottom)); }
#hint.coin::before { content: "🪙"; }
#hud, #hint { z-index: 2; }
/* vinheta morna durante a partida: borda mais quente, centro limpo */
body[data-screen="playing"]::after, body[data-screen="over"]::after {
  content: ""; position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse 85% 75% at 50% 45%, transparent 58%, rgba(120, 60, 20, .2) 100%);
}
button:not(.node):not(:disabled):active { transform: translateY(3px) scale(.97); }
.sheet-title { font-size: 20px !important; margin: 0 !important; }
#phase-kingdom { margin: 0 0 10px; font-weight: 600; font-size: 14px; }
.phase-info { display: grid; gap: 6px; margin: 0 0 12px; text-align: left; font-size: 15px; font-weight: 600; }
.phase-info li { padding: 7px 10px; border-radius: 12px; background: rgba(59, 36, 16, .05); }
.phase-info .hazard { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; }
.phase-info .hazard small { grid-column: 1 / -1; font-weight: 500; color: var(--ink-soft); }
.phase-info em { font-style: normal; font-size: 12px; font-weight: 700; color: #fff; background: #ff5a5a; padding: 1px 8px; border-radius: 99px; align-self: center; }
#phase-sheet { z-index: 6; }
