:root {
  --bg: #0B0D12; --bg2: #11141B; --card: #161A23; --card2: #1C2130; --line: #262C3B;
  --ink: #F3F5FA; --mute: #98A1B3; --dim: #6B7387;
  --green: #22D3EE; --purple: #8B5CF6; --yellow: #FFC94D; --red: #FF6B6B;
  --grad: linear-gradient(135deg, #22D3EE 0%, #8B5CF6 100%);
  --r: 16px; --tab-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 15px/1.45 Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif; min-height: 100dvh; }
h1, h2, .big, .brand, .zone-name { font-family: "Space Grotesk", Inter, system-ui, sans-serif; }
h2 { font-size: 16px; margin: 0 0 10px; font-weight: 600; }
.hidden { display: none !important; }
.center { text-align: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sub { color: var(--mute); font-size: 13px; }
.fine { color: var(--dim); font-size: 12px; }
.label { color: var(--mute); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.stack { display: grid; gap: 10px; }

/* Botones e inputs */
.btn { appearance: none; border: 0; border-radius: 12px; padding: 13px 16px; font: 600 15px Inter, sans-serif; color: var(--ink); background: var(--card2); cursor: pointer; width: 100%; transition: transform .08s, opacity .2s; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--grad); color: #07110C; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { color: var(--red); }
.btn.small { width: auto; padding: 8px 12px; font-size: 13px; }
input, textarea, select { width: 100%; background: var(--bg2); border: 1px solid var(--line); color: var(--ink); border-radius: 12px; padding: 12px 14px; font: 15px Inter, sans-serif; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--purple); }
textarea { min-height: 96px; resize: vertical; }
select { appearance: auto; }
.link { background: none; border: 0; color: var(--green); font: 600 14px Inter, sans-serif; cursor: pointer; padding: 0; }
.switch { text-align: center; color: var(--dim); font-size: 14px; margin: 12px 0 0; }
.lang-row { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.lang-row select { width: auto; padding: 8px 10px; font-size: 14px; border-radius: 10px; }
.field-label { color: var(--mute); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; margin: 4px 0 -4px; }

/* Bienvenida */
.welcome { min-height: 100dvh; display: grid; place-items: center; padding: 32px 20px;
  background: radial-gradient(600px 400px at 20% 0%, rgba(153,69,255,.25), transparent 60%), radial-gradient(500px 400px at 100% 100%, rgba(34,211,238,.15), transparent 60%), var(--bg); }
.welcome-inner { width: 100%; max-width: 380px; }
.logo-mark svg { width: 64px; height: 64px; }
.brand { font-size: 44px; margin: 8px 0 0; letter-spacing: .04em; }
.tagline { color: var(--mute); margin: 2px 0 22px; font-size: 13px; }
.pitch { list-style: none; padding: 0; margin: 0 0 22px; display: grid; gap: 10px; }
.pitch li { display: flex; align-items: center; gap: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.g { background: var(--green); } .dot.p { background: var(--purple); } .dot.y { background: var(--yellow); }
.welcome .fine { margin-top: 14px; text-align: center; }

/* Estructura */
.shell { max-width: 480px; margin: 0 auto; min-height: 100dvh; padding-bottom: calc(var(--tab-h) + var(--safe-b)); }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top)); background: rgba(11,13,18,.88); backdrop-filter: blur(10px); }
.top-brand { font: 700 18px "Space Grotesk", sans-serif; letter-spacing: .06em; display: flex; align-items: center; gap: 8px; }
.mini-logo { width: 18px; height: 18px; border-radius: 5px; background: var(--grad); }
.pill { background: var(--card); border: 1px solid var(--line); border-radius: 99px; padding: 6px 12px; font-size: 13px; font-weight: 600; }
main { padding: 4px 16px 16px; }
.view { display: none; animation: fade .2s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 12px; }
.section-title { margin: 18px 2px 10px; }

/* Inicio */
.balance { background: radial-gradient(400px 200px at 100% 0%, rgba(153,69,255,.28), transparent 70%), var(--card); }
.big { font-size: 38px; font-weight: 700; line-height: 1.1; margin: 4px 0 6px; }
.big small { font-size: 15px; color: var(--mute); font-weight: 600; }
.meter { height: 8px; background: var(--bg2); border-radius: 99px; overflow: hidden; margin: 12px 0 6px; }
.meter i { display: block; height: 100%; width: 0; background: var(--grad); border-radius: 99px; transition: width .4s; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin: 6px 0 10px; }
.week div { text-align: center; font-size: 11px; color: var(--dim); }
.week i { display: block; margin: 0 auto 4px; width: 30px; height: 30px; border-radius: 50%; background: var(--bg2); border: 1px solid var(--line); }
.week .on i { background: var(--grad); border: 0; box-shadow: 0 0 12px rgba(34,211,238,.35); }
.week .today { color: var(--ink); font-weight: 600; }
.flame-count { font-weight: 600; color: var(--yellow); }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.qbtn { background: var(--card); border: 1px solid var(--line); color: var(--ink); border-radius: var(--r); padding: 14px 6px; font: 600 13px Inter, sans-serif; display: grid; justify-items: center; gap: 6px; cursor: pointer; }
.qbtn .ico { width: 24px; height: 24px; background: var(--green); }
.history { list-style: none; margin: 0; padding: 0; }
.history li { display: flex; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.history li:first-child { border-top: 0; }
.history .pts { color: var(--green); font-weight: 600; }
.history .when { color: var(--dim); font-size: 12px; }
.history .empty { color: var(--mute); justify-content: center; }

/* Mapa */
.map-view.active { display: flex; flex-direction: column; margin: -4px -16px -16px; height: calc(100dvh - 56px - var(--tab-h) - var(--safe-b)); }
.map { position: relative; flex: 1; overflow: hidden; background: #0E1219; touch-action: none; }
.map-tiles { position: absolute; inset: 0; }
.map-tiles img { position: absolute; width: 256px; height: 256px; filter: invert(1) hue-rotate(185deg) brightness(.75) contrast(.9) saturate(.6); user-select: none; -webkit-user-drag: none; }
.map-overlay { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-msg { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); background: rgba(22,26,35,.92); border: 1px solid var(--line); padding: 8px 12px; border-radius: 99px; font-size: 13px; white-space: nowrap; }
.map-recenter { position: absolute; right: 12px; bottom: 12px; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 20px; cursor: pointer; }
.map-attrib { position: absolute; left: 6px; bottom: 4px; font-size: 10px; color: var(--dim); }
.map-sheet { background: var(--card); border-top: 1px solid var(--line); padding: 14px 16px 12px; display: grid; gap: 10px; }
.zone-name { font-size: 18px; font-weight: 600; }
.legend { font-size: 12px; color: var(--mute); display: flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.sw.claimed { background: rgba(34,211,238,.45); border: 1px solid var(--green); }
.sw.free { border: 1px solid rgba(153,69,255,.7); }
@keyframes pulse { 0% { r: 8; opacity: .7; } 100% { r: 26; opacity: 0; } }
.me-pulse { animation: pulse 1.8s ease-out infinite; }

/* Misiones */
.streak-hero { display: flex; justify-content: space-between; align-items: center; background: radial-gradient(300px 160px at 0% 0%, rgba(255,201,77,.18), transparent 70%), var(--card); }
.ring { --p: 0; width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--yellow) calc(var(--p) * 1%), var(--bg2) 0); position: relative; flex: none; }
.ring::before { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--card); }
.ring span { position: relative; font: 700 16px "Space Grotesk", sans-serif; }
.list { display: grid; gap: 10px; }
.item { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.item .ico-wrap { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: rgba(153,69,255,.15); flex: none; }
.item .ico-wrap .ico { width: 22px; height: 22px; background: var(--purple); }
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 600; }
.item .meta { color: var(--mute); font-size: 13px; }
.item .reward { color: var(--green); font-weight: 600; font-size: 13px; }
.item.done { opacity: .55; }
.item.done .ico-wrap { background: rgba(34,211,238,.15); }
.item.done .ico-wrap .ico { background: var(--green); }
.check { color: var(--green); font-weight: 700; font-size: 13px; }

/* Comercios */
.hero-shop { background: radial-gradient(300px 160px at 100% 0%, rgba(34,211,238,.18), transparent 70%), var(--card); }
.hero-shop .sub { margin: 0; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 4px; scrollbar-width: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); color: var(--mute); border-radius: 99px; padding: 7px 12px; font: 500 13px Inter, sans-serif; cursor: pointer; }
.chip.on { color: #07110C; background: var(--green); border-color: var(--green); }
.merchant .ico-wrap { background: rgba(34,211,238,.12); font: 700 16px "Space Grotesk", sans-serif; color: var(--green); }
.offer { color: var(--yellow); font-size: 13px; }

/* Perfil */
.code-box { display: flex; align-items: center; justify-content: space-between; background: var(--bg2); border: 1px dashed var(--purple); border-radius: 12px; padding: 10px 12px; margin: 12px 0; }
.code-box span { font: 700 22px "Space Grotesk", sans-serif; letter-spacing: .12em; }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; text-align: center; }
.stats3 b { display: block; font: 700 20px "Space Grotesk", sans-serif; }
.stats3 span { color: var(--mute); font-size: 12px; }
.withdraw { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin: 12px 0 8px; }
.withdraw .btn { width: auto; }
.card .btn + .btn { margin-top: 8px; }
.card .sub + .btn { margin-top: 10px; }

/* Barra inferior */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b); display: grid; grid-template-columns: repeat(5, 1fr); background: rgba(17,20,27,.96); border-top: 1px solid var(--line); backdrop-filter: blur(12px); max-width: 480px; margin: 0 auto; }
.tabbar button { background: none; border: 0; color: var(--dim); font: 500 11px Inter, sans-serif; display: grid; justify-items: center; align-content: center; gap: 4px; cursor: pointer; }
.tabbar .ico { width: 22px; height: 22px; background: var(--dim); }
.tabbar .active { color: var(--ink); }
.tabbar .active .ico { background: var(--green); }

/* Hoja modal y aviso */
.sheet-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 480px; background: var(--card); border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0; padding: 10px 18px calc(22px + var(--safe-b)); max-height: 88dvh; overflow: auto; animation: up .22s ease; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 14px; }
.sheet h3 { font: 600 19px "Space Grotesk", sans-serif; margin: 0 0 6px; }
.sheet .stack { margin-top: 14px; }
.opts { display: grid; gap: 8px; margin: 8px 0 14px; }
.opt { text-align: left; background: var(--bg2); border: 1px solid var(--line); color: var(--ink); border-radius: 12px; padding: 11px 12px; font: 14px Inter, sans-serif; cursor: pointer; }
.opt.on { border-color: var(--green); background: rgba(34,211,238,.08); }
.timer { font: 700 46px "Space Grotesk", sans-serif; text-align: center; margin: 18px 0; }
.video-box { aspect-ratio: 16/9; border-radius: 14px; background: radial-gradient(circle at 30% 30%, rgba(153,69,255,.5), transparent 60%), radial-gradient(circle at 70% 70%, rgba(34,211,238,.35), transparent 60%), var(--bg2); display: grid; place-items: center; margin: 12px 0; }
.stars { display: flex; gap: 6px; justify-content: center; margin: 10px 0; }
.stars button { background: none; border: 0; font-size: 30px; color: var(--line); cursor: pointer; }
.stars button.on { color: var(--yellow); }
.celebrate { text-align: center; padding: 10px 0 6px; }
.celebrate .big { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
#toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 14px + var(--safe-b)); transform: translateX(-50%) translateY(20px); z-index: 40; background: var(--card2); border: 1px solid var(--line); padding: 11px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { border-color: var(--red); }

/* Íconos (SVG como máscara, así toman el color del contexto) */
.ico { display: inline-block; -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
.ico.home { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 11 12 3l9 8v10h-6v-6H9v6H3z'/%3E%3C/svg%3E"); }
.ico.map { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2a7 7 0 0 0-7 7c0 5 7 13 7 13s7-8 7-13a7 7 0 0 0-7-7zm0 9.5A2.5 2.5 0 1 1 12 6.5a2.5 2.5 0 0 1 0 5z'/%3E%3C/svg%3E"); }
.ico.target { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20zm0 3a7 7 0 1 0 0 14 7 7 0 0 0 0-14zm0 3a4 4 0 1 1 0 8 4 4 0 0 1 0-8z'/%3E%3C/svg%3E"); }
.ico.shop { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 4h16l1 5a3 3 0 0 1-5 2 3 3 0 0 1-4 0 3 3 0 0 1-4 0 3 3 0 0 1-5-2zm1 9h14v8H5z'/%3E%3C/svg%3E"); }
.ico.user { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 12a5 5 0 1 0 0-10 5 5 0 0 0 0 10zm-9 10a9 9 0 0 1 18 0z'/%3E%3C/svg%3E"); }
.ico.sun { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='5'/%3E%3Cpath d='M11 1h2v4h-2zm0 18h2v4h-2zM1 11h4v2H1zm18 0h4v2h-4z'/%3E%3C/svg%3E"); }
.ico.list { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 5h3v3H4zm5 0h11v3H9zM4 10.5h3v3H4zm5 0h11v3H9zM4 16h3v3H4zm5 0h11v3H9z'/%3E%3C/svg%3E"); }
.ico.play { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 4v16l13-8z'/%3E%3C/svg%3E"); }
.ico.star { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m12 2 3 7 7 .6-5.3 4.7 1.6 7.2L12 17.8 5.7 21.5l1.6-7.2L2 9.6 9 9z'/%3E%3C/svg%3E"); }

.brand-logo { width: 210px; max-width: 72vw; height: auto; display: block; margin: 10px auto 0; }

.item.wall { background: radial-gradient(260px 120px at 100% 0%, rgba(34,211,238,.12), transparent 70%), var(--card); }

/* Escaneo de QR con la cámara */
#qrScan { position: fixed; inset: 0; z-index: 200; background: #000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; }
#qrScan video { width: 100%; max-width: 480px; aspect-ratio: 3/4; object-fit: cover; }
#qrScan .btn { min-width: 200px; }
