:root {
  --bg: #0b0b16;
  --bg2: #11111f;
  --card: #15152a;
  --card2: #1b1b35;
  --line: rgba(140, 120, 255, .16);
  --text: #ecebff;
  --muted: #9a98c3;
  --violet: #7c5cff;
  --cyan: #22d3ee;
  --gold: #f5b83d;
  --green: #34d399;
  --red: #f87171;
  --grad: linear-gradient(135deg, #7c5cff 0%, #22d3ee 100%);
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 Inter, system-ui, sans-serif; overflow-x: hidden; max-width: 100%; -webkit-text-size-adjust: 100%; }
#app { overflow-x: hidden; }
body {
  min-height: 100dvh;
  background:
    radial-gradient(600px 400px at 85% -10%, rgba(124, 92, 255, .22), transparent 60%),
    radial-gradient(500px 360px at -10% 30%, rgba(34, 211, 238, .10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
h1, h2, h3, .display { font-family: Rajdhani, Inter, sans-serif; letter-spacing: .02em; margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--cyan); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }

.wrap { max-width: 560px; margin: 0 auto; padding: calc(18px + var(--safe-t)) 16px calc(170px + var(--safe-b)); }

/* ---------- botões e campos ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: 14px; font-weight: 600;
  background: var(--card2); border: 1px solid var(--line); transition: transform .12s, filter .12s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--grad); border: 0; color: #0b0b16; box-shadow: 0 6px 24px rgba(124, 92, 255, .35); }
.btn.gold { background: linear-gradient(135deg, #f5b83d, #ff8a3d); color: #1a1200; border: 0; }
.btn.danger { color: var(--red); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; pointer-events: none; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
input, select, textarea {
  font-size: 16px !important;
  width: 100%; padding: 12px 14px; border-radius: 12px; background: var(--bg2);
  border: 1px solid var(--line); outline: none;
}
input:focus, select:focus { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(124, 92, 255, .2); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 12px; border-radius: 999px; background: var(--bg2); border: 1px solid var(--line);
  font-size: 13.5px; font-weight: 500; user-select: none;
}
.chip.on { background: rgba(124, 92, 255, .22); border-color: var(--violet); color: #fff; }

/* ---------- login ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: calc(24px + var(--safe-t)) 24px calc(24px + var(--safe-b)); }
.auth-card { width: 100%; max-width: 400px; }
.logo { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.logo img { width: 52px; height: 52px; border-radius: 14px; }
.logo h1 { font-size: 34px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { color: var(--muted); margin: 0 0 26px; }
.tabs { display: flex; background: var(--bg2); border-radius: 14px; padding: 4px; margin-bottom: 18px; border: 1px solid var(--line); }
.tabs button { flex: 1; padding: 10px; border-radius: 10px; font-weight: 600; color: var(--muted); }
.tabs button.on { background: var(--card2); color: var(--text); }
.error { color: var(--red); font-size: 13.5px; min-height: 20px; margin: 4px 0 10px; }

/* ---------- cabeçalho do jogador ---------- */
.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(160deg, rgba(124, 92, 255, .25), rgba(34, 211, 238, .08) 70%), var(--card);
  border: 1px solid var(--line); border-radius: 22px; padding: 16px; margin-bottom: 16px;
}
.hero-top { display: flex; align-items: center; gap: 14px; }
.avatar {
  position: relative; width: 62px; height: 62px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font: 700 26px Rajdhani, sans-serif;
}
.avatar svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.avatar .lv { position: relative; text-align: center; line-height: 1; }
.avatar .lv small { display: block; font: 600 9px Inter, sans-serif; color: var(--muted); letter-spacing: .1em; }
.rank {
  display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 7px; border-radius: 8px;
  font: 700 15px Rajdhani, sans-serif; border: 1px solid currentColor;
}
.rank-E { color: #9ca3af; } .rank-D { color: #cd8b5c; } .rank-C { color: #cbd5e1; }
.rank-B { color: var(--gold); } .rank-A { color: var(--cyan); } .rank-S { color: #ff5ec8; text-shadow: 0 0 12px #ff5ec8; }
.hero-name { font-size: 21px; display: flex; align-items: center; gap: 8px; }
.stats { display: flex; gap: 8px; margin-top: 14px; }
.stat { flex: 1; background: rgba(0, 0, 0, .25); border-radius: 12px; padding: 8px 10px; }
.stat b { font: 700 19px Rajdhani, sans-serif; display: block; }
.stat span { font-size: 11.5px; color: var(--muted); }
.xpbar { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .08); overflow: hidden; margin-top: 12px; }
.xpbar i { display: block; height: 100%; background: var(--grad); border-radius: 99px; transition: width .6s cubic-bezier(.2, .9, .3, 1.2); }

/* ---------- dia ---------- */
.daybar { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 12px; }
.daybar h2 { font-size: 22px; }
.daybar .nav { display: flex; gap: 6px; }
.iconbtn { width: 38px; height: 38px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); display: grid; place-items: center; font-size: 18px; }
.summary { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; color: var(--muted); font-size: 13.5px; }
.summary .xpbar { flex: 1; margin: 0; height: 6px; }

/* ---------- cards de missão ---------- */
.list { display: grid; gap: 10px; }
.mission {
  position: relative; display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
  transition: transform .2s, opacity .3s;
}
.mission.done { opacity: .62; }
.mission.done .m-title { text-decoration: line-through; text-decoration-color: rgba(255, 255, 255, .35); }
.mission.late { border-color: rgba(248, 113, 113, .5); }
.mission.urgent { border-color: rgba(245, 184, 61, .6); box-shadow: 0 0 0 1px rgba(245, 184, 61, .15), 0 0 24px rgba(245, 184, 61, .12); }
.m-icon { width: 44px; height: 44px; flex: none; border-radius: 13px; display: grid; place-items: center; font-size: 22px; background: var(--card2); }
.m-body { flex: 1; min-width: 0; }
.m-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-meta { font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 2px; }
.m-meta .warn { color: var(--gold); font-weight: 600; }
.m-meta .bad { color: var(--red); font-weight: 600; }
.m-prog { height: 5px; border-radius: 9px; background: rgba(255, 255, 255, .07); margin-top: 8px; overflow: hidden; }
.m-prog i { display: block; height: 100%; background: var(--grad); transition: width .4s; }
.m-actions { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.plus {
  width: 46px; height: 46px; border-radius: 14px; background: var(--grad); color: #0b0b16;
  font: 700 22px Rajdhani, sans-serif; display: grid; place-items: center; box-shadow: 0 4px 16px rgba(124, 92, 255, .35);
}
.plus.check { font-size: 20px; }
.mission.done .plus { background: var(--green); box-shadow: none; }
.minus { font-size: 12px; color: var(--muted); padding: 2px 8px; }
.empty { text-align: center; padding: 34px 16px; color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty .big { font-size: 40px; margin-bottom: 6px; }

.section-title { font-size: 14px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin: 22px 0 10px; font-family: Inter; font-weight: 600; }

/* ---------- metas ---------- */
.goal { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.goal-head { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.goal .big { font: 700 30px Rajdhani, sans-serif; }
.goal .m-prog { height: 10px; margin: 10px 0 8px; }
.pace { font-size: 13px; color: var(--muted); }
.pace b { color: var(--text); }

/* ---------- perfil ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.radar { display: block; margin: 0 auto; max-width: 300px; width: 100%; }
.badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.badge { text-align: center; padding: 12px 6px; border-radius: 14px; background: var(--bg2); border: 1px solid var(--line); }
.badge .i { font-size: 28px; }
.badge b { display: block; font-size: 12.5px; margin-top: 4px; }
.badge span { font-size: 11px; color: var(--muted); }
.badge.locked { filter: grayscale(1); opacity: .35; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border: 0; }

/* ---------- loja ---------- */
.coins { display: inline-flex; align-items: center; gap: 6px; font: 700 18px Rajdhani, sans-serif; color: var(--gold); }
.reward { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.reward .m-body b { display: block; }

/* ---------- navegação inferior ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: rgba(13, 13, 26, .86); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line); padding: 8px 8px calc(8px + var(--safe-b));
}
.tabbar-in { max-width: 560px; margin: 0 auto; display: flex; align-items: center; justify-content: space-around; }
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px 10px; border-radius: 12px; }
.tab .ti { font-size: 21px; filter: grayscale(.8); }
.tab.on { color: var(--text); }
.tab.on .ti { filter: none; }
.fab {
  position: fixed; z-index: 21; right: max(18px, calc(50% - 262px)); bottom: calc(84px + var(--safe-b));
  width: 58px; height: 58px; border-radius: 18px; background: var(--grad); color: #0b0b16; font-size: 32px; font-weight: 400;
  display: grid; place-items: center; box-shadow: 0 8px 30px rgba(124, 92, 255, .55);
}
.fab:active { transform: scale(.94); }

/* ---------- modal ---------- */
.sheet-bg { position: fixed; inset: 0; z-index: 40; background: rgba(4, 4, 12, .7); backdrop-filter: blur(4px); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; }
.sheet {
  position: relative; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  width: 100%; max-width: 560px; max-height: calc(90dvh - var(--safe-t)); overflow-y: auto; overflow-x: hidden; background: var(--bg2);
  border: 1px solid var(--line); border-bottom: 0; border-radius: 24px 24px 0 0; padding: 20px 18px calc(20px + var(--safe-b));
  animation: up .28s cubic-bezier(.2, .9, .3, 1);
}
.sheet h2 { font-size: 24px; margin-bottom: 16px; }
.sheet .grip { width: 44px; height: 5px; border-radius: 9px; background: rgba(255, 255, 255, .15); margin: -6px auto 14px; }
@media (min-width: 700px) { .sheet-bg { align-items: center; } .sheet { border-radius: 24px; border-bottom: 1px solid var(--line); } }

/* ---------- toasts e level up ---------- */
#toasts { position: fixed; top: calc(12px + env(safe-area-inset-top, 0px)); left: 0; right: 0; z-index: 60; display: grid; justify-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: rgba(27, 27, 53, .96); border: 1px solid var(--line); padding: 10px 16px; border-radius: 14px;
  font-weight: 600; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); animation: drop .3s cubic-bezier(.2, .9, .3, 1.3);
}
.toast.xp { color: var(--gold); }
.levelup { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(4, 4, 12, .82); animation: fade .25s; }
.levelup-in { text-align: center; animation: pop .5s cubic-bezier(.2, .9, .3, 1.4); }
.levelup .ring { width: 150px; height: 150px; margin: 0 auto 16px; border-radius: 50%; display: grid; place-items: center; background: var(--grad); box-shadow: 0 0 80px rgba(124, 92, 255, .7); font: 700 64px Rajdhani, sans-serif; color: #0b0b16; }
.levelup h2 { font-size: 34px; background: linear-gradient(90deg, #f5b83d, #fff, #22d3ee); -webkit-background-clip: text; background-clip: text; color: transparent; }
.spark { position: fixed; width: 8px; height: 8px; border-radius: 2px; pointer-events: none; z-index: 71; animation: spark 1.1s ease-out forwards; }
.pulse { animation: pulse .45s; }
@keyframes fade { from { opacity: 0 } }
@keyframes up { from { transform: translateY(40px); opacity: 0 } }
@keyframes drop { from { transform: translateY(-16px) scale(.9); opacity: 0 } }
@keyframes pop { from { transform: scale(.4); opacity: 0 } }
@keyframes pulse { 50% { transform: scale(1.04) } }
@keyframes spark { to { transform: translate(var(--dx), var(--dy)) rotate(540deg); opacity: 0 } }

.install-tip { background: linear-gradient(135deg, rgba(124, 92, 255, .2), rgba(34, 211, 238, .12)); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; display: flex; gap: 12px; align-items: center; }
.install-tip .m-body { font-size: 13.5px; }

/* ---------- ranking ---------- */
.rk-list { gap: 6px; }
.rk {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 11px 14px;
}
.rk.me { border-color: var(--violet); background: linear-gradient(90deg, rgba(124, 92, 255, .22), var(--card)); }
.rk-pos { width: 30px; text-align: center; font-size: 20px; }
.rk-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk-xp { font: 700 17px Rajdhani, sans-serif; color: var(--gold); }
.rk-xp small { font-size: 11px; color: var(--muted); }

/* ---------- finanças ---------- */
.fin-tabs { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px 14px; padding: 0 16px 4px; scrollbar-width: none; }
.fin-tabs::-webkit-scrollbar { display: none; }
.fin-tabs .chip { flex: none; }
.fin-hero { text-align: center; padding: 20px 16px; }
.fin-hero.neg { background: linear-gradient(160deg, rgba(248, 113, 113, .22), rgba(124, 92, 255, .08) 70%), var(--card); }
.fin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.fin-grid .stat { background: var(--card); border: 1px solid var(--line); padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.fin-grid .stat b { font-size: 20px; }
.fin-grid .stat .bad { color: var(--red); font-weight: 600; }
.fin-val { font: 700 16px Rajdhani, sans-serif; white-space: nowrap; }
.fin-row .m-actions { align-items: flex-end; }
.pill { padding: 7px 12px; border-radius: 10px; font-size: 13px; font-weight: 600; background: var(--grad); color: #0b0b16; white-space: nowrap; }
.pill.ok { background: rgba(52, 211, 153, .18); color: var(--green); }
.fin-add { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fin-add .btn { flex-direction: column; padding: 16px 10px; }
.reward { cursor: pointer; }

/* ---------- saúde ---------- */
.health-ring { display: flex; gap: 16px; align-items: center; }
.ring-wrap { position: relative; width: max-content; flex: none; }
.ring-in { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ring-in b { font-size: 30px; line-height: 1; }

.meal { padding: 12px 14px; margin-bottom: 10px; }
.meal-head { display: flex; align-items: center; gap: 10px; }
.meal-head b { flex: 1; }
.meal-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0 0; font-size: 14px; }
.card.meal-item { padding: 10px 14px; }
.food-res { display: grid; gap: 6px; max-height: 46dvh; overflow: auto; margin-top: 10px; }
.food-item { display: flex; justify-content: space-between; gap: 10px; text-align: left; padding: 11px 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); }
.food-calc { text-align: center; margin: 4px 0 14px; }
.water-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.water-btns .btn { flex-direction: column; gap: 2px; padding: 14px 8px; }
.wd-chips { flex-wrap: nowrap; justify-content: space-between; margin-bottom: 12px; }
.wd-chips .chip { padding: 8px 9px; flex: 1; text-align: center; }
.wd-chips .chip.has:not(.on) { border-color: rgba(34, 211, 238, .45); }

/* botão fechar de todas as janelas */
.sheet-x {
  position: sticky; top: 0; float: right; z-index: 3; margin: -6px -4px 0 8px;
  width: 38px; height: 38px; border-radius: 12px; background: var(--card2); border: 1px solid var(--line);
  font-size: 18px; color: var(--text); display: grid; place-items: center;
}
.sheet.dragging { transition: none; }
.food-sheet { display: flex; flex-direction: column; height: calc(88dvh - var(--safe-t)); overflow: hidden; }
.food-sheet .food-res { flex: 1; max-height: none; min-height: 0; overscroll-behavior: contain; }
.food-sheet #fsel { overflow-y: auto; min-height: 0; flex: 1; }
.food-sheet .sheet-foot { display: flex; gap: 8px; padding-top: 10px; }
.food-sheet .sheet-foot .btn { flex: 1; padding: 11px 8px; font-size: 13.5px; }
/* sem desfoque pesado: no iPhone o blur deixava tudo lento e "embaçado" */
.sheet-bg { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(4, 4, 12, .78); }
.food-sheet .sheet-x { align-self: flex-end; flex: none; margin: -6px -4px -38px 0; }

/* ---------- planos e bloqueio ---------- */
.lock-card { text-align: center; padding: 34px 20px; background: var(--card); border: 1px dashed rgba(245, 184, 61, .5); border-radius: var(--radius); }
.lock-card .lock-icon { font-size: 44px; }
.lock-card h3 { font-size: 22px; margin: 8px 0; }
.plan-card { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 18px 16px; color: var(--text); }
.plan-card.hl { border-color: var(--violet); background: linear-gradient(160deg, rgba(124, 92, 255, .22), rgba(34, 211, 238, .06) 70%), var(--card); }
.plan-card.cur { box-shadow: 0 0 0 2px rgba(52, 211, 153, .5); }
.plan-tag { position: absolute; top: -10px; right: 14px; background: var(--grad); color: #0b0b16; font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 99px; }
.feat { list-style: none; padding: 0; margin: 12px 0 14px; display: grid; gap: 5px; font-size: 14px; }
.feat li.off { color: var(--muted); opacity: .55; }
a.setting { cursor: pointer; }

/* ---------- foto, sacola e loja ---------- */
.avatar { width: 66px; height: 66px; text-decoration: none; color: var(--text); }
.avatar .pic { position: absolute; inset: 7px; width: 52px; height: 52px; border-radius: 50%; object-fit: cover; }
.pic.ini { display: grid; place-items: center; border-radius: 50%; background: var(--grad); color: #0b0b16; font-family: Rajdhani, sans-serif; font-weight: 700; flex: none; }
.setting .pic, .rk-av .pic { position: static; border-radius: 50%; object-fit: cover; flex: none; }
.rk-av { display: inline-flex; flex: none; }
.lvb { position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%); background: var(--grad); color: #0b0b16; font: 700 11px Rajdhani, sans-serif; padding: 1px 7px; border-radius: 99px; white-space: nowrap; }
.effects-line { display: block; margin-top: 10px; font-size: 12.5px; font-weight: 600; color: var(--gold); text-decoration: none; }
.qty { display: flex; align-items: center; gap: 8px; }
.qty button { width: 32px; height: 32px; border-radius: 10px; background: var(--card2); border: 1px solid var(--line); font-size: 18px; }
.qty b { min-width: 18px; text-align: center; }
.stat { display: block; }

/* ---------- títulos longos não empurram os botões para fora da tela ---------- */
.list { grid-template-columns: minmax(0, 1fr); }
.list > *, .mission, .reward, .goal, .card { min-width: 0; max-width: 100%; }
.mission .m-title, .reward .m-body b {
  white-space: normal; overflow: hidden; text-overflow: ellipsis; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.3;
}
.m-actions, .fin-row .m-actions { flex: none; }
.fin-row .m-body { min-width: 0; }
.fin-row .fin-val { font-size: 15px; }
.fin-row .pill { padding: 7px 11px; }

.ref-link { margin-top: 6px; padding: 10px 12px; border-radius: 12px; background: rgba(0, 0, 0, .3); border: 1px dashed var(--line); font-size: 13.5px; word-break: break-all; user-select: all; }
