* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #5fae45;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  user-select: none; -webkit-user-select: none; touch-action: none;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
}
canvas { position: fixed; inset: 0; display: block; touch-action: none; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: fixed; top: calc(env(safe-area-inset-top) + 6px); left: 8px; right: 8px;
  display: flex; justify-content: space-between; align-items: center;
  pointer-events: none; z-index: 5;
}
#lvl { display: flex; align-items: center; }
#lvlNum {
  width: 36px; height: 36px; border-radius: 50%; z-index: 1;
  background: radial-gradient(circle at 35% 30%, #ffe082, #f9a825);
  border: 2px solid #fff; display: grid; place-items: center;
  font-weight: 900; font-size: 15px; color: #5d3a00; box-shadow: 0 2px 0 rgba(0,0,0,.25);
}
#xpBar {
  position: relative; width: 100px; height: 17px; margin-left: -8px;
  background: rgba(0,0,0,.35); border: 2px solid #fff; border-radius: 0 10px 10px 0; overflow: hidden;
}
#xpFill { height: 100%; width: 0; background: linear-gradient(#9be15d, #4caf50); transition: width .3s; }
#xpText {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 10px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px #000;
}
#money { display: flex; gap: 5px; }
#money .cur {
  background: rgba(0,0,0,.35); border: 2px solid #fff; border-radius: 12px; padding: 2px 8px;
  color: #fff; font-weight: 900; font-size: 13px; text-shadow: 0 1px 2px #000; white-space: nowrap;
}

/* ---------- Barra inferior ---------- */
#bottom {
  position: fixed; bottom: calc(env(safe-area-inset-bottom) + 8px); left: 0; right: 0;
  display: flex; justify-content: center; gap: 6px; z-index: 5; pointer-events: none;
}
#bottom button {
  pointer-events: auto; position: relative; width: 62px; height: 46px; padding: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  background: linear-gradient(#e0a868, #b97a3c); color: #fff; font-weight: 900; font-size: 10.5px;
  text-shadow: 0 1px 2px rgba(0,0,0,.6); border: 2px solid #fff; border-radius: 14px;
  box-shadow: 0 3px 0 #7a4f2a, 0 4px 8px rgba(0,0,0,.3);
}
#bottom button span { font-size: 19px; line-height: 1; }
#bottom button:active { transform: translateY(2px); box-shadow: 0 1px 0 #7a4f2a; }
#bottom button.active { background: linear-gradient(#8fd46a, #43a047); box-shadow: 0 3px 0 #2e7031, 0 4px 8px rgba(0,0,0,.3); }
.badge {
  position: absolute; top: -7px; right: -7px; min-width: 19px; height: 19px; padding: 0 5px;
  background: #e53935; border: 2px solid #fff; border-radius: 10px;
  font-style: normal; font-size: 10.5px; line-height: 15px; color: #fff;
}

/* ---------- Barras de aviso (plantio, edição, construção) ---------- */
#seedBar, #editBar, #placeBar {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 6px; width: max-content; max-width: 94vw;
  border-radius: 12px; padding: 4px 5px 4px 10px;
  font-weight: 800; font-size: 11.5px; box-shadow: 0 3px 8px rgba(0,0,0,.25);
}
#seedBar, #editBar { top: calc(env(safe-area-inset-top) + 50px); }
#seedBar { background: #fff6e0; border: 2px solid #c58b4a; color: #5d3a1a; }
#editBar { background: #e8f5e9; border: 2px solid #43a047; color: #1b5e20; }
#placeBar { bottom: calc(env(safe-area-inset-bottom) + 62px); background: #fff6e0; border: 2px solid #c58b4a; color: #5d3a1a; }
#seedBar button, #editBar button, #placeBar button {
  border: 0; color: #fff; font-weight: 900; border-radius: 8px; padding: 6px 9px; font-size: 12px; flex-shrink: 0;
}
#seedBar button, #placeCancel { background: #e53935; box-shadow: 0 2px 0 #9c2321; }
#editBar button, #placeOk { background: #43a047; box-shadow: 0 2px 0 #2e7031; }

/* ---------- Zoom ---------- */
#zoomBtns {
  position: fixed; right: 8px; top: 50%; transform: translateY(-50%); z-index: 5;
  display: flex; flex-direction: column; gap: 8px;
}
#zoomBtns button {
  width: 36px; height: 36px; padding: 0; border-radius: 50%; border: 2px solid #fff;
  background: linear-gradient(#e0a868, #b97a3c); color: #fff; font-size: 18px; font-weight: 900; line-height: 1;
  box-shadow: 0 2px 0 #7a4f2a, 0 4px 6px rgba(0,0,0,.3); text-shadow: 0 1px 2px rgba(0,0,0,.5);
}
#zoomBtns button:active { transform: translateY(2px); box-shadow: 0 1px 0 #7a4f2a; }

/* ---------- Painel ---------- */
#backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 10; }
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; max-height: 66vh; z-index: 11;
  display: flex; flex-direction: column; background: #fff6e0;
  border-radius: 18px 18px 0 0; border-top: 4px solid #c58b4a;
  box-shadow: 0 -6px 20px rgba(0,0,0,.3); padding-bottom: env(safe-area-inset-bottom);
  animation: up .22s ease-out; max-width: 560px; margin: 0 auto;
}
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
.sheetHead { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px 4px; }
.sheetHead h2 { margin: 0; font-size: 16px; font-weight: 900; color: #6b3f16; }
#sheetClose { border: 0; background: #e53935; color: #fff; font-weight: 900; border-radius: 9px; width: 30px; height: 30px; font-size: 14px; padding: 0; }
#sheetBody { overflow-y: auto; padding: 4px 12px 12px; touch-action: pan-y; color: #4a2e12; font-size: 13px; }

h3 { margin: 10px 0 6px; font-size: 12px; color: #8a5a2b; text-transform: uppercase; letter-spacing: .5px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 7px; }
.card {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 4px;
  background: #fff; border: 2px solid #e3c08f; border-radius: 12px; color: #4a2e12; font: inherit;
}
.card .ic { font-size: 26px; line-height: 1.1; }
.card b { font-size: 12px; }
.card small { font-size: 10.5px; color: #8a6a4a; font-weight: 700; }
.card:disabled { opacity: .5; }
.card.sel { border-color: #43a047; background: #e8f5e9; box-shadow: 0 0 0 2px #43a047 inset; }
.note { text-align: center; color: #6b4a2a; font-weight: 700; font-size: 12px; margin: 2px 0 8px; }
.row {
  display: flex; align-items: center; gap: 8px; padding: 7px 8px; margin-bottom: 6px;
  background: #fff; border: 2px solid #e3c08f; border-radius: 12px;
}
.row .ic { font-size: 24px; width: 30px; text-align: center; flex-shrink: 0; }
.row .info { flex: 1; min-width: 0; }
.row .info b { display: block; font-size: 13px; }
.row .info small { font-size: 10.5px; color: #8a6a4a; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.chip { font-size: 11px; font-weight: 800; padding: 1px 6px; border-radius: 8px; background: #e8f5e9; color: #2e7d32; }
.chip.miss { background: #ffebee; color: #c62828; }
.btn {
  border: 0; border-radius: 9px; padding: 7px 10px; font: inherit; font-weight: 900; font-size: 12px;
  background: #43a047; color: #fff; box-shadow: 0 2px 0 #2e7031; white-space: nowrap;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #2e7031; }
.btn:disabled { background: #bdbdbd; box-shadow: 0 2px 0 #9e9e9e; }
.btn.orange { background: #fb8c00; box-shadow: 0 2px 0 #b35f00; }
.btn.red { background: #e53935; box-shadow: 0 2px 0 #9c2321; }
.btn.small { padding: 5px 8px; font-size: 11px; }
.btn.wide { width: 100%; padding: 9px; font-size: 13px; margin-bottom: 6px; }
.btns { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }

.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.slot {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px;
  background: #fff; border: 2px dashed #e3c08f; border-radius: 10px; font-size: 10.5px; font-weight: 800; color: #a58a6a;
}
.slot.busy { border-style: solid; color: #4a2e12; }
.slot .ic { font-size: 22px; }
.bar { width: 100%; height: 6px; background: #eadcc5; border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: #fbc02d; }
.order .reward { font-weight: 900; font-size: 11px; color: #6b3f16; margin-top: 3px; }
.empty { text-align: center; color: #a58a6a; font-weight: 700; padding: 14px; font-size: 12px; }

/* ---------- Toasts / nível ---------- */
#toasts {
  position: fixed; top: calc(env(safe-area-inset-top) + 86px); left: 0; right: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; gap: 5px; pointer-events: none;
}
.toast {
  background: rgba(40,25,10,.88); color: #fff; font-weight: 800; font-size: 12px; padding: 6px 11px;
  border-radius: 11px; max-width: 88vw; text-align: center; animation: tin .2s ease-out;
}
.toast.out { opacity: 0; transition: opacity .3s; }
@keyframes tin { from { transform: translateY(-10px); opacity: 0; } }
#levelUp { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.5); display: grid; place-items: center; }
.luCard {
  width: min(80vw, 300px); background: #fff6e0; border: 4px solid #f9a825; border-radius: 20px;
  padding: 14px; text-align: center; color: #4a2e12; font-size: 13px; animation: pop .35s cubic-bezier(.2,1.6,.4,1);
}
@keyframes pop { from { transform: scale(.4); } }
.luCard .luT { font-size: 24px; font-weight: 900; color: #e65100; }
.luCard p { font-weight: 700; margin: 6px 0; }
