:root {
  --green: #4caf50;
  --green-dark: #3d8b40;
  --green-deep: #2e6b31;
  --orange: #ff9800;
  --orange-dark: #e07f00;
  --cream: #fffaf0;
  --text: #333;
  --gold: #c9a227;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; font-family: Poppins, system-ui, sans-serif; color: var(--text); background: #cfe8c8; user-select: none; }
canvas#game { position: fixed; inset: 0; display: block; touch-action: none; cursor: pointer; }
button { font-family: inherit; cursor: pointer; }

/* ---------- topo ---------- */
#hud-top {
  position: fixed; top: 10px; left: 10px; right: 10px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; pointer-events: none; z-index: 5;
}
#hud-top > * { pointer-events: auto; }
.brand {
  display: flex; align-items: center; gap: 6px; padding: 6px 16px 6px 10px; border-radius: 18px;
  background: linear-gradient(#5cc061, var(--green-dark)); border: 3px solid #fff; box-shadow: 0 3px 0 var(--green-deep), 0 6px 14px rgba(0,0,0,.18);
  color: #fff; font-weight: 800; font-size: 20px; letter-spacing: .2px; text-shadow: 0 2px 0 rgba(0,0,0,.2);
}
.brand b { color: #ffe082; }
.brand-hat { font-size: 24px; }
.pill {
  display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 14px 0 6px; border-radius: 22px; background: #fff;
  border: 3px solid #fff; box-shadow: 0 3px 0 #b9cdb4, 0 6px 14px rgba(0,0,0,.14); font-weight: 700; font-size: 17px;
}
.pill .ico { font-size: 22px; width: 30px; text-align: center; }
.pill.coins { color: #8a6500; background: linear-gradient(#fffbe8, #fff1c2); }
.pill.charm { color: var(--green-deep); background: linear-gradient(#f3fff2, #dff3dc); }
.level .star {
  width: 36px; height: 36px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px;
  background: var(--orange); clip-path: polygon(50% 0, 62% 34%, 98% 35%, 69% 56%, 80% 92%, 50% 71%, 20% 92%, 31% 56%, 2% 35%, 38% 34%);
}
.xp { position: relative; width: 150px; height: 20px; border-radius: 10px; background: #e6eee4; overflow: hidden; border: 2px solid #cfdccb; }
#xpbar { height: 100%; width: 0; background: linear-gradient(#8fd694, var(--green)); transition: width .3s; }
#xptext { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #2d4a2e; }

/* ---------- barra de baixo ---------- */
#hud-bottom {
  position: fixed; bottom: 10px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; padding: 8px; z-index: 5;
  background: rgba(255,255,255,.85); border: 3px solid #fff; border-radius: 22px; box-shadow: 0 6px 18px rgba(0,0,0,.18); backdrop-filter: blur(4px);
}
#hud-bottom button {
  display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 74px; padding: 6px 8px 7px; border: 0; border-radius: 15px;
  background: linear-gradient(#fff, #eef6ec); box-shadow: 0 3px 0 #b9cdb4; font-weight: 700; font-size: 12px; color: var(--green-deep);
  transition: transform .08s;
}
#hud-bottom button span { font-size: 24px; line-height: 1.1; }
#hud-bottom button:hover { transform: translateY(-2px); }
#hud-bottom button:active { transform: translateY(2px); box-shadow: 0 1px 0 #b9cdb4; }
#hud-bottom button.cc { background: linear-gradient(#5cc061, var(--green-dark)); color: #fff; box-shadow: 0 3px 0 var(--green-deep); }

#zoom { position: fixed; right: 12px; bottom: 110px; display: flex; flex-direction: column; gap: 6px; z-index: 5; }
#zoom button { width: 40px; height: 40px; border-radius: 12px; border: 3px solid #fff; background: #f3fbf1; box-shadow: 0 3px 0 #b9cdb4; font-size: 20px; font-weight: 800; color: var(--green-deep); }

/* ---------- modo decorar / colocar ---------- */
#mode-bar {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 6; display: flex; gap: 8px; align-items: center;
  padding: 8px 10px 8px 18px; border-radius: 18px; background: #fff8e6; border: 3px solid var(--orange); box-shadow: 0 6px 16px rgba(0,0,0,.18); font-weight: 600; font-size: 14px;
}
#mode-bar[hidden] { display: none; }
#mode-bar button { border: 0; border-radius: 12px; padding: 8px 14px; font-weight: 700; background: #eee; box-shadow: 0 3px 0 #ccc; }
#mode-bar button.ok { background: var(--green); color: #fff; box-shadow: 0 3px 0 var(--green-deep); }
#mode-bar button.danger { background: #ef5350; color: #fff; box-shadow: 0 3px 0 #b71c1c; }
#mode-bar button[hidden] { display: none; }

/* ---------- modal ---------- */
#modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(30,50,30,.45); padding: 14px; }
#modal[hidden] { display: none; }
.sheet {
  position: relative; width: min(880px, 100%); max-height: calc(100vh - 28px); overflow: auto; border-radius: 26px; background: var(--cream);
  border: 5px solid #fff; box-shadow: 0 0 0 4px var(--green), 0 20px 50px rgba(0,0,0,.35); padding: 22px 22px 26px; animation: pop .18s ease-out;
}
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet .close { position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; border-radius: 50%; border: 3px solid #fff; background: #ef5350; color: #fff; font-weight: 800; font-size: 16px; box-shadow: 0 3px 0 #b71c1c; }
.sheet h2 { margin: 0 46px 4px 0; font-size: 26px; color: var(--green-deep); font-weight: 800; }
.sheet .sub { margin: 0 0 16px; color: #666; font-size: 14px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button { border: 0; padding: 8px 14px; border-radius: 12px; font-weight: 700; background: #e7f1e4; color: var(--green-deep); box-shadow: 0 3px 0 #c3d6be; }
.tabs button.on { background: var(--orange); color: #fff; box-shadow: 0 3px 0 var(--orange-dark); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 10px 12px; border-radius: 18px; background: #fff;
  border: 3px solid #e3eedf; box-shadow: 0 4px 0 #d3e2ce; text-align: center; transition: transform .1s, border-color .1s;
}
.card.can { cursor: pointer; }
.card.can:hover { transform: translateY(-3px); border-color: var(--green); }
.card.locked { opacity: .55; filter: grayscale(.7); }
.card .big { font-size: 46px; line-height: 1.1; }
.card img { width: 110px; height: 110px; }
.card .name { font-weight: 700; font-size: 15px; line-height: 1.2; min-height: 36px; display: grid; place-items: center; }
.card .row { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; font-size: 12px; font-weight: 600; }
.chip { padding: 2px 8px; border-radius: 10px; background: #f1f5f0; }
.chip.kcal { background: #e8f5e9; color: var(--green-deep); }
.chip.time { background: #fff3e0; color: #b25d00; }
.chip.gain { background: #fff8d9; color: #8a6500; }
.macros { font-size: 11px; color: #777; }
.price { margin-top: 4px; padding: 6px 14px; border-radius: 12px; background: var(--green); color: #fff; font-weight: 800; box-shadow: 0 3px 0 var(--green-deep); font-size: 14px; }
.price.no { background: #bdbdbd; box-shadow: 0 3px 0 #8d8d8d; }
.lock { position: absolute; top: 8px; right: 10px; font-size: 12px; font-weight: 800; color: #fff; background: #78909c; padding: 2px 8px; border-radius: 10px; }
.owned { font-size: 12px; font-weight: 700; color: var(--green-deep); }
.swatch { width: 110px; height: 70px; border-radius: 14px; border: 3px solid #fff; box-shadow: 0 0 0 2px #ddd; }

.help ol { padding-left: 20px; line-height: 1.6; }
.help li { margin-bottom: 6px; }
.cta { display: inline-block; margin-top: 10px; padding: 12px 22px; border-radius: 16px; background: var(--green); color: #fff; font-weight: 800; text-decoration: none; box-shadow: 0 4px 0 var(--green-deep); border: 0; font-size: 16px; }
.cta.orange { background: var(--orange); box-shadow: 0 4px 0 var(--orange-dark); }
.center { text-align: center; }
.levelup .burst { font-size: 70px; }

/* ---------- avisos ---------- */
#toasts { position: fixed; top: 74px; right: 12px; display: flex; flex-direction: column; gap: 8px; z-index: 20; align-items: flex-end; pointer-events: none; }
.toast { padding: 10px 16px; border-radius: 14px; background: #fff; border-left: 6px solid var(--green); box-shadow: 0 6px 16px rgba(0,0,0,.18); font-weight: 600; font-size: 14px; max-width: 320px; animation: slide .25s ease-out; }
.toast.warn { border-left-color: var(--orange); }
.toast.bad { border-left-color: #ef5350; }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 700px) {
  .brand { font-size: 16px; padding: 4px 12px 4px 8px; }
  .brand-hat { font-size: 18px; }
  .xp { width: 90px; }
  .pill { height: 36px; font-size: 14px; }
  #hud-bottom { gap: 4px; padding: 6px; width: calc(100% - 16px); justify-content: space-between; }
  #hud-bottom button { min-width: 0; flex: 1; font-size: 10px; padding: 5px 2px; }
  #hud-bottom button span { font-size: 20px; }
  #hud-bottom button { overflow: hidden; text-align: center; line-height: 1.15; }
  #zoom { bottom: 96px; }
  #mode-bar { top: auto; bottom: 90px; width: calc(100% - 20px); flex-wrap: wrap; justify-content: center; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

/* ---------- conta, Folhas, missões, bônus (etapa 1) ---------- */
button.pill { font-family: inherit; cursor: pointer; }
.pill.folhas { color: #2e6b31; background: linear-gradient(#f3fff2, #d7f0d0); }
.pill.conta { font-size: 13px; color: #455a64; }
#hud-bottom button.has-badge { position: relative; }
#badge-missoes { position: absolute; top: -6px; right: -4px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: #ef5350; color: #fff; font-style: normal; font-size: 12px; font-weight: 800; display: grid; place-items: center; border: 2px solid #fff; animation: pulse 1.4s infinite; }
#badge-missoes[hidden] { display: none; }
@keyframes pulse { 50% { transform: scale(1.15); } }
.price.folha { background: #2e7d32; box-shadow: 0 3px 0 #1b5e20; }
.stars { color: #f9a825; font-size: 16px; letter-spacing: 1px; }
.stars small { color: #888; font-size: 11px; margin-left: 4px; letter-spacing: 0; }
.mission { display: grid; grid-template-columns: 1fr 180px 110px; gap: 12px; align-items: center; padding: 12px 14px; margin-bottom: 10px; border-radius: 16px; background: #fff; border: 3px solid #e3eedf; }
.mission.bonus { grid-template-columns: 1fr auto; background: #fff8e6; border-color: #ffcc80; }
.mission.pego { opacity: .6; }
.mission .m-txt { font-weight: 700; }
.mission .cta { margin: 0; padding: 8px 14px; font-size: 14px; }
.m-bar { position: relative; height: 20px; border-radius: 10px; background: #e6eee4; overflow: hidden; }
.m-bar div { height: 100%; background: linear-gradient(#8fd694, #4caf50); }
.m-bar span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #2d4a2e; }
.m-falta { font-size: 12px; color: #888; text-align: center; }
.ladder { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin: 14px 0 18px; }
.ladder .step { display: flex; flex-direction: column; gap: 2px; padding: 10px 4px; border-radius: 14px; background: #fff; border: 3px solid #e3eedf; font-size: 13px; }
.ladder .step b { font-size: 12px; color: #777; }
.ladder .step.done { opacity: .45; }
.ladder .step.today { border-color: #ff9800; background: #fff3e0; transform: scale(1.06); }
.login form { display: flex; flex-direction: column; gap: 10px; max-width: 340px; margin: 0 auto; }
.login input { padding: 12px 14px; border-radius: 12px; border: 2px solid #cfdccb; font: inherit; font-size: 15px; }
.login input:focus { outline: none; border-color: #4caf50; }
.login .erro { color: #c62828; font-weight: 600; min-height: 1em; margin: 0; font-size: 14px; }
.login a, .help a, .sheet a:not(.cta) { color: #2e7d32; font-weight: 700; }
@media (max-width: 700px) {
  .pill.conta span:last-child { display: none; }
  .mission { grid-template-columns: 1fr; gap: 8px; }
  .ladder { grid-template-columns: repeat(4, 1fr); }
}
.mission.cc { grid-template-columns: 1fr auto; background: #f1faf0; border-color: #a5d6a7; }
.mission.cc.pro { background: #fffbea; border-color: #f2d27a; }
.mission.cc .cta { white-space: nowrap; }
.card a.price { text-decoration: none; display: inline-block; }

/* comprar Folhas (etapa 3) */
.card.pacote { text-align: center; }
.card.pacote .big { font-size: 40px; }
.card.pacote.destaque { outline: 3px solid #ff9800; }
.card.pacote button.price { border: 0; cursor: pointer; font: inherit; color: #fff; }
.card.pacote button.price:disabled { opacity: .45; cursor: default; }
label.maior { display: block; margin: 14px 0 4px; font-weight: 600; }
label.maior input { width: 18px; height: 18px; vertical-align: -3px; margin-right: 6px; }
.erro { color: #c62828; font-weight: 600; min-height: 1em; }

/* ---------- amigos, visitas e eventos (etapa 4) ---------- */
#badge-amigos { position: absolute; top: -6px; right: -4px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: #ef5350; color: #fff; font-style: normal; font-size: 12px; font-weight: 800; display: grid; place-items: center; border: 2px solid #fff; animation: pulse 1.4s infinite; }
#badge-amigos[hidden] { display: none; }
#visit-bar {
  position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%); z-index: 6; display: flex; gap: 8px; align-items: center;
  padding: 8px 10px 8px 18px; border-radius: 18px; background: #f1faf0; border: 3px solid var(--green); box-shadow: 0 6px 16px rgba(0,0,0,.18); font-weight: 700; font-size: 14px;
}
#visit-bar[hidden] { display: none; }
#visit-bar button { border: 0; border-radius: 12px; padding: 8px 14px; font-weight: 700; font-family: inherit; background: #eee; box-shadow: 0 3px 0 #ccc; cursor: pointer; }
#visit-bar button.ok { background: var(--orange); color: #fff; box-shadow: 0 3px 0 #c66900; }
#visit-bar button.back { background: var(--green); color: #fff; box-shadow: 0 3px 0 var(--green-deep); }
#visit-bar button:disabled { opacity: .5; cursor: default; }
#visit-bar button[hidden] { display: none; }
body.visitando .pill.coins, body.visitando .pill.charm, body.visitando .pill.folhas, body.visitando #btn-conta { display: none; }
@media (max-width: 700px) {
  #visit-bar { width: calc(100% - 20px); flex-wrap: wrap; justify-content: center; padding: 8px; }
}
.amigos-topo { background: #f1faf0; border: 3px solid #a5d6a7; border-radius: 16px; padding: 12px 14px; margin-bottom: 12px; }
.amigos-topo .codigo { font-size: 26px; font-weight: 800; letter-spacing: 3px; color: var(--green-deep); }
.amigos-topo .acoes { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.amigos-topo .acoes .cta { margin: 0; padding: 8px 14px; font-size: 14px; }
.amigo { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 10px 14px; margin-bottom: 8px; border-radius: 14px; background: #fff; border: 3px solid #e3eedf; }
.amigo .cta { margin: 0; padding: 7px 14px; font-size: 14px; }
.amigo small { color: #6b7c69; font-weight: 600; }
.por-codigo { display: flex; gap: 8px; margin: 10px 0; }
.por-codigo input, .nome-rest input { flex: 1; padding: 10px 12px; border-radius: 12px; border: 2px solid #c8e6c9; font: inherit; text-transform: uppercase; }
.nome-rest { display: flex; gap: 8px; margin-top: 8px; }
.nome-rest input { text-transform: none; }
.mission.evento { grid-template-columns: 1fr 180px 110px; background: #fff4f4; border-color: #f3b2b2; }
.mission.evento.breve { grid-template-columns: 1fr; background: #fffbea; border-color: #f2d27a; }
/* celular estreito: 8 botões não cabem com rótulo de 10px ("CaloriCerta" passava por cima do vizinho) */
@media (max-width: 440px) {
  #hud-bottom { gap: 3px; padding: 5px; width: calc(100% - 10px); }
  #hud-bottom button { font-size: 9px; letter-spacing: -.2px; padding: 5px 1px; border-radius: 12px; }
  #hud-bottom button span { font-size: 18px; }
}
@media (max-width: 350px) {
  #hud-bottom { gap: 2px; padding: 4px; width: calc(100% - 6px); }
  #hud-bottom button { font-size: 8px; letter-spacing: -.3px; padding: 4px 0; }
  #hud-bottom button span { font-size: 16px; }
}
@media (max-width: 700px) { .mission.evento { grid-template-columns: 1fr; } }
.tag-evento { display: inline-block; background: #e53935; color: #fff; border-radius: 8px; padding: 1px 7px; font-size: 11px; font-weight: 800; margin-bottom: 4px; }
.nome-rest[hidden] { display: none; }

/* receita de verdade (etapa 5) */
a.receita-cc { display: block; margin-top: 6px; font-size: 12px; font-weight: 700; color: var(--green-deep); text-decoration: underline; }
