:root {
  color-scheme: light;
  --sky: #DDF1FF;
  --sky-2: #F4FAFF;
  --ink: #0F1B2D;
  --muted: #4E5D72;
  --line: #D5E2EE;
  --card: #FFFFFF;
  --green: #0B7D43;
  --green-hi: #14A05A;
  --green-soft: #DDF7E7;
  --yellow: #FFD447;
  --yellow-soft: #FFF4C7;
  --blue: #1F5FD6;
  --gray: #66727F;
  --radius: 18px;
  --nav-h: 64px;
  --font-d: "Fredoka", "Trebuchet MS", system-ui, sans-serif;
  --font-b: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--sky);
  color: var(--ink);
  font: 500 16px/1.45 var(--font-b);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

a { color: var(--blue); font-weight: 700; }

h1, h2, h3 { font-family: var(--font-d); font-weight: 700; line-height: 1.1; margin: 0 0 8px; letter-spacing: -0.01em; }
h2 { font-size: 24px; }
h3 { font-size: 19px; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.top {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  background: var(--sky);
  z-index: 5;
}

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand-mark { width: 38px; height: 38px; flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-family: var(--font-d); font-weight: 700; font-size: 26px; line-height: 1; letter-spacing: -0.02em; }
.brand-tag { font-size: 13px; font-weight: 700; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card);
  border-top: 1px solid var(--line);
  z-index: 10;
}

.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 12.5px; font-weight: 800;
}

.tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabs a[aria-current="page"] { color: var(--green); }
.tabs a[aria-current="page"] svg { stroke-width: 2.6; }

.stage { position: relative; flex: 1; min-height: 0; margin-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }

.map {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, #CBEAFF 0%, #E9F6FF 60%, #F6FBFF 100%);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.map canvas { display: block; width: 100%; height: 100%; outline: none; }

.labels { position: absolute; inset: 0; pointer-events: none; }

.lbl {
  position: absolute; left: 0; top: 0;
  transform: translate(-50%, -100%);
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 2px 7px;
  font: 700 12px/1.2 var(--font-b);
  white-space: nowrap;
  box-shadow: 0 2px 0 var(--ink);
  will-change: transform;
}

.lbl b { font-family: var(--font-d); font-weight: 600; }
.lbl small { display: block; color: var(--muted); font-weight: 800; font-size: 11px; }
.lbl.me { background: var(--yellow); }

.map-ctrl { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; gap: 8px; }

.map-ctrl button {
  width: 42px; height: 42px; border-radius: 12px;
  border: 2px solid var(--ink); background: var(--card); color: var(--ink);
  font: 700 22px/1 var(--font-d); cursor: pointer; box-shadow: 0 3px 0 var(--ink);
  display: grid; place-items: center; padding: 0;
}

.map-ctrl button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.map-ctrl svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

.map-hint {
  position: absolute; left: 12px; top: 12px; margin: 0; max-width: calc(100% - 80px);
  background: rgba(255, 255, 255, 0.9); border-radius: 999px; padding: 6px 12px;
  font-size: 13px; font-weight: 800; color: var(--muted); transition: opacity 0.4s;
}

.map-hint.off, body[data-tab="casa"] .map-hint { opacity: 0; pointer-events: none; }
.map-fallback { position: absolute; inset: 30% 16px auto; text-align: center; font-weight: 800; }

.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 46%;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--card);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -6px 24px rgba(15, 27, 45, 0.12);
  padding: 8px 16px 12px;
  z-index: 4;
  transition: max-height 0.25s ease;
}

.grip { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }

body[data-tab="casa"] .sheet { max-height: 62%; }
body[data-tab="ranking"] .sheet, body[data-tab="lojas"] .sheet { max-height: 100%; top: 0; border-radius: 0; box-shadow: none; }
body[data-tab="ranking"] .grip, body[data-tab="lojas"] .grip { display: none; }

.pane { display: none; }
body[data-tab="mapa"] [data-pane="mapa"],
body[data-tab="casa"] [data-pane="casa"],
body[data-tab="ranking"] [data-pane="ranking"],
body[data-tab="lojas"] [data-pane="lojas"] { display: block; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }

.stat { background: var(--sky-2); border: 2px solid var(--line); border-radius: 14px; padding: 8px 6px; text-align: center; }
.stat b { display: block; font: 700 22px/1.05 var(--font-d); }
.stat span { display: block; font-size: 12px; line-height: 1.15; font-weight: 800; color: var(--muted); }

.howto ol { margin: 0 0 8px; padding-left: 22px; }
.howto li { margin: 4px 0; }
.small { font-size: 14px; color: var(--muted); margin: 6px 0 12px; }

.pill { display: inline-block; background: var(--yellow-soft); border: 2px solid var(--ink); border-radius: 999px; padding: 0 8px; font-weight: 800; font-size: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 14px;
  background: var(--green); color: #FFFFFF; border: 2px solid var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  font: 700 17px/1 var(--font-d); text-decoration: none; cursor: pointer;
}

.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn.alt { background: var(--yellow); color: var(--ink); }
.btn.block { width: 100%; }

.howto .btn { width: 100%; margin-top: 4px; }

.card { border: 2px solid var(--ink); border-radius: var(--radius); padding: 14px; margin: 4px 0 12px; box-shadow: 0 4px 0 var(--ink); background: var(--card); }
.card .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card .x { border: 0; background: var(--sky-2); width: 36px; height: 36px; border-radius: 10px; font: 700 20px/1 var(--font-d); cursor: pointer; color: var(--ink); flex: none; }
.card p { margin: 6px 0; }
.card ul { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.card li { background: var(--sky-2); border-radius: 999px; padding: 2px 10px; font-weight: 800; font-size: 14px; }
.card .more { color: var(--muted); }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 3px 10px; font-weight: 800; font-size: 13px; border: 2px solid var(--ink); }
.badge.founder { background: var(--yellow); }
.badge.gov { background: var(--green-soft); }
.badge.res { background: var(--sky-2); }

.search { display: flex; align-items: center; gap: 8px; border: 2px solid var(--ink); border-radius: 16px; padding: 4px 4px 4px 12px; background: var(--card); }
.search .at { font: 700 20px/1 var(--font-d); color: var(--muted); }
.search input { flex: 1; min-width: 0; border: 0; outline: none; font: 700 17px/1 var(--font-b); padding: 10px 0; background: transparent; color: var(--ink); }
.search input::-webkit-search-cancel-button { display: none; }
.search .btn { min-height: 42px; box-shadow: none; border-width: 0; }
.search:focus-within { box-shadow: 0 0 0 3px var(--yellow); }

.suggest { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-wrap: wrap; gap: 6px; }
.suggest button { border: 2px solid var(--line); background: var(--sky-2); border-radius: 999px; padding: 4px 12px; font: 800 14px/1.2 var(--font-b); color: var(--ink); cursor: pointer; }

.empty { background: var(--yellow-soft); border-color: var(--ink); }
.empty .btn { margin-top: 8px; width: 100%; }

.rank { list-style: none; padding: 0; margin: 0 0 22px; counter-reset: r; }
.rank li { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); counter-increment: r; }
.rank li::before { content: counter(r); font: 700 18px/1 var(--font-d); text-align: center; color: var(--muted); }
.rank li:nth-child(1)::before { content: "1"; background: var(--yellow); color: var(--ink); border: 2px solid var(--ink); border-radius: 10px; padding: 5px 0; }
.rank .nm { font-weight: 800; min-width: 0; }
.rank .nm small { display: block; font-weight: 700; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .n { font: 700 20px/1 var(--font-d); text-align: right; }
.rank .n small { display: block; font: 800 11px/1.2 var(--font-b); color: var(--muted); }
.rank li.off { color: var(--gray); }
.rank li.off .n { color: var(--gray); }
.rank button.lnk { all: unset; cursor: pointer; }
.rank button.lnk:focus-visible { outline: 3px solid var(--yellow); }

.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.plan { border: 2px solid var(--ink); border-radius: 16px; padding: 10px 6px; text-align: center; box-shadow: 0 3px 0 var(--ink); background: var(--sky-2); display: flex; flex-direction: column; gap: 2px; }
.plan:nth-child(2) { background: var(--green-soft); }
.plan:nth-child(3) { background: var(--yellow-soft); }
.plan-name { font-weight: 800; font-size: 13px; }
.plan-price { font: 700 24px/1.1 var(--font-d); }
.plan-sub { font-size: 11.5px; font-weight: 800; color: var(--muted); }

.form { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 800; font-size: 14px; }
.form input, .form select {
  font: 700 16px/1.2 var(--font-b); color: var(--ink);
  border: 2px solid var(--ink); border-radius: 12px; padding: 11px 12px; background: var(--card);
  appearance: none; -webkit-appearance: none;
}
.form select { background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }
.form input:focus, .form select:focus { outline: none; box-shadow: 0 0 0 3px var(--yellow); }
.form .btn { margin-top: 4px; }
.note { background: var(--green-soft); border: 2px solid var(--ink); border-radius: 12px; padding: 10px 12px; font-weight: 700; margin: 0; white-space: pre-wrap; }

.foot { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; padding: 14px 0 4px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); margin-top: 8px; }

@media (min-width: 960px) {
  .top { padding: 14px 24px; }
  .brand-mark { width: 46px; height: 46px; }
  .brand-name { font-size: 32px; }
  .brand-tag { font-size: 14px; }

  .tabs { position: static; display: flex; gap: 6px; height: auto; padding: 0; background: transparent; border: 0; }
  .tabs a { flex-direction: row; gap: 8px; padding: 10px 16px; border-radius: 14px; font-size: 16px; color: var(--ink); border: 2px solid transparent; }
  .tabs a:hover { background: rgba(255, 255, 255, 0.6); }
  .tabs a[aria-current="page"] { background: var(--card); border-color: var(--ink); box-shadow: 0 3px 0 var(--ink); color: var(--green); }

  .stage { margin: 0 24px 24px; display: grid; grid-template-columns: 1fr 420px; gap: 20px; }
  .map { position: relative; border-radius: 28px; border: 2px solid var(--ink); box-shadow: 0 5px 0 var(--ink); }
  .sheet,
  body[data-tab] .sheet { position: relative; max-height: none; top: auto; border-radius: 28px; border: 2px solid var(--ink); box-shadow: 0 5px 0 var(--ink); padding: 20px; }
  .grip { display: none; }
  h2 { font-size: 28px; }
}

body.doc { height: auto; min-height: 100%; overflow: auto; display: block; }
.page { max-width: 680px; margin: 0 auto; padding: 8px 16px 48px; }
.page h1 { font-size: 40px; margin: 12px 0 12px; }
.page h2 { margin-top: 28px; }
.page li { margin: 4px 0; }
